Virtual machine migration method and system, device, medium, and program product

By transferring the memory data of the virtual queue to the destination after the virtual machine is stopped at the source end, the network performance problem caused by memory page faults during virtual machine migration is solved, and a fast and unaffected migration process is achieved.

WO2026152983A1PCT designated stage Publication Date: 2026-07-23CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD
Filing Date
2025-12-15
Publication Date
2026-07-23

AI Technical Summary

Technical Problem

In the current virtual machine migration method, memory page faults frequently occur after the destination virtual machine starts up, leading to a decline in network performance and affecting the normal operation of services. In particular, network latency increases significantly when handling sudden traffic surges.

Method used

After the source virtual machine is shut down, the memory data corresponding to the virtual queue is transferred to the destination host machine in advance, so that the destination virtual machine can directly load and process I/O operations when it starts up, avoiding or reducing memory page faults.

Benefits of technology

By pre-transmitting memory data with a high hit rate, the occurrence of page faults on critical memory in the destination virtual machine is reduced, the impact of virtual machine migration on services is reduced, and network performance is ensured to be almost unaffected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025142409_23072026_PF_FP_ABST
    Figure CN2025142409_23072026_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a virtual machine migration method and system, a device, a medium, and a program product. The method comprises: when a source virtual machine is shut down, for a virtual queue maintained by a virtual device in the source virtual machine, acquiring queue attribute information of the virtual queue; on the basis of the acquired queue attribute information, determining memory data corresponding to the virtual queue, the memory data corresponding to the virtual queue being data used for implementing a function of the virtual queue; and sending the memory data to a destination host machine, such that the destination host machine starts a destination virtual machine when writing the memory data into a memory space corresponding to the destination virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Virtual machine migration methods, systems, devices, media, and program products Technical Field

[0001] This disclosure relates to the field of virtual machine migration technology, and more particularly to a virtual machine migration method, system, device, medium, and program product. Background Technology

[0002] With the rapid development of big data, artificial intelligence, and real-time applications, the complexity of services within virtual machines is constantly increasing, and the performance requirements for virtual machines are also rising. To meet these demands, virtual machine configurations are continuously improving. This trend has not only enhanced the processing power and data throughput of virtual machines but has also brought new challenges, especially during virtual machine migration.

[0003] Current virtual machine migration methods transfer memory data to the destination virtual machine after it has started. Because a large amount of memory data needs to be transferred, frequent memory page faults occur after the destination virtual machine starts, leading to high recovery latency. Furthermore, memory page fault recovery latency can directly affect network performance, especially when dealing with sudden traffic surges, which may cause a significant increase in network latency or even network interruptions of several seconds, seriously affecting the normal operation of services within the virtual machine. Summary of the Invention

[0004] In view of the above, one or more embodiments of this disclosure provide the following technical solutions.

[0005] According to a first aspect of one or more embodiments of this disclosure, a virtual machine migration method is proposed, the method comprising: after a source virtual machine is shut down, obtaining queue attribute information of a virtual queue maintained by a virtual device in the source virtual machine; determining memory data corresponding to the virtual queue based on the obtained queue attribute information, wherein the memory data corresponding to the virtual queue is data used to implement the function of the virtual queue; and sending the memory data to a destination host machine, so that the destination host machine starts the destination virtual machine after writing the memory data into the memory space corresponding to the destination virtual machine.

[0006] According to a second aspect of one or more embodiments of this disclosure, a virtual machine migration method is proposed, the method comprising: receiving memory data corresponding to a virtual queue maintained by a virtual device in a source virtual machine, the memory data being determined based on queue attribute information of the virtual queue after the source virtual machine is shut down, and the memory data corresponding to the virtual queue being data used to implement the function of the virtual queue; writing the received memory data into the memory space corresponding to a destination virtual machine; and starting the destination virtual machine after the writing is completed.

[0007] According to a third aspect of one or more embodiments of this disclosure, a virtual machine migration system is proposed. The system includes a source host and a destination host. A source virtual machine runs on the source host, and a destination virtual machine runs on the destination host. The source host is configured to, after the source virtual machine is shut down, obtain queue attribute information of a virtual queue maintained by a virtual device in the source virtual machine, determine memory data corresponding to the virtual queue based on the obtained queue attribute information, and send the memory data to the destination host. The memory data corresponding to the virtual queue is data used to implement the function of the virtual queue. The destination host is configured to receive the memory data, write the memory data into the memory space corresponding to the destination virtual machine, and start the destination virtual machine after the writing is completed.

[0008] According to a fourth aspect of one or more embodiments of the present disclosure, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor performs the executable instructions to implement the steps of the method as described in the first or second aspect above.

[0009] According to a fifth aspect of one or more embodiments of the present disclosure, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method as described in the first or second aspect above.

[0010] According to a sixth aspect of one or more embodiments of the present disclosure, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the method as described in the first or second aspect above.

[0011] As can be seen from the above embodiments, after the source virtual machine is shut down, this disclosure transfers the memory data corresponding to the virtual queue in the source virtual machine to the destination host machine. This allows the destination virtual machine to directly load and use the memory data for I / O operations after startup. Since the memory data corresponding to the virtual queue has a high hit rate, page faults on critical memory can be avoided or reduced after the destination virtual machine starts. Furthermore, because this disclosure only transfers the memory data corresponding to the virtual queue during shutdown, combined with the aforementioned high hit rate, it can avoid or reduce page faults on critical memory in the destination virtual machine while only transferring a relatively small amount of data during shutdown. Therefore, the destination virtual machine can be started promptly after only a short shutdown period for the source virtual machine. In summary, this disclosure requires only a short shutdown period to pre-transfer critical memory to the destination virtual machine, ensuring that the destination virtual machine will not experience or will experience fewer page faults on critical memory during subsequent operation, thereby minimizing the impact of virtual machine migration on the services provided by the virtual machine. Attached Figure Description

[0012] Figure 1 is a schematic diagram of the architecture of a virtual machine migration system provided in an exemplary embodiment.

[0013] Figure 2 is a flowchart of a virtual machine migration method provided in an exemplary embodiment.

[0014] Figure 3 is a flowchart of a virtual machine migration method based on multiple virtual queues provided in an exemplary embodiment.

[0015] Figure 4 is a flowchart of a method for determining cached data pointed to by a virtual queue, provided in an exemplary embodiment.

[0016] Figure 5 is a schematic diagram of a data structure for a virtual queue provided in an exemplary embodiment.

[0017] Figure 6 is a flowchart of a processing method for each virtual queue provided in an exemplary embodiment.

[0018] Figure 7 is a flowchart of a virtual machine migration method on the destination host side provided by an exemplary embodiment.

[0019] Figure 8 is a flowchart of a system-side virtual machine migration method provided in an exemplary embodiment.

[0020] Figure 9 is a schematic diagram of the implementation environment of a virtual machine migration method provided in an exemplary embodiment.

[0021] Figure 10 is a schematic diagram of the structure of a device provided in an exemplary embodiment.

[0022] Figure 11 is a block diagram of a virtual machine migration apparatus provided in an exemplary embodiment.

[0023] Figure 12 is a block diagram of a virtual machine migration apparatus provided in an exemplary embodiment. Detailed Implementation

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

[0025] Figure 1 is a schematic diagram of the architecture of a virtual machine migration system provided in an exemplary embodiment. As shown in Figure 1, the system may include a source host 10 and a destination host 20.

[0026] In this system, the source host machine 10 runs virtual machines. A virtual machine refers to a complete computer system with full hardware system functionality, simulated by virtual machine software and running in a completely isolated environment. Virtual machine software can simulate one or more virtual computers (i.e., virtual machines) on a single physical computer (i.e., the host machine). These virtual machines function exactly like real computers; for example, they can install operating systems, install applications, and access network resources. From the user's perspective, it is simply an application running on the physical computer, but for the application running in the virtual machine, it is as if it is working on a real physical computer.

