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

By employing multi-threaded parallel processing and a shared memory communication model, the problem of low virtual machine migration efficiency is solved, achieving efficient and low-latency virtual machine migration, suitable for various virtual machine platforms and application scenarios.

CN120849022APending Publication Date: 2025-10-28JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511231889.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-29
Publication Date
2025-10-28

AI Technical Summary

Technical Problem

Existing technologies suffer from low virtual machine migration efficiency and high latency, making it difficult to meet migration requirements in high-performance and low-latency scenarios.

Method used

It adopts a multi-threaded parallel processing architecture and a shared memory communication (SMC) model. By dividing virtual machine memory data and storage data into multiple data blocks and migrating them to the target host in parallel, it leverages the parallel processing capabilities of multi-core processors and combines the transmission control protocol (TCP/IP) to ensure compatibility.

Benefits of technology

It significantly improves the efficiency and speed of virtual machine migration, providing a high-throughput and low-latency migration method, ensuring data integrity and system parallel processing capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120849022A_ABST
    Figure CN120849022A_ABST
Patent Text Reader

Abstract

The invention discloses a virtual machine migration method and device, equipment, a medium and a program product, and relates to the technical field of virtual machines.The virtual machine migration method comprises the steps that a migration instruction is received, and if a target port is located in a preset first port range, a plurality of migration threads and a data migration channel based on a shared memory are created, the migration threads and the data migration channels are bound one by one, memory data and storage data of the virtual machine are divided into a plurality of data blocks, the data blocks are distributed to the migration threads, and the migration threads are operated in parallel, so that the data blocks are migrated to the target host through the data migration channels. In a high-performance and low-latency application scene, high-throughput and low-latency data transmission is provided through a migration mechanism based on a shared memory and a multi-thread model, so that the migration speed of the virtual machine and the parallel processing capability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of virtual machine technology, and in particular to virtual machine migration methods, apparatus, devices, media, and program products. Background Technology

[0002] Virtual machine technology is an important component of modern computer systems, and virtual machine migration is a key challenge in this field. Shared Memory Communications (SMC) is a high-performance inter-thread communication mechanism widely used in applications requiring high performance and low latency.

[0003] Currently, in some technologies, virtual machine migration relies on traditional network transmission models to transfer the virtual machine's memory state and storage data. This approach often suffers from high latency and low efficiency when facing large-scale virtual machine migrations. Therefore, there is an urgent need for a solution that can improve the efficiency and performance of virtual machine migration to address the problems of low efficiency and high latency in related technologies. Summary of the Invention

[0004] This application provides a virtual machine migration method, a virtual machine migration apparatus, an electronic device, a computer-readable storage medium, and a computer program product to at least solve the problems of low efficiency and high latency in virtual machine migration in related technologies.

[0005] This application provides a virtual machine migration method, including:

[0006] Receive migration instructions, which specify the target virtual machine to be migrated, the target host to which the target virtual machine should be migrated, and the target port on the target host for receiving virtual machine data.

[0007] If the target port is within the preset first port range, multiple migration threads and shared memory-based data migration channels are created, and the migration threads and data migration channels are bound one-to-one.

[0008] The target virtual machine's memory and storage data are divided into multiple data blocks, and these data blocks are allocated to multiple migration threads. Different migration threads are allocated different data blocks.

[0009] Multiple migration threads run in parallel, so that each migration thread migrates the allocated data blocks to the target host through the bound data migration channel.

[0010] This application also provides a virtual machine migration apparatus, including:

[0011] The instruction receiving module is used to receive migration instructions. The migration instructions specify the target virtual machine to be migrated, the target host to which the target virtual machine should be migrated, and the target port on the target host for receiving virtual machine data.

[0012] The migration channel creation module is used to create multiple migration threads and shared memory-based data migration channels if the target port is within a preset first port range, and to bind the migration threads and data migration channels one by one.

[0013] The data partitioning module is used to divide the memory data and storage data of the target virtual machine into multiple data blocks and allocate the data blocks to multiple migration threads. Different migration threads are assigned different data blocks.

