Input and output virtualization method and system and electronic equipment

By directly passing the physical functions on the host to the virtual machine and enabling the virtual functions in user mode, the problem of providing SR-IOV functions for user-mode driver-based programs in the virtual machine is solved, and the program can run without modification.

CN120723364APending Publication Date: 2025-09-30HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410362571.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-27
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

Provide SR-IOV functionality in virtual machines for user-mode driver-based programs that rely on SR-IOV, avoiding program redevelopment and adaptation work.

Method used

Pass the physical functions on the host directly to the virtual machine, enable the virtual function in user mode, implement the SR-IOV function, and pass the physical and virtual functions directly to the virtual machine through VFIO passthrough.

Benefits of technology

The SR-IOV capability of the device is simulated in the virtual machine, so that programs that rely on SR-IOV can run directly without modification, reducing the complexity of the program running environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723364A_ABST
    Figure CN120723364A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an input and output virtualization method and system and electronic equipment. The input / output virtualization method comprises the following steps: directly connecting a physical function corresponding to physical input / output equipment on a host to a virtual machine on the host; enabling a virtual function corresponding to the physical work on the host in the user mode; and directly connecting the virtual function to the virtual machine. Therefore, the SR-IOV function is provided for the program which depends on the SR-IOV and is based on the user mode drive in the virtual machine, and the work of redevelopment and adaptation of the program is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of virtualization, and more particularly, to an input / output virtualization method, system, and electronic device. Background Art

[0002] Single Root Input / Output Virtualization (SR-IOV) technology is currently widely used in cloud computing environments. It enables a single physical Peripheral Component Interconnect Express (PCIe) device to support multiple virtual machines, thereby improving resource utilization and flexibility while providing good performance.

[0003] In addition to virtual machine scenarios, some user-mode driver-based programs also rely on SR-IOV. For example, the Data Plane Development Kit (DPDK), widely used in cloud computing, relies on SR-IOV to complete traffic forwarding configuration for network cards that do not support queue-based flow table configuration. In order to enable such user-mode driver-based programs that rely on SR-IOV to run in virtual machines without any modification, the current problem that needs to be solved is how to provide SR-IOV functionality for such programs in virtual machines. Summary of the Invention

[0004] The present application provides an input / output virtualization method, system, and electronic device, which provide complete SR-IOV functionality for user-mode driver-based programs that rely on SR-IOV in a virtual machine, avoiding the need for program redevelopment and adaptation.

[0005] In a first aspect, the present application provides an input and output virtualization method, comprising:

[0006] Passing the physical functions corresponding to the physical input and output devices on the host directly to the virtual machine on the host;

[0007] enabling, in user mode, a virtual function on the host corresponding to the physical function;

[0008] Passing the virtual function directly to the virtual machine.

[0009] In a second aspect, the present application provides an input and output virtualization method, comprising:

[0010] Passing the physical functions corresponding to the network card on the host directly to the virtual machine on the host;

[0011] enabling, in user mode, a virtual function on the host corresponding to the physical function;

[0012] Passing the virtual function directly to the virtual machine;

[0013] The data sent or received by the user-mode driven program in the virtual machine based on the virtual function is sent or received through the network card.

[0014] In a third aspect, the present application provides an input and output virtualization system, comprising: a host and a virtual machine running on the host;

[0015] The host directly passes the physical function corresponding to the physical input and output device on the host to the virtual machine, enables the virtual function corresponding to the physical function on the host in user mode, and directly passes the virtual function to the virtual machine.

[0016] In a fourth aspect, the present application provides an electronic device, comprising: a memory and a processor;

[0017] The memory is used to store computer programs;

[0018] The processor is configured to execute a computer program stored in the memory, and when the computer program is run, the processor is enabled to execute the method according to the first aspect or the second aspect.

[0019] In a fifth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes the method described in the first aspect or the second aspect.

[0020] In a sixth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in the first aspect or the second aspect.

[0021] In the seventh aspect, the present application provides a user-mode driven program product, including a computer program, which runs in a virtual machine on a host, and the computer program performs input and output through the virtual function in the virtual machine, and the virtual function is directly connected to the virtual machine by the host using the method described in the first aspect or the second aspect.

[0022] The input and output virtualization method, system, and electronic device provided in this application realize the SR-IOV capability of simulating a device in a virtual machine, so that user-mode driver-based programs that rely on SR-IOV can run directly in the virtual machine without modification, avoiding the redevelopment and adaptation of the program. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0024] Figure 1 This is a flow diagram of an IO virtualization method provided in an embodiment of the present application. Figure 1 ;