[0027] In cases where the source host 10 needs hardware upgrades, has insufficient resources, or experiences a failure, to ensure service continuity, the virtual machines running on the source host 10 are typically migrated to another host, referred to as the destination host 20. The virtual machine to be migrated from the source host 10 is referred to as the source virtual machine 11. When migrating the source virtual machine 11 from the source host 10 to the destination host 20, the source host 10 can send the configuration information of the source virtual machine 11 to the destination host 20. The destination host 20 then creates a virtual machine with the same configuration as the source virtual machine 11 based on this configuration information; this created virtual machine is the destination virtual machine 21. The source host 10 also sends the memory data and other data of the source virtual machine 11 to the destination virtual machine 21, allowing the destination virtual machine 21 to take over the operation of the source virtual machine 11 based on the received memory data.

[0028] Currently, there are two virtual machine migration modes: cold migration and hot migration. Because cold migration causes service interruption for the virtual machine, while hot migration does not, hot migration is more commonly used for virtual machine migration.

[0029] Hot migration modes are further divided into precopy hot migration and postcopy hot migration. Precopy hot migration is a hot migration mode in which memory data is transferred to the destination virtual machine first, and then the destination virtual machine is started. Specifically, while keeping the source virtual machine running continuously, iterative transfer of memory data is performed until the amount of data to be transferred can be transferred within the downtime. At this point, the source virtual machine is stopped, the data to be transferred is transferred, and finally the destination virtual machine is started.

[0030] Post-copy hot migration is a hot migration mode where the destination virtual machine is started first, and then memory data is transferred to the destination virtual machine. Specifically, after the source virtual machine is shut down, only necessary device data is transferred. Then, the destination virtual machine is started. During its operation, a page fault may occur. At this point, the user fault mechanism retrieves the corresponding memory data from the source host to recover from the page fault, until all memory data transfer is complete. This user fault mechanism is provided by the Linux kernel. The Linux kernel provides an interface for handling page faults in user space. After registering a memory segment in this interface, if a page fault occurs on that memory segment, a page fault event is generated, which then notifies the user-space process to perform page fault recovery and wake-up.

[0031] With the rapid development of big data, artificial intelligence, and real-time applications, the complexity of services within virtual machines is constantly increasing, and the performance requirements for virtual machines are also becoming more demanding. To meet these needs, virtual machine configurations are continuously improving. This leads to a situation where, during post-copy hot migration, the destination virtual machine needs to retrieve a large amount of memory data from the source virtual machine after startup. This results in frequent memory page faults after the destination virtual machine starts, causing significant recovery latency. Furthermore, memory page fault recovery latency directly impacts network performance, especially when handling sudden traffic spikes, potentially leading to a sharp increase in network latency or even network outages lasting several seconds, severely affecting the normal operation of services within the virtual machine.

[0032] If the above problems are solved by using a hotspot page solution or a prefetching solution, the effect is still not good, as detailed below.

[0033] The hot page scheme refers to recording recently accessed memory data on the source virtual machine. After the source virtual machine stops but before the destination virtual machine starts, the most frequently used memory data is transferred to the destination virtual machine to reduce the probability of page faults. However, since recently accessed memory data is usually not reused immediately, but only after the entire buffer is exhausted and reallocated, the hit rate of hot pages is low. Furthermore, back-copy hot migration is generally used in large, high-load virtual machines, which generate a relatively large amount of hot page data. If too much memory data is transferred, it will significantly increase downtime, negating the purpose of back-copy. Downtime refers to the time spent from the source virtual machine stopping to the destination virtual machine resuming operation.

[0034] The prefetching scheme refers to a method where, after the destination virtual machine starts up, while processing an I / O request (often after a page fault has been triggered), the destination virtual machine fetches several subsequent requests and performs page fault recovery in advance. However, this scheme only increases the concurrency of page fault handling and cannot avoid page faults altogether; page faults still affect the virtual machine's network performance. Furthermore, this scheme requires additional CPU resources to discover new pending I / O requests, which can lead to CPU resource contention within the virtual machine.

[0035] Therefore, this disclosure proposes a virtual machine migration scheme that pre-sends the critical memory data required for the destination virtual machine to run to the destination host machine before the destination virtual machine starts. This avoids page faults in critical memory, and the network performance of the virtual machine is almost unaffected, effectively solving the problems existing in current post-copy hot migration. A detailed description will follow with reference to the accompanying drawings.

[0036] Figure 2 is a flowchart of a virtual machine migration method provided in an exemplary embodiment. The execution subject of this method is the source host machine 10 in the system shown in Figure 1. Before introducing the process steps, the source host machine 10 and the source virtual machine 11 running on the source host machine 10 will be introduced first.

[0037] The source host 10 refers to the physical computer that hosts one or more virtual machines in the virtualization environment. When virtual machine migration is involved, the source host 10 refers to the original physical computer running the virtual machine. In one embodiment, a hypervisor runs on the source host. This hypervisor is a software layer in the virtualization environment responsible for managing and scheduling multiple guest operating systems (Guest OS) or virtual machines (VMs). The hypervisor is also known as a virtual machine monitor and can be used to complete virtual machine migration.

[0038] Regarding the source virtual machine 11 running on the source host machine 10, the source virtual machine 11 simulates a real hardware environment by configuring multiple different types of virtual devices to meet the needs of the operating system and applications. This disclosure does not limit the type of virtual device; for example, the virtual device can be a virtual network adapter, a virtual disk controller, a virtual display adapter, a virtual sound card, etc. This disclosure also does not limit the method of configuring and implementing the virtual device. For example, the virtual device can be a virtio device built based on the virtio framework; since the virtio framework is a general virtualization technology specification that supports multiple operating systems and virtualization platforms, it can reduce the limitations on the choice of operating system, virtualization platform, etc., for the host machine and the virtual machine. As another example, the virtual device can be a virtual device implemented based on pure software emulation provided by the virtualization platform, or a virtual device implemented based on third-party plugins installed on the virtualization platform. Furthermore, if the CPU used by the host machine provides hardware-assisted virtualization features, the virtual device can be a hardware-level emulation device implemented by the virtualization platform with the aforementioned hardware assistance. In summary, regardless of the technology used, virtual devices can simulate traditional physical devices, allowing the host machine and virtual machine to use virtual devices as if they were real physical devices, thereby enabling communication between the host machine and virtual machine.

[0039] Virtual devices within a virtual machine also maintain virtual queues (vq, virtqueues). These virtual queues are specifically used to handle the virtual device's own I / O requests and to enable efficient communication between the virtual device's front-end and back-end drivers. They are stored in the virtual machine's corresponding memory space and shared by the front-end and back-end drivers, allowing the virtual machine to exchange data quickly and reliably with the host machine.

[0040] Based on the aforementioned source host 10 and the source virtual machine 11 running on the source host 10, the virtual machine migration method shown in Figure 2 may include the following steps.

[0041] In step 201, after the source virtual machine is shut down, the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine is obtained.

[0042] During runtime, a virtual machine continuously processes received I / O requests. During this process, the virtual queues maintained for virtual devices in the source virtual machine also change continuously. After the source virtual machine is shut down, the virtual queues maintained for virtual devices in the source virtual machine cease to change. Therefore, the virtual machine migration method provided in this disclosure is executed after the source virtual machine is shut down.

[0043] Each virtual device can maintain one or more virtual queues, and this disclosure does not limit the number of virtual queues maintained by any virtual device.

[0044] The queue attribute information of a virtual queue is information used to describe the attributes of the virtual queue. In one embodiment, the queue attribute information may include at least one of the following: the number of virtual queues, the starting storage address of the virtual queue, the size of the virtual queue, information about the data structure of the virtual queue, and the queue type of the virtual queue. This disclosure does not limit the content of the queue attribute information.

[0045] In step 202, based on the acquired queue attribute information, the memory data corresponding to the virtual queue is determined. The memory data corresponding to the virtual queue is the data used to implement the function of the virtual queue.

[0046] The memory data corresponding to the virtual queue is the data used to implement the functionality of the virtual queue. Since the virtual queue maintained by the virtual device is specifically used to handle the virtual device's own I / O requests, the data used to implement the functionality of the virtual queue is the data required to handle the virtual device's own I / O requests.