[0014] The data migration module is used to run multiple migration threads in parallel, so that each migration thread can migrate the allocated data blocks to the target host through the bound data migration channel.

[0015] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described virtual machine migration methods when executing the computer program.

[0016] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described virtual machine migration methods.

[0017] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described virtual machine migration methods.

[0018] In some embodiments of this application, a target port range for receiving migration data is preset. Multiple migration threads and data migration channels are created using a multi-threaded model and shared memory communication. The virtual machine memory and storage data to be migrated are divided into multiple data blocks, and then the data is migrated in parallel through the aforementioned migration threads and data migration channels. This provides a high-throughput and low-latency virtual machine migration method, thereby improving the migration speed of virtual machines and the system's parallel processing capabilities. Attached Figure Description

[0019] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1A flowchart illustrating the virtual machine migration method provided in this application embodiment;

[0021] Figure 2 A flowchart illustrating another virtual machine migration method provided in an embodiment of this application;

[0022] Figure 3 A flowchart illustrating yet another virtual machine migration method provided in an embodiment of this application;

[0023] Figure 4 Schematic diagram of a virtual machine migration apparatus provided for some embodiments of this application;

[0024] Figure 5 A schematic diagram of the modules of an electronic device provided for some embodiments of this application. Detailed Implementation

[0025] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0026] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0027] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0028] Currently, virtual machine technology, as a core technology of cloud computing and data centers, improves the utilization of hardware resources by creating multiple isolated virtual environments on a single physical host. Virtual machine migration is a key function of virtual machine technology. Among related technologies, virtual machine migration uses the TCP / IP (Transmission Control Protocol / Internet Protocol) network model for data transmission, enabling the migration of virtual machines from one physical server to another without interrupting applications running on the virtual machine. However, these technologies have the following problems:

[0029] 1) High protocol overhead and CPU consumption. The TCP protocol stack resides in the operating system kernel. Data transmission involves frequent user-mode and kernel-mode switching and multiple memory copies, consuming significant CPU resources. Furthermore, its fixed congestion control and acknowledgment mechanisms introduce high latency. These factors result in underutilization of network bandwidth, excessively long migration times, and an inability to meet the virtual machine migration requirements of high-performance and low-latency scenarios.

[0030] 2) High transmission latency. As a connection-oriented reliable transport protocol, TCP relies on an acknowledgment mechanism for data transmission. The sender must wait for the receiver's acknowledgment before sending subsequent data, and the protocol itself incurs a certain delay in processing data, resulting in high transmission latency.

[0031] In view of this, this application provides a virtual machine migration method that can solve the above problems. The virtual machine migration method can be applied to the physical host performing the virtual machine migration task, or to electronic devices related to the virtualization environment. Electronic devices may include, but are not limited to, servers and compute nodes that manage the virtualization environment.

[0032] See also Figure 1 This is a flowchart illustrating a virtual machine migration method provided in some embodiments of this application. Figure 1 In this context, the virtual machine migration method includes the following steps:

[0033] Step S101: Receive migration instructions. The migration instructions are used to specify the target virtual machine to be migrated, the target host to which the target virtual machine should be migrated, and the target port on the target host for receiving virtual machine data.

[0034] Specifically, the migration instructions are sent through the virtual machine management platform. These instructions include, but are not limited to, the target virtual machine to be migrated, the target host, and the port number on the target host used to establish the data migration connection.

[0035] Step S102: If the target port is within the preset first port range, then create multiple migration threads and data migration channels based on shared memory, and bind the migration threads and data migration channels one by one.

[0036] Specifically, a port range is preset to distinguish different migration modes. For example, the port range 49152-49215 can be used as a dedicated port segment for virtual machine migration. When the migration command explicitly specifies that the target port is within the first port range (e.g., 49210-49215), the SMC transport model is used for virtual machine migration, and multiple independent migration threads are created using a multi-threaded model. Simultaneously, a corresponding shared memory-based data migration channel is allocated to each migration thread to ensure that each thread corresponds to a data migration channel.

[0037] Step S103: Divide the memory data and storage data of the target virtual machine into multiple data blocks and allocate the data blocks to multiple migration threads. Different migration threads are allocated different data blocks.