[0025] Figure 2 This is a schematic diagram of implementing a vSRIOV function provided in an embodiment of the present application;

[0026] Figure 3 This is a flow diagram of an IO virtualization method provided in an embodiment of the present application. Figure 2 ;

[0027] Figure 4 This is a schematic diagram of the structure of an IO virtualization device provided in an embodiment of the present application. Figure 1 ;

[0028] Figure 5 This is a schematic diagram of the structure of an IO virtualization device provided in an embodiment of the present application. Figure 2 ;

[0029] Figure 6 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0030] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0031] The terms involved in the embodiments of this application are introduced.

[0032] SR-IOV: Software-defined I / O virtualization technology that virtualizes physical I / O devices into multiple logical I / O devices, improving system efficiency and flexibility.

[0033] Physical Function (PF): A PCIe function used to support SR-IOV, capable of fully configuring or controlling PCIe device resources. A PF corresponds to a PCIe physical function and can be discovered and managed by the physical host. Each PF can be associated with multiple virtual function (VFs).

[0034] Virtual Function (VF): A function virtualized by a PF. A VF is a lightweight PCIe function that can share one or more physical resources with the PF and other VFs associated with the PF.

[0035] vSRIOV: Emulates the SR-IOV capability of devices in a virtual machine.

[0036] Virtual Function Input / Output (VFIO): A user-mode driver solution that, combined with the Input / Output Memory Management Unit (IOMMU), securely exposes device I / O, interrupts, and Direct Memory Access (DMA) capabilities to user space. When a device is passed directly to a virtual machine using VFIO, the device is taken over by the corresponding device driver in the virtual machine, allowing direct access to the device's capabilities, such as sending data using a network card.

[0037] For user-mode driven programs that rely on SR-IOV, their operation depends on the PF and VF in the host. If such programs are to be run in a virtual machine, they need to be redeveloped and adapted to enable the program to run normally. However, if the SR-IOV function can be provided for the program in the virtual machine, the program can be run directly in the virtual machine without modification. To achieve the above purpose, an IO virtualization method is proposed in an embodiment of the present application, which directly connects the PF on the host to the virtual machine, enables the VF associated with the PF on the host, and directly connects the VF to the virtual machine, thereby realizing the vSRIOV function based on the direct device.

[0038] Figure 1 This is a flow diagram of an IO virtualization method provided in an embodiment of the present application. Figure 1 .like Figure 1 As shown, the method includes:

[0039] S101: Directly connect the PF corresponding to the physical IO device on the host to the virtual machine on the host.

[0040] Device passthrough refers to attaching a device on the host directly to a virtual machine, allowing the virtual machine to directly access the device on the host. In this step, the PF corresponding to the physical I / O device is passed directly to the virtual machine as a passthrough device. To enable user-mode driver-based programs to use SR-IOV functions in the virtual machine, this step can use user-mode driver-based passthrough to pass the PF on the host directly to the virtual machine. In this way, user-mode driver-based programs in the virtual machine can directly access the PF.

[0041] This example uses VFIO passthrough to connect a PF to a virtual machine. First, bind the PF to the VFIO driver and add its identifier to the virtual machine manager. Then, add the SR-IOV capability configuration to the PF's emulated configuration space and pass the base address register (BAR) space in the SR-IOV capability configuration to the virtual machine.

[0042] For the PF in the host, it has a corresponding default driver in the host. Therefore, when using VFIO for direct passthrough, it is necessary to bind the PF to the VFIO driver so that the PF is taken over by the VFIO driver. It is understandable that before binding the PF to the VFIO driver, the PF can also be unbound from the original default driver. After binding the PF to the VFIO driver, the PF identification information is added to the virtual machine manager to complete the addition of the PF to the virtual machine. Adding the PF identification information in the virtual machine manager can be adding the PF identification information to the startup parameters of the virtual machine manager. The PF identification information can be the address information of the PF.

[0043] In addition, when passing PF directly to the virtual machine, it is necessary to simulate the configuration space of the PF passed directly to the virtual machine, that is, to copy part or all of the information of the configuration space of PF in the host. The simulated configuration space is used by the virtual machine. In order to make the device driver in the virtual machine aware that PF has SR-IOV capability, when simulating the configuration space, it is necessary to copy the configuration related to SR-IOV capability in the configuration space of PF, that is, to copy the configuration related to SR-IOV capability in the configuration space of PF to the simulated configuration space of PF.