[0047] In one embodiment, a virtual queue is dedicated to handling one type of I / O request from the virtual device itself, implementing that type of I / O operation. The function of the virtual queue is the function of that type of I / O operation. For example, a virtual queue may be dedicated to handling network receive I / O requests from the virtual device itself, implementing network receive I / O operations. In this case, the function of the virtual queue is network receive. Similarly, a virtual queue may be dedicated to handling disk read / write I / O requests from the virtual device itself, implementing disk read / write I / O operations. In this case, the function of the virtual queue is disk read / write. It should be noted that this disclosure does not limit the number of functions of the virtual queue. If a virtual queue is used to handle multiple types of I / O requests from the virtual device itself, implementing multiple types of I / O operations, the function of the virtual queue is the function corresponding to each of those multiple types of I / O operations. For example, the functions of the virtual queue are network receive and disk read / write.

[0048] In one illustrated embodiment, the memory data corresponding to the virtual queue can be the virtual queue itself; that is, the memory data corresponding to the virtual queue includes the queue data of the virtual queue. In another illustrated embodiment, at least one virtual queue maintained by any virtual device points to data related to I / O requests of the virtual device itself, enabling the at least one virtual queue to be used to process the I / O requests of the virtual device itself. In this case, the memory data corresponding to the virtual queue may also include cache data pointed to by the virtual queue, which is the data related to the I / O requests of the virtual device itself pointed to by the virtual queue. In another illustrated embodiment, the memory data corresponding to the virtual queue includes the queue data of the virtual queue and the cache data pointed to by the virtual queue.

[0049] In step 203, memory data is sent to the destination host machine so that the destination host machine starts the destination virtual machine after writing the memory data into the memory space corresponding to the destination virtual machine.

[0050] Before the destination virtual machine starts, the destination host machine has already allocated memory space for the destination virtual machine, and the destination host machine can write data to this memory space.

[0051] In this disclosure, the memory data is sent to the destination virtual machine after the source virtual machine is stopped and before the destination virtual machine is started, and written to the corresponding memory space of the destination virtual machine. In this way, after the destination virtual machine starts, it can directly process subsequent I / O requests based on the memory data. Thus, the migration of the virtual machine has almost no impact on the operation of the destination virtual machine.

[0052] In the above technical solution, after the source virtual machine is shut down, the memory data corresponding to the virtual queue in the source virtual machine is transferred to the destination host machine. This allows the destination virtual machine to directly load and use the memory data for I / O operations after startup. Since the memory data corresponding to the virtual queue has a high hit rate, page faults on critical memory can be avoided or reduced after the destination virtual machine starts. Furthermore, because this disclosure only transfers the memory data corresponding to the virtual queue during shutdown, combined with the aforementioned high hit rate, it can avoid or reduce page faults on critical memory in the destination virtual machine while only transferring a relatively small amount of data during shutdown. Therefore, the destination virtual machine can be started promptly after only a short shutdown period for the source virtual machine. In summary, this disclosure requires only a short shutdown period to pre-transfer critical memory to the destination virtual machine, ensuring that the destination virtual machine experiences few or no page faults on critical memory during subsequent operation, thereby minimizing the impact of virtual machine migration on the services provided by the virtual machine.

[0053] It should be noted that a source virtual machine can be configured with multiple virtual devices, and at least one virtual queue can be maintained for each virtual device. Therefore, a source virtual machine typically includes multiple virtual queues. Next, this disclosure will exemplify the virtual machine migration method using the embodiment shown in Figure 3 as an example of how to transfer memory data corresponding to multiple virtual queues.

[0054] Figure 3 is a flowchart of a virtual machine migration method based on multiple virtual queues, provided by an exemplary embodiment. The execution entity of this method can be the source host machine. As shown in Figure 3, the method includes the following steps.

[0055] In step 301, after the source virtual machine is shut down, the queue attribute information of the multiple virtual queues maintained by the virtual devices in the source virtual machine and the number of queues of the multiple virtual queues are obtained.

[0056] In one embodiment, this disclosure obtains memory data through a collaborative analysis method between the front-end driver and the back-end driver. Specifically, the back-end driver provides queue attribute information of the virtual queue, and the corresponding data (i.e., the memory data corresponding to the virtual queue) of the front-end driver is obtained based on this queue attribute information. In this way, accurate queue attribute information can be obtained, thereby accurately obtaining the memory data corresponding to the virtual queue maintained by the virtual device in the source virtual machine.

[0057] For example, the virtual queue is created by the front-end driver corresponding to the virtual device in the source virtual machine, and the host machine where the source virtual machine resides also runs a back-end driver corresponding to the virtual device. The queue attribute information of the virtual queue is obtained from the back-end driver. Specifically, obtaining the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine includes: after the source virtual machine is shut down, obtaining the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine from the back-end driver of the virtual device.

[0058] This disclosure is merely an example of obtaining queue attribute information of a virtual queue from a backend driver to illustrate the process of obtaining queue attribute information. Of course, queue attribute information of a virtual queue can also be obtained from other modules, and this disclosure does not limit this.

[0059] The queue attribute information obtained for each virtual queue is information used to describe the attributes of the corresponding virtual queue, and may include at least one of the following: the starting storage address of the virtual queue, the size of the virtual queue, the data structure information of the virtual queue, and the queue type of the virtual queue. This disclosure does not limit the queue attribute information of the virtual queues.

[0060] In step 302, the queue attribute information of each virtual queue is traversed based on the number of queues. For the queue attribute information of the current virtual queue, data corresponding to the size of the current virtual queue is read from the starting storage address of the current virtual queue in the memory space corresponding to the source virtual machine, so as to obtain the queue data of the current virtual queue.

[0061] In this embodiment, the queue attribute information of each virtual queue includes the starting storage address and the size of the virtual queue. Therefore, based on the obtained queue attribute information, determining the memory data corresponding to the virtual queue includes: for the memory space corresponding to the source virtual machine, reading data corresponding to the size of the virtual queue starting from the starting storage address of the virtual queue to obtain the queue data of the virtual queue. This method can be used to obtain the queue data corresponding to each virtual queue during the process of traversing the queue attribute information of each virtual queue based on the number of queues. That is, based on the number of queues, traversing the queue attribute information of each virtual queue, for the queue attribute information of the current virtual queue encountered, for the memory space corresponding to the source virtual machine, reading data corresponding to the size of the current virtual queue starting from the starting storage address of the current virtual queue to obtain the queue data of the current virtual queue.

[0062] This disclosure does not restrict the timing of sending queue data for virtual queues. For example, during the process of traversing the queue attribute information of each virtual queue based on the number of queues, the queue data of a virtual queue is sent to the destination host machine after the queue data of that virtual queue is obtained based on the queue attribute information of that virtual queue. This saves more time and has less impact on virtual machine downtime compared to obtaining the memory data of all virtual queues and then sending the memory data of all virtual queues at the same time.

[0063] In step 303, if the queue type of the current virtual queue is the target type, the current virtual queue is reconstructed based on the queue data of the current virtual queue, and the cached data pointed to by the reconstructed current virtual queue is determined based on the reconstructed current virtual queue. The target type is the queue type of the virtual queue with allocated buffers, and the cached data pointed to by the virtual queue is the data cached in the allocated buffer.

[0064] Upon receiving an I / O request from any virtual device, corresponding information can be written to the virtual queue corresponding to that virtual device. This information can indicate information about the buffer that caches the relevant data for the I / O request, such as the buffer address and size. The cached data pointed to by the virtual queue is the data cached in the buffer indicated by the corresponding information written to the virtual queue. Of course, this information can also be used to indicate other information about the I / O request, such as the operation type corresponding to the I / O request. This disclosure does not limit the content and function of the corresponding information written to the virtual queue.

[0065] Since the cached data pointed to by the virtual queue is the same as the data cached in the buffer indicated by the corresponding information written in the virtual queue, this disclosure reconstructs the current virtual queue based on its queue data. This allows the acquisition of the corresponding information written in the reconstructed virtual queue, the determination of the buffer pointed to by the reconstructed virtual queue based on this information, and the identification of the cached data in that buffer as the cached data pointed to by the reconstructed virtual queue. Because the reconstructed virtual queue has the same queue data as the current virtual queue, the cached data pointed to by the reconstructed virtual queue is the same as the cached data pointed to by the current virtual queue.

