WO2020220790A1 - 数据处理的方法、装置与设备 - Google Patents

数据处理的方法、装置与设备 Download PDF

Info

Publication number
WO2020220790A1
WO2020220790A1 PCT/CN2020/075084 CN2020075084W WO2020220790A1 WO 2020220790 A1 WO2020220790 A1 WO 2020220790A1 CN 2020075084 W CN2020075084 W CN 2020075084W WO 2020220790 A1 WO2020220790 A1 WO 2020220790A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
virtual machine
memory space
type
virtual
Prior art date
Application number
PCT/CN2020/075084
Other languages
English (en)
French (fr)
Inventor
阙鸣健
冯犇
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20798422.0A priority Critical patent/EP3951591A4/en
Publication of WO2020220790A1 publication Critical patent/WO2020220790A1/zh
Priority to US17/513,043 priority patent/US20220050795A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/14Handling requests for interconnection or transfer
    • G06F13/16Handling requests for interconnection or transfer for access to memory bus
    • G06F13/1668Details of memory controller
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Definitions

  • This application relates to the field of computer technology, and in particular to a method, device, and equipment for data processing in the field of virtualization.
  • I ⁇ O input ⁇ output
  • Virtualization scenarios are the main part of cloud computing, and the demand for I ⁇ O devices is huge.
  • hardware-assisted virtualization technology such as single-root input ⁇ Output virtualization (single root I/Ovirtualization, SR-IOV) technology can virtualize a hardware device into multiple virtual devices and present it to the virtual machine, and the virtual machine can bypass the host's participation when accessing the virtual device to realize the device High performance of I ⁇ O.
  • SR-IOV is a virtualized I/O hardware solution. It is one of the hardware-assisted I ⁇ O virtualization technologies, including physical functions (PF) and virtual functions (VF), among which PF It refers to a PCIe function supported by peripheral component interconnect express (PCIe) equipment, and a PF can be expanded into several VFs.
  • PF physical functions
  • VF virtual functions
  • VF refers to the virtual I/O device that supports SR-IOV and is obtained.
  • a VF corresponds to a virtual I/O device, and the virtual machine uses the virtual I/O device through VF.
  • Each virtual I/O device corresponds to an independent I/O device storage space
  • the I/O device storage space is set in the I/O device
  • the I/O device storage space is used to store and indicate the working status of the virtual I/O device
  • the hardware data of the virtual network card device is stored in the I/O device storage space corresponding to the virtual network card device.
  • an I/O device supporting SR-IOV when it includes multiple virtual I/O devices, needs to configure a complete I/O device storage space for each virtual I/O device to store virtual
  • the hardware data of the I/O device will increase the overhead of the hardware resource of the I/O device.
  • the present application provides a data processing method, device, and equipment to reduce the overhead of hardware resources of I/O equipment.
  • this application provides a data processing method, which relates to a data access process.
  • the method is applied to a data processing system.
  • the data processing system includes a virtual machine and an input/output I/O device.
  • the method Including: the virtual machine receives an I/O access request, where the I/O access request is used to access data, and the I/O access request includes the type of hardware data used to indicate the working status of the virtual I/O device, the virtual I
  • the /O device is the I/O device obtained after I/O device virtualization; when the virtual machine recognizes that the hardware data type in the I/O access request is the first type of data, the virtual machine obtains the to-be-accessed from the first memory space Data, where the first type of data is hardware data that the virtual I/O device remains unchanged during data processing, and the first memory space is the memory storage space of the data processing system.
  • the first type of data in the hardware data of the I/O device is stored in the memory of the data processing system, compared to the existing storage space of all hardware data of the virtual I/O device in the I/O device storage space
  • the occupation of the storage space of the I/O device can be greatly reduced, thereby reducing the hardware overhead of the I/O device.
  • the virtual machine accesses data
  • the virtual machine recognizes that the type of hardware data requested by the I/O access request is the first type of data
  • the virtual machine accesses the data from the first memory space of the data processing system, which is different from the existing virtual machine.
  • the number of accesses to the I/O device can be reduced, thereby effectively improving the data access speed.
  • the first type of data includes first data
  • the first data is hardware data that causes additional operations of the I/O device when the virtual machine accesses
  • the first memory space includes the first sub-memory A space
  • the first sub-memory space stores first data and a processing function
  • the processing function is used to simulate additional operations corresponding to the first data.
  • the virtual machine obtains the data to be accessed from the first memory space, including: the virtual machine obtains the first data from the first sub-memory space, and causes the virtual machine monitor to call the processing function to simulate the additional corresponding to the first data Operations to control the I/O device to perform actions corresponding to the additional operations, wherein the data processing system includes a virtual machine monitor.
  • the first data that causes additional operations of the I/O device when the virtual machine is accessed is stored in the first sub-memory space of the first memory space, so that the virtual machine can download from the first sub-memory space.
  • Access the first data and at the same time store the processing function corresponding to the first data in the first sub-memory space, so that when the virtual monitor detects that the virtual machine accesses the first data in the first sub-memory space, the processing can be called
  • the function simulates the additional operation corresponding to the first data to control the I/O device to execute the action corresponding to the additional operation, which ensures the authenticity and effectiveness of the virtual machine's access to the first data.
  • the first type of data further includes second data
  • the second data is hardware data in the first type of data other than the above-mentioned first data
  • the first memory space also includes a second sub
  • the second data is stored in the second sub-memory space.
  • the virtual machine acquiring the data to be accessed from the first memory space includes: the virtual machine accesses the second data from the second sub-memory space.
  • the virtual machine directly accesses the second data from the second sub-memory space instead of accessing the second data from the I/O device storage space, which can reduce the number of operations on the I/O device and reduce the I/O The hardware overhead of the device.
  • mapping relationship between the virtual address of the virtual machine and the address of the first memory space, so that the virtual machine can directly access the first type of data from the first memory space according to the mapping relationship, thereby improving the Access speed of class data.
  • the hardware data of the virtual I/O device of the present application also includes a second type of data.
  • the second type of data is hardware data other than the first type of data in the hardware data of the virtual I/O device.
  • the data is stored in the storage space of the I/O device, and the storage space of the I/O device is set in the I/O device and is the storage space of the I/O device.
  • the method of the present application further includes: when the virtual machine recognizes that the hardware data type in the I/O access request is the second type of data, the virtual machine obtains the data to be accessed from the storage space of the I/O device.
  • the second data is the hardware data of the virtual I/O device that will change during the data processing process, and when these hardware data are accessed, the I/O device needs to know immediately. Therefore, this application refers to the second type of data Stored in the storage space of the I/O device, it is convenient for the I/O device to know that the second type of data is accessed by the virtual machine in time, and take corresponding actions immediately to ensure the timeliness of data access.
  • the virtual machine accesses the second type of data from the storage space of the I/O device based on the pass-through method, which further improves the timeliness of access to the second type of data.
  • this application provides a data processing method, which involves a data storage process.
  • the method is applied to a data processing system.
  • the data processing system includes a virtual machine monitor, a virtual machine, and an input/output I/O device.
  • the method includes: the virtual machine monitor obtains the first type of data, where the first type of data is the hardware data of the virtual I/O device that remains unchanged during the data processing process, and the virtual I/O device is the I/O device virtualization The I/O device obtained later; the virtual machine monitor stores the first type of data in the first memory space, and the first memory space is the storage space in the memory of the data processing system.
  • the virtual machine monitor stores the first type of data in the hardware data of the virtual I/O device in the first memory space of the server, compared to the existing storage of all hardware data of the virtual I/O device in In the I/O device storage space, when the I/O device includes more virtual I/O devices, the method of the present application can greatly reduce the occupation of the I/O device storage space and reduce the hardware overhead of the I/O device .
  • the method further includes: the virtual machine monitor processes the data from the data according to the size of the first type of data.
  • the first memory space is applied for in the memory storage space of the system. This can include that the first type of data can be stored in the first memory space.
  • the first type of data includes first data
  • the first data is hardware data that causes additional operations of the I/O device when accessed by the virtual machine.
  • the application method includes: a virtual machine monitor applies for a first sub-memory space from the first memory space according to the size of the first data; the virtual machine monitor stores the first data and processing functions in the In the first sub-memory space, the processing function is used to simulate additional operations corresponding to the first data. In this way, the first data is stored in the first sub-memory space of the first memory space.
  • the virtual machine accesses the first data, the virtual machine can directly access the first data from the first sub-memory space instead of I/O.
  • Accessing the first data in the storage space of the device can reduce the number of operations on the I/O device and reduce the hardware overhead of the I/O device.
  • the processing function corresponding to the first data is stored in the first sub-memory space, so that when the virtual monitor detects that the virtual machine accesses the first data in the first sub-memory space, the processing function can be called to simulate the first data
  • the corresponding additional operation is used to control the I/O device to execute the action corresponding to the additional operation, which ensures the authenticity and effectiveness of the virtual machine's access to the first data.
  • the application further includes: when the virtual machine monitor detects that the virtual machine accesses the first data from the first sub-memory space, it calls the processing function to simulate the additional corresponding to the first data. Operation; The virtual machine monitor controls the I/O device to execute the action corresponding to the additional operation, thereby ensuring the authenticity and effectiveness of the virtual machine's access to the first data.
  • the first type of data further includes second data
  • the second data is hardware data in the first type of data other than the first data
  • the method also The method includes: a virtual machine monitor applies for a second sub-memory space from the first memory space according to the size of the second data; the virtual machine monitor stores the second data in the second sub-memory space .
  • the second data can be completely stored in the second sub-memory.
  • the virtual machine accesses the second data, the virtual machine can directly access the second data from the second sub-memory space instead of storing it from the I/O device.
  • the second data is accessed in the space, so that the number of operations on the I/O device can be reduced, and the hardware overhead of the I/O device can be reduced.
  • the above method further includes: when the virtual machine monitor detects that the second data has changed, sending the changed second data to the I/O device.
  • the protocol of the virtual I/O device is updated, a new functional domain segment is added, or a vendor-specific register is added, the problem of inconvenient addition of new data can be solved by changing or adding the second data in the second sub-memory space.
  • the virtual machine monitor detects a change in sending the second data in the second sub-memory space, it sends the changed second data to the I/O device to ensure that the driver of the virtual machine and the I/O device work together normally.
  • the hardware data of the virtual I/O device of the present application also includes a second type of data
  • the second type of data is hardware data other than the first type of data in the hardware data of the virtual I/O device, that is, virtual The hardware data of the I/O device that will change during the data processing process.
  • the above method further includes: the virtual machine monitor stores the second type of data in the I/O device storage space.
  • the second data is the hardware data of the virtual I/O device that will change during the data processing process, and when these hardware data are accessed, the I/O device needs to know immediately.
  • this application refers to the second type of data Stored in the storage space of the I/O device, it is convenient for the I/O device to know that the second type of data is accessed by the virtual machine in time, and take corresponding actions immediately to ensure the timeliness of data access.
  • the above method further includes: the virtual machine monitor maps the address of the second type of data in the storage space of the I/O device to the address of the second memory space, so that when the virtual machine Access to the second type of data in the storage space of the I/O device can be achieved by accessing the second memory space.
  • the above method further includes: the virtual machine monitor maps both the address of the first memory space and the address of the second memory space to the virtual address space of the virtual machine, so that the virtual The computer can access the second type of data in the I/O device storage space and access the first type of data in the first memory space by accessing its own virtual address space.
  • the present application provides a data processing device that can realize the functions of the above-mentioned virtual machine.
  • the device is applied to a data processing system.
  • the data processing system includes the device and an input/output I/O device.
  • the device includes: a receiving unit, a processing unit, and an obtaining unit.
  • the receiving unit is configured to receive an I/O access request, the I/O access request is used to access data, and the I/O access request includes a virtual I/O access request.
  • the type of hardware data in the working state of the /O device, the virtual I/O device is the I/O device obtained after the I/O device is virtualized; the processing unit is used to identify the type of the I/O access request
  • the hardware data type is the first type of data, and the first type of data is the hardware data that the virtual I/O device remains unchanged during the data processing process; the acquiring unit is configured to acquire the to-be-accessed data from the first memory space Data, the first memory space is a memory storage space of the data processing system.
  • the first type of data includes first data, the first data being hardware data that causes additional operations of the I/O device when accessed by the device, and the first memory space includes A first sub-memory space, where the first data and processing functions are stored in the first sub-memory space, and the processing functions are used to simulate additional operations corresponding to the first data; at this time, the acquiring unit, Specifically, it is used to obtain the first data from the first sub-memory space, and make the virtual machine monitor call the processing function to simulate the additional operation corresponding to the first data, so as to control the I/O device to execute the Actions corresponding to the additional operations, the data processing system includes a virtual machine monitor.
  • the first type of data further includes second data, and the second data is hardware data other than the first data in the first type of data; the first type of data A memory space further includes a second sub-memory space, and the second data is stored in the second sub-memory space; at this time, the acquiring unit is specifically configured to access the second sub-memory space The second data.
  • mapping relationship between the virtual address of the device and the address of the first memory space is optionally, the mapping relationship between the virtual address of the device and the address of the first memory space.
  • the present application provides a data processing device that can realize the function of the above-mentioned virtual machine monitor.
  • the device is applied to a data processing system, and the data processing system includes the device, a virtual machine, and an input/output device.
  • the device includes: an acquisition unit and a processing unit, wherein the acquisition unit is configured to acquire a first type of data, and the first type of data is the hardware that the virtual I/O device remains unchanged during data processing Data, the virtual I/O device is an I/O device obtained after the I/O device is virtualized; a processing unit configured to store the first type of data in a first memory space, and the first memory The space is the storage space in the memory of the data processing system.
  • the processing unit is further configured to apply for the first memory space from the memory storage space of the data processing system according to the size of the first type of data.
  • the first type of data includes first data
  • the first data is hardware data that causes additional operations of the I/O device when accessed by the virtual machine
  • the processing The unit is specifically configured to apply for a first sub-memory space from the first memory space according to the size of the first data, and store the first data and processing functions in the first sub-memory space, The processing function is used to simulate additional operations corresponding to the first data.
  • the processing unit is further configured to: when detecting that the virtual machine accesses the first data from the first sub-memory space, call the processing function to simulate the first data Corresponding additional operations, and control the I/O device to perform actions corresponding to the additional operations.
  • the first type of data further includes second data
  • the second data is hardware data other than the first data in the first type of data
  • the processing The unit is specifically configured to apply for a first sub-memory space from the first memory space according to the size of the second data, and store the second data in the second sub-memory space.
  • the device further includes: a sending unit; wherein the processing unit is further configured to detect that the second data has changed; and the sending unit is configured to detect that the processing unit detects all changes.
  • sending of the second data changes, sending the changed second data to the I/O device.
  • the processing unit is further configured to store the second type of data in the storage space of the I/O device, and the second type of data is the data of the virtual I/O device.
  • Hardware data other than the first type of data in the hardware data.
  • the processing unit is further configured to map the address of the second type of data in the storage space of the I/O device to the address of the second memory space of the server.
  • the processing unit is further configured to map both the address of the first memory space and the address of the second memory space to the virtual address space of the virtual machine.
  • this application provides a data processing device, including a processor, configured to execute the method described in the first aspect or the second aspect.
  • the present application provides a computer storage medium.
  • the storage medium includes computer instructions. When the instructions are executed by a computer, the computer realizes the method described in the first or second aspect.
  • the present application provides a computer program product, the program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of a data processing device can read from the readable storage medium Taking the computer program, the at least one processor executes the computer program to enable a data processing device to implement the method of any one of the first aspect or the second aspect.
  • the virtual machine monitor stores the first type of data in the hardware data of the virtual I/O device in the first memory space of the server, compared to In the existing virtual I/O device, all hardware data is stored in the I/O device storage space.
  • the method of the present application can greatly reduce the I/O Occupation of device storage space and hardware overhead of I/O devices.
  • the virtual machine In the data access process, after the virtual machine receives the I/O access request, it identifies the type of hardware data requested by the I/O access request, and identifies the type of hardware data requested by the I/O access request as the first type Data, the virtual machine accesses the data from the first memory space of the server; identifying that the hardware data type requested by the I/O access request is the second type of data, the virtual machine accesses the data from the I/O device storage space.
  • the number of visits to the I/O device can be reduced, thereby effectively improving the data access speed.
  • FIG. 1 is a schematic structural diagram of a data processing system provided by an embodiment of the application
  • FIG. 2 is a schematic diagram of a configuration of hardware data involved in an embodiment of the application
  • FIG. 3 is a schematic diagram of another configuration of hardware data involved in an embodiment of the application.
  • FIG. 4 is a schematic flowchart of a data processing method provided by an embodiment of the application.
  • FIG. 5 is a schematic diagram of an address mapping provided by an embodiment of the application.
  • FIG. 6 is a schematic diagram of another flow of a data processing method provided by an embodiment of this application.
  • FIG. 7 is a schematic diagram of memory allocation provided by an embodiment of the application.
  • FIG. 8 is a schematic structural diagram of a device provided by an embodiment of this application.
  • FIG. 9 is a schematic structural diagram of another device provided by an embodiment of this application.
  • FIG. 10 is a schematic structural diagram of a data processing device provided by an embodiment of this application.
  • Virtual machine monitor used to manage virtual machines.
  • the virtual machine monitor includes, but is not limited to, a hypervisor.
  • a quick emulator QEMU
  • VMware a type of virtual machine software
  • VirtualBox a type of virtual machine software
  • Virtual function input ⁇ output (virtual function I/O, VFIO): is a set of user-mode driver framework, which provides user-mode access to hardware devices and configuration management device interfaces, Hypervisor can use the VFIO framework to achieve SR-IOV support The purpose of device pass-through to virtual machines.
  • Memory mapped input/output (memory mapped I/O, MMIO): It maps the resources of peripheral devices to the host memory space to facilitate the access of the central processing unit (CPU).
  • CPU central processing unit
  • Virtualization input/output (Virtio): Virtio is a set of I/O virtualization frameworks for paravirtualization platforms. It abstracts the general analog devices in the hypervisor and provides a set of standard interfaces for virtual machines to access these analog devices .
  • Single root input ⁇ input virtualization (single root I/O virtualization, SR-IOV): It is a hardware-based virtualization solution that can improve virtual machine performance and scalability.
  • SR-IOV creates a series of I/O The virtual function (VF) of the physical port of the O device, each virtual machine is configured with a VF, one VF corresponds to a virtual I/O device, and the virtual machine loads the I/O device corresponding to the VF by loading the VF.
  • SR-IOV allocates I/O functions to multiple virtual interfaces in order to share the resources of an I/O device in a virtualized environment. SR-IOV allows network transmission to bypass the software simulation layer and directly allocate it to the virtual machine.
  • FIG. 1 is a schematic structural diagram of a data processing system provided by an embodiment of the application.
  • the data processing system includes a processor and I/O devices.
  • the following takes the data processing system as a server as an example for detailed description.
  • the server is used to generate one or more virtual machines by running virtualization software and virtualizing the hardware resources of the server.
  • the server includes one or more processors, and each processor includes one or more processor cores.
  • the server also includes a virtual machine monitor. For ease of description, an example is described by taking the processor of the server running only one virtual machine monitor and one virtual machine as an example.
  • I/O devices include physical network cards, physical offload cards, physical memory cards, and other devices connected to the processor.
  • the I/O device can be connected to the server in the form of a PCIe slot to realize the communication between the I/O device and the processor.
  • the aforementioned I/O device can also be directly integrated with the server motherboard.
  • the I/O device supports the SR-IOV function. By integrating the SR-IOV function into the I/O device, a single I/O device is virtualized into one or more virtual I/O devices.
  • Figure 1 is an example Only the case where the I/O device includes a virtual I/O device is shown.
  • Virtual machine is the most common type of resource in the public cloud service environment. It runs a virtual machine monitor program, such as a hypervisor program, on the server, thereby exerting the virtualization capabilities provided by the processor and other hardware, and sharing hardware resources with Implemented by multiple operating systems running in parallel and logically isolated.
  • a virtual machine can be understood as a client, which can occupy one or more virtual I/O devices for accessing the virtual I/O devices according to the user's access instructions.
  • Each virtual machine includes a front-end driver. When the virtual machine accesses a virtual I/O device, the front-end driver is loaded. The front-end driver is used to access the hardware data of the virtual I/O device, thereby achieving access to the virtual I/O device .
  • the virtual machine monitor running on the processor, is used to manage virtual machines and specify virtual I/O devices for the virtual machines.
  • the virtual machine monitor can be implemented by software, that is, a specific program code is run in the processor to realize the management of the virtual machine.
  • the processor running the program can be the same as the processor running the virtual machine.
  • the virtual machine and the virtual machine monitor run on the same processor; different processors can also be used to implement the virtual machine monitors.
  • the function of the virtual machine for example, one processor is used to realize the function of a virtual machine monitor, and other processors are used to run the virtual machine.
  • the virtual machine monitor can also be implemented by hardware, that is, a separate processor or logic circuit is used to implement the function of the virtual machine monitor.
  • the following takes the virtual machine and virtual machine monitor deployment form shown in FIG. 1 as an example for description.
  • the above-mentioned hardware data of the virtual I/O device can be understood as the attribute data and function data of the virtual I/O device that enable the virtual I/O device to work normally.
  • the hardware data of the virtual I/O device complies with the preset regulations, for example, complies with the preset I ⁇ O protocol.
  • the preset I ⁇ O protocol is the Virtio protocol as an example to further introduce the embodiments of the present application.
  • virtual I/O devices comply with four standard capabilities (Capability), which are: Common Configuration, Notification, Interrupt Service Routine (ISR), and device specificity ( Device-specific).
  • ISR Interrupt Service Routine
  • Device-specific Device specificity
  • public configuration capabilities used to provide queue information configuration (such as queue depth, queue address, queue enable), device characteristics (that is, features supported by the device, such as the descriptor format supported by the device) configuration, and device status information, etc. .
  • Notification capability Used to notify the device of I ⁇ O access generated when the host accesses the space, which is similar to the doorbell register in the non-volatile memory host controller interface (non-volatile memory express, NVMe) protocol.
  • Interrupt service program capability The device informs the host CPU of the completion of I ⁇ O processing or an abnormality by reporting an interrupt.
  • Device specific capabilities Since the Virtio protocol supports a variety of I ⁇ O devices, such as network cards, disk controllers, graphics processing units (GPUs), etc., this space stores the specific attributes of the corresponding devices. Take the network card device as an example, where the number of network card queues, the maximum supported maximum transmission unit (MTU) value, and physical address (media access control or medium access control, MAC) are stored here.
  • MTU maximum supported maximum transmission unit
  • MAC medium access control
  • the hardware data of the virtual I/O device includes the specific hardware data described by the above four standard capabilities.
  • the hardware data corresponding to the common configuration includes fields related to device function (device_feature), driver function (driver_feature), and queue (queue).
  • the hardware data corresponding to the notification includes multiple notification registers, which are associated with the above queue.
  • the server divides the hardware data of the virtual I/O device into the first type of data and the second type of data.
  • the embodiment of the present application does not limit the way in which the server divides the foregoing hardware data into the first type of data and the second type of data.
  • the server divides the aforementioned hardware data into the first type of data and the second type of data according to whether the hardware data of the virtual I/O device changes during the data processing process as a criterion.
  • the first type of data is the hardware data of the virtual I/O device that remains unchanged during data processing.
  • the device function (device_feature) is used to identify the features supported by the virtual I/O device, and the number of queues (num_queues) is used to identify the virtual I The maximum number of queues supported by the /O device. All these data are only recorded as inherent information in the virtual I/O device driver during the initialization phase of the virtual I/O device.
  • the device function (device_feature) is used to represent the virtual I/O device status information. It only changes during the virtual I/O device driver initialization or driver unloading stage, and has no effect in the I ⁇ O access process. In this way, these device functions (device_feature), driver functions (driver_feature), and queues (queue) can take effect in the virtual I/O device initialization phase.
  • the second type of data is the hardware data of the virtual I/O device other than the first type of data, or the hardware data of the virtual I/O device that will change during the data processing process, such as in the Virtio protocol
  • the notification register defined by the notification capability space is used to notify the virtual I/O device when the front-end driver of the virtual machine initiates an I ⁇ O access request, so that the virtual I/O device immediately starts the direct memory access (DMA) engine
  • DMA direct memory access
  • the relevant data defined in the interrupt service program capability space is used to identify interrupt status information.
  • FIG. 2 is a schematic diagram of a configuration of hardware data involved in an embodiment of the application.
  • the virtual machine monitor is used to apply for the first memory space for the first type of data in the server's memory according to the size of the first type of data, and store the first type of data in the first memory of the server In space.
  • the virtual machine monitor is also used to store the second type of data in the storage space of the I/O device.
  • the storage space of the I/O device can be understood as the storage space on the I/O device that can be accessed by the processor.
  • the virtual machine initiates an access request. If the data accessed by the I/O access request is the first type of data, the virtual machine accesses the data from the first memory space of the server. If the data accessed by the access request is the first type of data In the case of the second type of data, the virtual machine accesses the data from the I/O device storage space.
  • the I/O device further includes a configuration space.
  • the configuration space includes one or more base address registers (BAR).
  • BAR base address registers
  • a virtual I/O device in this embodiment of the application has one I/O storage space.
  • the I/O device storage space has a mapping relationship with the BAR space.
  • the BAR space of each virtual I/O device can be accessed through the PF bus, device and function number (route ID), and then according to the BAR space and I/O The mapping relationship between O device storage space, access to the I/O device storage space of each virtual I/O device.
  • the server is also used to store the second type of data in the I/O device storage space.
  • the address is mapped to the address of the second memory space of the server, so that the space mapped to the I/O device storage space in the second memory space of the server can be understood as the MMIO space.
  • the I/O access request of the virtual machine is the first address segment in the I/O device storage space, according to the mapping relationship between the address of the MMIO space and the address of the I/O device storage space, from the I/O device storage space
  • the second type of data is accessed in the storage space of the O device.
  • the first type of data is further divided into the first data and the second data, where the first data is the I/ The hardware data of the additional operation of the O device, and the second data is the hardware data that does not cause the additional operation of the I/O device when accessed by the virtual machine.
  • the data related to device function (device_feature), driver function (driver_feature) and queue (queue) are inherent attributes for the front-end driver in the virtual machine. After the front-end driver reads these data, it ends and no subsequent additions will occur. Action, therefore, these data are recorded as second data.
  • the device_status field in the public configuration indicates the device status information.
  • the front-end driver can write to the device_status field.
  • the virtio protocol defines that when the front-end driver writes 0 to device_status, the I/O device needs to perform a corresponding I/O device reset action. Including additional operations such as clearing historical configuration information, clearing the queue buffer, and recording these data as the first data.
  • FIG. 3 is a schematic diagram of another configuration of hardware data involved in an embodiment of this application.
  • the first memory space of the server includes a first sub-memory space and a second sub-memory space. .
  • the virtual machine monitor is used to apply for the first sub-memory space for the first data according to the size of the first data, and store the first data in the first sub-memory space, and at the same time provide
  • the data configuration processing function is used to simulate additional operations corresponding to the first data.
  • the virtual machine monitor is further configured to apply for a second sub-memory space for the second data according to the size of the second data, and store the second data in the second sub-memory space.
  • the processing function can be understood as the program code in the virtual machine monitor or the software module or unit that realizes the above configuration function.
  • the virtual machine receives the I/O access request. If the data accessed by the I/O access request is the first data, since the first data will cause additional operations of the I/O device, the virtual machine monitors The processor intercepts the I/O access request, calls the processing function corresponding to the first data, and simulates the additional operation corresponding to the first data through the processing function. At the same time, the I/O device is controlled to complete the action corresponding to the additional operation, such as a reset action. If the data accessed by the I/O access request is the second data, the virtual machine directly accesses the data from the second sub-memory of the server.
  • the data processing process in the embodiment of the application includes a data storage process and a data access process, where the data storage process is executed by a virtual machine monitor in the processor, The data access process is executed by a virtual machine in the processor, and the method may include:
  • the virtual machine monitor obtains the first type of data.
  • the first type of data belongs to hardware data used to indicate the working status of a virtual I/O device, and the virtual I/O device is an I/O device obtained after the I/O device is virtualized.
  • the type of hardware data of the virtual I/O device can be determined according to a preset rule, for example, the type of hardware data is determined according to an I/O protocol.
  • the corresponding hardware data may be different.
  • the hardware data corresponding to the NVMe protocol and the Virtio protocol are different.
  • the virtual I/O device is designed according to preset rules and presented to the server in the form of a controller, such as an NVMe controller or a Virtio controller.
  • the virtual machine monitor can obtain the hardware data of the virtual I/O device according to the preset rules followed by the virtual I/O device, and proceed from the preset rules to distinguish the first from the hardware data of the virtual I/O device.
  • the specific process of distinguishing between the type data and the second type data please refer to the description of FIG. 2 above, which will not be repeated here.
  • the hardware data of the virtual I/O device that remains unchanged during the data processing process is determined as the first type of data, such as reset ⁇ initial configuration ⁇ information negotiation and other data.
  • the hardware data of the virtual I/O device that will change during the data processing process is determined as the second type of data, such as data such as the state of the virtual I/O device.
  • the hardware data of the aforementioned virtual I/O device may be hardware data of the I/O device, that is, the virtual I/O device multiplexes the hardware data of the I/O device.
  • the virtual machine monitor stores the first type of data in the first memory space.
  • the first memory space is the storage space in the memory of the server.
  • the virtual machine monitor After the virtual machine monitor obtains the first type of data of the virtual I/O device, it applies for the first memory space for the first type of data from the memory space of the server, and stores the first type of data in the first memory space of the server .
  • this step may include: the virtual machine monitor applies for the first memory space from the memory space of the server according to the size of the first type of data; and saves the first type of data in the first memory space in.
  • the size of the first memory space may be greater than or equal to the size of the first type of data.
  • the size of the first storage space may also be the first value.
  • the first value is a value obtained after calculation based on the statistical value of the size of the first type of data that the system has processed.
  • the size of the first storage space can also be directly set to the second value.
  • the second value can be the default value. When the I/O access request is actually processed, it will be dynamically expanded according to the current size of the first type of data.
  • the first memory space is greater than or equal to the size of the first type of data.
  • the first memory space that the virtual machine monitor applies for from the memory space of the server is a memory space that does not store data.
  • the virtual machine monitor stores the first type of data in the first memory space according to the preset rules of the virtual I/O device, for example, stores a certain data of the first type of data in the fields a to the first memory space. In the space corresponding to the field b, and so on, the first type of data is stored in the first memory space.
  • the first memory space may be a continuous storage space of a preset size in the memory, or may be a storage space composed of intermittent functions of multiple storage areas.
  • the embodiment of the present application further includes steps S103 and S104.
  • the virtual machine monitor obtains the second type of data.
  • the virtual machine monitor stores the second type of data in the storage space of the I/O device.
  • the virtual machine monitor After the virtual machine monitor obtains the second type of data of the virtual I/O device, it stores the second type of data in the I/O device storage space.
  • the I/O device storage space is the storage space of the I/O device. The storage space accessed by the processor. In this way, when accessing the second type of data, the virtual machine directly accesses the I/O device storage space, and the I/O device knows that the second type of data is accessed in time, and immediately takes corresponding actions to ensure real-time data access.
  • the occupation of the storage space of the I/O device is reduced.
  • the second type of data of the virtual I/O device is stored in the I/O device storage space. Since the second data is the hardware data of the virtual I/O device that will change during the data processing process, this application will use the second type of data Stored in the storage space of the I/O device, when the second type of data is accessed, the I/O device can know it in time and take corresponding actions immediately to ensure the timeliness of data access.
  • the first parameter is used to identify the virtual I/O device that supports the configuration of hardware data in the server's memory space
  • the second parameter is used to identify the location of additional simulation functions.
  • the required processing function According to the characteristics of the virtual I/O device, QEMU assigns the above two parameters to the virtual I/O device that supports storing the first type of data in the first memory space of the server.
  • QEMU first starts the virtual machine and specifies a virtual I/O device for the virtual machine.
  • QEMU determines whether the virtual I/O device has the above-mentioned first parameter and second parameter. If the virtual I/O device has the above two parameters, QEMU uses the above steps S101 to S103 to configure the hardware data for the virtual I/O device. Specifically, QEMU obtains the hardware data and divides the hardware data into the first category Data and the second type of data.
  • QEMU applies for the first memory space from the server, and stores the first type of data in the first memory space.
  • QEMU stores the second type of data in the storage space of the I/O device, thereby realizing the configuration of the hardware data of the virtual I/O device.
  • the virtual machine monitor can directly read the first type of data from the server's memory through the MMIO method, reducing The message exchange between the virtual machine monitor and the I/O device.
  • the processor can directly access the data in the memory, so that the virtual machine monitor can read more quickly Taking the first type of data reduces the processing time of the entire I/O access request and improves the processing efficiency of the I/O access request.
  • the embodiment of the present application further includes:
  • the virtual machine monitor maps the address of the second type of data in the storage space of the I/O device to the address of the second memory space of the server.
  • the above S1041 may be executed after the above S104.
  • the address of the second type of data in the I/O device storage space is mapped to the address of the second memory space of the server.
  • the virtual machine monitor can access the second type of data in the storage space of the I/O device by accessing the address of the second memory space.
  • the virtual machine monitor maps both the address of the first memory space and the address of the second memory space to the virtual address space of the virtual machine.
  • the virtual address space of the virtual machine is divided into two parts, which are respectively denoted as the first virtual address space and the second virtual address space.
  • the virtual machine monitor maps the address of the second memory space to the first virtual address space of the virtual machine, and maps the first memory space to the second virtual address space of the virtual machine.
  • the virtual machine accesses the first type of data
  • the virtual machine accesses the second virtual address space, and the mapping relationship between the second virtual address space and the address of the first memory space, so that the virtual machine can directly download from the first memory space Access to the first type of data.
  • the virtual machine when a virtual machine accesses the second type of data, the virtual machine directly accesses the first virtual address space, and the addresses of the first virtual address space and the second memory space have a mapping relationship, and the addresses of the second memory space and I/O The address of the device storage space has a mapping relationship, so that the virtual machine can directly access the second type of data from the I/O device storage space.
  • the foregoing S104 may be replaced by S1043.
  • the virtual machine monitor stores the second type of data in the storage space of the I/O device based on the pass-through method.
  • the virtual machine monitor configures the second type of data in the I/O device storage space based on the pass-through method to ensure that the virtual machine is accessing the second type of data. , Based on the pass-through method to directly access the second type of data from the I/O device storage space to improve the access speed of the second type of data.
  • VFIO is a set of user mode device driver framework, including: VFIO interface layer (interface), I ⁇ O storage unit (I ⁇ O memory unit, IOMMU) driver, Vfio-IOMMU abstraction layer, Vfio-pci abstraction layer, PCI bus driver (pci-bus driver).
  • IOMMU is a module integrated on the north bridge of the processor. It is used to establish memory address mapping for I ⁇ O devices, address isolation between control devices, and interrupt remapping. It is the core hardware unit that realizes I ⁇ O device pass-through. IOMMU completes DMA address mapping and interrupt mapping of I ⁇ O devices.
  • the VFIO framework encapsulates the IOMMU module and PCIe module, and provides a set of standard interfaces for using IOMMU and I ⁇ O devices to user mode programs.
  • VFIO provides the user mode with the ability to manage the IOMMU page table by encapsulating the IOMMU driver.
  • the IOMMU page table is used to record the mapping relationship between I/O devices and server memory addresses. Each I/O device has a different IOMMU page table.
  • VFIO also provides direct access and configuration management device interfaces to the user mode by encapsulating I ⁇ O device drivers. When the I ⁇ O device adopts the VFIO pass-through mode, the user-mode Hypervisor program only needs to call the various capabilities provided by VFIO through the agreed ioctl interface.
  • the specific configuration process includes: the virtual machine monitor inquires and configures the storage space of the I ⁇ O device of the second type of data.
  • the storage space may include multiple registers defined in the I/O protocol for recording the second type of data.
  • the address of the second type of data in the storage space of the I/O device is mapped to the address of the second memory space of the server.
  • the addresses of the second memory space of the server are mapped to the virtual address space of the virtual machine, and the DMA and interrupt resources of the I ⁇ O device are associated through the IOMMU, and finally the relevant data is registered to the virtual machine to realize I ⁇ O Device pass-through function.
  • the virtual machine In the data access process, if the accessed hardware data type is the second type of data, the virtual machine directly accesses the data from the I/O device storage space based on the pass-through method. Specifically, based on the mapping relationship between the addresses of the first virtual address space and the second memory space, and the mapping relationship between the addresses of the second memory space and the addresses of the I/O device storage space, when the virtual machine directly accesses the first virtual address space , the second type of data can be accessed directly from the I/O device storage space, ensuring the timeliness of access to the second type of data.
  • the virtual machine receives an I/O access request.
  • the I/O access request is used to access data, and the I/O access request includes the type of hardware data used to indicate the working state of the virtual I/O device.
  • the type of hardware data accessed in the I/O access request may be the first type of data or the second type of data.
  • S106 The virtual machine recognizes that the hardware data type in the I/O access request is the first type of data.
  • the virtual machine obtains the data to be accessed from the first memory space.
  • the virtual machine After the virtual machine receives the I/O access request, it recognizes the I/O access request. If the hardware data type in the I/O access request is identified as the first type of data, the virtual machine will download from the first memory space of the server Access this first type of data.
  • the aforementioned I/O access request is a read request.
  • the virtual machine After the virtual machine receives the read request, it identifies whether the type of hardware data requested by the read request is the first type of data or the second type of data. If it is the first type of data, then The virtual machine reads the first type of data from the first memory space of the server. If it is the second type of data, the virtual machine reads the second type of data from the I/O device storage space.
  • the virtual machine recognizes that the hardware data type in the I/O access request is the second type of data.
  • the virtual machine obtains the data to be accessed from the storage space of the I/O device.
  • the virtual machine If the virtual machine recognizes that the hardware data type in the I/O access request is the second type of data, the virtual machine accesses the second type of data from the storage space of the I/O device.
  • the virtual machine monitor stores the second type of data in the I/O device storage space based on the pass-through method, so that during the data access process, the virtual machine recognizes the above I/O access
  • the virtual machine can directly access the data from the I/O device storage space based on the pass-through method.
  • the second type of data can be accessed directly from the I/O device storage space, ensuring the timeliness of access to the second type of data.
  • the virtual machine accesses the data from the first memory space of the server, and if the I/O access request The hardware data type to be accessed is the second type of data, and the virtual machine accesses the data from the I/O device storage space.
  • the existing access data from the I/O device storage space it can lessen the I/O The number of accesses to the device, thereby increasing the speed of data access.
  • the virtual machine monitor stores the first type of data in the hardware data of the virtual I/O device in the first memory space of the server, which is compared with the existing All hardware data of the virtual I/O device is stored in the I/O device storage space.
  • the method of the embodiment of the present application can greatly reduce the impact on the I/O device. Occupation of storage space and hardware overhead of I/O devices.
  • the virtual machine In the data access process, after the virtual machine receives the I/O access request, it identifies the type of hardware data requested by the I/O access request, and identifies the type of hardware data requested by the I/O access request as the first type Data, the virtual machine accesses the data from the first memory space of the server; identifying that the type of hardware data requested by the I/O access request is the second type of data, the virtual machine accesses the data from the I/O device storage space, The number of visits to the I/O device can be reduced, thereby effectively improving the data access speed.
  • FIG. 6 is another flowchart of the data processing method provided by an embodiment of the application.
  • the embodiment of the application details the storage process and access process of the first data and the second data in the first type of data.
  • the introduction is as follows, referring to FIG. 1, FIG. 5, and FIG. 6, the method of the embodiment of the present application may include:
  • the virtual machine monitor applies for a first sub-memory space from the first memory space according to the size of the first data.
  • the virtual machine monitor stores the first data in the first sub-memory space, and configures a processing function for the first data, where the processing function is used to simulate additional operations corresponding to the first data.
  • This application divides the first type of data into the first data and the second data. This application does not limit the method of dividing the first data and the second data, which is specifically determined according to actual needs.
  • the first type of data is divided into the first data and the first data.
  • Two data The first data is hardware data that will cause additional operations of the I/O device when accessed by the virtual machine, and the second data is data in the first type of data other than the first data, that is, the second data is not when the virtual machine is accessed. Hardware data that will cause additional operations of the I/O device.
  • the virtual machine monitor applies for the first sub-memory space for storing the first data from the first memory space of the server according to the size of the first data, and stores the first data in the first memory space.
  • the virtual machine monitor applies for the first sub-memory space for storing the first data from the first memory space of the server according to the size of the first data, and stores the first data in the first memory space.
  • a subspace to reduce the hardware burden of I ⁇ O devices.
  • the device_status field is used to synchronize the status information between the front-end driver and the I/O device.
  • the device_status field When cleared by the virtual machine, it means that the I/O device is reset, and the I/O device will clear the previous configuration information or restore it to the default value.
  • setting the queue_enable field means that the virtual machine has allocated the necessary shared memory for the queue. The I/O device needs to record the queue address and prepare the queue to initiate data transmission at any time. The virtual machine monitor applies for the corresponding first sub-memory space for these fields.
  • the above first data Since the above first data is accessed by the virtual machine, it will cause additional operations of the I/O device.
  • the above first data is reset data, and the virtual machine accesses the reset data, which will cause a reset operation of the I/O device.
  • the embodiment of the present application since the above-mentioned first data is that the virtual machine monitor is configured in the first memory space of the server through simulation, when it is accessed, the I/O device cannot directly generate additional operations. Therefore, the embodiment of the present application configures a processing function for the first data, and the processing function is used to simulate additional operations corresponding to the first data.
  • the above processing function is a piece of software program that can be executed by the processor in the server.
  • the virtual machine monitor calls the processing function to simulate the additional operation corresponding to the first data. Then, the I/O device is driven to complete the action corresponding to the additional operation, such as reset.
  • the virtual machine monitor applies for a second sub-memory space from the first memory space according to the size of the second data.
  • the virtual machine monitor stores the second data in the second sub-memory space.
  • the Device-specific Capability space is used to describe the specific attributes of the device, such as the Virtio_Net network card device, MAC address, the maximum number of supported queues, the number of queues and other device-related attribute data.
  • These data are generally stored statically and randomly. Fetch memory (staticrandom-accessmemory, SRAM) ⁇ registers and other methods, these data do not involve I ⁇ O process. And these attribute data are synchronized only once in the front-end driver initialization phase of the virtual machine, and then solidified into the basic attributes of the front-end driver for business use, and will not be accessed again in the device I ⁇ O process. Record this type of data For the second data.
  • the virtual machine monitor applies for a second sub-memory space from the first memory space of the server, and stores the second data in the second sub-memory space, thereby reducing the hardware of the I ⁇ O device burden.
  • FIG. 7 shows as an example that the addresses of the second memory space, the first sub-memory space, and the second sub-memory space are connected, but the embodiment of the present application is not limited to FIG. 7, that is, the second memory space
  • the addresses of the first sub-memory space and the second sub-memory space may or may not be connected, which is not limited in the embodiment of the present application.
  • the data storage process in this embodiment of the present application further includes:
  • the virtual machine monitor maps the address of the second type of data in the storage space of the I/O device to the address of the second memory space of the server.
  • the virtual machine monitor maps the addresses of the second memory space, the addresses of the first sub-memory space, and the addresses of the second sub-memory space to the virtual address space of the virtual machine.
  • the virtual address space of the virtual machine is divided into three parts, which are respectively denoted as the first virtual address space, the second sub virtual address space, and the third sub virtual address space.
  • the second sub virtual address space and The third virtual address space belongs to the second virtual address space.
  • the virtual machine monitor maps the address of the second memory space to the first virtual address space of the virtual machine, maps the first sub-memory space to the second sub-virtual address space of the virtual machine, and maps the second sub-memory space to the virtual machine The third sub virtual address space.
  • the virtual machine directly accesses the virtual address space it can access. When, you can directly access the data.
  • the virtual machine accesses the second data
  • the virtual machine accesses the third sub-virtual address space, and the mapping relationship between the third sub-virtual address space and the address of the second sub-memory space, so that the virtual machine can directly access the second sub-virtual address space.
  • the second data is accessed in the memory space.
  • the virtual machine when the virtual machine accesses the first data, the virtual machine directly accesses the second sub-virtual address space.
  • the second virtual address space has a mapping relationship with the address of the first sub-memory space of the server.
  • the first data is accessed in the memory space.
  • the virtual machine monitor detects that the virtual machine accesses the first data of the first sub-memory space, the virtual machine monitor intercepts the I/O access request.
  • the processing function corresponding to the first data of the virtual machine monitor simulates the additional operation corresponding to the first data, and controls the I/O device to complete the action corresponding to the additional operation.
  • the first type of data is divided into first data and second data according to whether additional operations of the I/O device will be caused when the virtual machine is accessed, and the first data and second data are stored in the first memory
  • the first data is stored in the first sub-memory space
  • the second data is stored in the second sub-memory space
  • the additional operations corresponding to the first data are stored in the first sub-memory space
  • the virtual machine receives the I/O access request.
  • S206 The virtual machine recognizes that the hardware data type in the I/O access request is the first data.
  • the virtual machine accesses the first data from the first sub-memory space.
  • the virtual machine After receiving the I/O access request, the virtual machine identifies the type of hardware data included in the I/O access request. For example, it can identify that the type of hardware data included in the I/O access request is the first data in the first type of data. The virtual machine accesses the first data from the first sub-memory space.
  • the virtual machine monitor controls the I/O device to perform actions corresponding to the additional operations.
  • the virtual machine monitor when the virtual machine monitor detects that the data accessed by the virtual machine accesses the first data from the first sub-memory space, the virtual machine monitor intercepts the I/O access request and calls the processing function corresponding to the first data To simulate the additional operations corresponding to the first data. Then, the virtual machine monitor controls the I/O device to perform actions corresponding to the additional operation, such as resetting, according to the simulated additional operation.
  • the processing function is essentially a combination of a set of program codes, used to realize the simulation of the data processing process, so that the I/O device realizes real actions.
  • the foregoing first data is reset data.
  • the front-end driver of the virtual machine When the virtual machine receives the I/O access request, the front-end driver of the virtual machine generates a signal, for example, a VM exit signal.
  • the I/O access request is intercepted by the virtual machine monitor and the callback processing function simulates the reset operation, and controls the actual reset operation of the I/O device.
  • the virtual machine recognizes that the hardware data type in the I/O access request is the second data.
  • the virtual machine accesses the second data from the second sub-memory space.
  • the virtual machine After receiving the I/O access request, the virtual machine recognizes that the hardware data type included in the I/O access request is the second data in the first type of data, and the virtual machine accesses the second data from the second sub-memory space.
  • the virtual machine monitor divides the first type of data into first data and second data, applies for the first sub-memory space for the first data from the first memory space, and combines the first data Stored in the first sub-memory space, while configuring the processing function for the first data; the virtual machine monitor applies for the second sub-memory space for the second data from the first memory space, and stores the second data in the second sub-memory space. In the memory space.
  • the virtual machine When the virtual machine accesses the first data, the virtual machine monitor intercepts the I/O access operation, and calls the processing function to simulate the additional operation corresponding to the first data, and controls the I/O device to complete the action corresponding to the additional operation , Thereby realizing effective access to the first data.
  • the virtual machine directly accesses the first data and the second data from the memory space of the server instead of accessing the first data from the storage space of the I/O device And the second data, this can reduce the number of operations on the I/O device and reduce the hardware overhead of the I/O device.
  • an I/O device storage space is configured for a virtual I/O device.
  • the I/O device storage corresponds to an I/O storage space.
  • the data in the I/O storage space is solidified and cannot be changed.
  • new functional domain segments are added or vendor-specific registers are added, traditional methods cannot meet the technical requirements.
  • the method of the embodiment of the present application includes:
  • the second data in the embodiment of the present application is stored in the second sub-memory space of the server.
  • the second data in the second sub-memory space can be changed or added. In this way, when the protocol of the virtual I/O device is updated, a new one is added.
  • the functional domain segment or the manufacturer-specific register is added, it can be realized by changing or adding the second data in the second sub-memory space.
  • the virtual machine monitor When the virtual machine monitor detects that the second data in the second sub-memory space has changed, it needs to send the changed second data to the I/O device in time to ensure that the virtual machine's driver and the I/O device cooperate normally jobs.
  • the virtual machine monitor defines multiple trigger events, which can be understood as events that cause the second data to change, for example, changing the MAC address of an I/O device, I/O device gives new function fields, queue enable, etc.
  • trigger events can be understood as events that cause the second data to change, for example, changing the MAC address of an I/O device, I/O device gives new function fields, queue enable, etc.
  • the virtual machine monitor stores the changed second data in the second sub-memory space, intercepts the trigger event, and obtains the changed second data from the second sub-memory space according to the trigger event And send the changed second data to the I/O device, the I/O device writes the changed second data into the storage space of the I/O device, for example, writes the changed second data Into the management buffer of the I/O device.
  • the forward driver of the virtual machine allocates necessary shared memory for the queue, and fills the memory address into the queue_desc, queue_avail, and queue_used fields defined in the public configuration capability capability space. These information needs to be timely
  • the /O device acquires and records to ensure that when I ⁇ O is initiated, the I/O device can use this information and the DMA engine to transfer data to the corresponding address of the server.
  • the queue enable (queue_enable) is defined as a trigger event in the virtual machine monitor, when the forward driver of the virtual machine has filled in the queue information.
  • the forward driver of the virtual machine enables the queue_enable field.
  • the virtual machine monitor intercepts the trigger event, simulates the trigger event, and configures the queue information queue_desc, queue_avail, and queue_used in the second sub-memory space of the server.
  • the virtual machine monitor obtains the above-mentioned queue information queue_desc, queue_avail and queue_used from the second sub-memory space, and transfers these information to the I/O device in the form of ioctl, so that the I/O device writes this information into the I ⁇ The storage space of the O device.
  • the I/O device combines the internal logic of the I ⁇ O device to complete the synchronization of queue information.
  • the virtual machine monitor can obtain the changed second data, and will change the second data.
  • the data is synchronized to the I/O device to ensure the synchronization of the software and hardware information of the I/O device, thereby solving the problem of inconvenient addition of new data.
  • the virtual machine monitor applies for the second sub-memory space for the second data from the first memory space of the server, and stores the second data in the second sub-memory space.
  • the second data in the second sub-memory space can be changed or added, so that when the protocol of the virtual I/O device is updated, new functional domain segments are added or vendor-specific registers are added, the second data in the second sub-memory space can be changed or added.
  • the second data solves the problem of inconvenient addition of newly added data.
  • the virtual machine monitor detects a change in sending the second data in the second sub-memory space, it sends the changed second data to the I/O device to ensure that the driver of the virtual machine and the I/O device work together normally.
  • FIG. 8 is a schematic structural diagram of a data processing apparatus provided in an embodiment of this application.
  • the apparatus 100 is used to execute the method on the virtual machine side in the above method embodiment.
  • the device 100 is applied to a data processing system.
  • the data processing system includes a device 100 and an input/output I/O device. As shown in FIG. 8, the device 100 includes: a receiving unit 110, a processing unit 120, and an acquiring unit 130.
  • the receiving unit 110 is configured to receive an I/O access request, the I/O access request is used to access data, and the I/O access request includes the type of hardware data used to indicate the working status of the virtual I/O device, and
  • the virtual I/O device is an I/O device obtained after the I/O device is virtualized.
  • the processing unit 120 is configured to identify that the hardware data type in the I/O access request is the first type of data, and the first type of data is the hardware that remains unchanged during the data processing of the virtual I/O device data.
  • the acquiring unit 130 is configured to acquire data to be accessed from a first memory space, where the first memory space is a memory storage space of the data processing system.
  • the apparatus 100 of the embodiment of the present application may be used to execute the operation steps performed by the virtual machine in the foregoing method embodiments, and its implementation principles and technical effects are similar, and will not be repeated here.
  • the first type of data includes first data
  • the first data is hardware data that causes additional operations of the I/O device when accessed by the apparatus 100
  • the first memory space includes first data.
  • a sub-memory space where the first data and processing functions are stored in the first sub-memory space, and the processing functions are used to simulate additional operations corresponding to the first data;
  • the acquiring unit 130 is specifically configured to acquire the first data from the first sub-memory space, and cause the virtual machine monitor to call the processing function to simulate additional operations corresponding to the first data, so as to control the I
  • the /O device executes the action corresponding to the additional operation, and the data processing system includes a virtual machine monitor.
  • the foregoing first type of data further includes second data, and the second data is hardware data in the first type of data other than the first data; the first memory space also includes second data.
  • a sub-memory space where the second data is stored in the second sub-memory space;
  • the acquiring unit 130 is specifically configured to access the second data from the second sub-memory space.
  • mapping relationship between the virtual address of the device 100 and the address of the first memory space is optionally, the mapping relationship between the virtual address of the device 100 and the address of the first memory space.
  • the apparatus 100 of the embodiment of the present application may be implemented by an application-specific integrated circuit (ASIC) or a programmable logic device (PLD), and the above PLD may be a complex program logic device. (complex programmable logical device, CPLD), field-programmable gate array (field-programmable gate array, FPGA), general array logic (generic array logic, GAL) or any combination thereof.
  • ASIC application-specific integrated circuit
  • PLD programmable logic device
  • CPLD complex programmable logical device
  • FPGA field-programmable gate array
  • GAL general array logic
  • the device 100 and its various modules may also be software modules.
  • the device 100 according to the embodiment of the present application can correspond to the method described in the embodiment of the present application, and the above and other operations and/or functions of each unit in the device 100 are respectively implemented to implement the virtual machines in FIGS. 4 and 6 For the sake of brevity, the corresponding process of each method of the method will not be repeated here.
  • the device 200 can be understood as a piece of software code in the processor of the data processing system.
  • the device 200 is used to execute the virtual Method on the machine monitor side.
  • the device 200 is applied to a data processing system.
  • the data processing system includes a device 200, a virtual machine, and an input/output I/O device. As shown in FIG. 9, the device 200 includes: an acquisition unit 210 and a processing unit 220.
  • the obtaining unit 210 is configured to obtain a first type of data, where the first type of data is hardware data that the virtual I/O device remains unchanged during data processing, and the virtual I/O device is the I/O device. I/O devices obtained after O device virtualization;
  • the processing unit 220 is configured to store the first type of data in a first memory space, where the first memory space is a storage space in the memory of the data processing system.
  • the apparatus 200 of the embodiment of the present application may be used to execute the technical solutions of the virtual machine monitor in the foregoing method embodiments, and its implementation principles and technical effects are similar, and will not be repeated here.
  • the aforementioned processing unit 220 is further configured to apply for the first memory space from the memory storage space of the data processing system according to the size of the first type of data.
  • the first type of data includes first data, and the first data is hardware data that causes additional operations of the I/O device when accessed by the virtual machine;
  • the processing unit 220 is specifically configured to apply for a first sub-memory space from the first memory space according to the size of the first data, and store the first data and processing functions in the first sub-memory space.
  • the processing function is used to simulate additional operations corresponding to the first data.
  • the processing unit 220 is further configured to, when detecting that the virtual machine accesses the first data from the first sub-memory space, call the processing function to simulate additional operations corresponding to the first data, And control the I/O device to execute the action corresponding to the additional operation.
  • the first type of data further includes second data, and the second data is hardware data other than the first data in the first type of data;
  • the processing unit 220 is specifically configured to apply for a second sub-memory space from the first memory space according to the size of the second data, and store the second data in the second sub-memory space in.
  • the apparatus 200 further includes: a sending unit 230,
  • the processing unit 220 is further configured to detect a change in the second data
  • the sending unit 230 is configured to send the changed second data to the I/O device when the processing unit 220 detects a change in sending the second data.
  • the processing unit 220 is further configured to store the second type of data in the storage space of the I/O device, where the second type of data is the hardware data of the virtual I/O device. Describe hardware data other than the first type of data.
  • processing unit 220 is further configured to map the address of the second type of data in the storage space of the I/O device to the address of the second memory space.
  • processing unit 220 is further configured to map both the address of the first memory space and the address of the second memory space to the virtual address space of the virtual machine.
  • the apparatus 200 of the embodiment of the present application may be implemented by an application specific integrated circuit (ASIC) or a programmable logic device (PLD).
  • PLD programmable logic device
  • the above-mentioned PLD may be a complex program logic device (CPLD), a field programmable gate array ( FPGA), General Array Logic (GAL) or any combination thereof.
  • CPLD complex program logic device
  • FPGA field programmable gate array
  • GAL General Array Logic
  • the device 200 may correspond to executing the method described in the embodiment of the present application, and the above and other operations and/or functions of each unit in the device 200 are used to implement the virtual machine monitor in FIGS. 4 and 6 respectively. For the sake of brevity, the corresponding flow of each method executed will not be repeated here.
  • FIG. 10 is a schematic structural diagram of a data processing device provided by an embodiment of this application.
  • the device 300 includes a processor 301, and the processor 301 is connected to one or more data storage devices.
  • the data storage device may include a storage medium 306 and a memory unit 304.
  • the storage medium 306 may be read-only, such as read-only memory (ROM), or readable/writable, such as a hard disk or flash memory.
  • the memory unit 304 may be a random access memory (RAM).
  • the memory unit 304 may be physically integrated in the processor 301, or may be constructed in a separate unit or unit.
  • the processor 301 is the control center of the device 300, and provides sequencing and processing facilities for executing instructions, executing interrupt actions, providing timing functions and other functions.
  • the processor 301 includes one or more central processing units (CPUs). CPU 0 and CPU 1 as shown in Figure 10.
  • the device 300 includes multiple processors.
  • the processor 301 may be a single-core (single CPU) processor or a multi-core (multi-CPU) processor. Unless otherwise specified, components such as a processor or memory used to perform tasks may be implemented as temporarily configured A general component that performs a task at a given time or a specific component manufactured to perform a task, as used herein, the term "processor" refers to one or more devices or circuits.
  • the processor 301 may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete Hardware components, etc.
  • DSP digital signal processors
  • ASIC application specific integrated circuits
  • FPGA field programmable gate arrays
  • the general-purpose processor may be a microprocessor or any conventional processor.
  • the program code executed by the CPU of the processor 301 may be stored in the memory unit 304 or the storage medium 302.
  • the program code (for example, the kernel, the program to be debugged) is stored in the storage medium 302 and copied to the memory unit 304 for the processor 301 to execute.
  • the processor 301 can execute at least one kernel (for example, the kernel comes from a kernel sold in operating systems such as LINUX TM , UNIX TM , windows TM , ANDROID TM , IOS TM, etc.).
  • the processor 301 controls the execution of other programs or processes, controls communication with peripheral devices, and controls the use of device resources for data processing, thereby controlling the operation of the device 300.
  • the data processing device 300 also includes a communication interface 303 for communicating with other devices or systems directly or through an external network.
  • the device 300 further includes an output device and an input device (not shown in FIG. 10).
  • the output device is connected to the processor 301 and can display information in one or more ways.
  • An example of the output device is a visual display device such as a liquid crystal display (LCD), a light emitting diode (LED) display, a cathode ray tube (CRT), or a projector.
  • the input device is also connected to the processor 301. It can receive user input from the device 300 or more. Examples of input devices include a mouse, a keyboard, a touch screen device or a sensing device, etc.
  • the aforementioned elements of the data processing device 300 may be connected together via a bus, such as any one or any combination of a data bus, an address bus, a control bus, an expansion bus, and a local bus.
  • a bus such as any one or any combination of a data bus, an address bus, a control bus, an expansion bus, and a local bus.
  • the data processing device 300 may also include the I/O device 306 involved in the foregoing embodiment, and the I/O device includes one or more virtual I/O devices.
  • the virtual I/O device is in a one-to-one correspondence with the virtual machine, which is used to realize the access of the virtual machine to the I/O device.
  • the processor 301 may receive an I/O access request, and the I/O access request is used to access Data, the I/O access request includes a type of hardware data used to indicate a working state of a virtual I/O device, and the virtual I/O device is an I/O device obtained after virtualization of the I/O device; And identify that the hardware data type in the I/O access request is the first type of data; obtain the data to be accessed from a first memory space, where the first memory space is a memory storage space of the data processing system.
  • the processor 301 may obtain the first type of data, where the first type of data is virtual I/O Hardware data that remains unchanged during data processing, the virtual I/O device is an I/O device obtained after virtualization of the I/O device; and storing the first type of data in a first memory space,
  • the first memory space is a storage space in the memory of the data processing system.
  • the data processing device 300 described in this embodiment may be the data processing system (or a component that can be used in the data processing system) mentioned in the foregoing method embodiment.
  • the data processing device 300 can be used to implement the method corresponding to a virtual machine or a virtual machine monitor described in the foregoing method embodiment. For details, refer to the description in the foregoing method embodiment.
  • the foregoing embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination.
  • the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may 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.
  • the computer instructions may be transmitted from a website, computer, server, or data center.
  • 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 a data center that includes one or more sets of available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium.
  • the semiconductor medium may be a solid state drive (SSD).

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)