[0044] In addition, the bar space in the SR-IOV capability configuration needs to be passed directly to the virtual machine. When the device driver inside the virtual machine initializes the PF, it will allocate a physical address (Guest Physical Address, GPA) for its bar space and set the bar space address through the simulated configuration space. The operation of setting the bar space address will be intercepted by the virtual machine manager in the host, and the virtual machine manager obtains the virtual address (Host Virtual Address, HVA) of the PF bar space in the kernel state, sets the correspondence between GPA and HVA in the memory, and realizes the direct connection of the PF bar space to the virtual machine.

[0045] S102: Enable the VF corresponding to the PF on the host in user mode.

[0046] The VF corresponding to the PF is the function virtualized by the PF. After the PF is directly connected to the virtual machine, the user can operate on the virtual machine to trigger the VF through user instructions. The virtual machine triggers the host to enable the VF in user mode based on the received user instructions. That is, the host responds to the enable operation triggered by the virtual machine based on the user instruction and enables the VF in user mode. The user instruction includes the number of VFs to be enabled and the path of the enable control file. The path of the enable control file is generated by the virtual machine. The user instruction on the virtual machine can be a command line input by the user. The user controls the enablement of one or more VFs through the command line. The virtual machine responds to the command line and triggers the host side to enable the VF. The host can enable the VF by calling the interface for enabling the VF.

[0047] S103. Connect the VF directly to the virtual machine.

[0048] After the preceding steps, a VF is already present on the host. You can then connect the VF directly to the VM, enabling SR-IOV in the VM. Alternatively, you can connect the VF directly to the VM using hot-plugging, which involves binding the VF to the VFIO driver and hot-plugging the VF into the VM. When hot-plugging the VF, you must use the VF's PCI address.

[0049] According to the SR-IOV specification, once a VF is enabled, it can be accessed via its PCI address. This corresponds to the device driver, which actively traverses the VF based on its PCI address. When a VF is hot-plugged into a VM, the VM exit process is complete, allowing the VM to return and resume normal operation. Therefore, hot-plugging a VF into a VM does not require sending an interrupt to the VM to indicate the insertion of a new device. Hot-plugging allows VFs to be dynamically added or removed from a VM.

[0050] The IO virtualization method of the embodiment of the present application, that is, the implementation method of vSRIOV, directly passes the PF on the host to the virtual machine, enables the VF associated with the PF on the host, and directly passes the VF to the virtual machine, thereby realizing the vSRIOV function based on the direct pass-through device, that is, the SR-IOV function can be provided to the program in the virtual machine. Therefore, the user-mode driven program that depends on SR-IOV can run directly in the virtual machine without any modification, avoiding the redevelopment and adaptation of the program and reducing the complexity of the program running environment.

[0051] Figure 2 This is a schematic diagram of implementing a vSRIOV function provided by an embodiment of the present application. Figure 2 As shown, the implementation of vSRIOV includes the following steps:

[0052] S201. Directly connect the PF to the virtual machine on the host.

[0053] To pass the PF directly to the VM via VFIO passthrough, the SR-IOV capability must be added to the PF's emulated configuration space to make the VM's device driver aware of the PF's SR-IOV capabilities. Furthermore, the bar space described in the PF's SR-IOV capability configuration includes both the PF's bar space and the VF's bar space. Passing the PF's SR-IOV capability configuration directly to the VM also includes passing both the PF's bar space and the VF's bar space directly to the VM.

[0054] After the PF is passed directly to the virtual machine, the virtual machine will load the corresponding device driver according to the vendor ID and device ID of the PF, and will generate a file path similar to the following in the system directory: / sys / devices / pciXXX / …… / sriov_numvfs, indicating that the device has SR-IOV capability. Subsequent users can control the enabling and disabling of VF through this file, which is referred to as the enabling control file in the embodiment of this application.

[0055] S202: Enable the VF corresponding to the PF on the host in user mode.

[0056] After the PF is directly connected to the VM, a user command can be used to trigger the VF to be enabled. Specifically, the user command is executed in the VM, which triggers the host to enable the VF. The user command can be a command line entered by the user. The user enters the command line on the VM, and the VM responds to the command line, triggering the host to enable the VF. The host can then enable the VF by calling the VF enablement API.