[0066] Only virtual queues of the target type undergo buffer pre-allocation, while other types of virtual queues do not. Therefore, only virtual queues of the target type have cached data pointed to, while other types of virtual queues do not. Thus, in this disclosure, the cached data pointed to by the current virtual queue is determined only if the queue type of the current virtual queue is the target type.

[0067] The target type is the queue type of a virtual queue that has been allocated a buffer. For example, the target type is a network receive queue. When the virtual queue is a network receive queue, the steps of "reconstructing the current virtual queue based on its queue data and determining the cached data pointed to by the current virtual queue based on the reconstructed current virtual queue" are performed. It should be noted that this disclosure only uses a network receive queue as an example to illustrate the target type and does not limit the target type.

[0068] This disclosure does not restrict the timing of sending cached data pointed to by virtual queues. For example, during the process of traversing the queue attribute information of each virtual queue based on the number of queues, whenever the cached data pointed to by a virtual queue is determined based on the queue data of a virtual queue, the cached data pointed to by that virtual queue is sent to the destination host. Compared to obtaining the cached data pointed to by all virtual queues and then sending all the cached data pointed to by all virtual queues at once, this can save more time and has a smaller impact on virtual machine downtime.

[0069] In step 304, if the queue type of the current virtual queue is not the target type, the current virtual queue is skipped.

[0070] Since only virtual queues of the target type have cached data to point to, while other types of virtual queues do not, if the current virtual queue's queue type is not the target type, the current virtual queue will be skipped, and the step of determining the cached data pointed to by the virtual queue will not be executed.

[0071] It should be noted that this disclosure is merely an example of traversing the queue attribute information of each virtual queue based on the number of queues to illustrate the process of determining the memory data corresponding to each virtual queue. In another embodiment, the memory data corresponding to each virtual queue may not be determined sequentially, but rather in parallel based on the queue attribute information of each virtual queue.

[0072] In step 305, memory data corresponding to each virtual queue is sent to the destination host machine so that the destination host machine writes the memory data into the memory space corresponding to the destination virtual machine and starts the destination virtual machine. The memory data corresponding to any virtual queue includes the queue data of the virtual queue. When the queue type of any virtual queue is the target type, the memory data corresponding to any virtual queue also includes the cache data pointed to by any virtual queue.

[0073] As can be seen from the descriptions of steps 302 and 303 above, whenever the memory data corresponding to a virtual queue is determined, the memory data can be sent to the destination host machine, which will not be elaborated further here.

[0074] In the above technical solution, after the source virtual machine is shut down, the memory data corresponding to the virtual queue in the source virtual machine is transferred to the destination host machine. This allows the destination virtual machine to directly load and use the memory data for I / O operations after startup. Since the memory data corresponding to the virtual queue has a high hit rate, page faults on critical memory can be avoided or reduced after the destination virtual machine starts. Furthermore, because this disclosure only transfers the memory data corresponding to the virtual queue during shutdown, combined with the aforementioned high hit rate, it can avoid or reduce page faults on critical memory in the destination virtual machine while only transferring a relatively small amount of data during shutdown. Therefore, the destination virtual machine can be started promptly after only a short shutdown period for the source virtual machine. In summary, this disclosure requires only a short shutdown period to pre-transfer critical memory to the destination virtual machine, ensuring that the destination virtual machine experiences few or no page faults on critical memory during subsequent operation, thereby minimizing the impact of virtual machine migration on the services provided by the virtual machine.

[0075] Furthermore, since only virtual queues of the target type need to transmit their queue data and the buffer data they point to, while other types of virtual queues only need to transmit their queue data, only virtual queues of the target type need to transmit approximately 12MB of buffer data, while the queue sizes of other virtual queues are all around 10KB, thus requiring only about 10KB of queue data to be transmitted. Therefore, this disclosure only requires transmitting a relatively small amount of data during the shutdown process, thus enabling the target virtual machine to start promptly after only a short shutdown of the source virtual machine, minimizing the impact on virtual machine downtime.

[0076] In addition, neither the source virtual machine nor the destination virtual machine is running during the above hot migration process. The determination and transmission of memory data can use the CPU resources reserved by the virtual machine without consuming additional CPU resources.

[0077] Figure 4 is a flowchart of a method for determining cached data pointed to by a virtual queue, provided by an exemplary embodiment. The execution entity of this method can be the source host machine. As shown in Figure 4, the method includes the following steps.

[0078] In step 401, based on the information of the queue data and data structure of the virtual queue, the available rings, used rings, and descriptor tables that conform to the data structure of the virtual queue are reconstructed.

[0079] As shown in Figure 5, the virtual queue includes a descriptor table, an available ring, and a used ring. The descriptor table stores descriptors. Upon receiving an I / O request, a descriptor is written to the descriptor table. This descriptor points to a buffer in the virtual machine's corresponding memory space, which stores the relevant data for the I / O request. The descriptor may contain information about the buffer (e.g., its address, size, etc.). The available ring is a circular buffer filled by the virtual device's front-end driver. It contains indices of the descriptors corresponding to pending I / O requests; these indices are called the available indexes. The virtual device's front-end driver adds new descriptors to the descriptor table and updates the available index to notify the virtual device's back-end driver that a new I / O request needs to be processed. The used ring is a circular buffer filled by the virtual device's back-end driver. It contains indices of the descriptors corresponding to completed I / O requests; these indices are called the used indexes. After processing an I / O request, the virtual device's back-end driver updates the used index to notify the virtual device's front-end driver that the I / O request has been completed.

[0080] In this embodiment, the queue attribute information of the virtual queue also includes information about the data structure of the virtual queue. This data structure information may include the order of the components within the virtual queue, the queue depth of each component, etc. This disclosure does not limit the information about the data structure of the virtual queue; it only requires ensuring that a virtual queue conforming to that data structure can be reconstructed based on that information.

[0081] For example, the data structure information of the virtual queue indicates that the order of the components in the virtual queue is descriptor table, available ring, and used ring; the data structure information of the virtual queue also indicates the queue depth of the descriptor table, the queue depth of the available ring, and the queue depth of the used ring. Since the descriptor table comes first, the starting address of the virtual queue is the starting address of the descriptor table. Based on the starting address of the virtual queue and the queue depth of the descriptor table, the storage location of the descriptor table can be determined; based on the storage location of the descriptor table and the queue depth of the available ring, the storage location of the available ring can be determined; based on the storage location of the available ring and the queue depth of the used ring, the storage location of the used ring can be determined. The descriptor table can be reconstructed based on the queue data stored at the storage location of the descriptor table; the available ring can be reconstructed based on the queue data stored at the storage location of the available ring; the used ring can be reconstructed based on the queue data stored at the storage location of the used ring. Therefore, based on the queue data of the virtual queue and the information of the virtual queue's data structure, the available ring, the used ring, and the descriptor table that conform to the data structure of the virtual queue can be reconstructed.

[0082] In step 402, based on each index in the reconstructed available ring and used ring, the descriptor corresponding to each index is searched in the reconstructed descriptor table. For any descriptor found, the cached data pointed to by the descriptor is determined, and the flag bit of the descriptor is obtained.

[0083] Since the available index in the available ring is used to instruct the backend driver of the virtual device to continue processing unfinished I / O requests, during virtual machine migration, it is necessary to determine the cached data pointed to by the corresponding descriptor based on the available index and transfer the cached data to the destination host so that the destination virtual machine can continue processing unfinished I / O requests. Additionally, when processing the current I / O request, the virtual machine may use the results of completed I / O requests. Therefore, this disclosure also determines the cached data pointed to by the corresponding descriptor based on the used index and transfers the cached data to the destination host so that the destination host can continue processing unfinished I / O requests based on the results of completed I / O requests.

[0084] In this disclosure, the descriptor points to a buffer in the memory space corresponding to the virtual machine, and the cached data pointed to by the descriptor in step 402 above refers to the data cached in the cache area pointed to by the descriptor.

[0085] In one embodiment, when determining the cached data pointed to by any found descriptor, it can first be determined whether the descriptor is reliable. Only if the descriptor is reliable is the step of determining the cached data pointed to by the descriptor and sending the cached data to the destination host executed, thus avoiding the transmission of unreliable memory data to the destination host, which could affect the normal operation of the destination virtual machine. Specifically, based on the indices of the reconstructed available rings and used rings, the descriptors in the reconstructed descriptor table are traversed to determine the cached data pointed to by each descriptor. This includes: searching for the descriptor corresponding to each index in the reconstructed available rings and used rings; for any found descriptor, if the descriptor meets the reliability judgment condition, determining the cached data pointed to by the descriptor; and if the descriptor does not meet the reliability judgment condition, skipping the descriptor.