[0038] Specifically, after the migration thread is initialized, the electronic device executing the method of this application divides the memory data and storage data of the target virtual machine into multiple data blocks, and distributes the data blocks evenly to each migration thread according to the number of migration threads.

[0039] In this embodiment, when allocating data blocks, the system will prioritize load balancing of each migration thread to avoid a particular migration thread becoming a bottleneck due to excessive load or wasting resources due to insufficient load.

[0040] Step S104: Run multiple migration threads in parallel so that each migration thread migrates the allocated data blocks to the target host through the bound data migration channel.

[0041] Specifically, once the migration threads and data migration channels are ready, the migration threads operate in parallel. Each migration thread independently transfers its allocated data blocks using its bound shared-memory-based data migration channel.

[0042] The virtual machine migration method provided in this embodiment presets migration instructions, determines the target virtual machine to be migrated, the target host, and the receiving data port number, and binds the migration thread and the migration channel by utilizing a multi-threaded model and a shared memory-based data migration channel. Finally, the virtual machine's memory data and storage data are split and transmitted to the target host through the migration channel. The multi-threaded parallel processing architecture used in this application fully utilizes the parallel processing capabilities of multi-core processors, thereby significantly improving data processing and migration efficiency and providing a high-throughput and low-latency data migration method.

[0043] In some embodiments, the virtual machine migration method further includes: if the target port is located within a preset second port range, then migrating the data of the target virtual machine to the target host based on the transmission control protocol.

[0044] Specifically, this embodiment provides a traditional migration mode compatible with the high-performance migration mode based on SMC. When the target port specified in the migration command is detected to be within the second port range (e.g., 49152-49209), the system automatically switches to the traditional migration mode, using a data transmission method based on the TCP / IP protocol.

[0045] In the above embodiments, when the hardware conditions do not meet the requirements for virtual machines to use the SMC-based migration model for data migration, a network transmission protocol based on TCP / IP is used. This network transmission protocol transmits data through network sockets to the migration thread. Although the transmission efficiency is lower than that of the SMC mode, it can ensure system compatibility and reliability.

[0046] In some embodiments, after creating multiple migration threads and a shared memory-based data migration channel, step S102 of the above embodiments further includes, but is not limited to, the following steps S1021 to S1022:

[0047] Step S1021: Obtain the number of central processing unit cores in the target host.

[0048] Specifically, after adopting a shared memory-based data migration model and creating migration threads and channels, the hypervisor on the source host where the target virtual machine resides can initiate a query request to the target host through a preset communication mechanism (such as using an established management connection or a dedicated probe protocol). This request is used to obtain information about the available resources of the target host, especially the number of cores in its central processor. Other data includes, but is not limited to, the target host's free memory capacity, storage space, and current load.

[0049] Step S1022: Based on the number of cores, create multiple migration threads and migration channels.

[0050] Specifically, after receiving the number of CPU cores returned from the target host, the optimal number of migration threads and data migration channels to create is determined based on this number. For example, the number of migration threads and channels to create can be set as a certain percentage (e.g., 50% or 75%) of the number of CPU cores on the target host. Alternatively, an upper limit can be set for the maximum number of threads or channels (e.g., 8 or 16), ensuring that the number will not be exceeded even if the target host has a large number of CPU cores. Another option is to combine the number of CPU cores on the source host and the target host, perform a comprehensive evaluation based on network bandwidth, and dynamically calculate the optimal number of migration threads and channels using an algorithm (e.g., estimation based on the bandwidth-delay product). This algorithm then dynamically adjusts the allocation and parallel processing scale of migration threads and channels.

[0051] In the above embodiments, by sensing the number of CPU cores and available resources of the target host, the parallelism of the migration task is ensured to match the processing power of the target host, thereby ensuring migration efficiency while avoiding resource contention and performance bottlenecks.

[0052] This embodiment provides a virtual machine migration method, which can be referred to in conjunction with the above. Figure 2This is another flowchart illustrating a virtual machine migration method provided in an embodiment of this application. Figure 2 The virtual machine migration method also includes the following steps:

[0053] Step S201: Receive migration instructions. These instructions specify the target virtual machine to be migrated, the target host to which the target virtual machine will be migrated, and the target port on the target host used to receive virtual machine data. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.

[0054] Step S202: If the target port is within a preset first port range, multiple migration threads and shared memory-based data migration channels are created, and the migration threads and data migration channels are bound one-to-one. For details, please refer to [link to details]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.

[0055] Step S203 involves dividing the target virtual machine's memory and storage data into multiple data blocks and allocating these data blocks to multiple migration threads. Different migration threads are assigned different data blocks. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.

[0056] In some embodiments, when the memory data and storage data of the target virtual machine are divided into multiple data blocks, the above step S203 includes, but is not limited to, the following steps S2031 to S2032:

[0057] Step S2031: Divide the memory data into multiple data pages and treat each data page as a separate data block.

[0058] Specifically, before performing data partitioning, the electronic device executing the method of this application partitions the memory of the target virtual machine, dividing it into memory page units of fixed size, and assigning each independent data page as an independent data block to different migration threads for processing.

[0059] In the above embodiments, by dividing the memory data into memory pages of fixed size, this method is in line with the paging management of the central processing unit and the operating system, simplifies the migration logic, improves the efficiency of memory data migration, and is conducive to the integrity of the migrated data.

[0060] In some embodiments, during the migration of the target virtual machine to the target host, the target virtual machine remains running, and the above step S2031 includes, but is not limited to, the following steps a1 to a4:

[0061] Step a1: After triggering the migration of the target virtual machine, monitor the modified memory data in the target virtual machine and treat the modified memory data as dirty page data.

[0062] Specifically, when the migration of the target virtual machine begins, the virtual machine monitor on the source host will record dirty page data through a dirty page tracking mechanism. Whenever a data page is migrated, if that data page is modified during the migration process, it is marked as dirty page data. This step continues throughout the entire pre-copy phase of the migration, ensuring that all data pages modified during the migration process can be accurately identified and marked.

[0063] Step a2: During the migration of data pages, at least a portion of the dirty page data is migrated to the target host based on the migration thread and data migration channel.

[0064] Specifically, during the initial data page migration process, the electronic device executing the method of this application can periodically scan the dirty page data recorded above. The dirty page data is regarded as incremental data that needs to be retransmitted and is migrated to the target host along with the unmigrated data pages during the subsequent migration process.

[0065] Step a3: When the data page migration is completed, control the target virtual machine to pause operation and migrate at least a portion of the dirty page data of the target virtual machine that has not yet been migrated to the target host.

[0066] Specifically, after iterative migration of data pages and dirty pages, when the number of dirty pages falls below a preset threshold, the target virtual machine's running state will be paused, and the generation of new dirty pages will stop, ensuring that the remaining data can be completely transferred in the final migration phase.

[0067] Step a4: After receiving the data page and dirty page data, the target host verifies whether the data page and dirty page data of the target virtual machine have been migrated completely based on the memory image verification mechanism.

[0068] Specifically, after receiving data pages and dirty pages from the target virtual machine, the virtual machine monitor on the target host verifies whether the migration of data pages and dirty pages has been completed through a memory image verification mechanism. This memory image verification mechanism includes, but is not limited to, hash verification and metadata comparison.

[0069] In the above embodiments, the integrity of memory data during migration is ensured through dirty page tracking and memory image verification mechanisms. Furthermore, the target virtual machine remains running during the pre-copy phase and is only paused during the final migration phase, significantly reducing the target virtual machine service interruption time.

[0070] In some embodiments, after the data page migration is completed, step a4 above further includes:

[0071] Receive a missing data migration request sent by the target host. The missing data migration request is initiated by the target host after it discovers a missing data page through memory image verification, based on the abnormal state of the missing data page, and the missing data page is migrated back to the target host.