Abstract

本申请提供一种数据处理的方法、装置与设备,该方法包括:在数据存储过程中,虚拟机监控器将虚拟I/O设备的硬件数据中的第一类数据存储在服务器的第一内存空间中。在数据访问过程中,虚拟机接收到I/O访问请求后,识别该I/O访问请求所请求访问的硬件数据类型,识别该I/O访问请求所请求访问的硬件数据类型为第一类数据,则虚拟机从服务器的第一内存空间中访问数据。由此降低对I/O设备硬件资源的占用。

Description

数据处理的方法、装置与设备 技术领域
本申请涉及计算机技术领域,尤其涉及虚拟化领域中一种数据处理的方法、装置与设备。
背景技术
随着云计算技术的快速发展,各种云平台基础设施,例如存储、网络设备等输入\输出(input\output,I\O)实例得到了越来越广泛的应用。虚拟化场景是云计算的主要部分,其对I\O设备的需求体量极大,现在虚拟机使用的高性能虚拟I\O设备大多基于硬件辅助的虚拟化技术实现,例如通过单根输入\输出虚拟化(single root I/Ovirtualization,SR-IOV)技术可以将一个硬件设备虚拟化成多个虚拟设备呈现给虚拟机使用,且虚拟机访问虚拟设备时可以绕过宿主机的参与从而实现设备I\O的高性能。
SR-IOV是虚拟化I/O硬件解决方案,它属于硬件辅助的I\O虚拟化技术中的一种,包括物理功能(physical functions,PF)和虚拟功能(virtual functions,VF),其中PF是指外设部件互连标准(peripheral component interconnect express,PCIe)设备所支持的一项PCIe功能,一个PF可以扩展出若干个VF。VF是指支持SR-IOV的I/O设备虚拟后获得,一个VF对应一个虚拟I/O设备,虚拟机通过VF实现对虚拟I/O设备使用。每个虚拟I/O设备对应有独立的I/O设备存储空间,I/O设备存储空间设置于I/O设备中,该I/O设备存储空间用于存储指示虚拟I/O设备工作状态的硬件数据,例如虚拟网卡设备对应的I/O设备存储空间中存储了虚拟网卡设备的硬件数据。
由上述描述可知,一个支持SR-IOV的I/O设备,当其包括多个虚拟I/O设备时,需要为每个虚拟I/O设备配置完整的I/O设备存储空间,以存储虚拟I/O设备的硬件数据,这样会增大I/O设备硬件资源的开销。
发明内容
本申请提供一种数据处理的方法、装置与设备,以降低对I/O设备硬件资源的开销。
第一方面,本申请提供了一种数据处理的方法,该方法涉及的是数据访问过程,该方法应用于数据处理系统,该数据处理系统包括虚拟机和输入/输出I/O设备,该方法包括:虚拟机接收I/O访问请求,其中,该I/O访问请求用于访问数据,且该I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,虚拟I/O设备为I/O设备虚拟化后获得的I/O设备;虚拟机识别该I/O访问请求中的硬件数据类型为第一类数据时,虚拟机从第一内存空间中获取待访问数据,其中,第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,第一内存空间为数据处理系统的内存存储空间。
本申请通过将I/O设备的硬件数据中的第一类数据存储在数据处理系统的内存中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,本申请可以大大降低对I/O设备存储空间的占用,进而较少对I/O设备的硬件开销。虚拟机访问数据时,当虚拟机识别I/O访问请求所请求访问的硬件数据类型为第一类数据时,虚拟机从数据处理系统的第一内存空间中访问数据,这于已有的虚拟机均从I/O设备存储空间中访问数据相比,可以较少对I/O设备的访问次数,进而有效提高数据访问速度。
在一种可能的实现方式中,若上述第一类数据包括第一数据,该第一数据为虚拟机访问时引起I/O设备的附加操作的硬件数据,第一内存空间包括第一子内存空间,该第一子内存空间中存储有第一数据和处理函数,该处理函数用于仿真第一数据对应的附加操作。此时,虚拟机从第一内存空间中获取待访问数据,包括:虚拟机从第一子内存空间中获取第一数据,并使得虚拟机监控器调用所述处理函数仿真第一数据对应的附加操作,以控制I/O设备执行所述附加操作对应的动作,其中数据处理系统包括虚拟机监控器。本申请,将第一类数据中虚拟机访问时引起I/O设备的附加操作的第一数据存储在第一内存空间的第一子内存空间中,方便虚拟机从该第一子内存空间中访问该第一数据,同时在该第一子内存空间中存储第一数据对应的处理函数,这样当虚拟监控机检测到虚拟机访问第一子内存空间中的第一数据时,可以调用该处理函数来仿真第一数据对应的附加操作,以控制I/O设备执行该附加操作对应的动作,保证了虚拟机对第一数据访问的真实性和有效性。
在另一种可能的实现方式中,第一类数据还包括第二数据,该第二数据为第一类数据中除上述第一数据之外的硬件数据;第一内存空间还包括第二子内存空间,第二数据存储在第二子内存空间中。此时,虚拟机从第一内存空间中获取待访问数据包括:虚拟机从第二子内存空间中访问第二数据。本申请,虚拟机直接从第二子内存空间中访问第二数据,而不是从I/O设备存储空间中访问第二数据,这样可以减少对I/O设备的操作次数,且降低I/O设备的硬件开销。
可选的,虚拟机的虚拟地址与第一内存空间的地址之间具有映射关系,这样虚拟机根据该映射关系可以直接从第一内存空间中访问到第一类数据,进而提高了对第一类数据的访问速度。
进一步的,本申请的虚拟I/O设备的硬件数据还包括第二类数据,该第二类数据为虚拟I/O设备的硬件数据中除第一类数据之外的硬件数据,第二类数据存储在I/O设备存储空间中,该I/O设备存储空间设置在I/O设备中,为I/O设备的存储空间。
此时,本申请的方法还包括:虚拟机识别该I/O访问请求中的硬件数据类型为第二类数据时,虚拟机从I/O设备存储空间中获取待访问数据。本申请,由于第二数据为虚拟I/O设备在数据处理过程中会发生变化的硬件数据,而这些硬件数据被访问时,I/O设备需要立即获知,因此,本申请将第二类数据存储在I/O设备存储空间中,方便I/O设备及时获知第二类数据被虚拟机访问,并立即采取相应的动作,进而保证数据访问时效性。
可选的,虚拟机基于直通方式,从I/O设备存储空间中访问第二类数据,进一步提高了第二类数据的访问时效性。
第二方面,本申请提供一种数据处理方法,该方法涉及涉及的是数据存储过程,该方法应用于数据处理系统,数据处理系统包括虚拟机监控器、虚拟机和输入/输出I/O设备,该方法包括:虚拟机监控器获取第一类数据,其中第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,虚拟I/O设备为I/O设备虚拟化后获得的I/O设备;虚拟机监控器将第一类数据存储在第一内存空间,该第一内存空间为数据处理系统的内存中存储空间。
本申请,虚拟机监控器将虚拟I/O设备的硬件数据中的第一类数据存储在服务器的第一内存空间中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,当I/O设备包括的虚拟I/O设备较多时,本申请的方法可以大大降低对I/O设备存储空间的占用,较少对I/O设备的硬件开销。
在一种示例中,上述虚拟机监控器将所述第一类数据存储在第一内存空间之前,该方法还包括:虚拟机监控器根据所述第一类数据的大小,从所述数据处理系统的内存存储空间中申请所述第一内存空间。这样可以包括第一内存空间中可以存储下第一类数据。
在一种可能的实现方式中,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据,此时,本申请的方法包括:虚拟机监控器根据所述第一数据的大小,从所述第一内存空间中申请第一子内存空间;虚拟机监控器将所述第一数据和处理函数存储在所述第一子内存空间中,所述处理函数用于仿真所述第一数据对应的附加操作。这样将第一数据存储在第一内存空间的第一子内存空间中,当虚拟机访问第一数据时,虚拟机可以直接从第一子内存空间中访问第一数据,而不是从I/O设备存储空间中访问第一数据,这样可以减少对I/O设备的操作次数,且降低I/O设备的硬件开销。同时在该第一子内存空间中存储第一数据对应的处理函数,这样当虚拟监控机检测到虚拟机访问第一子内存空间中的第一数据时,可以调用该处理函数来仿真第一数据对应的附加操作,以控制I/O设备执行该附加操作对应的动作,保证了虚拟机对第一数据访问的真实性和有效性。
在该实现方式下,本申请还包括:虚拟机监控器检测到所述虚拟机从第一子内存空间中访问所述第一数据时,调用所述处理函数仿真所述第一数据对应的附加操作;虚拟机监控器控制所述I/O设备执行所述附加操作对应的动作,进而保证了虚拟机对第一数据访问的真实性和有效性。
在另一种可能的实现方式中,第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;此时该方法还包括:虚拟机监控器根据所述第二数据的大小,从所述第一内存空间中申请第二子内存空间;虚拟机监控器将所述第二数据存储在所述第二子内存空间中。这样可以实现将第二数据完成地存储在第二子内存中,当虚拟机访问第二数据时,虚拟机可以直接从第二子内存空间中访问第二数据,而不是从I/O设备存储空间中访问第二数据,这样可以减少对I/O设备的操作次数,且降低I/O设备的硬件开销。
在另一种可能的实现方式中,上述方法还包括:虚拟机监控器检测到所述第二数据发生变化时,将变化后的所述第二数据发送给所述I/O设备。这样当虚拟I/O设备的协议更新,增加新的功能域段或增加厂商特定的寄存器时,通过更改或增加第二子 内存空间中的第二数据来解决新增数据不便于追加的问题。当虚拟机监控器检测到第二子内存空间中的第二数据发送变化时,将变化后的第二数据发送给I/O设备,以确保虚拟机的驱动和I/O设备正常协同工作。
进一步的,本申请的虚拟I/O设备的硬件数据还包括第二类数据,该第二类数据为虚拟I/O设备的硬件数据中除第一类数据之外的硬件数据,即为虚拟I/O设备在数据处理过程中会发生变化的硬件数据,此时,上述方法还包括:虚拟机监控器将第二类数据存储在所述I/O设备存储空间中。本申请,由于第二数据为虚拟I/O设备在数据处理过程中会发生变化的硬件数据,而这些硬件数据被访问时,I/O设备需要立即获知,因此,本申请将第二类数据存储在I/O设备存储空间中,方便I/O设备及时获知第二类数据被虚拟机访问,并立即采取相应的动作,进而保证数据访问时效性。
在一种示例中,上述方法还包括:虚拟机监控器将所述第二类数据在所述I/O设备存储空间中的地址映射至所述第二内存空间的地址,这样,当虚拟机可以通过访问第二内存空间,实现对I/O设备存储空间中的第二类数据的访问。
在另一种示例中,上述方法还包括:虚拟机监控器将所述第一内存空间的地址和所述第二内存空间的地址均映射至所述虚拟机的虚拟地址空间中,这样,虚拟机可以通过访问自身的虚拟地址空间,实现对I/O设备存储空间中的第二类数据的访问,以及对第一内存空间中第一类数据的访问。
第三方面,本申请提供一种数据处理的装置,该装置能够实现上述虚拟机的功能,该装置应用于数据处理系统,所述数据处理系统包括该装置和输入/输出I/O设备,该装置包括:接收单元、处理单元和获取单元,其中接收单元,用于接收I/O访问请求,所述I/O访问请求用于访问数据,所述I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;处理单元,用于识别所述I/O访问请求中的所述硬件数据类型为第一类数据,该第一类数据为所述虚拟I/O设备在数据处理过程中保持不变的硬件数据;获取单元,用于从第一内存空间中获取待访问数据,所述第一内存空间为所述数据处理系统的内存存储空间。
在一种可能的实现方式中,第一类数据包括第一数据,所述第一数据为所述装置访问时引起所述I/O设备的附加操作的硬件数据,所述第一内存空间包括第一子内存空间,所述第一子内存空间中存储有所述第一数据和处理函数,所述处理函数用于仿真所述第一数据对应的附加操作;此时,所述获取单元,具体用于从第一子内存空间中获取所述第一数据,并使得虚拟机监控器调用所述处理函数仿真所述第一数据对应的附加操作,以控制所述I/O设备执行所述附加操作对应的动作,所述数据处理系统包括虚拟机监控器。
在另一种可能的实现方式中,所述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;所述第一内存空间还包括第二子内存空间,所述第二数据存储在所述第二子内存空间中;此时,所述获取单元,具体用于从所述第二子内存空间中访问所述第二数据。
可选的,所述装置的虚拟地址与所述第一内存空间的地址之间的映射关系。
第四方面,本申请提供一种数据处理的装置,该装置能够实现上述虚拟机监控器 的功能,该装置应用于数据处理系统,所述数据处理系统包括该装置、虚拟机和输入/输出I/O设备,所述装置包括:获取单元和处理单元,其中,获取单元,用于获取第一类数据,所述第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;处理单元,用于将所述第一类数据存储在第一内存空间,所述第一内存空间为所述数据处理系统的内存中存储空间。
在一种可能的实现方式中,所述处理单元,还用于根据所述第一类数据的大小,从所述数据处理系统的内存存储空间中申请所述第一内存空间。
在另一种可能的实现方式中,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据;所述处理单元,具体用于根据所述第一数据的大小,从所述第一内存空间中申请第一子内存空间,并将所述第一数据和处理函数存储在所述第一子内存空间中,所述处理函数用于仿真所述第一数据对应的附加操作。
在另一种可能的实现方式中,所述处理单元,还用于检测到所述虚拟机从第一子内存空间中访问所述第一数据时,调用所述处理函数仿真所述第一数据对应的附加操作,并控制所述I/O设备执行所述附加操作对应的动作。
在另一种可能的实现方式中,所述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;所述处理单元,具体具体用于根据所述第二数据的大小,从所述第一内存空间中申请第一子内存空间,并将所述第二数据存储在所述第二子内存空间中。
在另一种可能的实现方式中,所述装置还包括:发送单元;其中处理单元,还用于检测所述第二数据发生变化;所述发送单元,用于在所述处理单元检测到所述第二数据发送变化时,将变化后的所述第二数据发送给所述I/O设备。
在另一种可能的实现方式中,所述处理单元,还用于将第二类数据存储在所述I/O设备存储空间中,所述第二类数据为所述虚拟I/O设备的硬件数据中除所述第一类数据之外的硬件数据。
在另一种可能的实现方式中,所述处理单元,还用于将所述第二类数据在所述I/O设备存储空间中的地址映射至所述服务器的第二内存空间的地址。
在另一种可能的实现方式中,所述处理单元,还用于将所述第一内存空间的地址和所述第二内存空间的地址均映射至所述虚拟机的虚拟地址空间中。
第五方面,本申请提供一种数据处理的设备,包括:处理器,所述处理器用于执行实现第一方面或第二方面所述的方法。
第六方面,本申请提供一种计算机存储介质,所述存储介质包括计算机指令,当所述指令被计算机执行时,使得所述计算机实现如第一方面或第二方面所述的方法。
第七方面,本申请提供一种计算机程序产品,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,数据处理设备的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得数据处理设备实施第一方面或第二方面任一所述的方法。
本申请提供的数据处理的方法、装置与设备,在数据存储过程中,虚拟机监控器 将虚拟I/O设备的硬件数据中的第一类数据存储在服务器的第一内存空间中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,当I/O设备包括的虚拟I/O设备较多时,本申请的方法可以大大降低对I/O设备存储空间的占用和I/O设备的硬件开销。在数据访问过程中,虚拟机接收到I/O访问请求后,识别该I/O访问请求所请求访问的硬件数据类型,识别该I/O访问请求所请求访问的硬件数据类型为第一类数据,则虚拟机从服务器的第一内存空间中访问数据;识别该I/O访问请求所请求访问的硬件数据类型为第二类数据,则虚拟机从I/O设备存储空间中访问数据。可以较少对I/O设备的访问次数,进而有效提高数据访问速度。
附图说明
图1为本申请实施例提供的一种数据处理系统的架构示意图;
图2为本申请实施例涉及的硬件数据的一种配置示意图;
图3为本申请实施例涉及的硬件数据的另一种配置示意图;
图4为本申请实施例提供的数据处理方法的一种流程示意图图;
图5为本申请实施例提供的一种地址映射示意图;
图6为本申请实施例提供的数据处理方法的另一流程示意图;
图7为本申请实施例提供的一种内存分配示意图;
图8为本申请实施例提供的一种装置的结构示意图;
图9为本申请实施例提供的另一种装置的结构示意图;
图10为本申请实施例提供的一种数据处理设备的结构示意图。
具体实施方式
下面结合本申请实施例的附图,对本申请实施例中的技术方案进行描述。
为了便于理解本申请的实施例,首先对本申请实施例涉及到的相关概念进行如下简单介绍:
虚拟机监视器(virtual machine monitor,VMM):用于管理虚拟机。示例性的,该虚拟机监视器包括但不限于Hypervisor,具体可以利用快速模拟器(quick emulator,QEMU)、VMware(一种虚拟机软件)、VirtualBox(一种虚拟机软件)实现虚拟化检视器的功能。
虚拟功能输入\输出(virtual function I/O,VFIO):是一套用户态驱动框架,它向用户态提供访问硬件设备和配置管理设备的接口,Hypervisor可以借助VFIO框架达到将支持SR-IOV的设备直通给虚拟机使用的目的。
内存映射输入\输出(memory mapped I/O,MMIO):是通过将外围设备的资源映射到主机内存空间,以便于中央处理器(central processing unit,CPU)的访问。
虚拟化输入\输出(Virtio):Virtio是一套针对准虚拟化平台的I/O虚拟化框架,其对Hypervisor中的通用模拟设备进行抽象,并提供一组标准接口供虚拟机访问这些模拟设备。
单根输入\输入虚拟化(single root I/O virtualization,SR-IOV):是一种基于硬件的虚拟化解决方案,可以提高虚机性能和可伸缩性,SR-IOV创建了一系列I/O设备物 理端口的虚拟功能(VF),每一个虚拟机配置有一个VF,一个VF对应一个虚拟I/O设备,虚拟机通过加载VF来实现对该VF对应的I/O设备的加载。SR-IOV将I/O功能分配到多个虚拟接口以便在虚拟化环境中共享一个I/O设备的资源,SR-IOV能够让网络传输绕过软件模拟层,直接分配到虚拟机,这样就降低了软件模拟层中的I/O开销。创建VF后,可以直接将其指定给虚拟机,此功能使得虚拟功能可以共享物理设备,并在没有CPU和虚拟机管理程序软件开销的情况下执行I/O。这样通过将SR-IOV功能集成到I/O设备上,将单一的I/O设备虚拟成多个VF接口,每个VF接口都有单独的虚拟I/O通道,这些虚拟的I/O通道共用I/O设备的I/O通道。每个虚拟机可占用一个或多个VF接口,这样虚拟机就可以直接访问自己的VF接口来加载虚拟I/O设备,而不需要hypervisor的协调干预,从而大幅提升网络I\O性能。
图1为本申请实施例提供的一种数据处理系统的架构示意图。如图1所示,数据处理系统包括:处理器和I/O设备。为便于描述下文以该数据处理系统为一个服务器为例进行详细说明。
服务器,用于通过运行虚拟化软件,并将服务器的硬件资源虚拟化后生成一个或多个虚拟机。服务器中包括一个或多个处理器,每个处理器包括一个或多个处理器核。服务器中还包括虚拟机监控器。为便于描述,以服务器的处理器仅运行一个虚拟机监控器和一个虚拟机为例进行说明。
I/O设备包括物理网卡、物理卸载卡、物理存储卡等与处理器连接的设备。作为一种可能的可能的实施例,I/O设备可以通过PCIe插槽形式接入服务器,实现I/O设备和处理器的通信。可选的,上述I/O设备也可以直接和服务器主板集成。该I/O设备支持SR-IOV功能,通过将SR-IOV功能集成到I/O设备上,将单一的I/O设备虚拟成一个或多个虚拟I/O设备,图1作为一种示例只示出了I/O设备包括一个虚拟I/O设备的情况。
虚拟机,是公有云服务环境中最常见的一类资源,它是通过在服务器上运行虚拟机监视器程序,例如Hypervisor程序,从而发挥处理器等硬件提供的虚拟化能力,将硬件资源分享给多套并行运行且逻辑隔离的操作系统实现的。虚拟机可以理解为一个客户端,可占用一个或多个虚拟I/O设备,用于根据用户的访问指示访问虚拟I/O设备。每个虚拟机包括前端驱动,当虚拟机访问虚拟I/O设备时,加载该前端驱动,该前端驱动用于访问该虚拟I/O设备的硬件数据,进而实现对虚拟I/O设备的访问。
虚拟机监控器,运行在处理器上,用于管理虚拟机,并为虚拟机指定虚拟I/O设备。虚拟机监控器可以由软件实现,即在处理器中运行特定程序代码,实现对虚拟机的管理。其中,运行程序的处理器可以与运行虚拟机的处理器相同,例如,如图1中虚拟机和虚拟机监控器运行在同一处理器上;也可以使用不同的处理器分别实现虚拟机监控器和虚拟机的功能,例如,利用一个处理器实现虚拟机监控器的功能,利用其他处理器运行虚拟机。可选地,虚拟机监控器还可以由硬件实现,即利用单独的处理器或逻辑电路实现虚拟机监控器的功能。为便于描述,下文以图1所示的虚拟机和虚拟机监控器部署形式为例进行说明。
上述虚拟I/O设备的硬件数据可以理解为该虚拟I/O设备的属性数据、功能数据等使虚拟I/O设备正常工作的数据。
虚拟I/O设备的硬件数据符合预设规定,例如符合预设的I\O协议,下面,以预设的I\O协议为Virtio协议为例进一步介绍本申请实施例。根据Virtio协议规范,虚拟I/O设备符合4个标准能力(Capability),分别为:公共配置(Common Configuration)、通知(Notification)、中断服务程序(Interrupt Service Routine,ISR)和设备的特殊性(Device-specific)。其中,公共配置能力:用于提供队列信息配置(如队列深度、队列地址、队列使能)、设备特征(即设备所支持的特性,如设备支持处理的描述符格式)配置以及设备状态信息等。通知能力:用于主机访问该段空间时,通知设备有I\O访问产生,这类似于非易失性内存主机控制器接口(non-volatile memory express,NVMe)协议中的门铃寄存器。中断服务程序能力:设备通过上报中断给主机CPU通知主机I\O处理完成或出现异常。设备的特殊性能力:由于Virtio协议支持各种各样的I\O设备,例如网卡,磁盘控制器,图形处理器(graphics processing unit,GPU)等,这个空间存储了对应设备的特定属性。以网卡设备为例,这里存放了网卡队列数目,最大支持的最大传输单元(maximum transmission unit,MTU)值,物理地址(media access control或者medium access control,MAC)等信息。为了符合上述4个标准能力,则虚拟I/O设备的硬件数据包括上述4个标准能力所描述的具体硬件数据。其中,公共配置对应的硬件数据包括设备功能(device_feature)、驱动程序功能(driver_feature)和队列(queue)相关的字段,通知对应的硬件数据包括多个通知寄存器,该通知寄存器与上述队列关联,当虚拟机发起I/O访问请求时,会通过更改通知寄存器中字段通知I/O设备有I/O访问请求产生,由此可知,通知寄存器在I/O流程中起至关重要的作用,对这些通知寄存器的处理速度快慢,会影响I/O访问请求的实效性。
服务器将上述虚拟I/O设备的硬件数据划分为第一类数据和第二类数据。本申请实施例对服务器将上述硬件数据划分为第一类数据和第二类数据的划分方式不做限制。
在一种可能的实施例中,服务器按照虚拟I/O设备在数据处理过程中硬件数据是否会发生变化为准则,将上述硬件数据划分为第一类数据和第二类数据。
第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,例如设备功能(device_feature)用于标识虚拟I/O设备支持的特性,队列数(num_queues)用于标识虚拟I/O设备最大支持的队列数目,这些数据全部仅在虚拟I/O设备初始化阶段作为一个固有的信息记录到虚拟I/O设备的驱动当中。设备功能(device_feature)用于表示虚拟I/O设备状态信息,其仅在虚拟I/O设备驱动初始化或驱动卸载阶段会发生变更,在I\O访问流程中均不起作用。这样可以将这些设备功能(device_feature)、驱动程序功能(driver_feature)和队列(queue)等在虚拟I/O设备初始化阶段生效。
第二类数据为虚拟I/O设备的硬件数据中除第一类数据之外的硬件数据,或者,为虚拟I/O设备在数据处理过程中会发生变化的硬件数据,例如Virtio协议中的通知能力空间定义的通知寄存器,用于虚拟机的前端驱动发起I\O访问请求时通知虚拟I/O设备,以使虚拟I/O设备立即启动直接内存存取(direct memory Access,DMA)引擎进行数据搬运,中断服务程序能力空间定义的相关数据,用于标识中断状态信息,这些数据虚拟机直接从I/O设备存储空间访问,以确保实时性。
图2为本申请实施例涉及的硬件数据的一种配置示意图。
在数据配置过程中,虚拟机监控器,用于根据第一类数据的大小,在服务器的内 存上为第一类数据申请第一内存空间,并将第一类数据存储在服务器的第一内存空间中。虚拟机监控器,还用于将第二类数据存储在I/O设备存储空间中,该I/O设备存储空间可以理解为I/O设备上可以被处理器访问的存储空间。
在数据访问过程中,虚拟机发起访问请求,若I/O访问请求访问的数据为第一类数据时,则虚拟机从服务器的第一内存空间中访问数据,若访问请求访问的数据为第二类数据时,则虚拟机从I/O设备存储空间中访问数据。
可选的,I/O设备还包括配置空间,该配置空间包括一个或多个基址寄存器(base address register,BAR),本申请实施例的一个虚拟I/O设备具有一个I/O存储空间,该I/O设备存储空间与BAR空间具有映射关系。在实际数据访问过程中,一旦在PF中启用了SR-IOV,就可以通过PF的总线、设备和功能编号(路由ID)访问各个虚拟I/O设备的BAR空间,进而根据BAR空间与I/O设备存储空间之间的映射关系,访问各个虚拟I/O设备的I/O设备存储空间。
可选的,继续参照图2所示,后续为了方便服务器快速访问I/O设备存储空间中保存的第二类数据,则服务器还用于将第二类数据在I/O设备存储空间中的地址映射至服务器的第二内存空间的地址上,以便该服务器的第二内存空间中映射I/O设备存储空间的空间可以理解为MMIO空间。此时,当虚拟机的I/O访问请求为I/O设备存储空间中第一地址段时,可以根据该MMIO空间的地址与I/O设备存储空间的地址之间映射关系,从I/O设备存储空间中访问到第二类数据。
本申请实施例中,为了便于虚拟机监控器对第一类数据的存储,再将第一类数据划分为第一数据和第二数据,其中,第一数据为被虚拟机访问时引起I/O设备的附加操作的硬件数据,第二数据为被虚拟机访问时不会引起I/O设备的附加操作的硬件数据。例如设备功能(device_feature)、驱动程序功能(driver_feature)和队列(queue)相关的数据对虚拟机中的前端驱动来说是固有属性,前端驱动读取这些数据之后结束,不会发生什么后续的附加动作,因此,将这些数据记为第二数据。而公共配置中的device_status字段表示设备状态信息,前端驱动对该device_status字段可写,例如virtio协议定义当前端驱动对device_status写0时,I/O设备需要发生相应的I/O设备复位动作,具体包括清除历史配置信息,清空队列缓存等附加操作,将这些数据记为第一数据。
在上述图1的基础上,参照图3所示,图3为本申请实施例涉及的硬件数据的另一种配置示意图,服务器的第一内存空间包括第一子内存空间和第二子内存空间。
在数据配置过程中,虚拟机监控器,用于根据第一数据的大小,为第一数据申请第一子内存空间,并将第一数据存储在第一子内存空间中,同时为该第一数据配置处理函数,该处理函数用于仿真该第一数据对应的附加操作。虚拟机监控器,还用于根据第二数据的大小,为第二数据申请第二子内存空间,并将该第二数据存储在第二子内存空间中。其中,处理函数可以理解为虚拟机监控器中程序代码或实现上述配置功能的软件模块或单元。
在数据访问过程中,虚拟机接收到I/O访问请求,若I/O访问请求访问的数据为第一数据时,由于该第一数据会引起I/O设备的附加操作,因此虚拟机监控器截获该I/O访问请求,并调用该第一数据对应的处理函数,通过该处理函数仿真第一数据对应 的附加操作。同时,控制I/O设备完成该附加操作对应的动作,例如复位动作。若I/O访问请求访问的数据为第二数据时,则虚拟机直接从服务器的第二子内存中访问数据。
接下来,结合上述图1至图3,介绍本申请实施例提供的数据处理方法。
图4为本申请实施例提供的数据处理方法的一种流程图,本申请实施例的数据处理过程包括数据存储过程和数据访问过程,其中数据存储过程由处理器中的虚拟机监控器执行,数据访问过程由处理器中的虚拟机执行,所述方法可以包括:
S101、虚拟机监控器获取第一类数据。
其中,第一类数据属于用于指示虚拟I/O设备工作状态的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备。
虚拟I/O设备的硬件数据的类型可以按照预设规则确定,例如根据I/O协议确定硬件数据的类型。当虚拟I/O设备使用的I/O协议不同时,对应的硬件数据可以不同,例如NVMe协议与Virtio协议对应的硬件数据不同。虚拟I/O设备遵循预设规则进行设计,以一个控制器的形态呈现给服务器,如NVMe控制器或Virtio控制器。这样,虚拟机监控器可以根据虚拟I/O设备遵循的预设规则,获得虚拟I/O设备的硬件数据,并从预设规则出发,从虚拟I/O设备的硬件数据中区分出第一类数据和第二类数据,其具体区分过程可以参照上述图2的描述,在此不再赘述。
在一种可能的实施例中,将虚拟I/O设备在数据处理过程中保持不变的硬件数据确定为第一类数据,如复位\初始化配置\信息协商等数据。将虚拟I/O设备在数据处理过程中会发生变化的硬件数据确定为第二类数据,例如虚拟I/O设备的状态等数据。
可选的,上述虚拟I/O设备的硬件数据可以为I/O设备的硬件数据,即虚拟I/O设备复用I/O设备的硬件数据。
S102、虚拟机监控器将第一类数据存储在第一内存空间。
其中,该第一内存空间为服务器的内存中存储空间。
虚拟机监控器获取虚拟I/O设备的第一类数据后,从服务器的内存空间中为第一类数据申请第一内存空间,并将该第一类数据存储在服务器的第一内存空间中。
在一种可能的实施中,本步骤可以包括:虚拟机监控器根据第一类数据的大小,从服务器的内存空间中申请第一内存空间;并将该第一类数据保存在第一内存空间中。
可选的,该第一内存空间的大小可以大于或等于该第一类数据的大小。第一存储空间的大小也可以为第一值。该第一值为根据系统已经处理的第一类数据的大小的统计值进行计算后获得的数值。第一存储空间的大小也可以直接设置为第二值,第二值具体可以为默认值,当实际处理I/O访问请求时,再根据当前第一类数据的大小进行动态的扩容,扩容后的第一内存空间大于或等于第一类数据的大小。
虚拟机监控器从服务器的内存空间中申请的第一内存空间为未存储数据的内存空间。虚拟机监控器根据虚拟I/O设备的预设规则规定,将第一类数据存储在第一内存空间中,例如,将第一类数据的某一个数据存储在第一内存空间的字段a至字段b对应的空间中,以此类推,实现将第一类数据存储在该第一内存空间中。
第一内存空间可以是内存中连续的预设大小的存储空间,也可以是间断的多个存储区域功能组成的存储空间。
在一种可能的可能的实施例中,本申请实施例还包括S103和S104的步骤。
S103、虚拟机监控器获取第二类数据。
S104、虚拟机监控器将第二类数据存储至I/O设备存储空间中。
虚拟机监控器获取虚拟I/O设备的第二类数据后,将该第二类数据存储在I/O设备存储空间中,该I/O设备存储空间为I/O设备的存储空间中可以被处理器访问的存储空间。这样当访问第二类数据时,虚拟机直接访问I/O设备存储空间,I/O设备及时获知第二类数据被访问,并立即采取相应的动作,以确保数据访问的实时性。
本申请实施例的方法,通过将虚拟I/O设备的第一类数据存储在服务器的第一内存中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,降低了对I/O设备存储空间的占用。将虚拟I/O设备的第二类数据存储在I/O设备存储空间,由于第二数据为虚拟I/O设备在数据处理过程中会发生变化的硬件数据,这样本申请将第二类数据存储在I/O设备存储空间中,当该第二类数据被访问时,I/O设备可以及时获知,并立即采取相应的动作,进而保证数据访问时效性。
下面以虚拟机监控器为QEMU为例,对上述数据存储过程进行说明。
QEMU新增两个参数分别为:第一参数和第二参数,第一参数用于标识虚拟I/O设备支持将硬件数据配置在服务器的内存空间中,第二参数用于标识仿真附加功能所需要的处理函数。QEMU根据虚拟I/O设备的特性,将上述两个参数分配给支持将第一类数据存储在服务器的第一内存空间的虚拟I/O设备。
在数据配置过程中,首先QEMU启动虚拟机,并为虚拟机指定虚拟I/O设备,QEMU判断虚拟I/O设备是否具有上述第一参数和第二参数。若虚拟I/O设备带有上述两个参数,则QEMU使用上述步骤S101至S103的方式为虚拟I/O设备配置硬件数据,具体是,QEMU获取硬件数据,并将硬件数据划分为第一类数据和第二类数据。QEMU从服务器中申请第一内存空间,并将第一类数据存储在该第一内存空间中。QEMU将第二类数据存储在I/O设备存储空间中,进而实现了虚拟I/O设备的硬件数据的配置。
本申请实施例的方法,通过将虚拟I/O设备的一部分硬件数据,即第一类数据存储在服务器的第一内存中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,降低了对I/O设备存储空间的占用,在数据处理过程中,虚拟机监控器可以通过MMIO方式直接从服务器的内存中读取第一类数据,减少了虚拟机监控器和I/O设备间的消息交互,与此同时,由于虚拟机监控器部署在服务器的处理器中,处理器可直接访问内存中数据,使得虚拟机监控器可以更快速的读取第一类数据,减少了整个I/O访问请求处理时长,提升了I/O访问请求的处理效率。
在一种可能的可能的实施例中,为了方便虚拟机对虚拟I/O设备的硬件数据的访问,本申请实施例在数据存储过程中,还包括:
S1041、虚拟机监控器将第二类数据在I/O设备存储空间中的地址映射至服务器的第二内存空间的地址。
上述S1041可以在上述S104之后执行。
如图5所示,为了方便虚拟机访问第二类数据,则将第二类数据在I/O设备存储空间中的地址映射至服务器的第二内存空间的地址。这样,虚拟机监控器可以通过访问第二内存空间的地址,实现对I/O设备存储空间中的第二类数据的访问。
S1042、虚拟机监控器将第一内存空间的地址和所述第二内存空间的地址均映射至所述虚拟机的虚拟地址空间中。
如图5所示,假设将虚拟机的虚拟地址空间划分成2部分,分别记为第一虚拟地址空间和第二虚拟地址空间。虚拟机监控器将第二内存空间的地址映射至虚拟机的第一虚拟地址空间,将第一内存空间映射至虚拟机的第二虚拟地址空间。
这样,在数据访问阶段,由于上述第一内存空间的地址、第二内存空间的地址与虚拟地址空间的映射关系,虚拟机直接访问其可以访问的虚拟地址空间时,可以直接访问到数据。
例如,虚拟机访问第一类数据时,虚拟机访问第二虚拟地址空间,而该第二虚拟地址空间与第一内存空间的地址的映射关系,这样,虚拟机可以直接从第一内存空间中访问到第一类数据。
再例如,虚拟机访问第二类数据时,虚拟机直接访问第一虚拟地址空间,该第一虚拟地址空间与第二内存空间的地址具有映射关系、该第二内存空间的地址与I/O设备存储空间的地址具有映射关系,这样虚拟机可以直接从I/O设备存储空间中访问到第二类数据。
在上述S1041和S1042的基础上,在一种可能的可能的实施例中,上述S104可以被S1043替换。
S1043、虚拟机监控器基于直通方式,将所述第二类数据存储至所述I/O设备存储空间中。
本步骤中,为了提高虚拟机访问第二类数据的速度,则虚拟机监控器基于直通方式,将第二类数据配置至I/O设备存储空间中,保证虚拟机在访问第二类数据时,基于直通方式从I/O设备存储空间中直接访问到第二类数据,以提高第二类数据的访问速度。
本步骤对虚拟机监控器采用的直通方式不做限制,例如本步骤采用的直通方式可以为VFIO,VFIO是一套用户态设备驱动框架,包括:VFIO接口层(interface)、I\O存储单元(I\O memory unit,IOMMU)驱动,Vfio-IOMMU抽象层、Vfio-pci抽象层、PCI总线驱动(pci-bus driver)。
其中,IOMMU是集成在处理器北桥上的模块,用于为I\O设备建立内存地址映射、控制设备间地址隔离、中断重映射等功能,是实现I\O设备直通的核心硬件单元。IOMMU完成I\O设备的DMA地址映射和中断映射工作。
VFIO框架通过对IOMMU模块和PCIe模块进行封装,向用户态程序提供一套使用IOMMU和I\O设备的标准接口。
VFIO通过封装IOMMU驱动向用户态提供管理IOMMU页表的能力,该IOMMU页表用于记录I/O设备与服务器内存地址的映射关系,每个I/O设备有不同IOMMU页表。VFIO还通过对I\O设备驱动的封装向用户态提供直接访问和配置管理设备的接口。在I\O设备采用VFIO直通方式时,用户态Hypervisor程序只需要通过约定的ioctl接口即可调用VFIO提供的各种能力。
具体配置过程包括:虚拟机监控器查询配置第二类数据的I\O设备存储空间,该 存储空间可以包括I/O协议中定义的多个寄存器,用于记录第二类数据。接着,将第二类数据在I/O设备存储空间中的地址映射至服务器的第二内存空间的地址。然后,将服务器的第二内存空间的地址均映射至虚拟机的虚拟地址空间,并通过IOMMU来关联I\O设备的DMA和中断资源,最后将相关数据注册给虚拟机,从而实现I\O设备直通功能。
在数据访问过程中,若访问的硬件数据类型为第二类数据,虚拟机基于直通方式,从I/O设备存储空间中直接访问数据。具体是,基于第一虚拟地址空间与第二内存空间的地址具有映射关系、以及第二内存空间的地址与I/O设备存储空间的地址的映射关系,虚拟机直接访问第一虚拟地址空间时,可以直接从I/O设备存储空间中访问到第二类数据,保证了第二类数据的访问时效性。
基于上述S101至S104介绍的虚拟机监控器对数据的存储过程,下面结合步骤S105至S109进一步介绍虚拟机对数据的访问过程。
S105、虚拟机接收I/O访问请求。
该I/O访问请求用于访问数据,该I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型。
该I/O访问请求中访问的硬件数据类型可以为第一类数据,也可以为第二类数据。
S106、虚拟机识别I/O访问请求中的硬件数据类型为第一类数据。
S107、虚拟机从第一内存空间中获取待访问数据。
虚拟机接收到I/O访问请求后,识别该I/O访问请求,若识别该I/O访问请求中的硬件数据类型为第一类数据时,则虚拟机从服务器的第一内存空间中访问该第一类数据。
例如,上述I/O访问请求为读请求,虚拟机接收到该读请求后,识别该读请求所请求的硬件数据类型为第一类数据还是第二类数据,若为第一类数据,则虚拟机从服务器的第一内存空间中读取第一类数据,若为第二类数据,则虚拟机从I/O设备存储空间中读取第二类数据。
S108、虚拟机识别I/O访问请求中的硬件数据类型为第二类数据。
S109、虚拟机从I/O设备存储空间中获取待访问数据。
若虚拟机识别该I/O访问请求中的硬件数据类型为第二类数据,则虚拟机从所述I/O设备存储空间中访问该第二类数据。
在一种示例中,参照上述S1043,虚拟机监控器基于直通方式,将所述第二类数据存储至I/O设备存储空间中,这样在数据访问过程中,虚拟机识别上述I/O访问请求中的硬件数据类型为第二类数据时,虚拟机可以基于直通方式,从I/O设备存储空间中直接访问数据。具体是,基于第一虚拟地址空间与第二内存空间的地址具有映射关系、以及第二内存空间的地址与I/O设备存储空间的地址的映射关系,虚拟机直接访问第一虚拟地址空间时,可以直接从I/O设备存储空间中访问到第二类数据,保证了第二类数据的访问时效性。
由上述可知,本申请实施例的数据访问过程,若I/O访问请求访问的硬件数据类型为第一类数据,则虚拟机从服务器的第一内存空间中访问数据,若I/O访问请求访 问的硬件数据类型为第二类数据,则虚拟机从I/O设备存储空间中访问数据,相比于已有的均从I/O设备存储空间中访问数据,可以较少对I/O设备的访问次数,进而提高数据访问速度。
本申请实施例提供的数据处理方法,在数据存储过程中,虚拟机监控器将虚拟I/O设备的硬件数据中的第一类数据存储在服务器的第一内存空间中,相比于已有的将虚拟I/O设备的所有硬件数据存储在I/O设备存储空间中,当I/O设备包括的虚拟I/O设备较多时,本申请实施例的方法可以大大降低对I/O设备存储空间的占用和I/O设备的硬件开销。在数据访问过程中,虚拟机接收到I/O访问请求后,识别该I/O访问请求所请求访问的硬件数据类型,识别该I/O访问请求所请求访问的硬件数据类型为第一类数据,则虚拟机从服务器的第一内存空间中访问数据;识别该I/O访问请求所请求访问的硬件数据类型为第二类数据,则虚拟机从I/O设备存储空间中访问数据,可以较少对I/O设备的访问次数,进而有效提高数据访问速度。
上述图4详细介绍了虚拟机监控器存储第一类数据和第二数据的过程,以及虚拟机访问第一类数据和第二类数据的过程。参照图6所示,图6为本申请实施例提供的数据处理方法的另一流程图,本申请实施例对第一类数据中的第一数据和第二数据的存储过程和访问过程进行详细介绍如下,参照图1、图5和图6所示,本申请实施例的方法可以包括:
S201、虚拟机监控器根据第一数据的大小,从第一内存空间中申请第一子内存空间。
S202、虚拟机监控器将第一数据存储在第一子内存空间中,并为第一数据配置处理函数,该处理函数用于仿真第一数据对应的附加操作。
本申请将第一类数据划分为第一数据和第二数据,本申请对第一数据和第二数据的划分方式不做限制,具体根据实际需要确定。
在一种可选的方式中,基于虚拟机访问第一类数据时是否引起I/O设备的附加操作,例如复位、队列使能等附加操作,将第一类数据划分为第一数据和第二数据。其中第一数据为虚拟机访问时会引起I/O设备的附加操作的硬件数据,第二数据为第一类数据中除第一数据之外的数据,即第二数据为虚拟机访问时不会引起I/O设备的附加操作的硬件数据。
针对第一数据,在存储时,虚拟机监控器根据第一数据的大小,从服务器的第一内存空间中申请用于存储第一数据的第一子内存空间,并将第一数据存储在第一子空间中,以减轻I\O设备的硬件负担。
例如,Virtio协议中的公共配置能力能力空间定义的部分数据当被虚拟机访问时会产生附加操作,例如,device_status字段用于使前端驱动与I/O设备之间的状态信息同步,当device_status字段被虚拟机清零时意味着I/O设备复位,I/O设备将以往的配置信息清空或是恢复至默认值。再例如,queue_enable字段置位意味着虚拟机已为队列分配了必要的共享内存,I/O设备需要记录队列地址,并做好队列随时会发起数据传输的准备工作。虚拟机监控器为这些字段申请相应的第一子内存空间。
由于上述第一数据当虚拟机访问时,会引起I/O设备的附加操作,例如,上述第 一数据为复位数据,虚拟机访问该复位数据,会引起I/O设备的复位操作。
本申请实施例中,由于上述第一数据是虚拟机监控器通过仿真的方式配置在服务器的第一内存空间中,当其访问时,无法使I/O设备直接产生附加操作。因此,本申请实施例为第一数据配置处理函数,该处理函数用于仿真第一数据对应的附加操作。
需要说明的是,上述处理函数为一段软件程序,可以被服务器中的处理器执行。在后续的数据访问过程中,当虚拟机访问第一子内存空间时,虚拟机监控器调用处理函数仿真第一数据对应的附加操作。接着,驱动I/O设备完成该附加操作对应的动作,例如复位。
S203、虚拟机监控器根据第二数据的大小,从第一内存空间中申请第二子内存空间。
S204、虚拟机监控器将第二数据存储在第二子内存空间中。
以Virtio协议为例,Device-specific Capability这个能力空间用于描述设备具体的属性,如Virtio_Net网卡设备、MAC地址、最大支持队列数目、队列数目等设备相关的属性数据,这些数据一般通过静态随机存取存储器(staticrandom-accessmemory,SRAM)\寄存器等方式实现,这些数据不涉及I\O流程。且这些属性数据仅在虚拟机的前端驱动初始化阶段进行前后端同步一次,后续便固化为前端驱动的基本属性供业务使用,在设备I\O流程中均不会再访问,将这类数据记为第二数据。针对第二数据,虚拟机监控器从服务器的第一内存空间中为其申请第二子内存空间,并将该第二数据存储在该第二子内存空间中,进而减轻I\O设备的硬件负担。
需要说明的是,图7作为一种示例示出的第二内存空间、第一子内存空间和第二子内存空间的地址相连,但是本申请实施例不局限于图7,即第二内存空间、第一子内存空间与第二子内存空间的地址可以相连,也可以不相连,本申请实施例对此不做限制。
在一种可能的可能的实施例下,为了方便虚拟机对虚拟I/O设备的硬件数据的访问,本申请实施例的数据存储过程还包括:
S2041、虚拟机监控器将第二类数据在所述I/O设备存储空间中的地址映射至所述服务器的第二内存空间的地址。
S2042、虚拟机监控器将第二内存空间、第一子内存空间的地址和第二子内存空间的地址均映射至虚拟机的虚拟地址空间中。
如图7所示,假设将虚拟机的虚拟地址空间划分成3部分,分别记为第一虚拟地址空间、第二子虚拟地址空间和第三子虚拟地址空间,其中第二子虚拟地址空间和第三虚拟地址空间属于第二虚拟地址空间。虚拟机监控器将第二内存空间的地址映射至虚拟机的第一虚拟地址空间,将第一子内存空间映射至虚拟机的第二子虚拟地址空间,将第二子内存空间映射至虚拟机的第三子虚拟地址空间。
这样,在数据访问阶段,由于上述第一子内存空间的地址、第二子内存空间的地址、第二内存空间的地址与虚拟地址空间的映射关系,虚拟机直接访问其可以访问的虚拟地址空间时,可以直接访问到数据。
例如,虚拟机访问第二数据时,虚拟机访问第三子虚拟地址空间,而该第三子虚拟地址空间与第二子内存空间的地址的映射关系,这样,虚拟机可以直接从第二子内 存空间中访问到第二数据。
再例如,虚拟机访问第一数据时,虚拟机直接访问第二子虚拟地址空间,该第二虚拟地址空间与服务器的第一子内存空间的地址具有映射关系,虚拟机可以直接从第一子内存空间中访问到第一数据。同时,虚拟机监控器检测到虚拟机访问第一子内存空间的第一数据时,虚拟机监控器截获该I/O访问请求。虚拟机监控器该第一数据对应的处理函数来仿真该第一数据对应的附加操作,并控制I/O设备完成该附加操作对应的动作。
本申请实施例,根据虚拟机访问时是否会引起I/O设备的附加操作,将第一类数据划分为第一数据和第二数据,且将第一数据和第二数据保存在第一内存空间的两个内存子空间中,即将第一数据存储在第一子内存空间,将第二数据存储在第二子内存空间,且在第一子内存空间中存储第一数据对应的附加操作,这样,方便后续虚拟机对第一数据和第二数据的访问,且保证了虚拟机访问第一数据的真实性。
基于上述S201至S204的步骤,实现第一数据和第二数据的存储,后续S205至S211为虚拟机访问第一数据的访问过程,S210至S211为虚拟机访问第二数据的访问过程。
S205、虚拟机接收I/O访问请求。
上述S205的具体执行过程可以参照上述S105的描述,在此不再赘述。
S206、虚拟机识别I/O访问请求中的硬件数据类型为第一数据。
S207、虚拟机从第一子内存空间中访问第一数据。
虚拟机接收到I/O访问请求后,识别该I/O访问请求包括的硬件数据类型,例如可以识别该I/O访问请求包括的硬件数据类型为第一类数据中的第一数据,则虚拟机从第一子内存空间中访问第一数据。
S208、虚拟机监控器检测到虚拟机从第一子内存空间中访问第一数据时,调用处理函数仿真第一数据对应的附加操作。
S209、虚拟机监控器控制I/O设备执行附加操作对应的动作。
具体是,当虚拟机监控器监测到虚拟机访问的数据从第一子内存空间中访问第一数据时,虚拟机监控器截获该I/O访问请求,并调用该第一数据对应的处理函数来仿真第一数据对应的附加操作。接着,虚拟机监控器根据该仿真的附加操作控制I/O设备执行该附加操作对应的动作,例如复位。其中,处理函数本质为一组程序代码的组合,用于实现对数据处理过程的仿真,以使得I/O设备实现真实的动作。
例如,上述第一数据为复位数据,当虚拟机接收到该I/O访问请求时,虚拟机的前端驱动发生一个信号,例如为VM exit信号。该I/O访问请求被虚拟机监控器截获并回调处理函数仿真复位操作,并控制I/O设备的实际复位操作。
S210、虚拟机识别I/O访问请求中的硬件数据类型为第二数据。
S211、虚拟机从第二子内存空间中访问第二数据。
虚拟机接收到I/O访问请求后,识别该I/O访问请求包括的硬件数据类型为第一类数据中的第二数据,则虚拟机从第二子内存空间中访问第二数据。
本申请实施例的方法,虚拟机监控器通过将第一类数据划分为第一数据和第二数 据,且从第一内存空间中为第一数据申请第一子内存空间,并将第一数据存储在第一子内存空间中,同时,为第一数据配置处理函数;虚拟机监控器从第一内存空间中为第二数据申请第二子内存空间,并将第二数据存储在第二子内存空间中。当虚拟机访问第一数据时,虚拟机监控器截获该I/O访问操作,并使调用处理函数来仿真该第一数据对应的附加操作,并控制I/O设备完成该附加操作对应的动作,进而实现对第一数据的有效访问,同时,本申请实施例,虚拟机直接从服务器的内存空间中访问第一数据和第二数据,而不是从I/O设备存储空间中访问第一数据和第二数据,这样可以减少对I/O设备的操作次数,且降低I/O设备的硬件开销。
传统技术中,为虚拟I/O设备配置一个I/O设备存储空间,该I/O设备存储对应一个I/O存储空间,I/O存储空间中的数据固化,无法更改,当虚拟I/O设备的协议更新,增加新的功能域段或增加厂商特定的寄存器时,传统方法无法满足技术要求。
为了解决该技术问题,在上述S201至S205的基础上,本申请实施例的方法包括:
S200、虚拟机监控器检测到第二数据发生变化时,将变化后的第二数据发送给I/O设备。
本申请实施例的第二数据存储在服务器的第二子内存空间中,该第二子内存空间中的第二数据可以更改或增加,这样,当虚拟I/O设备的协议更新,增加新的功能域段或增加厂商特定的寄存器时,可以通过更改或增加第二子内存空间中的第二数据来实现。
当虚拟机监控器检测到第二子内存空间中的第二数据发生变化时,需要将发生变化的第二数据及时发送给I/O设备,以确保虚拟机的驱动和I/O设备正常协同工作。
在S200的一种可能的可能的实施例中,虚拟机监控器定义多个触发事件,该触发事件可以理解为引起第二数据发生变化的事件,例如,更改I/O设备的MAC地址,为I/O设备赋予新的功能的字段、队列使能等。当上述触发事件发生时,虚拟机监控器将该发生变化的第二数据存储在第二子内存空间中,且截获该触发事件,根据该触发事件,从第二子内存空间中获得该发生变化的第二数据,并将发生变化的第二数据发送I/O设备,I/O设备将发生变化的第二数据写入I/O设备的存储空间中,例如将发生变化的第二数据写入I/O设备的管理缓冲区中。
示例性的,在Virtio协议中,虚拟机的前向驱动会为队列分配必要的共享内存,并将内存地址填入公共配置能力能力空间定义的queue_desc,queue_avail和queue_used字段,这些信息需要及时被I/O设备获取并记录,以确保当I\O发起时,I/O设备可以借助这些信息以及DMA引擎去服务器的对应地址上搬运数据。
例如,本申请实施例在虚拟机监控器定义队列使能(queue_enable)为触发事件,当虚拟机的前向驱动填写完队列信息。虚拟机的前向驱动使能queue_enable字段,虚拟机监控器截获此次触发事件,并仿真该触发事件,将队列信息queue_desc,queue_avail,queue_used配置在服务器的第二子内存空间中。同时,虚拟机监控器从第二子内存空间中获取上述队列信息queue_desc,queue_avail和queue_used,将这些信息通过ioctl的形式传递给I/O设备,以使I/O设备将这些信息写入I\O设备的存储空间,同时,I/O设备结合I\O设备内部逻辑完成队列信息的同步。
本步骤,当后续出现由于协议更新引入新功能域段或是需要增加厂商特定寄存器,使得第二数据发生变化时,虚拟机监控器可以获得变化后的第二数据,并将变化后的第二数据同步给I/O设备,保证I/O设备的软硬件信息同步,进而解决了新增数据不便于追加的问题。
本申请实施例提供的数据处理方法,虚拟机监控器从服务器的第一内存空间中为第二数据申请第二子内存空间,并将该第二数据存储在第二子内存空间中,该第二子内存空间中的第二数据可以更改或追加,这样当虚拟I/O设备的协议更新,增加新的功能域段或增加厂商特定的寄存器时,通过更改或增加第二子内存空间中的第二数据来解决新增数据不便于追加的问题。当虚拟机监控器检测到第二子内存空间中的第二数据发送变化时,将变化后的第二数据发送给I/O设备,以确保虚拟机的驱动和I/O设备正常协同工作。
上文中结合图1至图7,详细描述了根据本申请实施例所提供的数据处理的方法,下面将结合图8至图10,描述根据本申请实施例所提供的数据处理的装置和设备。
图8为本申请实施例提供的数据处理的装置的一种结构示意图,该装置100用于执行上述方法实施例中虚拟机侧的方法。该装置100应用于数据处理系统,该数据处理系统包括装置100和输入/输出I/O设备,如图8所示,装置100包括:接收单元110、处理单元120和获取单元130。
接收单元110,用于接收I/O访问请求,所述I/O访问请求用于访问数据,所述I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备。
处理单元120,用于识别所述I/O访问请求中的所述硬件数据类型为第一类数据,该第一类数据为所述虚拟I/O设备在数据处理过程中保持不变的硬件数据。
获取单元130,用于从第一内存空间中获取待访问数据,所述第一内存空间为所述数据处理系统的内存存储空间。
本申请实施例的装置100,可以用于执行上述各方法实施例中虚拟机所执行的操作步骤,其实现原理和技术效果类似,此处不再赘述。
可选的,所述第一类数据包括第一数据,所述第一数据为所述装置100访问时引起所述I/O设备的附加操作的硬件数据,所述第一内存空间包括第一子内存空间,所述第一子内存空间中存储有所述第一数据和处理函数,所述处理函数用于仿真所述第一数据对应的附加操作;
所述获取单元130,具体用于从第一子内存空间中获取所述第一数据,并使得虚拟机监控器调用所述处理函数仿真所述第一数据对应的附加操作,以控制所述I/O设备执行所述附加操作对应的动作,所述数据处理系统包括虚拟机监控器。
可选的,上述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;所述第一内存空间还包括第二子内存空间,所述第二数据存储在所述第二子内存空间中;
所述获取单元130,具体用于从所述第二子内存空间中访问所述第二数据。
可选的,所述装置100的虚拟地址与所述第一内存空间的地址之间的映射关系。
应理解的是,本申请实施例的装置100可以通过专用集成电路(application-specific  integrated circuit,ASIC)实现,或可编程逻辑器件(programmable logic device,PLD)实现,上述PLD可以是复杂程序逻辑器件(complex programmable logical device,CPLD),现场可编程门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。也可以通过软件实现图4和图6所示的数据处理方法时,装置100及其各个模块也可以为软件模块。
根据本申请实施例的装置100可对应于执行本申请实施例中描述的方法,并且装置100中的各个单元的上述和其它操作和/或功能分别为了实现图4和图6中虚拟机所执行的各个方法的相应流程,为了简洁,在此不再赘述。
图9为本申请实施例提供的数据处理的装置200的一种结构示意图,该装置200可以理解为数据处理系统的处理器中的一段软件代码,该装置200用于执行上述方法实施例中虚拟机监控器侧的方法。该装置200应用于数据处理系统,该数据处理系统包括装置200、虚拟机和输入/输出I/O设备,如图9所示,装置200包括:获取单元210和处理单元220。
获取单元210,用于获取第一类数据,所述第一类数据为所述虚拟I/O设备在数据处理过程中保持不变的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;
处理单元220,用于将所述第一类数据存储在第一内存空间,所述第一内存空间为所述数据处理系统的内存中存储空间。
本申请实施例的装置200,可以用于执行上述各方法实施例中虚拟机监控器的技术方案,其实现原理和技术效果类似,此处不再赘述。
可选的,上述处理单元220,还用于根据所述第一类数据的大小,从所述数据处理系统的内存存储空间中申请所述第一内存空间。
可选的,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据;
所述处理单元220,具体用于根据所述第一数据的大小,从所述第一内存空间中申请第一子内存空间,并将所述第一数据和处理函数存储在所述第一子内存空间中,所述处理函数用于仿真所述第一数据对应的附加操作。
可选的,所述处理单元220,还用于检测到所述虚拟机从第一子内存空间中访问所述第一数据时,调用所述处理函数仿真所述第一数据对应的附加操作,并控制所述I/O设备执行所述附加操作对应的动作。
可选的,所述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;
所述处理单元220,具体具体用于根据所述第二数据的大小,从所述第一内存空间中申请第二子内存空间,并将所述第二数据存储在所述第二子内存空间中。
可选的,装置200还包括:发送单元230,
所述处理单元220,还用于检测所述第二数据发生变化;
所述发送单元230,用于在所述处理单元220检测到所述第二数据发送变化时,将变化后的所述第二数据发送给所述I/O设备。
可选的,所述处理单元220,还用于将第二类数据存储在所述I/O设备存储空间中, 所述第二类数据为所述虚拟I/O设备的硬件数据中除所述第一类数据之外的硬件数据。
可选的,所述处理单元220,还用于将所述第二类数据在所述I/O设备存储空间中的地址映射至所述第二内存空间的地址。
可选的,所述处理单元220,还用于将所述第一内存空间的地址和所述第二内存空间的地址均映射至所述虚拟机的虚拟地址空间中。
应理解的是,本申请实施例的装置200可以通过专用集成电路(ASIC)实现,或可编程逻辑器件(PLD)实现,上述PLD可以是复杂程序逻辑器件(CPLD),现场可编程门阵列(FPGA),通用阵列逻辑(GAL)或其任意组合。也可以通过软件实现图4和图6所示的数据处理方法时,装置200及其各个模块也可以为软件模块。
根据本申请实施例的装置200可对应于执行本申请实施例中描述的方法,并且装置200中的各个单元的上述和其它操作和/或功能分别为了实现图4和图6中虚拟机监控器所执行的各个方法的相应流程,为了简洁,在此不再赘述。
图10为本申请实施例提供的一种数据处理的设备的结构示意图。如图所示设备300包括处理器301,处理器301连接一个或多个数据存储设备。该数据存储设备可以包括存储介质306和内存单元304。存储介质306可以是只读的,如只读存储器(ROM),或可读/可写,如硬盘或闪存存储器。内存单元304可以是随机存取存储器(RAM)。内存单元304可以物理上集成在处理器301中,也可以在独立单元或单元中构建。
处理器301是设备300的控制中心,提供执行指令、执行中断动作、提供定时功能和其他功能的排序和处理设施。可选的,处理器301包括一个或多个中央处理器(CPU)。如图10所示的CPU 0和CPU 1。可选的,设备300包括多个处理器。处理器301可以是单核(单CPU)处理器,也可以是多核(多CPU)处理器,除非另有说明,否则用于执行任务的处理器或存储器等部件可以实现为临时配置的用于在给定时间执行任务的通用组件或制造用于执行任务的特定组件,如本文所使用的术语“处理器”是指一个或多个设备或电路。该处理器301还可以是其他通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者是任何常规的处理器等。
处理器301的CPU执行的程序代码可以存储在内存单元304或存储介质302中。可选的,程序代码(例如,内核、待调试程序)存储在存储介质302中,被复制到内存单元304中供处理器301执行。处理器301可执行至少一个内核(例如,内核来自销售在LINUX TM、UNIX TM、windows TM、ANDROID TM、IOS TM等操作系统中的内核)。处理器301通过控制其他程序或进程的执行,控制与周边设备的通信,控制数据处理的设备资源的使用,从而控制设备300的运行。
数据处理的设备300还包括用于直接或通过外部网络与其他设备或系统通信的通信接口303。可选的,设备300还包括输出设备和输入设备(图10未示出)。输出设备与处理器301连接,能够以一种或多种方式显示信息。输出设备的一个示例是液晶显示器(LCD)、发光二极管(LED)显示器、阴极射线管(CRT)或投射器等视觉显示设备。输入设备还与处理器301连接。能够接收来自设备300或更多方式的用户的输入。输入设备的示例包括鼠标、键盘、触摸屏设备或感应设备等。
数据处理的设备300的上述元素可以通过总线连接在一起,例如数据总线、地址总线、控制总线、扩展总线和本地总线中的任何一个或任意组合。
可选的,所述数据处理的设备300还可以包括上述实施例涉及的I/O设备306,所述I/O设备中包括一个或多个虚拟I/O设备,该I/O设备与处理器通信连接,虚拟I/O设备与虚拟机一一对应,用于实现虚拟机对I/O设备的访问。
可选的,若数据处理的设备300用于实现对应于上述各实施例中虚拟机的操作时,例如,可以由处理器301接收I/O访问请求,所述I/O访问请求用于访问数据,所述I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;并识别所述I/O访问请求中的所述硬件数据类型为第一类数据;从第一内存空间中获取待访问数据,所述第一内存空间为所述数据处理系统的内存存储空间。
其中,上述处理器301的具体实现过程可以参见上述各实施例中虚拟机的相关描述,此处不再赘述。
可选的,若数据处理的设备300用于实现对应于上述各实施例中虚拟机的操作时,例如可以由处理器301获取第一类数据,所述第一类数据为虚拟I/O在数据处理过程中保持不变的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;并将所述第一类数据存储在第一内存空间,所述第一内存空间为所述数据处理系统的内存中存储空间。
其中,上述处理器301的具体实现过程可以参见上述各实施例中虚拟机监控器的相关描述,此处不再赘述。
本实施例所述的数据处理的设备300可以是前述方法实施例中提到的数据处理系统(或者可用于数据处理系统的部件)。数据处理的设备300可用于实现上述方法实施例中描述的对应于虚拟机或者虚拟机监控器的方法,具体参见上述方法实施例中的说明。
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载或执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质。半导体介质可以是固态硬盘(solid state drive,SSD)。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。 另外,各个方法实施例之间、各个装置实施例之间也可以互相参考,在不同实施例中的相同或对应内容可以互相引用,不做赘述。