[0086] The reliability judgment condition includes at least one of the following: the index of the descriptor does not exceed the queue depth of the virtual queue to which the index belongs; the buffer address pointed to by the descriptor is not 0 and does not exceed the maximum physical address of the source virtual machine; the length of the buffer pointed to by the descriptor is not 0; the descriptor's flag bits include a first flag bit and a second flag bit, or the descriptor's flag bits include a third flag bit and a second flag bit, wherein the first flag bit indicates that the descriptor belongs to a descriptor chain, the second flag bit indicates the type of operation corresponding to the descriptor (such as a write operation, a read operation, etc.), and the third flag bit indicates that the descriptor points to an indirect descriptor table.

[0087] For example, the first flag can be represented as VRING_DESC_F_NEXT(virtual ring_descriptor_flag_next); the second flag can be represented as VRING_DESC_F_WRITE; and the third flag can be represented as VRING_DESC_F_INDIRECT(virtual ring_descriptor_flag_indirect).

[0088] In the Virtio specification, the flags field in a descriptor is used to set multiple flags to indicate the descriptor's attributes and behavior. These flags help the front-end and back-end drivers of the virtual device to perform their respective operations correctly.

[0089] This disclosure does not restrict the timing of sending cached data pointed to by a descriptor. For example, after determining the cached data pointed to by any descriptor, the cached data can be sent to the destination host. That is, whenever cached data pointed to by a descriptor is determined, the determined cached data can be sent to the destination host. This can save virtual machine migration time and reduce the impact on virtual machine downtime.

[0090] In step 403, if the flag bit of any descriptor indicates that any descriptor belongs to a descriptor chain, then the cached data pointed to by the descriptor chain is determined.

[0091] If the flag bit of any descriptor indicates that any descriptor belongs to a descriptor chain, then determining the cached data pointed to by the descriptor chain can be done by continuously determining all the cached data pointed to by the descriptor chain. That is, by continuously determining the cached data pointed to by each descriptor in the descriptor chain, all the cached data pointed to by the descriptor chain can be obtained.

[0092] For example, if the descriptor's flag is VRING_DESC_F_NEXT, it means that the current descriptor's flag indicates that the current descriptor belongs to a descriptor chain.

[0093] In one embodiment, the next field of the descriptor contains the index of the next descriptor in the descriptor chain. Based on this index, the next descriptor can be determined, and thus the cached data pointed to by the next descriptor can be determined. If the next field of the descriptor is 0, it indicates that the descriptor is the last descriptor in the descriptor chain. After determining the cached data pointed to by this descriptor, all cached data corresponding to the descriptor chain is determined.

[0094] In one embodiment, during the process of determining the cached data pointed to by the descriptor chain, for each descriptor in the descriptor chain, before determining the cached data corresponding to the descriptor, it can be determined whether the descriptor is reliable. If the descriptor is reliable, the cached data corresponding to the descriptor is determined, as shown in step 402 above.

[0095] In this disclosure, descriptors in the reconstructed descriptor table are traversed based on indices in the reconstructed available ring and used ring. Therefore, after determining the cached data pointed to by the descriptor chain, the descriptor corresponding to the next index in the descriptor table can be determined based on the next index in the available ring and used ring.

[0096] This disclosure does not restrict the timing of sending cached data pointed to by a descriptor. For example, during the process of continuously determining all cached data corresponding to the descriptor chain, the cached data can be sent to the destination host machine whenever the cached data pointed to by a descriptor in the descriptor chain is determined. This can save the time of hot migration and reduce the impact on virtual machine downtime.

[0097] In step 404, if the flag bit of any descriptor indicates that the descriptor points to an indirect descriptor table, the indirect descriptor table is traversed to determine the cached data pointed to by each indirect descriptor in the indirect descriptor table.

[0098] For example, if the flag of the current descriptor is VRING_DESC_F_INDIRECT, it means that the current descriptor points to an indirect descriptor table.

[0099] In one embodiment, during the traversal of the indirect descriptor table, for each indirect descriptor in the table, before determining the cached data pointed to by the indirect descriptor, it can be determined whether the indirect descriptor is reliable. If the indirect descriptor is reliable, the cached data pointed to by the indirect descriptor can be determined, as shown in step 402 above.

[0100] In this disclosure, descriptors in the reconstructed descriptor table are traversed based on indices in the reconstructed available ring and used ring. Therefore, after traversing the indirect descriptors to determine the cached data pointed to by each indirect descriptor in the descriptor table, the descriptor corresponding to the next index in the descriptor table can be determined based on the next index in the available ring and used ring.

[0101] This disclosure does not restrict the timing of sending cached data pointed to by descriptors. For example, after determining the cached data pointed to by any indirect descriptor in the indirect descriptor table, the cached data can be sent to the destination host. That is, whenever cached data pointed to by an indirect descriptor is determined, the determined cached data can be sent to the destination host immediately. This can save virtual machine migration time and reduce the impact on virtual machine downtime.

[0102] It should be noted that the cached data pointed to by the virtual queue is the cached data pointed to by each descriptor in the virtual queue. Therefore, after determining the cached data pointed to by all the descriptors in the virtual queue, the cached data pointed to by the virtual queue is obtained.

[0103] Another point to note is that this disclosure is only an example of the embodiment shown in Figure 4 to illustrate the process of "traversing the descriptors in the reconstructed descriptor table based on the indexes in the reconstructed available ring and used ring to determine the cached data pointed to by each descriptor", but it does not limit the process.

[0104] For example, based on the description of steps 401 to 404 above, the processing method for each virtual queue is illustrated in Figure 6. The method includes the following steps.

[0105] 601. Based on the starting address and size of the virtual queue, determine the memory range to be sent, and send the queue data of the virtual queue to the destination host machine based on the memory range.

[0106] 602. Determine the queue type of the virtual queue. If the queue type is the target type, proceed to step 3; otherwise, proceed to the end.

[0107] 603. Initialize the data structure of the virtual queue using the starting address of the virtual queue and the queue depth of each component of the virtual queue.

[0108] 604. Based on the data structure of the virtual queue, read the virtual machine memory to obtain the available and used indices in the virtual queue.

[0109] 605. Starting from the used index, traverse the descriptors in the descriptor table, and for each index, jump to step 606 for processing, until all available indexes have been processed, then jump to the end.

[0110] 606. For each index, first determine the reliability of the descriptor it points to. If the descriptor is reliable, proceed to step 607; if the descriptor is unreliable, proceed to step 605 to continue processing the next index.

[0111] 607. The source hypervisor sends the memory page containing the buffer pointed to by the descriptor to the destination hypervisor, and the destination hypervisor writes the memory page into the memory space corresponding to the destination virtual machine and restores the page table entry of the corresponding page.

[0112] 608. Obtain the flags of the current descriptor. If the flags of the current descriptor are VRING_DESC_F_NEXT, proceed to step 609; if the flags of the current descriptor are VRING_DESC_F_INDIRECT, proceed to step 610; if the flags of the current descriptor are other (i.e., the flags of the current descriptor are neither VRING_DESC_F_NEXT nor VRING_DESC_F_INDIRECT), proceed to step 605 to continue processing the next index.

[0113] 609. Obtain the index of the next descriptor to be processed from the next field of the current descriptor, and jump to step 606 to perform reliability judgment.

[0114] 610. Read the indirect descriptor from the buffer pointed to by the current descriptor and jump to step 606 to perform reliability judgment.

[0115] Among the above technical solutions, a relatively complete analysis algorithm is proposed, which traverses the descriptors one by one from the used index to the available index. It can also handle scenarios such as indirect descriptors and multi-level nested indirect descriptors as specified in the virtio 0.95 standard, and can analyze key memory data more accurately.

[0116] Figure 7 is a flowchart of a virtual machine migration method on the destination host side according to an exemplary embodiment. The execution subject of this method can be the destination host. As shown in Figure 7, the method includes the following steps.