[0072] Specifically, if the memory image verification mechanism detects that one or more data pages have not been successfully received or are corrupted, the target host initiates a missing data migration request to the source host where the target virtual machine resides. This request contains the identification information of the missing data page (such as the starting address in the target virtual machine's physical address space). After receiving the request, the source host can locate the physical address space of the missing data page and can set the highest priority to retransmit the data page to the target host using the migration method described in the above embodiment. Once the target host receives the data page, it will perform verification again until the entire memory image is confirmed to be complete and error-free.

[0073] In the above embodiments, by initiating missing data requests and retransmission mechanisms, the migration process can detect missing data pages due to certain reasons. Based on the memory verification mechanism, a complete data migration process is formed during the entire virtual machine memory migration process, which significantly improves the stability and success rate of migration operations in some complex environments.

[0074] Step S2032: Based on the disk block size of the disk where the stored data is located, the stored data is divided into multiple storage units, and each storage unit is treated as a data block.

[0075] Specifically, during the partitioning and migration of the target virtual machine's memory data, the target virtual machine's storage data is also partitioned and migrated simultaneously. Specifically, the storage data is partitioned according to disk block size, thus dividing it into multiple fixed-size storage units. Each storage unit can be considered a data block to be migrated.

[0076] In the above embodiments, by dividing and transferring the target virtual machine's storage data in units of disk block size, the read and write operations during the migration process are fully aligned with the IO granularity of the physical storage device. This avoids cross-boundary partitioned IO, i.e., the situation where reading or writing a data block requires accessing two physical disk blocks, thereby significantly improving the IO efficiency of stored data and reducing latency.

[0077] In some embodiments, before migrating the storage units, step S2032 further includes: calculating a first check code for each storage unit and sending the first check code to the target host, so that after receiving the storage unit, the majority of target hosts recalculate a second check code based on the storage unit and compare the first check code and the second check code to determine whether the migration of the storage unit is correct.

[0078] Specifically, during the migration of each of the above storage units, a checksum verification method is used to ensure the integrity and accuracy of the virtual machine storage data during the migration process. This verification method includes, but is not limited to, the following steps b1 to b:

[0079] Step b1: The source physical host performs a checksum calculation and transmission once.

[0080] Specifically, after the target virtual machine's storage data is divided into storage units, before the migration operation, a unique first checksum is generated by calculating the data content of the storage unit using a preset verification algorithm. Then, this first checksum is transmitted to the target host through the migration channel. The verification algorithm includes, but is not limited to, CRC32-C, MD5, or SHA-256.

[0081] Step b2: The target host receives the checksum and performs a second calculation.

[0082] Specifically, after the target host receives the aforementioned storage unit through the migration channel, it performs a second checksum calculation on the received data using the same checksum algorithm as the source physical machine.

[0083] Step b3: Verification code comparison.

[0084] The target host calculates a secondary checksum and compares it bit by bit with the primary checksum received through the migration channel. If the primary and secondary checksums match perfectly, it is determined that the data in the storage unit was transmitted without error, and the storage unit can be used for the subsequent reconstruction of virtual machines on the target host.

[0085] In the above embodiments, data verification is provided for each independent storage unit. By comparing the first check code and the second check code calculated by the source physical host and the target host, it is possible to detect whether data loss occurs during the migration process, which significantly improves the reliability of storage data migration.

[0086] In some embodiments, after migrating the storage unit, the method further includes: if a message indicating that the comparison of the first check code and the second check code has failed is received from the target host, the target storage unit corresponding to the first check code is located, and the target storage unit is migrated back to the target host.

[0087] Specifically, after the target host completes the reception and checksum comparison of a target storage unit, if the first checksum and the second checksum are inconsistent, the target host can generate a checksum failure notification message. This message can be transmitted to the source physical host through the migration channel of the first checksum. This message may include, but is not limited to, the identification information of the target storage unit. When the source physical host receives the checksum failure notification message, it locates the target storage unit locally based on the identification information in the message and re-initiates the migration task for that target storage unit. After the target host receives the message, it performs checksum calculation and comparison again until the target storage unit successfully passes the checksum verification.

[0088] In the above embodiments, when a target storage unit migration error is detected, a verification failure notification message is sent, the target storage unit is relocated and resent, ensuring data consistency during the migration process. Furthermore, this verification mechanism can pinpoint the individual faulty storage unit, minimizing the amount of data and resource overhead required to repair the error, and significantly improving retransmission efficiency when migration errors occur.

[0089] Step S204 involves running multiple migration threads in parallel, so that each migration thread migrates the allocated data blocks to the target host through its bound data migration channel. For details, please refer to [link to details]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.

[0090] This embodiment provides a virtual machine migration method, which can be referred to in conjunction with the above. Figure 3 This is another flowchart illustrating a virtual machine migration method provided in this application. Figure 3 The virtual machine migration method also includes the following steps:

[0091] Step S301: Receive migration instructions. For details, please refer to [link to relevant documentation]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.

[0092] Step S302: Create a thread pool and initialize tasks.

[0093] Specifically, when the main thread receives the virtual machine migration instruction and starts the virtual machine migration process, it creates a thread pool containing a preset number of n child threads through the main thread (such as the thread management interface provided by the virtual machine management platform). The thread pool size n can be a fixed value or can be adjusted according to the number of central processing unit cores (i.e., steps S1021 and S1022).

[0094] Step S303: Create n child threads and a migration channel based on shared memory.

[0095] Specifically, once the thread pool is created, n child threads are created using thread management tools and a task queue, and an independent data migration channel based on shared memory is established for each child thread.

[0096] Step S304: Divide the data into blocks and distribute the data.

[0097] Specifically, the memory data and storage data of the target virtual machine are divided, with the memory data divided into multiple data pages of different sizes and the storage data divided into multiple storage units. For details, please refer to steps S2031 to S2032 in the above embodiments, which will not be repeated here.

[0098] Step S305: Allocate different data pages, dirty page data, or storage units.

[0099] Specifically, after the data is segmented, different data blocks are allocated to different migration threads for data migration. During the migration process, dirty pages may be generated in the target virtual machine's memory. These dirty pages are migrated to the target host along with the aforementioned sub-threads and migration channels. For details, please refer to steps a1 to a4 in the above embodiments, which will not be repeated here.

[0100] Step S306, run in parallel. See details below. Figure 1 Step S104 of the illustrated embodiment will not be described again here.

[0101] Step S307: After all migration tasks are completed, return the results.

[0102] Specifically, the completion status of the migration task can be determined by monitoring, collecting, and confirming the status of all parallel sub-thread tasks. The specific process includes, but is not limited to, the following steps c1 to c3:

[0103] Step c1, task status monitoring.

[0104] Specifically, the main thread can continuously monitor the status of the task queue. When the main thread no longer allocates new data block tasks (such as data pages, storage units, dirty page data, data blocks that need to be re-migrated after verification failure) to the task queue, and all child threads have processed the last task from the task queue, the migration completion confirmation stage can be carried out.

[0105] Step c2: Summarize the results.

[0106] Specifically, the execution results from all n child threads are collected. After completing all the tasks assigned to it, each child thread can report its current status to the main thread (such as task completion, no errors in the migration process). The main thread summarizes and verifies these results to ensure that all child threads have completed their assigned tasks.

[0107] Step c3 returns a completion signal.

[0108] Specifically, when the main thread confirms that all child threads have successfully completed their respective data block migration tasks, and all results indicate that the migration process is normal, it can generate an internal signal or status indicating that all migration tasks are complete.

[0109] Step S308: Confirm that the migration is complete and send virtual machine status information.

[0110] Specifically, upon receiving internal signals or status indicating the completion of all the aforementioned migration tasks, the main thread sends the final target virtual machine status information (such as the status of the device model, the status of the memory management unit, etc.) to the target host. Once the target host receives this target virtual machine status information, it uses this information to rebuild the virtual machine environment and restore the virtual machine's running state.

[0111] In the above embodiments, virtual machine migration is achieved by constructing a collaborative architecture that includes main thread coordination and parallel execution of multiple sub-threads. By creating multiple sub-threads and binding them to independent shared memory-based migration channels, parallel migration of data blocks is achieved, significantly improving migration speed and efficiency. Furthermore, the reliability and data integrity of the migration process are further ensured by confirming the migration results.

[0112] In summary, the virtual machine migration method provided in this application can significantly improve migration efficiency, ensure data integrity, and achieve efficient resource utilization during the migration process. Furthermore, it is widely applicable to various virtual machine platforms and application scenarios.

[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0114] Corresponding to the virtual machine migration method, this application also provides a virtual machine migration apparatus. (See also...) Figure 4 This is a schematic diagram of a virtual machine migration apparatus provided in some embodiments of this application. Figure 4 In this context, the virtual machine migration device includes:

[0115] The instruction receiving module 401 is used to receive migration instructions. The migration instructions specify the target virtual machine to be migrated, the target host to which the target virtual machine should be migrated, and the target port on the target host for receiving virtual machine data.

[0116] The migration channel creation module 402 is used to create multiple migration threads and data migration channels based on shared memory if the target port is within a preset first port range, and bind the migration threads and data migration channels one by one.

[0117] The data partitioning module 403 is used to divide the memory data and storage data of the target virtual machine into multiple data blocks and allocate the data blocks to multiple migration threads. Different migration threads are allocated different data blocks.

[0118] The data migration module 404 is used to run multiple migration threads in parallel, so that each migration thread can migrate the allocated data blocks to the target host through the bound data migration channel.

[0119] In some embodiments, the virtual machine migration method further includes:

[0120] The Transmission Control Protocol (TCP) migration module is used to migrate the data of the target virtual machine to the target host based on the TCP if the target port is located within a preset second port range.

[0121] In some embodiments, when creating multiple migration threads and a shared memory-based data migration channel, the migration channel creation module 402 is further configured to:

[0122] Obtain the number of central processing unit cores in the target host;

[0123] Based on the number of cores, create multiple migration threads and data migration channels.

[0124] In some embodiments, when the memory data and storage data of the target virtual machine are divided into multiple data blocks, the data partitioning module 403 includes:

[0125] A memory data partitioning unit is used to partition memory data into multiple data pages, and to treat each data page as a separate data block.

[0126] The storage data partitioning unit is used to divide the stored data into multiple storage units based on the disk block size of the disk where the stored data is located, and to treat each storage unit as a separate data block.

[0127] In some embodiments, the data migration module 404 is further configured to:

[0128] After the migration of the target virtual machine is triggered, the modified memory data in the target virtual machine is monitored and the modified memory data is treated as dirty page data.

[0129] During the migration of data pages, at least a portion of the dirty page data is migrated to the target host based on migration threads and data migration channels;

[0130] When the data page migration is complete, control the target virtual machine to pause running and migrate at least a portion of the dirty page data of the target virtual machine that has not yet been migrated to the target host;

[0131] Upon receiving the data page and dirty page data, the target host verifies, based on the memory image verification mechanism, whether the migration of the target virtual machine's data page and dirty page data has been completed.

[0132] In some embodiments, the data migration module 404 is further configured to:

[0133] Receive missing data migration request sent by the target host, wherein the missing data migration request is initiated by the target host based on the abnormal state of the missing data page after the missing data page is discovered through memory image verification;

[0134] The missing data pages were migrated back to the target host.

[0135] In some embodiments, the data migration module 404 is further configured to:

[0136] Before migrating storage units, a first checksum is calculated for each storage unit and sent to the target host. Upon receiving the storage unit, the target host recalculates a second checksum based on the storage unit and compares the first and second checksums to determine whether the migration of the storage unit is correct.

[0137] In some embodiments, the data migration module 404 is further configured to:

[0138] If a message indicating that the first check code and the second check code have failed to match is received from the target host, the target storage unit corresponding to the first check code is located.

[0139] The target storage unit was relocated to the target host.

[0140] Based on the rollback mechanism of the source physical host, the storage unit corresponding to the initial checksum can be found through the initial checksum.

[0141] Based on the storage unit, the data is migrated back to the target host.

[0142] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0143] See also Figure 5 Embodiments of this application also provide an electronic device including a memory 10 and a processor 20, wherein the memory 10 stores a computer program and the processor 20 is configured to run the computer program to perform the steps in any of the above-described virtual machine migration method embodiments.

