Input / output virtualization method and system, and electronic device

By passing the physical function PF directly to the virtual machine in the virtual machine and enabling VF in user mode, the adaptation problem of SR-IOV programs running in the virtual machine is solved, and direct operation without modification is achieved, reducing development complexity and cost.

WO2025202740A1PCT designated stage Publication Date: 2025-10-02CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/IB2025/051432
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-27
Filing Date
2025-02-12
Publication Date
2025-10-02

AI Technical Summary

Technical Problem

In the prior art, user-mode driver-based programs that rely on Single Root Input/Output Virtualization (SR-IOV) need to be redeveloped and adapted when running in a virtual machine, and cannot run normally directly in the virtual machine.

Method used

The SR-IOV function in the virtual machine is implemented by directly passing the physical function (PF) on the host to the virtual machine and enabling the virtual function (VF) in the user state. The PF and VF are directly passed to the virtual machine using VFIO passthrough, and the SR-IOV manager is used to control the enabling and disabling of VF in the user state.

Benefits of technology

It provides SR-IOV functionality for user-mode driver-based programs in virtual machines, allowing them to run directly without modifying the programs, reducing the complexity of the program runtime environment and development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure IB2025051432_02102025_PF_FP_ABST
    Figure IB2025051432_02102025_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide an input / output virtualization method and system, and an electronic device. The input / output virtualization method comprises: directly allocating a physical function corresponding to a physical input / output device on a host to a virtual machine on the host; in a user mode, enabling a virtual function, on the host, corresponding to the physical function; and directly allocating the virtual function to the virtual machine. Therefore, in virtual machines, an SR-IOV function is provided for user-mode driver-based programs that depend on SR-IOV, avoiding re-development and adaptation of programs.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This disclosure claims priority to Chinese patent application number 202410362571.3, filed with the China Patent Office on March 27, 2024, entitled "Input / Output Virtualization Method, System, and Electronic Device," the entire contents of which are incorporated herein by reference. Technical Field: This disclosure relates to the field of virtualization, and more specifically, to an input / output virtualization method, system, and electronic device. Background: Single Root Input / Output Virtualization (SR-10V) technology is currently widely used in cloud computing environments, enabling a single physical Peripheral Component Interconnect Express (PCIe) device to support multiple virtual machines, thereby improving resource utilization and flexibility while offering superior performance. 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 interfaces (NICs) that do not support queue-based flow table configuration. To enable these user-mode driver-based programs that rely on SR-IOV to run in virtual machines without any modification, the current problem is how to provide SR-IOV functionality for these programs in virtual machines. SUMMARY OF THE INVENTION The present disclosure provides an input / output virtualization method, system, and electronic device that provide complete SR-IOV functionality for user-mode driver-based programs that rely on SR-IOV in virtual machines, eliminating the need for program redevelopment and adaptation. In a first aspect, the present disclosure provides an input / output virtualization method, comprising: directly passing physical functions corresponding to physical input / output devices on a host to a virtual machine on the host; enabling virtual functions on the host corresponding to the physical functions in user mode; and directly passing the virtual functions to the virtual machine. In a second aspect, the present disclosure provides an input and output virtualization method, comprising: directly passing a physical function corresponding to a network card on a host to a virtual machine on the host; enabling a virtual function corresponding to the physical function on the host in user mode; directly passing the virtual function to the virtual machine; and sending and receiving data sent and received by a user-mode driven program in the virtual machine based on the virtual function through the network card.In a third aspect, the present disclosure provides an input / output virtualization system, comprising: a host and a virtual machine running on the host; the host directly passes physical functions corresponding to physical input / output devices on the host to the virtual machine, enables virtual functions corresponding to the physical functions on the host in user mode, and directly passes the virtual functions to the virtual machine. In a fourth aspect, the present disclosure provides an electronic device, comprising: a memory and a processor; the memory is configured to store a computer program; the processor is configured to execute the computer program stored in the memory, wherein the computer program, when executed, causes the processor to perform the method according to the first or second aspect. In a fifth aspect, the present disclosure provides a computer-readable storage medium, wherein the computer program is stored on the computer-readable storage medium, and when executed by the processor, causes the processor to perform the method according to the first or second aspect. In a sixth aspect, the present disclosure provides a computer program product, comprising the computer program, wherein when executed by the processor, the computer program implements the method according to the first or second aspect. In a seventh aspect, the present disclosure provides a user-mode driver-based program product, comprising a computer program, the computer program running in a virtual machine on a host. The computer program performs input and output via virtual functions in the virtual machine, the virtual functions being directly connected to the virtual machine by the host using the method described in the first or second aspect. The input and output virtualization method, system, and electronic device provided in the present disclosure implement the SR-IOV capability of emulating a device in a virtual machine, thereby enabling user-mode driver-based programs that rely on SR-IOV to run directly in the virtual machine without modification, avoiding the need for program redevelopment and adaptation. BRIEF DESCRIPTION OF THE DRAWINGS To more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below represent some embodiments of the present disclosure. Persons skilled in the art can derive other drawings based on these drawings without inventive effort. Figure 1 is a flow chart of an I0 virtualization method provided in an embodiment of the present disclosure; Figure 2 is a schematic diagram of an implementation of a vSR 10V function provided in an embodiment of the present disclosure; Figure 3 is a flow chart of an I0 virtualization method provided in an embodiment of the present disclosure; Figure 4 is a structural schematic diagram of an I0 virtualization device provided in an embodiment of the present disclosure; Figure 5 is a structural schematic diagram of an I0 virtualization device provided in an embodiment of the present disclosure; Figure 6 is a schematic block diagram of an electronic device provided in an embodiment of the present disclosure.To further clarify the objectives, technical solutions, and advantages of the embodiments of the present disclosure, the following will provide a clear and complete description of the technical solutions in the embodiments of the present disclosure, with reference to the accompanying drawings. It should be understood that the described embodiments represent only a portion of the embodiments of the present disclosure, but are not exhaustive. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present disclosure without inventive effort are intended to fall within the scope of protection of the present disclosure. The following describes the terms used in the embodiments of the present disclosure.