[0117] In step 701, the memory data corresponding to the virtual queue maintained by the virtual device in the source virtual machine is received. This memory data is determined based on the queue attribute information of the virtual queue after the source virtual machine is shut down, and the memory data corresponding to the virtual queue is the data used to implement the function of the virtual queue.

[0118] In one illustrated embodiment, the memory data corresponding to the virtual queue includes at least one of the following: queue data of the virtual queue and cache data pointed to by the virtual queue.

[0119] In one embodiment, when the queue type of the virtual queue is a target type, the memory data corresponding to the virtual queue includes the queue data of the virtual queue and the cache data pointed to by the virtual queue. When the queue type of the virtual queue is not a target type, the memory data corresponding to the virtual queue includes the queue data of the virtual queue, but does not include the cache data pointed to by the virtual queue.

[0120] In step 702, the received memory data is written into the memory space corresponding to the destination virtual machine.

[0121] In step 703, after the writing is complete, the destination virtual machine is started.

[0122] It should be noted that the embodiment shown in Figure 7 is an embodiment on the destination host side corresponding to the embodiment shown in Figure 2. The embodiment shown in Figure 7 can be understood by referring to the embodiment shown in Figure 2, and will not be described in detail here.

[0123] In the above technical solution, after the source virtual machine is shut down, the memory data corresponding to the virtual queue in the source virtual machine is transferred to the destination host machine. This allows the destination virtual machine to directly load and use the memory data for I / O operations after startup. Since the memory data corresponding to the virtual queue has a high hit rate, page faults on critical memory can be avoided or reduced after the destination virtual machine starts. Furthermore, because this disclosure only transfers the memory data corresponding to the virtual queue during shutdown, combined with the aforementioned high hit rate, it can avoid or reduce page faults on critical memory in the destination virtual machine while only transferring a relatively small amount of data during shutdown. Therefore, the destination virtual machine can be started promptly after only a short shutdown period for the source virtual machine. In summary, this disclosure requires only a short shutdown period to pre-transfer critical memory to the destination virtual machine, ensuring that the destination virtual machine experiences few or no page faults on critical memory during subsequent operation, thereby minimizing the impact of virtual machine migration on the services provided by the virtual machine.

[0124] Figure 8 is a flowchart of a system-side virtual machine migration method provided in an exemplary embodiment. The execution entity of this method can be the virtual machine migration system shown in Figure 1, which includes a source host and a destination host. The source host runs a source virtual machine, and the destination host runs a destination virtual machine. As shown in Figure 8, the method includes the following steps.

[0125] In step 801, after the source virtual machine is shut down, the source host obtains the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine, determines the memory data corresponding to the virtual queue based on the obtained queue attribute information, and sends the memory data to the destination host. The memory data corresponding to the virtual queue is the data used to implement the function of the virtual queue.

[0126] In step 802, the destination host receives the memory data, writes the memory data into the memory space corresponding to the destination virtual machine, and starts the destination virtual machine after the writing is completed.

[0127] Steps 801 and 802 described above can be referred to the embodiments shown in Figure 2 and Figure 7, and will not be repeated here. Only the following embodiments will be used for supplementary explanation.

[0128] In one embodiment, both the source and destination host machines run hypervisors. A hypervisor is a software layer responsible for managing and scheduling multiple guest operating systems (OS) or virtual machines (VMs) in a virtualization environment; it is also known as a virtual machine monitor and can be used to perform virtual machine migration.

[0129] In this embodiment, as shown in Figure 9, the backend driver of the source virtual machine in the source host adds a vq query interface to provide queue attribute information of the virtual queue to the hypervisor of the source host. The hypervisor of the source host also adds a vq query interface to obtain queue attribute information from the backend driver of the virtual machine; the hypervisor of the source host also adds a vq analysis algorithm to determine the memory data corresponding to the virtual queue based on the queue attribute information. The hypervisor of the source host also adds memory data transmission logic during the post-copy phase to transmit the memory data corresponding to the virtual queue before the destination virtual machine starts. The hypervisor of the destination host adds memory data receiving logic during the post-copy phase to receive and write the memory data corresponding to the virtual queue before the destination virtual machine starts.

[0130] In the above technical solution, after the source virtual machine is shut down, the memory data corresponding to the virtual queue in the source virtual machine is transferred to the destination host machine. This allows the destination virtual machine to directly load and use the memory data for I / O operations after startup. Since the memory data corresponding to the virtual queue has a high hit rate, page faults on critical memory can be avoided or reduced after the destination virtual machine starts. Furthermore, because this disclosure only transfers the memory data corresponding to the virtual queue during shutdown, combined with the aforementioned high hit rate, it can avoid or reduce page faults on critical memory in the destination virtual machine while only transferring a relatively small amount of data during shutdown. Therefore, the destination virtual machine can be started promptly after only a short shutdown period for the source virtual machine. In summary, this disclosure requires only a short shutdown period to pre-transfer critical memory to the destination virtual machine, ensuring that the destination virtual machine experiences few or no page faults on critical memory during subsequent operation, thereby minimizing the impact of virtual machine migration on the services provided by the virtual machine.

[0131] An exemplary embodiment of this disclosure also provides a virtual machine migration system, which includes a source host and a destination host. The source host runs a source virtual machine, and the destination host runs a destination virtual machine. The source host is configured to, after the source virtual machine is stopped, obtain queue attribute information of a virtual queue maintained by a virtual device in the source virtual machine, determine the memory data corresponding to the virtual queue based on the obtained queue attribute information, and send the memory data to the destination host. The memory data corresponding to the virtual queue is data used to implement the function of the virtual queue. The destination host is configured to receive the memory data, write the memory data into the memory space corresponding to the destination virtual machine, and start the destination virtual machine after the writing is completed.

[0132] In one illustrated embodiment, the memory data includes queue data of a virtual queue, and the acquired queue attribute information includes the starting storage address of the virtual queue and the size of the virtual queue; the source host machine is used to read data corresponding to the size of the virtual queue from the starting storage address in the memory space corresponding to the source virtual machine, so as to obtain the queue data of the virtual queue.

[0133] In one illustrated implementation, the memory data also includes cached data pointed to by the virtual queue; the source host is used to reconstruct the virtual queue based on the queue data of the virtual queue; and based on the reconstructed virtual queue, to determine the cached data pointed to by the reconstructed virtual queue.

[0134] In one illustrated embodiment, the acquired queue attribute information also includes information about the virtual queue's data structure; the source host is used to reconstruct the available ring, used ring, and descriptor table that conform to the virtual queue's data structure based on the queue data and the information about the virtual queue's data structure; the source host is used to traverse the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available ring and used ring to determine the cached data pointed to by each descriptor.

[0135] In one illustrated implementation, the source host machine is configured to search for descriptors corresponding to each index in the reconstructed available ring and used ring, based on the respective indices in the reconstructed available ring and used ring. For any descriptor found, the cached data pointed to by the descriptor is determined, and a flag bit of the descriptor is obtained. If the flag bit of any descriptor indicates that the descriptor belongs to a descriptor chain, the cached data pointed to by the descriptor chain is determined. If the flag bit of any descriptor indicates that the descriptor points to an indirect descriptor table, the indirect descriptor table is traversed to determine the cached data pointed to by each indirect descriptor in the indirect descriptor table.

[0136] In one illustrated embodiment, the source host machine is configured to search for descriptors corresponding to each index in the reconstructed available ring and used ring, respectively, from the reconstructed descriptor table; for any descriptor found, if the descriptor satisfies a reliability judgment condition, determine the cached data pointed to by the descriptor; and if the descriptor does not satisfy the reliability judgment condition, skip the descriptor; wherein the reliability judgment condition includes at least one of the following: the index of the descriptor does not exceed the queue depth of the virtual queue to which the index belongs; the buffer address pointed to by the descriptor is not 0 and does not exceed the maximum physical address of the source virtual machine; the length of the buffer pointed to by the descriptor is not 0; the descriptor's flags include a first flag and a second flag, or the descriptor's flags include a third flag and a second flag, wherein the first flag indicates that the descriptor belongs to a descriptor chain, the second flag indicates the type of operation corresponding to the descriptor, and the third flag indicates that the descriptor points to an indirect descriptor table.