Claims (17)

  1. 一种数据处理的方法,其特征在于,所述方法应用于数据处理系统,所述数据处理系统包括虚拟机和输入/输出I/O设备,所述方法包括:
    所述虚拟机接收I/O访问请求,所述I/O访问请求用于访问数据,所述I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;
    所述虚拟机识别所述I/O访问请求中的所述硬件数据类型为第一类数据;所述第一类数据为所述虚拟I/O设备在数据处理过程中保持不变的硬件数据;
    所述虚拟机从第一内存空间中获取待访问数据,所述第一内存空间为所述数据处理系统的内存存储空间。
  2. 根据权利要求1所述的方法,其特征在于,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据,所述第一内存空间包括第一子内存空间,所述第一子内存空间中存储有所述第一数据和处理函数,所述处理函数用于仿真所述第一数据对应的附加操作;
    所述虚拟机从第一内存空间中获取待访问数据,包括:所述虚拟机从第一子内存空间中获取所述第一数据,并使得虚拟机监控器调用所述处理函数仿真所述第一数据对应的附加操作,以控制所述I/O设备执行所述附加操作对应的动作,所述数据处理系统包括虚拟机监控器。
  3. 根据权利要求2所述的方法,其特征在于,所述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;所述第一内存空间还包括第二子内存空间,所述第二数据存储在所述第二子内存空间中;
    所述虚拟机从第一内存空间中获取待访问数据包括:所述虚拟机从所述第二子内存空间中访问所述第二数据。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述虚拟机的虚拟地址与所述第一内存空间的地址之间具有映射关系。
  5. 一种数据处理方法,其特征在于,应用于数据处理系统,所述数据处理系统包括虚拟机监控器、虚拟机和输入/输出I/O设备,所述方法包括:
    所述虚拟机监控器获取第一类数据,所述第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;
    所述虚拟机监控器将所述第一类数据存储在第一内存空间,所述第一内存空间为所述数据处理系统的内存中存储空间。
  6. 根据权利要求5所述的方法,其特征在于,所述虚拟机监控器将所述第一类数据存储在第一内存空间之前,所述方法还包括:
    所述虚拟机监控器根据所述第一类数据的大小,从所述数据处理系统的内存存储空间中申请所述第一内存空间。
  7. 根据权利要求6所述的方法,其特征在于,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据,所述方法还包括:
    所述虚拟机监控器根据所述第一数据的大小,从所述第一内存空间中申请第一子内存空间;
    所述虚拟机监控器将所述第一数据和处理函数存储在所述第一子内存空间中,所述处理函数用于仿真所述第一数据对应的附加操作。
  8. 根据权利要求7所述的方法,其特征在于,所述方法还包括:
    所述虚拟机监控器检测到所述虚拟机从第一子内存空间中访问所述第一数据时,调用所述处理函数仿真所述第一数据对应的附加操作;
    所述虚拟机监控器控制所述I/O设备执行所述附加操作对应的动作。
  9. 一种数据处理的装置,其特征在于,所述装置应用于数据处理系统,所述数据处理系统包括所述装置和输入/输出I/O设备,所述装置包括:
    接收单元,用于接收I/O访问请求,所述I/O访问请求用于访问数据,所述I/O访问请求包括用于指示虚拟I/O设备工作状态的硬件数据的类型,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;
    处理单元,用于识别所述I/O访问请求中的所述硬件数据类型为第一类数据;所述第一类数据为所述虚拟I/O设备在数据处理过程中保持不变的硬件数据;
    获取单元,用于从第一内存空间中获取待访问数据,所述第一内存空间为所述数据处理系统的内存存储空间。
  10. 根据权利要求9所述的装置,其特征在于,所述第一类数据包括第一数据,所述第一数据为所述装置访问时引起所述I/O设备的附加操作的硬件数据,所述第一内存空间包括第一子内存空间,所述第一子内存空间中存储有所述第一数据和处理函数,所述处理函数用于仿真所述第一数据对应的附加操作;
    所述获取单元,具体用于从第一子内存空间中获取所述第一数据,并使得虚拟机监控器调用所述处理函数仿真所述第一数据对应的附加操作,以控制所述I/O设备执行所述附加操作对应的动作,所述数据处理系统包括虚拟机监控器。
  11. 根据权利要求10所述的装置,其特征在于,所述第一类数据还包括第二数据,所述第二数据为所述第一类数据中除所述第一数据之外的硬件数据;所述第一内存空间还包括第二子内存空间,所述第二数据存储在所述第二子内存空间中;
    所述获取单元,具体用于从所述第二子内存空间中访问所述第二数据。
  12. 根据权利要求9-11任一项所述的装置,其特征在于,所述装置的虚拟地址与所述第一内存空间的地址之间的映射关系。
  13. 一种数据处理的装置,其特征在于,所述装置应用于数据处理系统,所述数据处理系统包括所述装置、虚拟机和输入/输出I/O设备,所述装置包括:
    获取单元,用于获取第一类数据,所述第一类数据为虚拟I/O设备在数据处理过程中保持不变的硬件数据,所述虚拟I/O设备为所述I/O设备虚拟化后获得的I/O设备;
    处理单元,用于将所述第一类数据存储在第一内存空间,所述第一内存空间为所述数据处理系统的内存中存储空间。
  14. 根据权利要求13所述的装置,其特征在于,
    所述处理单元,还用于根据所述第一类数据的大小,从所述数据处理系统的内存存储空间中申请所述第一内存空间。
  15. 根据权利要求14所述的装置,其特征在于,所述第一类数据包括第一数据,所述第一数据为所述虚拟机访问时引起所述I/O设备的附加操作的硬件数据;
    所述处理单元,具体用于根据所述第一数据的大小,从所述第一内存空间中申请第一子内存空间,并将所述第一数据和处理函数存储在所述第一子内存空间中,所述处理函数用于仿真所述第一数据对应的附加操作。
  16. 根据权利要求14所述的装置,其特征在于,
    所述处理单元,还用于检测到所述虚拟机从第一子内存空间中访问所述第一数据时,调用所述处理函数仿真所述第一数据对应的附加操作,并控制所述I/O设备执行所述附加操作对应的动作。
  17. 一种数据处理设备,其特征在于,包括:处理器,所述处理器用于执行实现如权利要求1至4或如权利要求5至8中任一项权利要求所述的方法。