[0002] 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. Physical Function (PF): A PCIe function used to support SR-10V, 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 functions (VFs). 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 same PF. vSRIOV: Emulates the SR-10V capabilities of a device within a virtual machine. Virtual Function Input / Output (VFIO): A user-mode driver solution that, combined with the Input / Output Memory Management Unit (IOMM), securely exposes device I / O, interrupts, and Direct Memory Access (DMA) capabilities to user space. By using VFIO passthrough to pass a device directly to a virtual machine, 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. User-mode driver-based programs that rely on SR-IOV rely on the PF and VF in the host. Running such programs in a virtual machine requires redevelopment and adaptation to ensure proper operation. However, if SR-IOV functionality is provided for the program in the virtual machine, the program can run directly in the virtual machine without modification. To achieve the above objectives, embodiments of the present disclosure provide an I / O virtualization method that directly connects a PF on a host to a virtual machine, enables the VF associated with the PF on the host, and directly connects the VF to the virtual machine, thereby implementing vSR I / O functionality based on a direct device connection. Figure 1 is a flow diagram of a first embodiment of the I / O virtualization method provided by the present disclosure. As shown in Figure 1, the method includes:

[0003] 5101. Passthrough the PF corresponding to the physical I / O device on the host to the virtual machine on the host. Device passthrough refers to directly attaching a device on the host to the 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 through to the virtual machine as a passthrough device. To enable user-mode driver-based programs to use the SR-IOV function in the virtual machine, this step can use a user-mode driver-based passthrough method to passthrough the PF on the host to the virtual machine. In this way, user-mode driver-based programs in the virtual machine can directly access the PF. VF IO passthrough can be used to passthrough the PF to the virtual machine as an example. First, bind the PF to the VF IO driver, and add PF identification information to the virtual machine manager. Then, add SR-IOV capability configuration to the PF's simulated configuration space, and passthrough the base address register (BAR) space in the SR-IOV capability configuration to the virtual machine. The PF in the host has a corresponding default driver. Therefore, when using VF IO for direct passthrough, the PF needs to be bound to the VF IO driver so that the PF is taken over by the VF IO driver. It is understood that before binding the PF to the VF IO driver, the PF can also be unbound from the original default driver. After binding the PF to the VF IO 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 to the virtual machine manager can be done by adding the PF identification information to the virtual machine manager's startup parameters. The PF identification information can be the PF address information. In addition, when the PF is passed through to the virtual machine, it is necessary to simulate the configuration space of the PF passed through to the virtual machine, that is, to copy part or all of the information in the configuration space of the 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 the PF has the SR-IOV capability, it is necessary to copy the configuration related to the SR-IOV capability in the configuration space of the PF when simulating the configuration space, that is, to copy the configuration related to the SR-IOV capability in the configuration space of the PF to the simulated configuration space of the PF.In addition, the bar space in the SR-I OV capability configuration needs to be passed through 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 the GPA and HVA in the memory, and realizes the direct pass-through of the PF bar space to the virtual machine.