[0057] Optionally, the host responds to the virtual machine's operation of setting the enable bit in the SR-IOV capability configuration based on a user instruction. That is, the virtual machine receives the user instruction and, based on the user instruction, sets the enable bit in the SR-IOV capability configuration through the device driver in the virtual machine. The setting operation of the virtual machine triggers the virtual machine exit (VM exit), and the virtual machine manager in the host sets the enable bit in the SR-IOV capability configuration, and the virtual machine manager in the host enables the VF. Since the PF on the host is taken over by the VFIO driver, and the VFIO driver does not provide an interface for enabling and disabling the VF for the user-mode program, in an embodiment of the present application, an SR-IOV manager (SR-IOV-manager) can be added to the host to enable the VF on the host, that is, the virtual machine manager communicates with the SR-IOV manager, and enables the VF through the SR-IOV manager, wherein the SR-IOV manager includes interfaces for enabling and disabling the VF. The virtual machine manager enables the VF through the SR-IOV manager, that is, the virtual machine manager enables the VF by calling the interface for enabling the VF in the R-IOV manager.

[0058] In addition to enabling VF in the embodiment of the present application, the process of disabling VF is similar to that of enabling VF. That is, in response to a user instruction received by the virtual machine, the virtual machine triggers the host side to close the VF. For example, the virtual machine manager communicates with the SR-IOV manager and closes the VF by calling the VF closing interface in the SR-IOV manager.

[0059] For example, in a VM, you can control VFs by entering commands such as "echo X> / sys / devices / pciXXX / …… / sriov_numvfs." If X is 0, the VF is disabled; if X is not 0, the number of VFs enabled is X. For example, if X is 1, "echo 1> / sys / devices / pciXXX / …… / sriov_numvfs" enables one VF.

[0060] After the user executes the preceding user instruction, the device driver in the virtual machine sets the enable bit in the SR-IOV capability. This operation triggers a VM exit and traps to the host's virtual machine manager. For example, if the virtual machine manager is Qemu, upon detecting this event, Qemu communicates with sriov-manager and calls the VF enable interface in sriov-manager to enable the host's VF, also with a quantity of 1. Through the newly added sriov-manager kernel module, Qemu can control the enabling and disabling of VFs on the host.

[0061] S203: Connect the VF to the virtual machine.

[0062] After step 2, the VF device is already on the host. Then, bind the VF to the VFIO driver and hot-insert the VF into the virtual machine. When hot-inserting the VF, the PCI address of the VF (vf_bdf) to be used can be calculated using the following formula:

[0063] vf_bdf=pf_bdf+vf_offset+vf_id*vf_stride

[0064] Among them, vf_offset and vf_stride are defined in the SR-IOV capability, vf_id is the VF identifier, and vf_stride is the address stride.

[0065] Afterwards, the programs in the virtual machine, such as Figure 2 The corresponding input and output functions of PF and VF can be used by using the programs 1 and 2 shown in the figure.

[0066] Figure 3 This is a flow diagram of an IO virtualization method provided in an embodiment of the present application. Figure 2 .like Figure 3 As shown, the method includes:

[0067] S301 : Directly pass the physical function PF corresponding to the network card on the host to the virtual machine on the host.

[0068] S302: Enable the virtual function VF corresponding to the PF on the host in user mode.

[0069] S303: Connect the VF to the virtual machine.

[0070] S304: Send and receive data sent and received by the user-mode driven program in the virtual machine based on the VF through the network card.

[0071] In the embodiment of the present application, taking the physical IO device as a network card as an example, the PF corresponding to the network card is directly connected to the virtual machine, the VF corresponding to the PF is enabled in the user state, and the VF is directly connected to the virtual machine. In this way, the PF and VF corresponding to the network card are available in the virtual machine. The user-state-driven program in the virtual machine uses the network card to send and receive data through the VF directly connected to the virtual machine. In the scenario where the user-state-driven program runs on the host, the program uses the network card to send and receive data through the VF. Therefore, for the program, the process of processing data input and output is the same. In this way, the user-state-driven program that originally runs on the host and relies on SR-IOV can run directly in the virtual machine without modification.

[0072] Figure 4This is a schematic diagram of the structure of an IO virtualization device provided in an embodiment of the present application. Figure 1 .like Figure 4 As shown, the IO virtualization device 400 includes:

[0073] The first direct module 401 is used to directly pass the physical function PF corresponding to the physical IO device on the host to the virtual machine on the host;

