Virtual machine migration method, physical machine, medium and computer program product
By setting up a proxy middleware in the physical machine to facilitate data interaction between the virtual machine and the physical machine, the problems of driver intrusion and resource contention in online virtual machine migration are solved, enabling flexible and efficient migration without the need for additional drivers.
Patent Information
- Application Number
- CN202511241037.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-01
- Publication Date
- 2025-11-28
AI Technical Summary
Existing online migration methods for virtual machines require the installation of additional drivers in the virtual machine, resulting in strong intrusion, problems with physical device resource contention, and inflexible migration due to the inability to directly migrate physical device data.
By setting up a proxy middleware in the physical machine, data interaction between the virtual machine and the physical machine is realized. The proxy middleware is used to synchronize the status of the passthrough device and process tasks, avoiding the installation of additional drivers in the virtual machine. Data interaction is carried out through the proxy middleware to ensure that the middleware of the current virtual machine can interact with data, thus realizing online migration of virtual machines with passthrough devices.
It enables online migration without installing additional drivers in the virtual machine, reduces the complexity of virtual machine configuration, reduces the probability of resource contention, supports flexible migration between different physical machines, and improves security and isolation.
Smart Images

Figure CN121029318A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of virtualization technology, and specifically relates to a virtual machine migration method, physical machine, media, and computer program product. Background Technology
[0002] To enable online migration of virtual machines with passthrough devices, the virtual machine's operating system is typically configured not to directly control the passthrough device through the original driver, but rather to indirectly use it by adding an additional driver. When the virtual machine needs to be migrated online, the additional driver transmits the passthrough device's state over the network to the corresponding additional driver on the new virtual machine. Once the passthrough device's state data is synchronized, the virtual machine can be migrated online to the new virtual machine. This migration method, by adding an additional driver to the virtual machine, is intrusive to the virtual machine itself. The virtual machine's operating system needs to make synchronization adjustments to avoid resource contention on the physical device when multiple drivers are loaded. Summary of the Invention
[0003] This application provides a virtual machine migration method, a physical machine, a medium, and a computer program product.
[0004] This application provides a virtual machine migration method, applied to a source proxy middleware in a source physical machine. The source proxy middleware is used to enable data interaction between the source virtual machine and a passthrough device in the source physical machine. The method includes:
[0005] Obtain the interaction information between the pass-through device in the source physical machine and the source proxy middleware;
[0006] The interaction information is sent to the target proxy middleware, enabling the target proxy middleware to perform online migration of the source virtual machine based on the interaction information.
[0007] In some embodiments, before implementing the online migration of the source virtual machine, the method further includes: when the source disk data of the source virtual machine is stored on a shared disk, sending the source virtual central processing unit (vCPU) data and source memory data of the source virtual machine to the target agent middleware; wherein the source vCPU data, the source memory data, and the source disk data are used to configure the target virtual machine in the target physical machine; the target virtual machine is used to implement the online migration of the source virtual machine according to the interaction information.
[0008] As can be seen, the method given in this embodiment can make the configuration of the target virtual machine consistent with the configuration of the source virtual machine through data transmission between the source proxy middleware and the target proxy middleware.
[0009] In some embodiments, before obtaining the interaction information between the pass-through device in the source physical machine and the source proxy middleware, the method further includes: sending a virtual machine online migration request to the target proxy middleware, the virtual machine online migration request being used to create a target virtual machine and suspend the operation of the target virtual machine; after implementing the online migration of the source virtual machine, the method further includes: shutting down the source virtual machine and resuming the operation of the target virtual machine.
[0010] As can be seen, the method given in this embodiment enables the online migration of virtual machines with passthrough devices by running the source virtual machine's task through the target virtual machine after the online migration is completed.
[0011] In some embodiments, the method further includes: when the source virtual machine is not in online migration, recording the usage information of the source virtual machine to the passthrough device in the source physical machine, and forwarding the usage information to the passthrough device in the source physical machine.
[0012] It can be seen that recording usage information facilitates efficient migration of virtual machines with passthrough devices and also helps in quickly troubleshooting passthrough device faults. Forwarding usage information to the passthrough device reduces resource consumption by the source processing middleware.
[0013] In some embodiments, the source proxy middleware includes address information for hardware access of the source physical machine; the target proxy middleware includes address information for hardware access of the target physical machine; the address information is used to access the hardware in the physical machine.
[0014] As can be seen, the proxy middleware can access the hardware devices in the physical machine through the method given in this embodiment.
[0015] In some embodiments, the source proxy middleware and the target proxy middleware support an interruption mechanism. The interruption mechanism of the source proxy middleware is used to interrupt the connection between the source physical machine and the source virtual machine, and the interruption mechanism of the target proxy middleware is used to interrupt the connection between the target physical machine and the target virtual machine.
[0016] It can be seen that enabling the proxy middleware to support the interrupt mechanism is beneficial to improving the security and isolation between the virtual machine and the physical machine, ensuring that the interruption of the current virtual machine will not interfere with the normal operation of the physical machine or other virtual machines supported on the physical machine.
[0017] This application embodiment also provides a virtual machine migration method, applied to a target proxy middleware in a target physical machine, wherein the target proxy middleware is used to realize data interaction between the target virtual machine and the passthrough device in the target physical machine; the method includes:
[0018] Receive the interaction information between the pass-through device in the source physical machine and the source proxy middleware;
[0019] Based on the aforementioned interactive information, the source virtual machine can be migrated online.
[0020] This application embodiment also provides a virtual machine migration apparatus, applied to a source proxy middleware in a source physical machine, wherein the source proxy middleware is used to realize data interaction between the source virtual machine and a pass-through device in the source physical machine; the apparatus includes:
[0021] The acquisition module is used to acquire the interaction information between the pass-through device in the source physical machine and the source proxy middleware;
[0022] The sending module is used to send the interaction information to the target proxy middleware, so that the target proxy middleware can realize the online migration of the source virtual machine based on the interaction information.
[0023] This application embodiment also provides a virtual machine migration apparatus, applied to a target proxy middleware in a target physical machine, wherein the target proxy middleware is used to realize data interaction between the target virtual machine and a passthrough device in the target physical machine; the apparatus includes:
[0024] The receiving module is used to receive the interaction information between the pass-through device in the source physical machine and the source proxy middleware;
[0025] The first processing module is used to realize the online migration of the source virtual machine based on the interaction information.
[0026] This application provides a physical machine, which includes a source proxy middleware or a target proxy middleware. The source proxy middleware is used to implement the virtual machine migration method implemented by the source proxy middleware, and the target proxy middleware is used to implement the virtual machine migration method implemented by the target proxy middleware.
[0027] This application provides a computer storage medium storing a computer program that, when executed by a processor, implements any of the virtual machine migration methods described above.
[0028] This application provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-described virtual machine migration methods.
[0029] This application provides a virtual machine migration method, a physical machine, media, and a computer program product. Based on the virtual machine migration method provided in this application, online migration of virtual machines with passthrough devices is achieved by setting up a proxy middleware in the physical machine. This eliminates the need to install additional drivers in the virtual machine operating system or perform additional processing on the software programs in the virtual machine, reducing the complexity of virtual machine configuration and effectively reducing the probability of virtual machine drivers competing for physical device resources. This enables online migration of virtual machines with passthrough devices. Attached Figure Description
[0030] Figure 1 This application provides a schematic diagram of a virtual machine using a passthrough device as an embodiment of the present application.
[0031] Figure 2 This is a schematic diagram illustrating an online migration of a virtual machine based on an additional driver, as provided in an embodiment of this application.
[0032] Figure 3 This is a schematic diagram illustrating the path of a virtual machine using a pass-through device, provided in an embodiment of this application.
[0033] Figure 4 A schematic diagram of the communication connection of the proxy middleware provided in the embodiments of this application;
[0034] Figure 5 This is a schematic diagram of the proxy middleware provided in the embodiments of this application;
[0035] Figure 6 A flowchart of a virtual machine migration method provided in this application embodiment;
[0036] Figure 7 A flowchart of another virtual machine migration method provided in this application embodiment;
[0037] Figure 8 A flowchart illustrating an online migration process for virtual machines with pass-through devices, provided in this application embodiment;
[0038] Figure 9 This is a schematic diagram of the structure of a virtual machine migration device provided in an embodiment of this application;
[0039] Figure 10 This is a schematic diagram of another virtual machine migration device provided in an embodiment of this application. Detailed Implementation
[0040] Virtual machines with passthrough devices (VMs) have physical devices, such as graphics processing units (GPUs), network interface cards (NICs), and storage controllers, directly allocated to the VM for use. This bypasses the abstraction and translation of the virtualization layer, allowing the VM to directly access and control these physical devices. Common methods for online migration of VMs with passthrough devices include:
[0041] Method 1 involves achieving online migration by adding additional drivers to the virtual machine. For example... Figure 1 As shown, Figure 1 The diagram illustrates a virtual machine using a passthrough device. In this method, the operating system in the virtual machine does not directly control the passthrough device through the original actual driver, but indirectly uses the passthrough device through an additional driver. Figure 2 A schematic diagram illustrating an online migration of a virtual machine based on an additional driver is shown, such as... Figure 2 As shown, when a virtual machine performs an online migration, an additional driver transmits the state of the passthrough device over the network to the additional driver of the target virtual machine. Once the state data synchronization is complete, the online migration from the source virtual machine to the target virtual machine can be achieved. It can be seen that in this migration method, the virtual machine operating system does not interact directly with the passthrough device, but rather interacts with it through a newly added additional driver. Figure 1 , Figure 2 The corresponding method requires adding additional drivers to the virtual machine, which is intrusive to the virtual machine itself, as it needs to install these drivers to indirectly control hardware devices. Furthermore, when installing additional drivers, the virtual machine's operating system may need to make synchronized adjustments to avoid contention for physical device resources, including passthrough devices, when different drivers are loaded simultaneously.
[0042] Method two involves using the device's registers and memory data within the physical machine to achieve online migration of virtual machines with passthrough devices. In this method, the virtual machine's operating system directly uses the passthrough device while the virtual machine is running normally, requiring no additional processing at the virtual machine operating system level compared to Method one. During online migration, the hypervisor of the source physical machine hosting the virtual machine needs to first perform a synchronization operation on the passthrough device. Once the device status and related data of the passthrough device are synchronized, the virtual machine migration operation can be performed. Figure 3The flowchart illustrates the path of a virtual machine using passthrough devices. The physical machine's hardware devices are directly managed by the Virtual Function I / O (VFIO) kernel driver module. Peripheral Component Interconnect (PCI) is virtualized through VFIO, and passthrough of devices in the physical machine is achieved through VFIO PCI. The passthrough devices are then configured for the virtual machine, and the device driver in the virtual machine implements passthrough to the devices generated by VFIO PCI. In the open-source hardware virtualization and simulation tool (Quick Emulator, QEMU), its configuration parameters can be:
[0043] "-device
[0044] 'vfio-pci,host=0000:02:00.0,id=hostpci0.0,bus=ich9-pcie-port-1,addr=0x0.0,mu ltifunction=on'. "
[0045] 0000:02:00.0 is the PCI address of the device.
[0046] The implementation method described in Method 2 requires that the model and address space of the passthrough device in the target physical machine be consistent with those of the passthrough device in the source physical machine during online virtual machine migration. For example, when using VFIO to pass through a device, the PCI address of the passthrough device must be consistent. This method lacks flexibility when migrating virtual machines with passthrough devices online.
[0047] Therefore, when a virtual machine uses a passthrough device, the physical device's own data, such as register data and Direct Memory Access (DMA) data, is stored on the physical device itself rather than being simulated by the virtual machine manager. Consequently, during online migration, this physical device data cannot be directly migrated to the target physical machine, impacting the online migration of virtual machines with passthrough devices. For example, when migrating from the source virtual machine to the target virtual machine, a mismatch between the physical device data maintained by the source virtual machine's operating system and the data of the physical device in the target physical machine, especially if the parameters such as the model of the original passthrough device are inconsistent, may cause the virtual machine to crash or encounter other problems.
[0048] To address the problems associated with online migration of virtual machines with passthrough devices, this application provides a method for online migration of virtual machines with passthrough devices. This method does not require the installation of additional drivers in the virtual machine, nor does it require the passthrough devices in the physical machine to be identical before and after the migration. It can flexibly achieve online migration of virtual machines with passthrough devices.
[0049] The embodiments of this application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the embodiments provided herein are merely illustrative of the embodiments of this application and are not intended to limit the embodiments of this application. Furthermore, the embodiments provided below are some embodiments for implementing this application, and not all embodiments for implementing this application. Unless otherwise specified, the technical solutions described in the embodiments of this application can be implemented in any combination.
[0050] It should be noted that, in the embodiments of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a method or apparatus that includes a list of elements includes not only the elements expressly described, but also other elements not expressly listed, or elements inherent to implementing the method or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of other related elements in the method or apparatus that includes that element (e.g., steps in the method or units in the apparatus; for example, a unit in the apparatus may be a portion of circuitry, a portion of a processor, a portion of a program or software, etc.).
[0051] The virtual machine migration method provided in this application includes a series of steps. However, the virtual machine migration method provided in this application is not limited to the steps described. Similarly, the virtual machine migration device and physical machine provided in this application include a series of modules. However, the device and physical machine provided in this application are not limited to the modules or devices explicitly described. They may also include modules or devices that need to be set up to obtain relevant information or to process information.
[0052] This application provides a virtual machine migration method, applied to a source proxy middleware in the source physical machine. The source proxy middleware is used to enable data interaction between the source virtual machine and the passthrough device in the source physical machine. Figure 4 As shown, Figure 4A communication connection diagram of the proxy middleware is shown. Virtual machine 401 includes a virtual machine operating system 4011 and a device driver 4012. Physical machine 402 includes proxy middleware 4021, a VFIO PCI device 4022, and a passthrough device 4023. It can be seen that proxy middleware 4021 is located in physical machine 402, and virtual machine 401 interacts with passthrough device 4023 in physical machine 402 through proxy middleware 4021. In this embodiment, proxy middleware 4021 only forwards virtual machine requests to passthrough device 4023 without processing the requests itself. Correspondingly, proxy middleware 4021 returns the processing result of passthrough device 4023 to virtual machine 401.
[0053] In addition to facilitating communication between the virtual machine 401 and the passthrough device 4023, the proxy middleware 4021 also acquires and stores the status data and associated data of the passthrough device 4023. The status data of the passthrough device 4023 can be obtained through register status, buffer contents, etc. The status data acquired by the proxy middleware 4021 includes, but is not limited to, the operating mode, error status, and interrupt flags of the passthrough device 4023 obtainable from the register status, and the processing data and results of the passthrough device 4023 obtainable from the buffer contents. The associated data of the passthrough device 4023 includes, but is not limited to, various data related to the operation of the passthrough device 4023 stored in memory, such as interrupt signals and data packets received by the passthrough device 4023. This data can serve as interactive information between the proxy middleware 4021 and the passthrough device 4023.
[0054] In this embodiment of the application, when virtual machine 401 is the virtual machine before migration, virtual machine 401 is the source virtual machine, virtual machine operating system 4011 in virtual machine 401 is the source virtual machine operating system, and device driver 4012 in virtual machine 401 is the source device driver; physical machine 402 corresponding to virtual machine 401 before migration is the source physical machine, proxy middleware 4021 in physical machine 402 is the source proxy middleware, VFIO PCI device 4022 in physical machine 402 is the source VFIO PCI device, and passthrough device in physical machine 402 is the source passthrough device.
[0055] When virtual machine 401 is the migrated virtual machine, virtual machine 401 serves as the target virtual machine, virtual machine operating system 4011 within virtual machine 401 serves as the target virtual machine operating system, and device driver 4012 within virtual machine 401 serves as the target device driver. The physical machine 402 corresponding to the migrated virtual machine 401 serves as the target physical machine, proxy middleware 4021 within physical machine 402 serves as the target proxy middleware, VFIO PCI device 4022 within physical machine 402 serves as the target VFIO PCI device, and passthrough device 4023 within physical machine 402 serves as the target passthrough device. That is, the source virtual machine and source physical machine, and the target virtual machine and target physical machine in this embodiment have the same structure and can be referred to accordingly. Figure 4 Configure according to the given diagram.
[0056] Furthermore, the proxy middleware 4021 serves as the communication connection between virtual machine 401 and physical machine 402. For virtual machine 401, the proxy middleware can be viewed as a virtual pass-through device. To enable the proxy middleware to function as a pass-through device, a virtual physical device can be configured within the proxy middleware as the pass-through device for virtual machine 401. For example, ... Figure 4 As shown, when the proxy middleware 4021 is connected to the VFIO PCI device 4022, as follows: Figure 5 As shown, the proxy middleware 4021 may include a virtual PCI device 501, which serves as a pass-through device on one side of the virtual machine 401. The proxy middleware 4021 also includes a data status synchronization module 502 for interacting with the pass-through device 4023 and obtaining and recording interaction information.
[0057] In some other implementations, Figure 4 The physical machine 402 shown can also bypass the VFIO PCI device 4022 and instead communicate directly with the pass-through device 4023 via a proxy middleware 4021. In this case... Figure 5 The virtual PCI device 501 in the proxy middleware 4021 shown can be replaced with a virtual passthrough device, for example, when the passthrough device 4023 is a GPU. Figure 5 The virtual PCI device 501 shown can be replaced with a virtual GPU.
[0058] In summary, this embodiment of the application constructs a proxy middleware 4021 in the physical machine 402, and sets a virtual pass-through device in the proxy middleware 4021. The virtual pass-through device in the proxy middleware 4021 serves as the pass-through device for the virtual machine 401, receives task requests sent by the virtual machine 401, and forwards the task requests to the real pass-through device 4023 in the physical machine 402. At the same time, it records the interaction information between the proxy middleware 4021 and the pass-through device 4023, thereby realizing task processing for virtual machines with pass-through devices.
[0059] Virtual machines with pass-through devices based on the above architecture Figure 6 This diagram illustrates a virtual machine migration method using a source proxy middleware applied to the source physical machine. The source proxy middleware facilitates data interaction between the source virtual machine and the passthrough device in the source physical machine. For details, please refer to [reference needed]. Figure 4 and Figure 5 Virtual machine migration methods include:
[0060] Step 601: Obtain the interaction information between the pass-through device in the source physical machine and the source proxy middleware.
[0061] Before performing online migration of the source virtual machine, the interaction information between the source proxy middleware and the pass-through device in the source physical machine corresponding to the source virtual machine is first obtained. Corresponding to the interaction information given in the above method, the interaction information includes, but is not limited to, the information obtained by the data state synchronization module 502 regarding the interaction between the source proxy middleware and the pass-through device in the source physical machine, as well as the status data and associated data of the pass-through device in the source physical machine. Specifically, the information regarding the interaction between the source proxy middleware and the pass-through device in the source physical machine may include task requests forwarded by the source proxy middleware to the pass-through device in the source physical machine, and task processing results returned by the pass-through device in the source physical machine and received by the source proxy middleware. The status data and associated data of the pass-through device in the source physical machine may include the device's operating mode, error status, interrupt flag, processing data, and processing results.
[0062] In this embodiment, the interaction information can be information from the source processing middleware, and the interaction information can be adjusted according to the differences in the information stored in different source processing middleware. The interaction information in this embodiment can also be obtained through register status, buffer contents, memory data, etc.
[0063] Step 602: Send interaction information to the target proxy middleware, enabling the target proxy middleware to perform online migration of the source virtual machine based on the interaction information.
[0064] Upon receiving the interaction information, the source proxy middleware sends it to the target proxy middleware. Here, the target proxy middleware is the proxy middleware in the target physical machine corresponding to the migrated target virtual machine. After receiving the interaction information, the target proxy middleware updates its parameters and correspondingly updates the status data and associated data of the passthrough devices in the target physical machine, maintaining the consistency of task processing data before and after the virtual machine migration, and ensuring the consistency of passthrough devices and processing middleware before and after the migration.
[0065] In this embodiment of the application, the source processing middleware and the target processing middleware can transmit interactive information and other data through network communication. For example, data transmission between the source processing middleware and the target processing middleware can be achieved through socket communication.
[0066] As can be seen, since the communication between the virtual machine and the physical machine is completed through the processing middleware, the online migration process of the virtual machine is implemented through the processing middleware, and the pass-through device on the virtual machine side is also generated by the proxy middleware, the pass-through device can be switched through the interaction between the source processing middleware and the target processing middleware while the source virtual machine is running continuously, without affecting the operation of the pass-through device in the virtual machine and the physical machine, thus realizing the online migration of virtual machines with pass-through devices.
[0067] Meanwhile, for virtual machines, the passthrough device identified by the virtual machine is the virtual passthrough device in the proxy middleware, not the passthrough device in the physical machine. Therefore, before and after the migration, it is only necessary to ensure that the relevant parameters and configurations of the virtual passthrough device in the proxy middleware are the same. Even if the physical devices in the source physical machine and the target physical machine are different, especially if the passthrough devices in the source physical machine and the target physical machine are different, online migration of virtual machines with passthrough devices can still be achieved.
[0068] In practical applications, steps 601 to 602 can be implemented based on a processor, which can be at least one of the following: Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing Device (DSPD), Programmable Logic Device (PLD), Field Programmable Gate Array (FPGA), Central Processing Unit (CPU), Controller, Microcontroller, and Microprocessor.
[0069] Based on the virtual machine migration method given in the above embodiments, in order to ensure the successful online migration of virtual machines with passthrough devices, in addition to successfully migrating the passthrough devices, it is also necessary to achieve the online migration of the source virtual machine. In some embodiments, before achieving the online migration of the source virtual machine, the method further includes: when the source disk data of the source virtual machine is stored on a shared disk, sending the source vCPU data and source memory data of the source virtual machine to the target agent middleware; wherein, the source vCPU data, source memory data, and source disk data are used to configure the target virtual machine in the target physical machine; the target virtual machine is used to achieve the online migration of the source virtual machine according to the interaction information.
[0070] During online virtual machine migration, vCPU data, memory data, and disk data ensure seamless recovery of the virtual machine on the target physical machine. The source vCPU data includes register contents and interrupt / exception states. Migrating the source vCPU data allows us to determine if the source virtual machine is currently handling interrupts or exceptions, ensuring the migrated target virtual machine can correctly resume interrupt handling processes.
[0071] The source memory data may include user-mode memory data, kernel-mode memory data, cache and buffer data, etc. in the source virtual machine. User-mode memory data may include application information in the source virtual machine, kernel-mode memory data may include data structures of the source virtual machine operating system kernel, and cache and buffer data may include disk cache, network buffer data, etc.
[0072] When the source disk data is stored on a shared disk, the source virtual machine's source vCPU data and source memory data can be sent to the target agent middleware, and the target processing middleware can access the source disk data through the shared disk. Using the source vCPU, source memory, and source disk data obtained by the target processing middleware, the parameters of the target virtual machine can be configured to ensure that the target virtual machine's running state and configuration are consistent with those of the source virtual machine.
[0073] When the source disk data is not located on a shared disk, the source disk data can be sent to the target agent middleware simultaneously while sending the source vCPU data and source memory data of the source virtual machine to the target agent middleware.
[0074] While ensuring that the target virtual machine and the source virtual machine are in the same running state and configuration, by combining the interaction information corresponding to the passthrough device in the above embodiments, the virtual passthrough device in the target processing middleware is configured to be the same as the virtual passthrough device in the source processing middleware before migration, thereby ensuring the successful online migration of the source virtual machine with the passthrough device.
[0075] Based on the online migration of virtual machines and passthrough devices given in the above embodiments, in some embodiments, before obtaining the interaction information between the passthrough device and the source proxy middleware in the source physical machine, the method further includes: sending a virtual machine online migration request to the target proxy middleware, the virtual machine online migration request being used to create the target virtual machine and suspend the operation of the target virtual machine; after realizing the online migration of the source virtual machine, the method further includes: shutting down the source virtual machine and resuming the operation of the target virtual machine.
[0076] Before implementing online migration, the source processing middleware, or the source virtual machine's hypervisor, first sends a virtual machine online migration request to the target virtual machine's target processing middleware via network transmission. This online migration request triggers the migration process of the source virtual machine and transmits relevant interaction information, such as the source virtual machine's interaction details, to the target processing middleware.
[0077] Upon receiving a virtual machine online migration request, a target virtual machine can be created based on the request. The configuration of the target virtual machine is identical to that of the source virtual machine. After creating the target virtual machine, its operation is paused, i.e., it is set to a paused state. At this time, the target virtual machine's target vCPU, target memory data, and target device status are all paused, and the target virtual machine is currently unavailable.
[0078] Based on the method described in the above embodiments, the target processing middleware obtains the interaction information, source vCPU data, source memory data, source disk data, etc. sent by the source processing middleware. After completing the relevant configuration of the target virtual machine based on the interaction information, source vCPU data, source memory data, source disk data, etc., and completing the online migration of the source virtual machine with the passthrough device, the source virtual machine is shut down and the target virtual machine is restored to operation, so that the target virtual machine can process the unfinished tasks in the source virtual machine, thereby realizing the online migration of the source virtual machine and ensuring that the processing tasks in the source virtual machine are not interrupted.
[0079] As can be seen, in this embodiment of the application, the interaction with the pass-through device in the physical machine is all implemented by the processing middleware, which shields the direct interaction between the virtual machine and the pass-through device in the physical machine. Therefore, even if the hardware information of the pass-through device or other physical device in the original physical machine is different from the hardware information of the pass-through device or other physical device in the target physical machine, it will not affect the online migration of the virtual machine.
[0080] Furthermore, corresponding to the method given in the above embodiments, in some embodiments, when the source virtual machine is not in online migration, the usage information of the source virtual machine to the pass-through device in the source physical machine is recorded, and the usage information is forwarded to the pass-through device in the source physical machine.
[0081] When the source virtual machine is not undergoing online migration, or before online migration of the source virtual machine, during normal operation of the source virtual machine, the source processing middleware can be configured to record the source virtual machine's usage information of passthrough devices in the source physical machine, and forward the recorded usage information to the corresponding passthrough devices. Here, the usage information can also be part of the interaction information obtained in the above embodiments. The usage information may include, but is not limited to, one or more of the following: hardware information of the passthrough device, virtualization configuration information of the source virtual machine, resource utilization of the passthrough device, operating status of the passthrough device, logs of the passthrough device, user assigned to the passthrough device operation, and historical operation information of the passthrough device.
[0082] By recording usage information, efficient migration of virtual machines with passthrough devices can be achieved. Furthermore, forwarding the recorded usage information to the passthrough device helps optimize resource utilization of the passthrough device and quickly troubleshoot its faults. Forwarding usage information to the passthrough device also helps reduce the resource consumption of the processing middleware and improve its processing performance.
[0083] Corresponding to the above method, for the target processing middleware, after online migration is achieved, it can also record the target virtual machine's usage information of the pass-through device in the target physical machine during the target virtual machine's operation, and forward the usage information to the pass-through device in the target physical machine, based on the above method.
[0084] To further enable interaction between the processing middleware and the hardware devices in the physical machine, in some embodiments, the source proxy middleware includes address information for hardware access of the source physical machine; the target proxy middleware includes address information for hardware access of the target physical machine; the address information is used to access the hardware in the physical machine.
[0085] In this embodiment, to enable the source processing middleware to support complete physical machine device access, the address information for hardware access to the source physical machine can be configured in the source proxy middleware. The source processing middleware can then access the corresponding hardware devices in the source physical machine using this address information. For example, such as... Figure 5 As shown, when the proxy middleware 4021 uses the virtual PCI device 501 as a pass-through device for the virtual machine 401, it can access the physical device corresponding to the address information through the PCI device by setting the hardware access address information.
[0086] For example, hardware access address information includes, but is not limited to, one or more of the following: Memory-Mapped Input / Output (MMIO), Input / Output Port (I / O Port), PCI Configuration Space, and PCI Base Address Register Space (PCIBAR). Virtual PCI devices in the source processing middleware can access high-performance devices such as GPUs and network cards through MMIO, communicate with low-speed devices such as serial ports and keyboards through I / O Ports, configure the initialization and resources of virtual PCI devices through the PCI Configuration Space, and dynamically allocate MMIO or I / O ports to virtual PCI devices through PCIBAR.
[0087] Corresponding to the above method, the hardware access address information of the target physical machine can also be set in the target middleware. This address information can also include, but is not limited to, one or more of MMIO, I / O Port, PCI configuration space, and PCIBAR space.
[0088] Based on the above embodiments, in order to further achieve efficient and stable system operation, in some embodiments, the source proxy middleware and the target proxy middleware support an interruption mechanism. The interruption mechanism of the source proxy middleware is used to interrupt the connection between the source physical machine and the source virtual machine, and the interruption mechanism of the target proxy middleware is used to interrupt the connection between the target physical machine and the target virtual machine.
[0089] For source processing middleware, the supported interrupt mechanisms can be Message Signaled Interrupts / Enhanced Message Signaled Interrupts (MSI / MSI-X), Interrupt Remapping, and Posted Interrupt. Source processing middleware can send interrupt requests to the source physical machine's CPU based on MSI / MSI-X, dynamically change interrupt routes based on Interrupt Remapping for flexible interrupt management and isolation, and use Posted Interrupt to allow subsequent operations to continue without waiting for CPU confirmation after sending an interrupt request.
[0090] By configuring the source processing middleware to support interrupt mechanisms such as MSI / MSI-X, Interrupt Remapping, and PostedInterrupt, the source processing middleware can directly or indirectly interrupt the connection between the source virtual machine and the source physical machine, thereby improving the security and isolation between the source virtual machine and the source physical machine and ensuring that the interruption of the source virtual machine will not interfere with the operation of the source physical machine or other virtual machines on the source physical machine.
[0091] Corresponding to the above methods, the target processing middleware can also be configured to support an interrupt mechanism. The interrupt mechanism supported by the target processing middleware can be MSI / MSI-X, Interrupt Remapping, or Posted Interrupt.
[0092] Based on the virtual machine migration method proposed in the foregoing embodiments, this application also provides another virtual machine migration method, applied to a target agent middleware in the target physical machine. The target agent middleware is used to realize data interaction between the target virtual machine and the pass-through device in the target physical machine; such as Figure 7 As shown, the virtual machine migration method includes:
[0093] Step 701: Receive the interaction information between the pass-through device in the source physical machine and the source proxy middleware.
[0094] Step 702: Based on the interactive information, realize the online migration of the source virtual machine.
[0095] Corresponding to the virtual machine migration method applied to the source processing middleware given in the above embodiments, after the source processing middleware sends interaction information to the target processing middleware, the target processing middleware parses and processes the interaction information, and updates the status data and related parameters of the target processing middleware, as well as the pass-through devices in the target physical machine, based on the interaction information. This ensures that the parameters of the target processing middleware are the same as those of the source processing middleware. Simultaneously, it enables the pass-through devices in the target physical machine to process the tasks currently running on the pass-through devices in the source physical machine based on their operating status and data. It can be seen that the interaction information in this embodiment represents all the data in the source processing middleware that ensures the source virtual machine is identified and enables successful online migration of virtual machines with pass-through devices.
[0096] Since the parameters of the target processing middleware are the same as those of the source processing middleware, when the configurations of the source and target virtual machines are exactly the same, the target virtual machine can effectively and correctly identify the target processing middleware and receive the task requests of the target virtual machine through the target processing middleware. Finally, the task is processed by the passthrough device in the target physical machine, realizing the online migration of the source virtual machine with the passthrough device.
[0097] The implementation method of this embodiment is the same as that of the above embodiments. For specific implementation methods, please refer to the virtual machine migration method given in the above embodiments for understanding.
[0098] In practical applications, steps 701 to 702 can be implemented based on a processor, which can be at least one of ASIC, DSP, DSPD, PLD, FPGA, CPU, controller, microcontroller, and microprocessor.
[0099] Based on the virtual machine migration method provided in the above embodiments, Figure 8 A flowchart illustrating an online migration process for virtual machines with pass-through devices is shown, such as... Figure 8 As shown, the online migration method for virtual machines with passthrough devices includes:
[0100] Step 801: Initiate an online migration request from the source hypervisor to the target hypervisor.
[0101] Since the source virtual machine and the target virtual machine communicate through a proxy middleware, in actual execution, the source virtual machine hypervisor initiates a virtual machine online migration request to the source proxy middleware, which then initiates a virtual machine online migration request to the target proxy middleware. Finally, the target proxy middleware forwards the virtual machine online migration request to the target virtual machine hypervisor. Here, the virtual machine online migration request may include the configuration information of the source virtual machine.
[0102] Step 802: Create the target virtual machine using the target hypervisor and set it to a paused state.
[0103] Upon receiving a virtual machine online migration request, the target virtual machine is created using the target hypervisor based on the request, and its configuration is made identical to that of the source virtual machine. After creation, the target virtual machine's status is set to paused, effectively halting its operation.
[0104] Step 803: Synchronize data from the source hypervisor to the target hypervisor.
[0105] The source hypervisor sends relevant data about the source virtual machine to the source proxy middleware, which then forwards it to the target proxy middleware. The target proxy middleware then forwards this data to the target hypervisor, which further configures the target virtual machine based on this data. This source virtual machine data includes its source vCPU data, source memory data, and source disk data. If the source disk data is located on a shared disk, synchronization of the source disk data is not required in this step.
[0106] Step 804: Synchronize the source vCPU data, source memory data, and source disk data using the target hypervisor.
[0107] After receiving the relevant data from the source virtual machine, the target virtual machine hypervisor synchronizes the relevant data to the target virtual machine.
[0108] Step 805: The source proxy middleware synchronizes the middleware status with the target proxy middleware.
[0109] The source proxy middleware synchronizes the interaction information between the source proxy middleware and the pass-through device in the source physical machine to the target proxy middleware, and the target proxy middleware synchronizes the middleware status according to the interaction information.
[0110] Step 806: Unsuspend the target virtual machine from the source hypervisor to the target hypervisor.
[0111] The migration process involves the source hypervisor sending a migration complete message to the source agent middleware, which then forwards the message to the target agent middleware. Finally, the target agent middleware sends a migration complete message to the target hypervisor. Upon receiving the migration complete message, the target hypervisor cancels the target virtual machine's paused state and resumes its operation, completing the online migration of the source virtual machine. Simultaneously, the source hypervisor can shut down the source virtual machine, and ultimately, the target virtual machine executes the tasks from the source virtual machine.
[0112] During the online migration of virtual machines with passthrough devices, when the source virtual machine's disk data is not located on a shared disk and the amount of data on the source virtual machine's disk data is greater than or equal to the data volume threshold, the disk data can be migrated directly because the compression and decompression process for a large amount of data takes a long time. When the source virtual machine's disk data is not located on a shared disk and the amount of data on the source virtual machine's disk data is less than the data volume threshold, the source virtual machine's disk data can be compressed to obtain compressed disk data, and then the compressed disk data can be migrated to improve the efficiency of disk data migration.
[0113] This application provides a method for online migration of virtual machines. By setting up a proxy middleware in the virtual machine's host machine (physical machine), the middleware forwards relevant parameters of the passthrough device, enabling online migration of virtual machines with passthrough devices. For the virtual machine's operating system, no additional drivers need to be installed, and other software programs within the virtual machine do not require additional processing, making it non-intrusive to the virtual machine itself. The proxy middleware can respond to virtual machine requests and execute the actual requested operations through the passthrough device, without the virtual machine being aware of the changes. The middleware allows for flexible access to physical devices and direct use of the CPU to handle online migration of virtual machines, improving resource utilization and enabling online migration of virtual machines with passthrough devices.
[0114] Based on the virtual machine migration method proposed in the foregoing embodiments, this application also provides a virtual machine migration apparatus, applied to a source proxy middleware in the source physical machine. The source proxy middleware is used to realize data interaction between the source virtual machine and the pass-through device in the source physical machine; such as Figure 9 As shown, Figure 9 The virtual machine migration apparatus shown includes:
[0115] The acquisition module 901 is used to acquire the interaction information between the pass-through device in the source physical machine and the source proxy middleware.
[0116] The sending module 902 is used to send interactive information to the target agent middleware, enabling the target agent middleware to perform online migration of the source virtual machine based on the interactive information.
[0117] In practical applications, the acquisition module 901 and the sending module 902 can be implemented based on a processor and a communication device.
[0118] In some embodiments, before implementing the online migration of the source virtual machine, the sending module 902 is further configured to send the source vCPU data and source memory data of the source virtual machine to the target agent middleware when the source disk data of the source virtual machine is stored on a shared disk; wherein the source vCPU data, source memory data, and source disk data are used to configure the target virtual machine in the target physical machine; the target virtual machine is used to implement the online migration of the source virtual machine based on the interaction information.
[0119] In some embodiments, before obtaining the interaction information between the pass-through device in the source physical machine and the source proxy middleware, the sending module 902 is further configured to send a virtual machine online migration request to the target proxy middleware. The virtual machine online migration request is used to create a target virtual machine and suspend the operation of the target virtual machine. The virtual machine migration device also includes a second processing module. After the online migration of the source virtual machine is implemented, the second processing module is used to shut down the source virtual machine and enable the target virtual machine to resume operation.
[0120] In some embodiments, the second processing module is further configured to record the usage information of the source virtual machine to the pass-through device in the source physical machine when the source virtual machine is not in online migration, and forward the usage information to the pass-through device in the source physical machine.
[0121] It should be noted that the description of the above device embodiments is similar to the description of the above virtual machine migration method embodiments, and has similar beneficial effects as the same method embodiments. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0122] Based on the virtual machine migration method proposed in the foregoing embodiments, this application also provides another virtual machine migration apparatus, applied to a target agent middleware in the target physical machine. The target agent middleware is used to realize data interaction between the target virtual machine and the pass-through device in the target physical machine; such as Figure 10 As shown, Figure 10 Another virtual machine migration device shown includes:
[0123] The receiving module 1001 is used to receive the interaction information between the pass-through device in the source physical machine and the source proxy middleware.
[0124] The first processing module 1002 is used to realize the online migration of the source virtual machine based on interactive information.
[0125] In practical applications, the receiving module 1001 and the first processing module 1002 can be implemented based on a processor and a communication device.
[0126] In some embodiments, before realizing the online migration of the source virtual machine, the receiving module 1001 is further configured to receive source vCPU data and source memory data of the source virtual machine; wherein, the source vCPU data, source memory data, and source disk data are used to configure the target virtual machine in the target physical machine; the target virtual machine is used to realize the online migration of the source virtual machine according to the interaction information.
[0127] In some embodiments, before obtaining the interaction information between the pass-through device in the source physical machine and the source proxy middleware, the receiving module 1001 is further configured to receive a virtual machine online migration request, which is used to create a target virtual machine and suspend the operation of the target virtual machine; after the online migration of the source virtual machine is implemented, the first processing module 1002 is further configured to instruct the target virtual machine to resume operation.
[0128] In some embodiments, after the source virtual machine completes online migration and the target virtual machine resumes operation, the first processing module 1002 is further configured to record the usage information of the target virtual machine on the pass-through device in the target physical machine, and forward the usage information of the target virtual machine on the pass-through device in the target physical machine to the pass-through device in the target physical machine.
[0129] It should be noted that the description of the above device embodiments is similar to the description of the above virtual machine migration method embodiments, and has similar beneficial effects as the same method embodiments. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0130] It should be noted that, in the embodiments of this application, if the above-described methods are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a physical computer (which may be a terminal, server, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0131] This application also provides a physical machine. For example... Figure 4 As shown, physical machine 402 may include: proxy middleware 4021, wherein proxy middleware 4021 may be source proxy middleware or target proxy middleware, the source proxy middleware is used to implement the virtual machine migration method implemented by the source proxy middleware, and the target proxy middleware is used to implement the virtual machine migration method implemented by the target proxy middleware.
[0132] It should be noted that the description of the physical machine embodiments above is similar to the description of the virtual machine migration method embodiments above, and has similar beneficial effects as the same method embodiments. For technical details not disclosed in the physical machine embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0133] This application embodiment further provides a computer storage medium storing computer-executable instructions, which are used to implement any of the virtual machine migration methods provided in the above embodiments.
[0134] The aforementioned computer storage media can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM), etc.; or it can be various terminals that include one or any combination of the above-mentioned storage media, such as mobile phones, computers, tablet computers, personal digital assistants, etc.
[0135] Correspondingly, this application embodiment further provides a computer program product, the computer program product including computer executable instructions, which are used to implement any of the virtual machine migration methods provided in the above embodiments.
[0136] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0137] The methods disclosed in the various method embodiments provided in this application can be arbitrarily combined to obtain new method embodiments without conflict.
[0138] The features disclosed in the various product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0139] The features disclosed in the various methods or physical machine embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or physical machine embodiments.
[0140] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network physical machine, etc.) to execute the methods described in the various embodiments of this application.
[0141] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims. All of these forms are within the protection scope of this application.
Claims
1. A virtual machine migration method, characterized in that, A source proxy middleware applied in a source physical machine, the source proxy middleware being used to enable data interaction between the source virtual machine and a passthrough device in the source physical machine; the method includes: Obtain the interaction information between the pass-through device in the source physical machine and the source proxy middleware; The interaction information is sent to the target proxy middleware, enabling the target proxy middleware to perform online migration of the source virtual machine based on the interaction information.
2. The method according to claim 1, characterized in that, Before implementing the online migration of the source virtual machine, the method further includes: When the source disk data of the source virtual machine is stored on a shared disk, the source virtual CPU data and source memory data of the source virtual machine are sent to the target agent middleware; wherein, the source vCPU data, the source memory data, and the source disk data are used to configure the target virtual machine in the target physical machine; the target virtual machine is used to realize the online migration of the source virtual machine according to the interaction information.
3. The method according to claim 1 or 2, characterized in that, Before obtaining the interaction information between the pass-through device in the source physical machine and the source proxy middleware, the method further includes: Send a virtual machine online migration request to the target agent middleware. The virtual machine online migration request is used to create the target virtual machine and pause the operation of the target virtual machine. After implementing the online migration of the source virtual machine, the method further includes: Shutting down the source virtual machine allows the target virtual machine to resume operation.
4. The method according to claim 1, characterized in that, The method further includes: If the source virtual machine is not in online migration, record the usage information of the source virtual machine to the passthrough device in the source physical machine, and forward the usage information to the passthrough device in the source physical machine.
5. The method according to claim 1, characterized in that, The source proxy middleware includes the hardware access address information of the source physical machine; the target proxy middleware includes the hardware access address information of the target physical machine; the address information is used to access the hardware in the physical machine.
6. The method according to claim 1, characterized in that, The source proxy middleware and the target proxy middleware support an interruption mechanism. The interruption mechanism of the source proxy middleware is used to interrupt the connection between the source physical machine and the source virtual machine, and the interruption mechanism of the target proxy middleware is used to interrupt the connection between the target physical machine and the target virtual machine.
7. A virtual machine migration method, characterized in that, A target proxy middleware applied in a target physical machine, the target proxy middleware being used to enable data interaction between the target virtual machine and a pass-through device in the target physical machine; the method includes: Receive the interaction information between the pass-through device in the source physical machine and the source proxy middleware; Based on the aforementioned interactive information, the source virtual machine can be migrated online.
8. A physical machine, characterized in that, The physical machine includes a source proxy middleware or a target proxy middleware, wherein the source proxy middleware is used to execute the method according to any one of claims 1 to 6, and the target proxy middleware is used to execute the method according to claim 7.
9. A computer storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements any one of claims 1 to 6, or the method of claim 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 6, or claim 7.