[0004] 5102. Enable the VF corresponding to the PF on the host in user mode.

[0005] The VF corresponding to the PF is a virtualized function of the PF. After the PF is directly connected to the virtual machine, the user can operate on the virtual machine to trigger the VF to be enabled through user instructions. Based on the received user instructions, the virtual machine triggers the host to enable the VF in user mode. That is, in response to the enable operation triggered by the virtual machine based on the user instruction, the host enables the VF in user mode. The user instruction includes the number of VFs to be enabled and the path of the enablement control file, which 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 to enable the VF. The host can enable the VF by calling the VF enablement interface.

[0006] 5103. Directly connect the VF to the virtual machine. After the aforementioned steps, the VF is already present on the host. The VF is then directly connected to the virtual machine, thereby implementing the SR-1 OV function in the virtual machine. Optionally, hot-swapping the VF to the virtual machine involves binding the VF to a VF IO driver and hot-swapping the VF into the virtual machine. The VF's PCI address must be used during hot-swapping. According to the SR-1 OV specification, once the VF is enabled, it can be accessed using its PCI address. This corresponds to the device driver, which actively traverses the VF based on its PCI address. Once the VF is hot-swapped into the VM, the VM exit process is complete, allowing the VM to return and resume normal operation. Therefore, hot-swapping a VF into a virtual machine does not require sending an interrupt to the virtual machine to indicate the insertion of a new device. Hot-swapping allows VFs to be dynamically added or removed from the virtual machine. The 10 virtualization method of the disclosed embodiment, namely, the implementation method of vSRIOV, 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. This implements the vSRIOV function based on the direct device. In other words, it can provide SR-IOV functionality to programs in the virtual machine. As a result, user-mode driver-based programs that rely on SR-IOV can run directly in the virtual machine without any modification, avoiding program redevelopment and adaptation work and reducing the complexity of the program runtime environment. Figure 2 is a schematic diagram of an implementation of the vSRIOV function provided by the disclosed embodiment. As shown in Figure 2, the implementation of vSRIOV includes the following steps:

[0007] 5201. Pass the PF directly to the virtual machine on the host. Pass the PF directly to the virtual machine through VFIO passthrough. In order to make the device driver in the virtual machine aware that the PF has SR-10V capability, it is also necessary to add SR-10V capability in the simulation configuration space of the PF. oIn addition, the bar space described in the PF's SR-10V capability configuration includes the PF's bar space and the VF's bar space. Passing the bar space described in the PF's SR-10V capability configuration directly to the virtual machine also includes passing the PF's bar space and the VF's bar space directly to the virtual machine. After passing the PF directly to the virtual machine, the virtual machine loads the corresponding device driver based on the PF's vendor ID and device ID, and generates a file path similar to the following in the system directory: / sys / devices / pciXXX / / sr i ov_numvfs, indicating that the device has SR-10V capabilities. Users can subsequently control the enabling and disabling of the VF through this file, which is referred to as an enablement control file in the disclosed embodiments.