[0074] An enabling module 402 is configured to enable a virtual function VF corresponding to the PF on the host in user mode;

[0075] The second direct connection module 403 is used to connect the VF to the virtual machine.

[0076] In one implementation, the first direct module 401 is configured to:

[0077] Bind PF to the VFIO driver and add PF identification information in the virtual machine management;

[0078] Add single-root IO virtualization SR-IOV capability configuration in the PF simulation configuration space;

[0079] Pass the base address register space in the SR-IOV capability configuration directly to the virtual machine.

[0080] In one implementation, the enabling module 402 is configured to:

[0081] In response to the virtual machine's enabling operation triggered by a user instruction, the host enables the VF in user mode, wherein the user instruction includes the number of VFs to be enabled and the path of the enabling control file, which is generated by the virtual machine.

[0082] In one implementation, the enabling module 402 is configured to:

[0083] In response to the virtual machine setting the enable bit in the SR-IOV capability configuration based on a user instruction, the host enables the VF through the virtual machine manager.

[0084] In one implementation, the enabling module 402 is configured to:

[0085] The virtual machine manager communicates with the SR-IOV manager, and enables the VF through the SR-IOV manager. The SR-IOV manager includes an interface for enabling the VF.

[0086] In one implementation, the second pass-through module 403 is configured to:

[0087] Bind the VF to the VFIO driver and hot-insert the VF into the VM.

[0088] The device of the embodiment of the present application can be used to execute the IO virtualization method in the aforementioned embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0089] Figure 5 This is a schematic diagram of the structure of an IO virtualization device provided in an embodiment of the present application. Figure 2 .like Figure 5 As shown, the IO virtualization device 500 includes:

[0090] The first direct module 501 is used to directly pass the physical function PF corresponding to the network card on the host to the virtual machine on the host;

[0091] An enabling module 502 is configured to enable a virtual function VF corresponding to the PF on the host in user mode;

[0092] The second direct pass module 503 is used to directly pass the VF to the virtual machine;

[0093] The transceiver module 504 transmits and receives data sent and received by the user-mode driver program in the virtual machine based on the VF through the network card.

[0094] The device of the embodiment of the present application can be used to execute the IO virtualization method in the aforementioned embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0095] Figure 6 Schematic block diagram of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 600 may include at least one processor 601 for implementing the IO virtualization method provided in the embodiment of the present application.

[0096] Optionally, the electronic device 600 further includes at least one memory 602 for storing program instructions and / or data. The memory 602 is coupled to the processor 601. Coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units, or modules, which can be electrical, mechanical, or other forms, and is used for information exchange between devices, units, or modules. The processor 601 may operate in conjunction with the memory 602. The processor 601 may execute program instructions stored in the memory 602. At least one of the at least one memory may be included in the processor.

[0097] Optionally, the electronic device 600 further includes a communication interface 603 for communicating with other devices via a transmission medium, thereby enabling the electronic device 600 to communicate with other devices. The communication interface 603 may be, for example, a transceiver, an interface, a bus, a circuit, or a device capable of implementing transceiver functions. The processor 601 may utilize the communication interface 603 to transmit and receive data and / or information, and to implement the methods provided in the embodiments of the present application. For details, please refer to the detailed description in the preceding embodiments, which will not be repeated here.

[0098] The specific connection medium between the processor 601, the memory 602 and the communication interface 603 is not limited in the embodiment of the present application. Figure 6 The processor 601, the memory 602 and the communication interface 603 are connected via a bus 604. The bus 604 is connected to the Figure 6 The connections between the other components are shown in bold lines, which are only for illustration and not intended to be limiting. The bus can be divided into address bus, data bus, control bus, etc. Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0099] It should be understood that the processor in the embodiments of the present application can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above-mentioned method embodiment can be completed by hardware integrated logic circuits in the processor or by software instructions. The above-mentioned processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above-mentioned method.

[0100] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus RAM (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0101] The present application also provides an IO virtualization system, including a host and a virtual machine running on the host; the host directly passes the physical functions corresponding to the physical input and output devices on the host to the virtual machine, enables the virtual functions corresponding to the physical functions on the host in user mode, and directly passes the virtual functions to the virtual machine.

[0102] Optionally, a program based on a user-mode driver is running in the virtual machine, and the program based on the user-mode driver performs input and output through virtual functions.