PCT/CN2020/075084 2019-04-30 2020-02-13 数据处理的方法、装置与设备 WO2020220790A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20798422.0A EP3951591A4 (en) 2019-04-30 2020-02-13 DATA PROCESSING METHOD, APPARATUS AND DEVICE
US17/513,043 US20220050795A1 (en) 2019-04-30 2021-10-28 Data processing method, apparatus, and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910363976.8 2019-04-30
CN201910363976.8A CN111857943B (zh) 2019-04-30 2019-04-30 数据处理的方法、装置与设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/513,043 Continuation US20220050795A1 (en) 2019-04-30 2021-10-28 Data processing method, apparatus, and device

Publications (1)

Publication Number Publication Date
WO2020220790A1 true WO2020220790A1 (zh) 2020-11-05

Family

ID=72965061

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/075084 WO2020220790A1 (zh) 2019-04-30 2020-02-13 数据处理的方法、装置与设备

Country Status (4)

Country Link
US (1) US20220050795A1 (zh)
EP (1) EP3951591A4 (zh)
CN (1) CN111857943B (zh)
WO (1) WO2020220790A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20210028892A (ko) * 2019-09-05 2021-03-15 삼성전자주식회사 서버 및 이의 제어 방법
CN116257471A (zh) * 2021-12-10 2023-06-13 华为技术有限公司 一种业务处理方法及装置
CN114756332A (zh) * 2022-05-19 2022-07-15 阿里巴巴(中国)有限公司 基于虚拟机设备直通的数据访问方法、设备以及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591702A (zh) * 2011-12-31 2012-07-18 华为技术有限公司 虚拟化处理方法及相关装置和计算机系统
US8239655B2 (en) * 2010-01-18 2012-08-07 Vmware, Inc. Virtual target addressing during direct data access via VF of IO storage adapter
CN103389884A (zh) * 2013-07-29 2013-11-13 华为技术有限公司 处理输入/输出请求的方法、宿主机、服务器和虚拟机
CN104104705A (zh) * 2013-04-11 2014-10-15 阿里巴巴集团控股有限公司 分布式存储系统的接入方法和设备
CN104809124A (zh) * 2014-01-24 2015-07-29 中国移动通信集团河北有限公司 云虚拟文件系统及其输入/输出请求处理方法

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8001543B2 (en) * 2005-10-08 2011-08-16 International Business Machines Corporation Direct-memory access between input/output device and physical memory within virtual machine environment
US7657694B2 (en) * 2006-12-20 2010-02-02 Arm Limited Handling access requests in a data processing apparatus
CN104753992A (zh) * 2013-12-29 2015-07-01 中国移动通信集团公司 一种数据存储、虚拟平台故障恢复的方法、设备和系统
CN106445628A (zh) * 2015-08-11 2017-02-22 华为技术有限公司 一种虚拟化方法、装置和系统
CN106406981A (zh) * 2016-09-18 2017-02-15 深圳市深信服电子科技有限公司 一种读、写磁盘数据的方法及虚拟机监视器
US10228981B2 (en) * 2017-05-02 2019-03-12 Intel Corporation High-performance input-output devices supporting scalable virtualization
US10733112B2 (en) * 2017-06-16 2020-08-04 Alibaba Group Holding Limited Method and apparatus for hardware virtualization
CN107728936B (zh) * 2017-09-05 2020-10-09 华为技术有限公司 用于传输数据处理请求的方法和装置
KR101984714B1 (ko) * 2018-08-23 2019-05-31 (주) 글루시스 가상화 자원 모니터링 시스템

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8239655B2 (en) * 2010-01-18 2012-08-07 Vmware, Inc. Virtual target addressing during direct data access via VF of IO storage adapter
CN102591702A (zh) * 2011-12-31 2012-07-18 华为技术有限公司 虚拟化处理方法及相关装置和计算机系统
CN104104705A (zh) * 2013-04-11 2014-10-15 阿里巴巴集团控股有限公司 分布式存储系统的接入方法和设备
CN103389884A (zh) * 2013-07-29 2013-11-13 华为技术有限公司 处理输入/输出请求的方法、宿主机、服务器和虚拟机
CN104809124A (zh) * 2014-01-24 2015-07-29 中国移动通信集团河北有限公司 云虚拟文件系统及其输入/输出请求处理方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3951591A4 *