[0008] S202. Enable the VF corresponding to the PF on the host in user mode. After the PF is passed through to the virtual machine, the VF can be enabled using a user instruction. That is, the user instruction is executed in the virtual machine, and the virtual machine triggers the host to enable the VF. The user instruction can be a command line entered by the user. The user enters the command line on the virtual machine, and the virtual machine triggers the host to enable the VF in response to the command line. The host can enable the VF by calling the interface for enabling the VF. Optionally, the host responds to the virtual machine's operation of setting the enable bit in the SR-IOV capability configuration based on the 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. This setting operation by the virtual machine triggers a virtual machine exit (VM exit). The virtual machine manager in the host then sets the enable bit in the SR-IOV capability configuration, and the virtual machine manager in the host enables the VF. Because the PF on the host is taken over by the VFIO driver, and the VFIO driver does not provide an interface for user-mode programs to enable and disable VFs, in the embodiment of the present disclosure, an SR-IOV manager (SR-IOV-manager) can be added to the host to enable VFs on the host. Specifically, the virtual machine manager communicates with the SR-IOV manager, and the SR-IOV manager enables VFs. The SR-IOV manager includes interfaces for enabling and disabling VFs. The virtual machine manager enables VFs through the SR-IOV manager, that is, the virtual machine manager enables VFs by calling the VF-enabling interface in the SR-IOV manager. In addition to enabling VFs in the embodiment of the present disclosure, the process of disabling VFs is similar to that of enabling VFs. Specifically, in response to a user instruction received by the virtual machine, the virtual machine triggers the host-side VF disabling. For example, the virtual machine manager and the SR-IOV manager After the user executes the above user instruction, the device driver in the virtual machine will set the enable bit in the SR-IOV capability. This operation will trigger a VM exit and trap to the virtual machine manager on the host. For example, the virtual machine manager is Qemu. After Qemu discovers this event, it will communicate with SR-IOV-Manager and call the VF enable interface in SR-IOV-Manager to enable the VF on the host, and the number is also 1. Through the newly added SR-IOV-Manager kernel module, Qemu can control the enabling and disabling of VFs on the host through this module.

[0009] S203, connect the VF to the virtual machine. After step 2, the host has been hot-plugged into the virtual machine. The following formula is used for calculation: vf_bdf = pf_bdf + vf_offset + vf_id * vf_stride, where vf_offset and vf_stride are defined in the SR-10V capability, vf_id is the VF identifier, and vf_stride is the address step size. Subsequently, programs in the virtual machine, such as Program 1 and Program 2 shown in Figure 2, can use the corresponding input and output functions of the PF and VF. Figure 3 is a second flow diagram of an I / O virtualization method provided in an embodiment of the present disclosure. As shown in Figure 3, the method includes:

[0010] 5301. Pass the physical function PF corresponding to the network card on the host directly to the virtual machine on the host.

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

[0012] 5303. Connect the VF directly to the virtual machine.