[0103] The methods executed by the host and the virtual machine in the IO virtual machine system can refer to the description of the above embodiments.

[0104] The present application also provides a computer-readable storage medium, which stores a computer program (also referred to as code or instruction). When the computer program is executed by a processor, the method in any of the aforementioned embodiments is implemented.

[0105] The present application also provides a computer program product, including a computer program, which implements the method in any of the aforementioned embodiments when executed by a processor.

[0106] The present application also provides a program product based on user-mode drive, including a computer program, which runs in a virtual machine on a host. The computer program performs input and output through virtual functions in the virtual machine, and the virtual functions are directly connected to the virtual machine by the host using the method in any of the aforementioned embodiments.

[0107] The terms "unit," "module," and the like used in this specification may be used to refer to a computer-related entity, hardware, firmware, a combination of hardware and software, software, or software in execution.

[0108] Those skilled in the art will appreciate that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. In the several embodiments provided in this application, it should be understood that the disclosed devices, equipment, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices or units, and can be electrical, mechanical, or other forms.

[0109] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of the solution of this embodiment according to actual needs.

[0110] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0111] In the above-described embodiments, the functions of each functional unit can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). When the computer program instructions (program) are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid-state disk (SSD)).

[0112] If this function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

[0113] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0114] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. An input and output virtualization method, characterized in that: include: Passing the physical functions corresponding to the physical input and output devices on the host directly to the virtual machine on the host; enabling, in user mode, a virtual function on the host corresponding to the physical function; Passing the virtual function directly to the virtual machine.

2. The method according to claim 1, characterized in that The step of directly passing physical functions corresponding to physical input and output devices on the host to the virtual machine on the host includes: Binding the physical function to the virtual function input and output driver, and adding identification information of the physical function in the virtual machine manager; Adding a single-root input and output virtualization capability configuration in the simulation configuration space of the physical function; The base address register space in the single root input / output virtualization capability configuration is directly passed to the virtual machine.

3. The method according to claim 2, characterized in that The enabling of the virtual function corresponding to the physical function on the host in the user state includes: In response to an enable operation triggered by the virtual machine based on a user instruction, the host enables the virtual function in user mode, wherein the user instruction includes the number of the virtual functions to be enabled and the path of the enable control file, and the path of the enable control file is generated by the virtual machine.

4. The method according to claim 3, characterized in that In response to the enabling operation triggered by the virtual machine based on a user instruction, the host enabling the virtual function in the user state includes: In response to the virtual machine setting an enable bit in the single root input / output virtualization capability configuration based on the user instruction, the host enables the virtual function through the virtual machine manager.

5. The method according to claim 4, characterized in that The host enables the virtual function through the virtual machine manager, including: The virtual machine manager communicates with a single root input / output virtualization manager, and enables the virtual function through the single root input / output virtualization manager, wherein the single root input / output virtualization manager includes an interface for enabling the virtual function.

6. The method according to any one of claims 1 to 5, characterized in that The step of directly passing the virtual function to the virtual machine includes: The virtual function is bound to a virtual function input / output driver, and the virtual function is hot-plugged into the virtual machine.

7. An input and output virtualization method, characterized in that: include: Passing the physical functions corresponding to the network card on the host directly to the virtual machine on the host; enabling, in user mode, a virtual function on the host corresponding to the physical function; Passing the virtual function directly to the virtual machine; The data sent or received by the user-mode driven program in the virtual machine based on the virtual function is sent or received through the network card.

8. An input and output virtualization system, characterized in that: include: A host and a virtual machine running on the host; The host directly passes the physical function corresponding to the physical input and output device on the host to the virtual machine, enables the virtual function corresponding to the physical function on the host in user mode, and directly passes the virtual function to the virtual machine.

9. The system according to claim 8, characterized in that A program based on a user-mode driver runs in the virtual machine, and the program based on a user-mode driver performs input and output through the virtual function.

10. An electronic device, characterized in that: include: memory and processor; The memory is used to store computer programs; The processor is configured to execute a computer program stored in the memory, and when the computer program is executed, the processor is enabled to execute the method according to any one of claims 1 to 7.

11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.

12. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 7 when being executed by a processor.

13. A program product based on user mode driver, characterized in that: The method comprises a computer program, wherein the computer program runs in a virtual machine on a host, wherein the computer program performs input and output through a virtual function in the virtual machine, and wherein the virtual function is directly connected to the virtual machine by the host using the method according to any one of claims 1 to 7.