Also Published As

Publication number Publication date
EP3951591A1 (en) 2022-02-09
CN111857943A (zh) 2020-10-30
US20220050795A1 (en) 2022-02-17
EP3951591A4 (en) 2022-06-01
CN111857943B (zh) 2024-05-17

Similar Documents

Publication Publication Date Title
US9459922B2 (en) Assigning a first portion of physical computing resources to a first logical partition and a second portion of the physical computing resources to a second logical portion
WO2017024783A1 (zh) 一种虚拟化方法、装置和系统
EP3982261A1 (en) Method and apparatus for processing io
US9558041B2 (en) Transparent non-uniform memory access (NUMA) awareness
JP5180373B2 (ja) 仮想化環境における割り込みメッセージ終了のレイジー処理
WO2018119952A1 (zh) 一种设备虚拟化方法、装置、系统及电子设备、计算机程序产品
JP5608243B2 (ja) 仮想化環境においてi/o処理を行う方法および装置
CN115344521A (zh) 可扩展输入/输出(i/o)虚拟化(s-iov)架构中的虚拟设备构成
US9268717B2 (en) Sharing single root IO virtualization peripheral component interconnect express devices
US9697024B2 (en) Interrupt management method, and computer implementing the interrupt management method
US20180335971A1 (en) Configurable virtualized non-volatile memory express storage
US20220050795A1 (en) Data processing method, apparatus, and device
WO2018119951A1 (zh) Gpu虚拟化方法、装置、系统及电子设备、计算机程序产品
EP3086228A1 (en) Resource processing method, operating system, and device
US20210224210A1 (en) Information processing method, physical machine, and pcie device
US11194735B2 (en) Technologies for flexible virtual function queue assignment
WO2016119468A1 (zh) 虚拟机内存管理方法、物理主机、pcie设备及其配置方法以及迁移管理设备
EP2881860A1 (en) Method for implementing an interrupt between virtual processors, related device, and system
WO2022143714A1 (zh) 服务器系统、虚拟机创建方法及装置
US11586567B2 (en) Techniques for virtualizing PF-VF mailbox communication in SR-IOV devices
US9851992B2 (en) Paravirtulized capability for device assignment
US11513983B2 (en) Interrupt migration
US20160026567A1 (en) Direct memory access method, system and host module for virtual machine
US20230033583A1 (en) Primary input-output queue serving host and guest operating systems concurrently
CN117520215A (zh) 一种缺页处理方法和相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20798422

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020798422

Country of ref document: EP

Effective date: 20211027