[0013] S304. Data sent and received by a user-mode-driven program in the virtual machine based on a VF is sent and received via the network card. In this embodiment of the present disclosure, taking the physical I / O 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 user mode, and the VF is directly connected to the virtual machine. In this way, the virtual machine now has the PF and VF corresponding to the network card. The user-mode-driven program in the virtual machine uses the network card to send and receive data via the VF directly connected to the virtual machine. When the user-mode-driven program runs on the host, the program also uses the network card to send and receive data via the VF. Therefore, the data input and output process for the program is the same. In this way, a user-mode-driven program originally running on the host that relies on SR-IOV can run directly in the virtual machine without modification. Figure 4 is a first structural diagram of an I / O virtualization device provided in an embodiment of the present disclosure. As shown in Figure 4, an I / O virtualization device 400 includes: a first direct passthrough module 401 for direct passthrough of a physical function (PF) corresponding to a physical I / O device on a host to a virtual machine on the host; an enabling module 402 for enabling, in user mode, the virtual function (VF) corresponding to the PF on the host; and a second direct passthrough module 403 for direct passthrough of the VF to the virtual machine. In one implementation, the first direct passthrough module 401 is configured to: bind the PF to the VF IO driver and add PF identification information to the virtual machine management; add a single-root virtualization SR-IOV capability configuration to the PF's simulated configuration space; and direct passthrough of the base address register space in the SR-IOV capability configuration to the virtual machine. In one implementation, the enabling module 402 is configured to: enable the VF in user mode on the host in response to an enable operation triggered by a user instruction from the virtual machine. The user instruction includes the number of VFs to be enabled and the path of an enablement control file, where the path of the enablement control file is generated by the virtual machine. In one implementation, the enabling module 402 is configured to: in response to a virtual machine setting an enable bit in an SR-IOV capability configuration based on a user instruction, enable the VF via the host through the virtual machine manager. In one implementation, the enabling module 402 is configured to: enable the virtual machine manager to communicate with the SR-IOV manager and enable the VF via the SR-IOV manager, wherein the SR-IOV manager includes an interface for enabling the VF. In one implementation, the second pass-through module 403 is configured to: bind the VF to a VF IO driver and hot-insert the VF into the virtual machine.The apparatus of the embodiments of the present disclosure can be used to perform the IO virtualization method of the aforementioned embodiments. Its implementation principles and technical effects are similar and will not be further described here. Figure 5 is a second structural diagram of an IO virtualization apparatus provided by an embodiment of the present disclosure. As shown in Figure 5, IO virtualization apparatus 500 includes: a first direct passthrough module 501 for direct passthrough of the physical function (PF) corresponding to the network interface card (NIC) on a host to a virtual machine on the host; an enabling module 502 for enabling the virtual function (VF) corresponding to the PF on the host in user mode; a second direct passthrough module 503 for direct passthrough of the VF to the virtual machine; and a transceiver module 504 for transmitting and receiving data based on the VF by a user-mode driver program in the virtual machine via the NIC. The apparatus of the embodiments of the present disclosure can be used to perform the IO virtualization method of the aforementioned embodiments. Its implementation principles and technical effects are similar and will not be further described here. Figure 6 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. As shown in Figure 6, electronic device 600 may include at least one processor 601 for implementing the IO virtualization method provided by an embodiment of the present disclosure. Optionally, the electronic device 600 also 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 disclosure refers to an indirect coupling or communication connection between devices, units, or modules, and can be electrical, mechanical, or other forms, used for information exchange between the 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. Optionally, the electronic device 600 also 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 transmitting and receiving functions. The processor 601 may use the communication interface 603 to transmit and receive data and / or information, and to implement the methods provided in the embodiments of the present disclosure. For details, please refer to the detailed description in the previous embodiments and will not be repeated here. The specific connection medium between the processor 601, memory 602, and communication interface 603 is not limited in the embodiments of the present disclosure. In FIG6 , the processor 601, memory 602, and communication interface 603 are connected via a bus 604. Bus 604 is represented by a bold line in FIG6 . The connection between other components is for illustrative purposes only and is not intended to be limiting. This bus can be classified as an address bus, a data bus, a control bus, and so on.For ease of illustration, FIG6 shows only one thick line, but this does not indicate that there is only one bus or only one type of bus. It should be understood that the processor in the embodiments of the present disclosure may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above-described method embodiment may be completed by hardware integrated logic circuits in the processor or by software instructions. The above-described processor may 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 methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure may be implemented or executed. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present disclosure may be directly 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-established in the art, such as random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), electrically erasable programmable memory (EEPM), 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 method. It should also be understood that the memory in the embodiments of the present disclosure can be volatile memory or non-volatile memory, or can include both volatile and non-volatile memory. Among them, non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache.By way of example, but 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 used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory. The present disclosure also provides a 10 virtualization system comprising a host and a virtual machine running on the host; the host passes physical functions corresponding to physical input / output devices on the host directly to the virtual machine, enables virtual functions corresponding to the physical functions on the host in user mode, and passes the virtual functions directly to the virtual machine. Optionally, a user-mode-driven program runs in the virtual machine, and the user-mode-driven program performs input and output through virtual functions. The methods executed by the host and virtual machines in the virtual machine system can be found in the description of the aforementioned embodiments. The present disclosure also provides a computer-readable storage medium storing a computer program (also referred to as code or instructions). When the computer program is executed by a processor, it implements the method of any of the aforementioned embodiments. The present disclosure also provides a computer program product, including the computer program. When the computer program is executed by a processor, it implements the method of any of the aforementioned embodiments. The present disclosure also provides a user-mode-driven program product, including the computer program. The computer program runs in a virtual machine on a host. The computer program performs input and output through virtual functions in the virtual machine. The virtual functions are directly connected to the virtual machine by the host using the method of any of the aforementioned embodiments. The terms "unit," "module," etc., used in this specification, may be used to refer to computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution.Those skilled in the art will appreciate that the various illustrative logic 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 using 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 implementations should not be considered beyond the scope of this disclosure. In the several embodiments provided in this disclosure, 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 merely one logical functional division. In actual implementation, other divisions may be used, such as combining or integrating multiple units or components into another system, or omitting or not implementing certain features. Furthermore, the coupling, direct coupling, or communication connection shown or discussed may be an indirect coupling or communication connection through interfaces, devices, or units, and may be electrical, mechanical, or other forms. 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 these units may be selected to achieve the objectives of the present embodiment according to actual needs. Furthermore, the functional units in the various embodiments of the present disclosure may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. In the above embodiments, the functions of each functional unit may be implemented in whole or in part through software, hardware, firmware, or any combination thereof. When implemented using software, they may be implemented in whole or in part in the form of a computer program product. This computer program product includes one or more computer instructions (programs). When these computer program instructions (programs) are loaded and executed on a computer, they fully or partially generate the processes or functions described in the embodiments of the present disclosure. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from a website, computer, server, or data center via a wired connection.