[0137] In one illustrated embodiment, the acquired queue attribute information also includes the queue type of the virtual queue; the source host is used to reconstruct the virtual queue based on the queue data of the virtual queue when the queue type of the virtual queue is the target type, and to determine the cached data pointed to by the reconstructed virtual queue based on the reconstructed virtual queue, wherein the target type is the queue type of the virtual queue with allocated buffers, and the cached data pointed to by the virtual queue is the data cached in the allocated buffers.

[0138] In one illustrated implementation, the virtual queue is created by the front-end driver corresponding to the virtual device in the source virtual machine, and the host machine where the source virtual machine is located also runs the back-end driver corresponding to the virtual device; the source host machine is used to obtain the queue attribute information of the virtual queue from the back-end driver of the virtual device for the virtual queue maintained by the virtual device in the source virtual machine after the source virtual machine is stopped.

[0139] Figure 10 is a schematic structural diagram of a device provided in an exemplary embodiment. Referring to Figure 10, at the hardware level, the device includes a processor 1002, an internal bus 1004, a network interface 1006, a memory 1008, and a non-volatile memory 1010, and may also include other hardware required for its functions. One or more embodiments of this disclosure can be implemented in software, for example, the processor 1002 reads the corresponding computer program from the non-volatile memory 1010 into the memory 1008 and then runs it. Of course, in addition to software implementation, one or more embodiments of this disclosure do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0140] Please refer to Figure 11. The virtual machine migration device can be applied to the device shown in Figure 10 to implement the technical solution of this disclosure. The virtual machine migration device may include: an acquisition unit 1101, used to acquire queue attribute information of a virtual queue maintained by a virtual device in the source virtual machine after the source virtual machine is shut down; a determination unit 1102, used to determine the memory data corresponding to the virtual queue based on the acquired queue attribute information, wherein the memory data corresponding to the virtual queue is data used to implement the function of the virtual queue; and a sending unit 1103, used to send the memory data to the destination host machine, so that the destination host machine starts the destination virtual machine after writing the memory data into the memory space corresponding to the destination virtual machine.

[0141] In one illustrated embodiment, the memory data includes the queue data of the virtual queue, and the acquired queue attribute information includes the starting storage address of the virtual queue and the size of the virtual queue; the determining unit 1102 is used to read data corresponding to the size of the virtual queue starting from the starting storage address for the memory space corresponding to the source virtual machine, so as to obtain the queue data of the virtual queue.

[0142] In one illustrated embodiment, the memory data also includes cached data pointed to by the virtual queue. The determining unit 1102 is further configured to reconstruct the virtual queue based on the queue data of the virtual queue; and to determine the cached data pointed to by the reconstructed virtual queue based on the reconstructed virtual queue.

[0143] In one illustrated embodiment, the acquired queue attribute information also includes information about the data structure of the virtual queue; the determining unit 1102 is used to reconstruct the available ring, used ring, and descriptor table that conform to the data structure of the virtual queue based on the queue data and the information about the data structure of the virtual queue, and to traverse the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available ring and used ring to determine the cached data pointed to by each descriptor.

[0144] In one illustrated embodiment, the determining unit 1102 is specifically configured to: search for descriptors corresponding to each index in the reconstructed available ring and used ring, based on each index in the reconstructed descriptor table; for any descriptor found, determine the cached data pointed to by the descriptor and obtain the flag bit of the descriptor; if the flag bit of the descriptor indicates that the descriptor belongs to a descriptor chain, then determine the cached data pointed to by the descriptor chain; if the flag bit of the descriptor indicates that the descriptor points to an indirect descriptor table, then traverse the indirect descriptor table to determine the cached data pointed to by each indirect descriptor in the indirect descriptor table.

[0145] In one illustrated embodiment, the determining unit 1102 is specifically configured to: search for descriptors corresponding to each index in the reconstructed available ring and used ring, based on each index in the reconstructed descriptor table; for any descriptor found, if any descriptor satisfies the reliability judgment condition, determine the cached data pointed to by the descriptor; and, if any descriptor does not satisfy the reliability judgment condition, skip the descriptor; wherein the reliability judgment condition includes at least one of the following: the index of the descriptor does not exceed the queue depth of the virtual queue to which the index belongs; the buffer address pointed to by the descriptor is not 0 and does not exceed the maximum physical address of the source virtual machine; the length of the buffer pointed to by the descriptor is not 0; the flag bits of the descriptor include a first flag bit and a second flag bit, or the flag bits of the descriptor include a third flag bit and a second flag bit, wherein the first flag bit indicates that the descriptor belongs to a descriptor chain, the second flag bit indicates the type of operation corresponding to the descriptor, and the third flag bit indicates that the descriptor points to an indirect descriptor table.

[0146] In one illustrated embodiment, the acquired queue attribute information further includes the queue type of the virtual queue; the determining unit 1102 is configured to, when the queue type of the virtual queue is a target type, reconstruct the virtual queue based on the queue data of the virtual queue, and determine the cached data pointed to by the reconstructed virtual queue based on the reconstructed virtual queue, wherein the target type is the queue type of the virtual queue with an allocated buffer, and the cached data pointed to by the virtual queue is the data cached in the allocated buffer.

[0147] In one illustrated embodiment, the virtual queue is created by the front-end driver corresponding to the virtual device in the source virtual machine, and the host machine where the source virtual machine is located also runs the back-end driver corresponding to the virtual device; the acquisition unit 1101 is used to obtain the queue attribute information of the virtual queue from the back-end driver of the virtual device for the virtual queue maintained by the virtual device in the source virtual machine after the source virtual machine is stopped.

[0148] Please refer to Figure 12. The virtual machine migration device can be applied to the device shown in Figure 10 to implement the technical solution of this disclosure. The virtual machine migration device may include: a receiving unit 1201, used to receive memory data corresponding to a virtual queue maintained by a virtual device in the source virtual machine. The memory data is determined based on the queue attribute information of the virtual queue after the source virtual machine is shut down, and the memory data corresponding to the virtual queue is data used to implement the function of the virtual queue; a writing unit 1202, used to write the received memory data into the memory space corresponding to the destination virtual machine; and a starting unit 1203, used to start the destination virtual machine after the writing is completed.

[0149] In one illustrated embodiment, the memory data corresponding to the virtual queue includes at least one of the following: queue data of the virtual queue; cache data pointed to by the virtual queue.

[0150] Based on the same concept as the methods described above, this disclosure also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor executes the executable instructions to implement the steps of the method as described in any of the above embodiments.

[0151] Based on the same concept as the methods described above, this disclosure also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.

[0152] Based on the same concept as the methods described above, this disclosure also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.

Claims

1. A virtual machine migration method, comprising: After the source virtual machine is shut down, the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine is obtained. Based on the acquired queue attribute information, the memory data corresponding to the virtual queue is determined. The memory data corresponding to the virtual queue is the data used to implement the function of the virtual queue. The memory data is sent to the destination host machine so that the destination host machine starts the destination virtual machine after writing the memory data into the memory space corresponding to the destination virtual machine.

2. The method according to claim 1, wherein, The memory data includes the queue data of the virtual queue; the acquired queue attribute information includes the starting storage address of the virtual queue and the size of the virtual queue; The step of determining the memory data corresponding to the virtual queue based on the acquired queue attribute information includes: For the memory space corresponding to the source virtual machine, data corresponding to the size of the virtual queue is read starting from the starting storage address to obtain the queue data of the virtual queue.

3. The method according to claim 2, wherein, The memory data also includes cached data pointed to by the virtual queue; determining the memory data corresponding to the virtual queue based on the acquired queue attribute information further includes: Based on the queue data of the virtual queue, reconstruct the virtual queue; Based on the reconstructed virtual queue, the cached data pointed to by the reconstructed virtual queue is determined.

4. The method according to claim 3, wherein, The acquired queue attribute information also includes information about the data structure of the virtual queue; The process of reconstructing the virtual queue based on the queue data of the virtual queue includes: reconstructing the available rings, used rings, and descriptor tables that conform to the data structure of the virtual queue based on the queue data of the virtual queue and the information of the data structure of the virtual queue. The process of determining the cached data pointed to by the reconstructed virtual queue includes: traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available ring and used ring to determine the cached data pointed to by each descriptor.