[0144] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described virtual machine migration method embodiments at runtime.

[0145] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0146] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described virtual machine migration method embodiments.

[0147] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described virtual machine migration method embodiments.

[0148] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0149] The present application provides a detailed description of a virtual machine migration method, apparatus, device, and storage medium. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of these embodiments are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A virtual machine migration method, characterized in that, The methods include: Receive a migration instruction, which specifies the target virtual machine to be migrated, the target host to which the target virtual machine is to be migrated, and the target port of the target host for receiving virtual machine data. If the target port is within a preset first port range, multiple migration threads and shared memory-based data migration channels are created, and the migration threads and data migration channels are bound one-to-one. The memory and storage data of the target virtual machine are divided into multiple data blocks, and the data blocks are allocated to the multiple migration threads, with different data blocks allocated to different migration threads; The multiple migration threads are run in parallel so that each migration thread migrates the allocated data blocks to the target host through the bound data migration channel.

2. The method according to claim 1, characterized in that, The method further includes: If the target port is located within a preset second port range, the data of the target virtual machine will be migrated to the target host based on the transmission control protocol.

3. The method according to claim 1, characterized in that, The creation of multiple migration threads and a shared-memory-based data migration channel includes: Obtain the number of central processing unit cores in the target host; Based on the number of cores, multiple migration threads and data migration channels are created.