[0014] The data is transmitted to another website, computer, server, or data center via a computer-readable storage medium (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, hard disk, or magnetic tape), an optical medium (e.g., a digital video disc (DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)). If the 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 disclosure, or the portion that contributes to the prior art, or the portion of the technical solution, can be embodied in the form of a software product, and the computer software product can be stored in a storage medium. The present disclosure includes instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage media include various media capable of storing program code, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks. 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, storage, and display) involved in the present disclosure are all authorized by the user or fully authorized by all parties. The collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or reject. The above description is merely a specific embodiment of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any modifications or substitutions that can be easily conceived by any person skilled in the art within the technical scope of the present disclosure should be covered by the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.

Claims

Claims 1. An input and output virtualization method, wherein: include: Passing the physical functions corresponding to the physical input and output devices on the host directly to the virtual machine on the host; A virtual function corresponding to the physical function is enabled on the host in user mode; and the virtual function is directly connected to the virtual machine.

2. The method according to claim 1, wherein: Passing the physical function corresponding to the physical input / output device on the host directly to the virtual machine on the host includes: binding the physical function to the virtual function input / output driver and adding identification information of the physical function in the virtual machine manager; adding a single-root input / output virtualization capability configuration to the simulated configuration space of the physical function; and passing the base address register space in the single-root input / output virtualization capability configuration directly to the virtual machine.

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

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

5. The method according to claim 4, wherein: The host enabling the virtual function through the virtual machine manager includes: the virtual machine manager communicating with a single root input / output virtualization manager, and enabling 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, wherein: The passing the virtual function directly to the virtual machine includes: binding the virtual function to a virtual function input and output driver, and hot-plugging the virtual function into the virtual machine.

7. An input and output virtualization method, wherein: include: Passing the physical functions corresponding to the network card on the host directly to the virtual machine on the host; The method includes enabling a virtual function corresponding to the physical function on the host in user mode; directly connecting the virtual function to the virtual machine; and transmitting and receiving data transmitted and received by a user-mode driven program in the virtual machine based on the virtual function through the network card.

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

9. The system according to claim 8, wherein: 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, wherein: include: memory and processor; 9 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, wherein: 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, wherein: The method comprises a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

13. A program product based on a user-mode driver, wherein: The method comprises a computer program, wherein the computer program runs in a virtual machine on a host, the computer program performs input and output through a virtual function in the virtual machine, and 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.

Citation Information

Patent Citations

  • Data access method, device and system based on virtual machine device direct connection

    CN114756332A

  • Safe physical function passthrough using virtual machine functions

    US20180059974A1