5. The method according to claim 4, wherein, The method involves traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available and used rings to determine the cached data pointed to by each descriptor, including: Based on each index in the reconstructed available ring and used ring, the descriptor corresponding to each index is searched from the reconstructed descriptor table; For any descriptor found, determine the cached data pointed to by the descriptor and obtain the flag bit of the descriptor. If the flag of any descriptor indicates that any descriptor belongs to a descriptor chain, then the cached data pointed to by that descriptor chain is determined. If the flag of any descriptor indicates that the descriptor points to an indirect descriptor table, then the indirect descriptor table is traversed to determine the cached data pointed to by each indirect descriptor in the indirect descriptor table.

6. The method according to claim 4, wherein, The method involves traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available and used rings to determine the cached data pointed to by each descriptor, including: Based on each index in the reconstructed available ring and used ring, the descriptor corresponding to each index is searched from the reconstructed descriptor table; For any descriptor found, if the descriptor satisfies the reliability judgment condition, determine the cached data pointed to by the descriptor; and if the descriptor does not satisfy the reliability judgment condition, skip the descriptor. The reliability judgment condition includes at least one of the following: The index of the descriptor does not exceed the queue depth of the virtual queue to which the index belongs; The address of the buffer pointed to by the descriptor is not 0 and does not exceed the maximum physical address of the source virtual machine; The length of the buffer pointed to by the descriptor is not 0; The descriptor's flags include a first flag and a second flag, or the descriptor's flags include a third flag and a second flag, wherein the first flag indicates that the descriptor belongs to a descriptor chain, the second flag indicates the type of operation corresponding to the descriptor, and the third flag indicates that the descriptor points to an indirect descriptor table.

7. The method according to claim 3, wherein, The acquired queue attribute information also includes the queue type of the virtual queue; The step of determining the memory data corresponding to the virtual queue based on the acquired queue attribute information includes: When the queue type of the virtual queue is the target type, the virtual queue is reconstructed based on the queue data of the virtual queue, and the cached data pointed to by the reconstructed virtual queue is determined based on the reconstructed virtual queue. The target type is the queue type of the virtual queue with allocated buffers, and the cached data pointed to by the virtual queue is the data cached in the allocated buffer.

8. The method according to claim 1, wherein, The virtual queue is created by the front-end driver corresponding to the virtual device in the source virtual machine, and the host machine where the source virtual machine is located also runs the back-end driver corresponding to the virtual device; The step of obtaining queue attribute information for the virtual queue maintained by the virtual device in the source virtual machine includes: After the source virtual machine is shut down, the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine is obtained from the backend driver of the virtual device.

9. A virtual machine migration method, comprising: Receive memory data corresponding to the virtual queue maintained by the virtual device in the source virtual machine. The memory data is determined based on the queue attribute information of the virtual queue after the source virtual machine is shut down, and the memory data corresponding to the virtual queue is data used to implement the function of the virtual queue. Write the received memory data into the memory space corresponding to the destination virtual machine; After the writing is complete, start the destination virtual machine.

10. The method according to claim 9, wherein, The memory data corresponding to the virtual queue includes at least one of the following: The queue data of the virtual queue; The virtual queue points to the cached data.

11. A virtual machine migration system, wherein, The system includes a source host and a destination host, wherein a source virtual machine runs on the source host and a destination virtual machine runs on the destination host. The source host machine is configured to, after the source virtual machine is shut down, obtain queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine, determine the memory data corresponding to the virtual queue based on the obtained queue attribute information, and send the memory data to the destination host machine. The memory data corresponding to the virtual queue is data used to implement the function of the virtual queue. The destination host machine is used to receive the memory data, write the memory data into the memory space corresponding to the destination virtual machine, and start the destination virtual machine after the writing is completed.

12. An electronic device, comprising: processor; Memory for storing processor-executable instructions; wherein the processor implements by executing the executable instructions: After the source virtual machine is shut down, the queue attribute information of the virtual queue maintained by the virtual device in the source virtual machine is obtained. Based on the acquired queue attribute information, the memory data corresponding to the virtual queue is determined. The memory data corresponding to the virtual queue is the data used to implement the function of the virtual queue. The memory data is sent to the destination host machine so that the destination host machine starts the destination virtual machine after writing the memory data into the memory space corresponding to the destination virtual machine.

13. The electronic device according to claim 12, wherein, The memory data includes the queue data of the virtual queue; the acquired queue attribute information includes the starting storage address of the virtual queue and the size of the virtual queue; The step of determining the memory data corresponding to the virtual queue based on the acquired queue attribute information includes: For the memory space corresponding to the source virtual machine, data corresponding to the size of the virtual queue is read starting from the starting storage address to obtain the queue data of the virtual queue.

14. The electronic device according to claim 13, wherein, The memory data also includes cached data pointed to by the virtual queue; determining the memory data corresponding to the virtual queue based on the acquired queue attribute information further includes: Based on the queue data of the virtual queue, reconstruct the virtual queue; Based on the reconstructed virtual queue, the cached data pointed to by the reconstructed virtual queue is determined.

15. The electronic device according to claim 14, wherein, The acquired queue attribute information also includes information about the data structure of the virtual queue; The process of reconstructing the virtual queue based on the queue data of the virtual queue includes: reconstructing the available rings, used rings, and descriptor tables that conform to the data structure of the virtual queue based on the queue data of the virtual queue and the information of the data structure of the virtual queue. The process of determining the cached data pointed to by the reconstructed virtual queue includes: traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available ring and used ring to determine the cached data pointed to by each descriptor.

16. The electronic device according to claim 15, wherein, The method involves traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available and used rings to determine the cached data pointed to by each descriptor, including: Based on each index in the reconstructed available ring and used ring, the descriptor corresponding to each index is searched from the reconstructed descriptor table; For any descriptor found, determine the cached data pointed to by the descriptor and obtain the flag bit of the descriptor. If the flag of any descriptor indicates that any descriptor belongs to a descriptor chain, then the cached data pointed to by that descriptor chain is determined. If the flag of any descriptor indicates that the descriptor points to an indirect descriptor table, then the indirect descriptor table is traversed to determine the cached data pointed to by each indirect descriptor in the indirect descriptor table.

17. The electronic device according to claim 15, wherein, The method involves traversing the descriptors in the reconstructed descriptor table based on the indices in the reconstructed available and used rings to determine the cached data pointed to by each descriptor, including: Based on each index in the reconstructed available ring and used ring, the descriptor corresponding to each index is searched from the reconstructed descriptor table; For any descriptor found, if the descriptor satisfies the reliability judgment condition, determine the cached data pointed to by the descriptor; and if the descriptor does not satisfy the reliability judgment condition, skip the descriptor. The reliability judgment condition includes at least one of the following: The index of the descriptor does not exceed the queue depth of the virtual queue to which the index belongs; The address of the buffer pointed to by the descriptor is not 0 and does not exceed the maximum physical address of the source virtual machine; The length of the buffer pointed to by the descriptor is not 0; The descriptor's flags include a first flag and a second flag, or the descriptor's flags include a third flag and a second flag, wherein the first flag indicates that the descriptor belongs to a descriptor chain, the second flag indicates the type of operation corresponding to the descriptor, and the third flag indicates that the descriptor points to an indirect descriptor table.

18. The electronic device according to claim 14, wherein, The acquired queue attribute information also includes the queue type of the virtual queue; The step of determining the memory data corresponding to the virtual queue based on the acquired queue attribute information includes: When the queue type of the virtual queue is the target type, the virtual queue is reconstructed based on the queue data of the virtual queue, and the cached data pointed to by the reconstructed virtual queue is determined based on the reconstructed virtual queue. The target type is the queue type of the virtual queue with allocated buffers, and the cached data pointed to by the virtual queue is the data cached in the allocated buffer.

19. A computer-readable storage medium having stored thereon computer instructions, wherein, When the instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-10.

20. A computer program product comprising a computer program / instructions, wherein, When the computer program / instructions are executed by the processor, they implement the steps of the method as described in any one of claims 1-10.