4. The method according to claim 1, characterized in that, The method of dividing the memory data and storage data of the target virtual machine into multiple data blocks includes: The memory data is divided into multiple data pages, and each data page is treated as a data block. Based on the disk block size of the disk where the stored data is located, the stored data is divided into multiple storage units, and each storage unit is treated as a data block.

5. The method according to claim 4, characterized in that, During the process of migrating the target virtual machine to the target host, the target virtual machine remains running, further including: After the migration of the target virtual machine is triggered, the modified memory data in the target virtual machine is monitored and the modified memory data is treated as dirty page data. During the migration of the data pages, at least a portion of the dirty page data is migrated to the target host based on the migration thread and the data migration channel; When the migration of the data pages is completed, the target virtual machine is controlled to pause operation, and at least a portion of the dirty page data of the target virtual machine that has not yet been migrated is migrated to the target host; Upon receiving the data page and dirty page data, the target host verifies, based on a memory image verification mechanism, whether the migration of the target virtual machine's data page and dirty page data has been completed.

6. The method according to claim 5, characterized in that, After completing the migration of the data pages, the method further includes: Receive a missing data migration request sent by the target host, wherein the missing data migration request is initiated by the target host based on the abnormal state of the missing data page after the target host discovers the missing data page through memory image verification; The missing data page will be migrated back to the target host.

7. The method according to claim 4, characterized in that, The method further includes: Before migrating the storage units, a first checksum is calculated for each storage unit and sent to the target host. Upon receiving the storage unit, the target host recalculates a second checksum based on the storage unit and compares the first checksum with the second checksum to determine whether the migration of the storage unit is correct.

8. The method according to claim 7, characterized in that, Prior to the migration of the storage unit, the method further includes: If a message indicating that the first check code and the second check code have failed to match is received from the target host, the target storage unit corresponding to the first check code is located. The target storage unit is then migrated back to the target host.

9. A virtual machine migration device, characterized in that, The device includes: The instruction receiving module is used to receive migration instructions. The migration instructions specify the target virtual machine to be migrated, the target host to which the target virtual machine should be migrated, and the target port on the target host for receiving virtual machine data. The migration channel creation module is used to create multiple migration threads and a shared memory-based data migration channel if the target port is located within a preset first port range, and to bind the migration threads and the data migration channels one by one. The data partitioning module is used to divide the memory data and storage data of the target virtual machine into multiple data blocks and allocate the data blocks to the multiple migration threads, with different migration threads being allocated different data blocks; The data migration module is used to run the multiple migration threads in parallel, so that each migration thread migrates the allocated data blocks to the target host through the bound data migration channel.

10. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program, wherein when executed by a processor, the computer program implements the steps of the virtual machine migration method as claimed in any one of claims 1 to 7.