Data Migration Method, Apparatus, Electronic Device and Storage Medium for Virtual Machine

By binding the target service to the designated virtual processor during the dynamic migration of virtual machines and accurately limiting the speed during data migration, the problem of low success rate of virtual machine migration in the existing technology is solved, improving the success rate of migration and reducing the impact on the business.

CN115454565BActive Publication Date: 2025-07-29CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210906743.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2025-07-29
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

During the dynamic migration of virtual machines, the prior art has almost no traffic on the virtual machine due to the speed limit of all vCPUs, and the migration success rate is not high.

Method used

Bind the target service with the specified virtual processor, and limit the running speed of the specified virtual processor during data migration. When the running speed reaches the preset speed, adjust the first step length to the second step length, and the second step length is smaller than the first step length to improve the speed limit accuracy.

Benefits of technology

It improves the success rate of virtual machine data migration, reduces the overall impact on the business in the virtual machine, and ensures that some businesses can still operate normally during the migration process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115454565B_ABST
    Figure CN115454565B_ABST
Patent Text Reader

Abstract

The present invention discloses a data migration method, device, electronic device and storage medium for virtual machines. The method includes: obtaining a target service and binding the target service to a specified virtual processor, where the specified virtual processor is in the virtual machine; in response to a data migration instruction, controlling the virtual machine to perform data migration; when the virtual machine performs data migration, restricting the running speed of the specified virtual processor, and when the running speed reaches a preset speed, adjusting the first step length to a second step length, where the preset speed is obtained by restricting the running speed based on the first step length, and the second step length is less than the first step length; restricting the running speed based on the second step length to complete the data migration. This method does not need to limit the speed of all virtual processors in the virtual machine, improves the accuracy of speed limit, thereby reducing the overall impact on the services in the virtual machine during the migration process, and improves the success rate of data migration of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of virtual machines, and particularly to a method, apparatus, electronic device, and storage medium for data migration of virtual machines. Background Art

[0002] In the field of virtualization, with the increasing usage requirements, guest machines are becoming larger and larger, that is, the number of virtual processors (vCPUs) and random access memories (RAMs) of a single virtual machine are increasing. At the same time, it is required that the guest machine runs continuously without interruption. Therefore, the virtual machine live migration technology is being more and more widely used as an important operation and maintenance and management means.

[0003] Live migration is to migrate a guest virtual machine from one host to another while the guest machine is still running. During this period, the virtual machine maintains normal operation, and users will not be aware of the migration operation. Online migration involves many variables: generation of dirty pages in the virtual machine memory, network bandwidth, network latency, and storage availability, etc.

[0004] During live migration, if the generation rate of dirty pages is too fast, even exceeding the bandwidth of the migration network, the live migration will keep ongoing and cannot be completed. Without changing the current system resources, in the prior art, the running speed of all vCPUs in the virtual machine will be reduced during live migration, so as to reduce the generation of dirty pages until the live migration is finally completed. Since the speed of all vCPUs in the virtual machine is limited, almost all services on the virtual machine cannot be used, and it may also be difficult to complete the live migration in this case. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for data migration of virtual machines to solve the problems of low success rate of virtual machine live migration and low availability of services on the virtual machine.

[0006] According to a first aspect, an embodiment of the present invention provides a method for data migration of a virtual machine, the method comprising:

[0007] Obtain a target service and bind the target service to a specified virtual processor in the virtual machine;

[0008] In response to a data migration instruction, control the virtual machine to perform data migration;

[0009] When the virtual machine performs data migration, limit the running speed of the specified virtual processor. When the running speed reaches a preset speed, adjust a first step length to a second step length, where the preset speed is obtained by limiting the running speed based on the first step length, and the second step length is less than the first step length;

[0010] Limit the running speed based on the second step length to complete the data migration.

[0011] The data migration method for a virtual machine provided by the embodiments of the present invention binds a target service to a specified virtual processor. When speed limiting is required during data migration, only the running speed of the specified virtual processor is limited. And when the running speed of the virtual processor reaches a preset speed, the first step length can be adjusted to a second step length, where the second step length is less than the first step length, and there is no need to limit the speed of all virtual processors in the virtual machine, improving the accuracy of speed limiting and enhancing the success rate of data migration of the virtual machine.

[0012] In combination with the first aspect, in an implementation manner, the obtaining the target service and binding the target service to a specified virtual processor includes:

[0013] Obtain the memory usage of the services on the virtual machine, and determine whether the memory usage of the service exceeds a specified memory threshold;

[0014] When the memory usage exceeds the specified memory threshold, determine that the service is the target service, and bind the target service to the specified virtual processor.

[0015] In combination with the first aspect, in an implementation manner, the binding the target service to a specified virtual processor includes:

[0016] When the target service is started, in response to a binding instruction for the service, bind the target service to the specified virtual processor.

[0017] In combination with the first aspect, in an implementation manner, the binding the target service to a specified virtual processor includes:

[0018] After the target service is started, in response to a process query instruction for the service, determine the process corresponding to the service;

[0019] In response to a binding instruction for the process, bind the process to the specified virtual processor.

[0020] In combination with the first aspect, in an implementation manner, the limiting the running speed of the specified virtual processor and adjusting the first step length to the second step length when the running speed reaches a preset speed includes:

[0021] Obtain the number of dirty pages during the data migration process of the virtual machine, and determine whether it is necessary to limit the running speed of the virtual machine according to the number of dirty pages;

[0022] When it is necessary to limit the running speed of the virtual machine, in response to a speed limit instruction, limit the running speed of the specified virtual processor based on a first step length;

[0023] When the running speed of the specified virtual processor reaches a preset speed, adjust the first step length to the second step length, where the second step length is smaller than the first step length.

[0024] In combination with the first aspect, in an implementation, the obtaining the number of dirty pages of the virtual machine during data migration and determining whether to limit the running speed of the virtual machine according to the number of dirty pages includes:

[0025] Obtain the number of dirty pages of the virtual machine during data migration and the amount of data that has been migrated, compare the number of dirty pages with the amount of data that has been migrated, and obtain a comparison result;

[0026] Determine whether to limit the running speed of the virtual machine according to the comparison result.

[0027] In combination with the first aspect, in an implementation, the limiting the running speed based on the second step length to complete the data migration includes:

[0028] When the running speed of the specified virtual processor reaches a preset speed, limit the running speed based on the second step length;

[0029] Perform data migration based on the limited running speed and obtain the amount of data to be migrated;

[0030] Compare the amount of data to be migrated with a data migration threshold. When the amount of data to be migrated is less than the data migration threshold, stop limiting the running speed to complete the data migration.

[0031] According to the second aspect, an embodiment of the present invention provides a data migration device for a virtual machine, including:

[0032] A service binding module, configured to obtain a target service and bind the target service to a specified virtual processor, where the specified virtual processor is in the virtual machine;

[0033] A data migration module, configured to control the virtual machine to perform data migration in response to a data migration instruction;

[0034] A first speed limit module, configured to limit the running speed of the specified virtual processor when the virtual machine performs data migration. When the running speed reaches a preset speed, adjust the first step length to the second step length. The preset speed is obtained by limiting the running speed based on the first step length, and the second step length is smaller than the first step length;

[0035] A second speed limit module, configured to limit the running speed based on the second step length to complete the data migration.

[0036] According to a third aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to execute the data migration method of the virtual machine described in the first aspect or any one of the embodiments of the first aspect.

[0037] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the data migration method of the virtual machine described in the first aspect or any one of the embodiments of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0039] Figure 1 is a flowchart of the data migration method of the virtual machine according to an embodiment of the present invention;

[0040] Figure 2 is a flowchart of binding a target service according to an embodiment of the present invention;

[0041] Figure 3 is a flowchart of the step length adjustment method according to an embodiment of the present invention;

[0042] Figure 4 is a flowchart of the speed limit method according to an embodiment of the present invention;

[0043] Figure 5 is a flowchart of the data migration according to an embodiment of the present invention;

[0044] Figure 6 is a flowchart of the speed limit judgment according to an embodiment of the present invention;

[0045] Figure 7 is a structural block diagram of the data migration device of the virtual machine according to an embodiment of the present invention; <s

[0046] Figure 8 is a schematic hardware structure diagram of the electronic device provided by an embodiment of the present invention;

[0047] Figure 9 is a graph of the FIO 4K random read / write test results according to an embodiment of the present invention;

[0048] Figure 10 is a graph of the ping test results according to an embodiment of the present invention;

[0049] Figure 11 is a graph for checking migration results according to an embodiment of the present invention;

[0050] Figure 12 is a graph of the UnixBench test results according to an embodiment of the present invention;

[0051] Figure 13 is a graph of the FIO 4K random read / write test results;

[0052] Figure 14 is a graph of the ping test results;

[0053] Figure 15 is a graph for checking migration results;

[0054] Figure 16 is a graph of the UnixBench test results. Detailed implementation manners

[0055] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0056] According to an embodiment of the present invention, an embodiment of a method for migrating data of a virtual machine is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0057] In this embodiment, a method for migrating data of a virtual machine is provided, which can be used in terminals such as mobile phones, tablet computers, and computers. Figure 1 is a flowchart of a method for migrating data of a virtual machine according to an embodiment of the present invention, as Figure 1 shown, and the process includes the following steps:

[0058] S11, obtain a target service and bind the target service to a specified virtual processor.

[0059] There can be multiple virtual processors in a virtual machine, and different virtual processors can execute different services. Take memory-intensive services that occupy a large amount of memory during execution as target services. For example, use commands in Linux to determine whether the memory of a service is the largest or the memory occupancy exceeds a set threshold. The larger the memory occupancy of a service, the more dirty pages are generated. Specify a virtual processor in the virtual machine. The specified virtual processor can be a virtual processor with a set number, and the specification method is not restricted. Bind the target service to the specified virtual processor set. For example, bind the target service to virtual processors with even numbers. That is to say, if there are services with frequent memory writes on the virtual machine, then these services will run on a certain processor in the specified virtual processor set.

[0060] S12. In response to a data migration instruction, control the virtual machine to perform data migration.

[0061] The live migration of a virtual machine includes two phases, an initialization phase and a migration phase. In the initialization phase, initialize the objects and states to be used during the live migration of the virtual machine, and then start the migration phase. The data migration instruction can be to execute a live migration function. At the beginning of each round of migration, the amount of data to be migrated is counted. The amount of data to be migrated is the remaining data volume. If the remaining data volume is less than the set data volume, then the virtual machine can be prepared to be paused and no more dirty pages will be generated, and the remaining data can be sent to the destination end to complete the data migration. If the remaining data volume is not less than the set data volume, it means that even if the virtual machine is paused, the remaining data cannot be migrated to the destination end within the specified time, and then the next round of migration needs to be started.

[0062] When counting the remaining data volume, it is necessary to obtain all the memory dirty pages generated from the end of the previous round of data migration to the end of the current round of data migration from the kernel KVM (Kernel-based Virtual Machine), and check whether the number of dirty pages is greater than the set threshold. The set threshold can be 50% of the data volume already migrated in this round. The specific proportion and the size of the set threshold are not limited. This process is to check whether the migration converges, that is, whether the data migration can be completed according to the running speed of the current virtual machine. If not, start the next round of data migration process. After each round of data migration ends, obtain the number of all dirty pages generated during this process and judge whether the migration converges. It can be set that if it does not converge for two consecutive rounds, it means that the number of dirty pages needs to be restricted, otherwise the data migration cannot be completed. It can also set the conditions for restricting the number of dirty pages according to specific situations, which are not limited here.

[0063] S13. When the virtual machine performs data migration, limit the running speed of the specified virtual processor. When the running speed reaches the preset speed, adjust the first step length to the second step length.

[0064] Based on S12, when it is necessary to limit the number of dirty pages, it is necessary to limit the running speed of the virtual machine, so as to generate fewer dirty pages. In the services executed by the virtual machine, services with little memory usage do not generate a large number of dirty pages. Since memory-intensive services have been used as target services and bound to specified virtual processors, when limiting the running speed of the virtual machine, the speed of the specified virtual processor can be specifically limited, that is, accurately limit the virtual processor that contributes more to the generation of dirty pages, and the speed of the virtual processor where the service with less memory occupancy is located does not need to be limited.

[0065] When limiting the speed, limit the running speed of the specified virtual processor based on the first step length and perform data migration. When the migration is not completed and enters the next round of migration and limits the running speed of the virtual processor, limit the speed based on the running speed of the previous round and the first step length until the running speed becomes the preset speed, that is, the preset speed is obtained by limiting the running speed based on the first step length. To improve the accuracy of speed limiting, the first step length can be adjusted to the second step length, and the second step length can be set to be less than the first step length.

[0066] S14, limit the running speed based on the second step length to complete the data migration.

[0067] Taking the binding of the target service to the virtual processors with even numbers as an example, when limiting the speed, only the virtual processors with even numbers can be speed-limited, and if the number is odd, it is skipped without limitation. If the running speed of the virtual processor is 100 KB / s when the specified virtual processor is speed-limited for the first time, the first step length is 10%, and the initial speed limit is 20%, then the running speed becomes 80 KB / s. In the second round of speed limiting, the running speed becomes 70 KB / s, that is, the speed limit is 30%. Set the preset speed to 1% of the running speed of 100 KB / s, that is, the speed limit is 99%. When the running speed becomes the preset speed, set the second step length to 0.1% until the speed limit reaches 99.5%.

[0068] After each round of speed limiting, the amount of data to be migrated can be judged. If the amount of data to be migrated is less than the set amount of data, there is no need to perform a new round of data migration, and the data migration can be completed in this round.

[0069] The virtual machine data migration method provided by the embodiments of the present invention binds the target service to the specified virtual processor. When speed limiting is required during data migration, only the running speed of the specified virtual processor is limited, and when the running speed of the virtual processor reaches the preset speed, the first step length can be adjusted to the second step length, the second step length is less than the first step length, and it is not necessary to speed-limit all virtual processors in the virtual machine, improving the accuracy of speed limiting, thereby reducing the overall impact on the services in the virtual machine during the migration process, and improving the success rate of data migration of the virtual machine.

[0070] In this embodiment, a method for binding a target service is provided, corresponding to Figure 1 S11 in Figure 2 is a flowchart of binding a target service according to an embodiment of the present invention, as shown in Figure 2 shown, and includes the following steps:

[0071] S21, obtain the memory usage of the service on the virtual machine, and determine whether the memory usage of the service exceeds a specified memory threshold.

[0072] S22, when the memory usage exceeds the specified memory threshold, determine the service as the target service, and bind the target service to the specified virtual processor.

[0073] When deploying a service on a virtual machine, a script call tool can be used, such as the PS (Process Status) command in Linux, to determine whether the service is a target service according to an algorithm. Specifically, by obtaining the memory usage of each service in the virtual machine and comparing the memory usage with a pre-set specified memory threshold, when the memory usage exceeds the specified memory threshold, the service is classified as the target service. It can also be that the service with the largest memory occupancy among all services is used as the target service. The setting of the target service is to screen out services that occupy memory. As a memory-intensive service, the target service will generate more dirty pages during operation, while a service with little memory usage will not generate too many memory dirty pages even if the write memory is relatively frequent.

[0074] Bind the target service to a specified set of virtual processors. The specified virtual processors can be set according to specific circumstances. For example, virtual processors with even numbers can be set as the specified virtual processors. That is, if there is an application with very frequent write memory on the virtual machine, then it must be on these bound specified virtual processors. In this way, when performing speed limit, the virtual processors that contribute greatly to the generation of memory dirty pages can be accurately limited, and services with relatively small memory occupancy and less memory generation can be scheduled to unthrottled virtual processors. Therefore, the working process will not be affected, and the impact of the virtual machine on the services in the virtual machine during dynamic migration and virtual processor speed reduction is reduced.

[0075] In one implementation, binding the target service to the specified virtual processor includes: when the target service starts, in response to the binding instruction for the service, bind the target service to the specified virtual processor.

[0076] The method for binding the target service to the specified virtual processor can be: bind it to the specified virtual processor when the target service starts. For example, the target service named "hello" can be bound to the virtual processor numbered "0" through "taskset -c 0. / hello".

[0077] In one embodiment, binding a target service to a specified virtual processor includes: after the target service is started, in response to a process query instruction for the service, determining the process corresponding to the service; and in response to a binding instruction for the process, binding the process to the specified virtual processor.

[0078] Another method for binding a target service to a specified virtual processor may be: dynamically binding a virtual processor after the target service is started. The process query instruction may be a kernel command in Linux. The process corresponding to the target service is queried through the process query instruction, and then the process of the target service is bound to the specified kernel in the specified virtual processor through the binding instruction. Specifically, the process corresponding to the target service can be queried through the kernel command PS, and then the processor affinity of the process is bound through the taskset command. For example, "taskset -p 3 PID" means binding the process PID to the 3rd kernel in the specified virtual processor.

[0079] In this embodiment, a step size adjustment method is provided, corresponding to Figure 1 S13 in Figure 3 which is a flowchart according to an embodiment of the present invention, as Figure 3 shown, and includes the following steps:

[0080] S31, obtaining the number of dirty pages of a virtual machine during data migration, and determining whether to limit the running speed of the virtual machine according to the number of dirty pages.

[0081] Specifically, it includes:

[0082] (1) Obtaining the number of dirty pages of the virtual machine during data migration and the amount of data that has been migrated, comparing the number of dirty pages with the amount of data that has been migrated, and obtaining a comparison result.

[0083] (2) Determining whether to limit the running speed of the virtual machine according to the comparison result.

[0084] When performing data migration, it is necessary to determine whether the data migration can be completed within the specified time according to whether the amount of data to be migrated exceeds the set amount of data. If not, the next round of data migration needs to be started. When counting the amount of data to be migrated, it is necessary to obtain all the memory dirty pages generated during the period from the end of the previous round of data migration to the end of this round of data migration from the kernel KVM (Kernel-based Virtual Machine), and check whether the number of dirty pages is greater than the set threshold. The set threshold can be 50% of the amount of data already migrated in this round. The specific proportion and the size of the set threshold are not limited. This process is to check whether the migration converges, that is, whether the data migration can be completed according to the running speed of the current virtual machine. If not, the next round of data migration process will be started. After each round of data migration ends, the number of all dirty pages generated during this process will be obtained, and it will be judged whether the migration converges. It can be set that if it does not converge for two consecutive rounds, it means that the number of dirty pages needs to be restricted, otherwise the data migration cannot be completed. It can also be set according to the specific situation the conditions for restricting the number of dirty pages, which are not limited here.

[0085] S32. When it is necessary to limit the running speed of the virtual machine, in response to the speed limit instruction, limit the running speed of the specified virtual processor based on the first step size.

[0086] When the amount of dirty pages generated reaches the set condition, a speed limit instruction will be triggered, and based on the set speed limit condition for the specified virtual processor, the running speed of the specified virtual processor will be limited.

[0087] For example: Taking the binding of the target service to the virtual processors with even numbers as an example, when performing speed limit, only the virtual processors with even numbers can be speed-limited. It can be set that when the amount of dirty pages generated is greater than 50% of the amount of data already migrated in this round and is greater than 50% of the amount of data already migrated in this round in two consecutive rounds of data migration, it is necessary to limit the running speed of the virtual machine. When this speed limit condition is reached, the running speed of the virtual processor is limited. Specifically, the initial speed limit can be set to 20%, and the first step size is set to 10%. When the running speed of the virtual processor is 100 KB / s, after speed limit, the running speed becomes 80 KB / s. In the second round of speed limit, the running speed becomes 70 KB / s, that is, the speed limit is 30%.

[0088] S33. When the running speed of the specified virtual processor reaches the preset speed, adjust the first step size to the second step size.

[0089] Set the preset speed to 1% of the running speed of 100 KB / s. At this time, the speed limit is 99%. When the running speed becomes the preset speed, set the second step size to 0.1% until the speed limit reaches 99.5%. The second step size is smaller than the first step size. Specifically, the values of the first step size and the second step size can be adjusted according to the specific situation.

[0090] After each speed limit, continue data migration at the running speed after the speed limit. If the amount of data to be migrated exceeds the set amount of data, perform the next round of data migration, and increase the speed limit in the next round of speed limit until it is adjusted to the second step length and the speed limit reaches 99.5%. The purpose of doing this is to improve the accuracy of the speed limit, so that those scenarios that still cannot be migrated when the speed limit reaches 99% can be migrated successfully, and the success rate of migration is improved.

[0091] In one implementation, as Figure 4 shown, Figure 1 S14 in

[0092] S41, when the running speed of the specified virtual processor reaches the preset speed, limit the running speed based on the second step length.

[0093] For details, please refer to S33 and will not be elaborated here.

[0094] S42, perform data migration based on the limited running speed and obtain the amount of data to be migrated.

[0095] After each speed limit, continue data migration at the running speed after the speed limit, and obtain the amount of data to be migrated before the start of each round of data migration.

[0096] S43, compare the amount of data to be migrated with the data migration threshold. When the amount of data to be migrated is less than the data migration threshold, stop limiting the running speed to complete the data migration.

[0097] The data migration threshold is the set amount of data. Compare the amount of data to be migrated with the data migration threshold. If the amount of data to be migrated is less than the data migration threshold, it means that the data migration can be completed in this round and there is no need to perform the speed limit operation anymore. If the amount of data to be migrated is not less than the data migration threshold, a new round of data migration needs to be started.

[0098] The virtual machine data migration method provided by this application only limits the speed of specified virtual processors, that is, limits the speed of virtual processors that generate a large number of dirty pages, rather than all virtual processors in the virtual machine. This can avoid the indiscriminate speed limit of services with very few dirty pages and a very low write memory rate during data migration. Therefore, when limiting the speed of the virtual machine to ensure the success of data migration, only some virtual processors are limited. Services with very few dirty pages and a very low write memory rate can be scheduled to the virtual processors that are not speed-limited, ensuring that some services in the virtual machine can run normally, improving the availability of the operating system applications and some services in the virtual machine during data migration, and avoiding the situation where the virtual machine is briefly unavailable during migration due to speed reduction. When the data migration still cannot be completed after limiting the speed to the preset speed, the speed limit can be increased by adjusting the step size, further improving the success rate of data migration.

[0099] In a specific embodiment, the virtual machine data migration method provided by this application can be used in the auto converge function of QEMU-KVM virtual machine live migration. The working process of auto converge is as Figure 5 shown. During the migration process (migration_thread), it includes a setup (initialization) phase and a migration iteration phase. In the setup phase, some preparatory actions are mainly completed to initialize the objects and states to be used during the migration process. In the migration iteration phase, data migration is mainly completed, the migration iteration loop function (migration_iteration_runloop) is executed, and the current migration state of the virtual machine (qeum_savevm_state_pending) is calculated, such as calculating the remaining amount of memory data to be transferred, that is, the data volume to be migrated, and calculating the virtual memory migration state (ram_save_pending). When obtaining the data volume to be migrated, it is necessary to synchronize the memory dirty pages from the kernel KVM and determine whether the auto converge function is enabled. If it is not enabled, it is determined whether a new round of data migration needs to be started or the data migration can be completed in this round according to whether the remaining data volume is less than the threshold. If the auto converge function is enabled, the number of dirty pages is judged. If the number of dirty pages is greater than 50% of the migrated data volume during two rounds of data migration, the virtual machine needs to be speed-limited.

[0100] Please refer to Figure 6 , Figure 6It is a speed limit judgment flowchart. Through steps such as synchronizing the memory dirty page bitmap (migration_bitmap_sync), global memory synchronous dirty pages (memory_global_dirty_log_sync, that is, synchronizing memory dirty pages from the kernel KVM), and RAM memory dirty page synchronization (ramblock_sync_dirty_bitmap), it is judged whether the interval between two synchronizations of memory dirty pages is greater than 1 second. If not, speed limit is not required. If so, the migration_trigger_throttle function is used to judge whether it is necessary to trigger speed limit. It is judged whether the amount of dirty page generation exceeds the current threshold twice. If not, speed limit is not required. If so, data migration speed limit of the virtual machine (mig_throttle_guest_down) is performed, the speed limit percentage of the processor (CPU) (cpu_throttle_set) is set, and the speed limit time (throttle_timer) times out after 10 milliseconds. When the processor speed limit times out and the function (cpu_throttle_timer_tick) is executed, all virtual processors are traversed to respectively perform their asynchronous speed limit tasks (cpu_throttle_thread). The target service is pre-bound to the virtual processors with even numbers. Therefore, after traversing all virtual processors here, it is judged whether the number of the current virtual processor is even. If it is not even, speed limit is not required. If it is even, the processor is relinquished by sleeping or using the Linux instruction HALT to reduce the execution of the virtual processors in the virtual machine, so as to achieve the purpose of speed limit. As Figure 5 shown, the initial speed limit is set to 20%, the first step length is 10%, when the speed limit reaches 99%, it is adjusted to the second step length of 0.1% until the maximum speed limit of 99.5%. In this embodiment, there is no need to modify the libvirt (virtualization management software) and kernel code. Only a small amount of QEMU code needs to be modified and the binding core parameter is added to the startup parameters of memory-intensive services when deploying customer services.

[0101] Compare the effects of virtual machine dynamic migration before and after optimizing the virtual machine data migration method provided in the embodiment of the present application, and verify the feasibility and optimization effect of the method of the present application by testing the impact on services during the migration process and the success rate of data migration, specifically as follows:

[0102] Verification environment: The physical machine has 32 cores and 192G of memory; the test virtual machine has 32 cores and 32G of memory; the operating system is CentOS 7.6 for both.

[0103] Preparation before testing: Memory pressure is applied. The stress program has been bound to the cores with even numbers when it is deployed and started. This program will write 16G of memory per second through 16 CPUs in total. When migrating, the migration network speed is limited to the speed of a gigabit network card to construct a scenario with limited migration bandwidth.

[0104] Testing process for the migration process based on the solution of this application:

[0105] (1) Start the UnixBench test inside the virtual machine through Tmux (Terminal multiplexer).

[0106] (2) Test the ping packet delay by pinging the virtual machine IP on the host.

[0107] (3) Start dynamically migrating the virtual machine.

[0108] (4) Query the migration progress of the virtual machine. When the speed limit reaches 99.5%, start the FIO random read and write test and obtain the results, and start obtaining the ping test results during this period. The FIO 4K random read and write test results are as Figure 9 shown, and the ping test results are as Figure 10 shown.

[0109] (5) Check whether the dynamic migration is completed and the total migration time. As Figure 11 shown, the migration is successful and it takes about 55 minutes.

[0110] (6) Obtain the test results of UnixBench inside the virtual machine. As Figure 12 shown.

[0111] Testing process for the migration process not based on the solution of this application:

[0112] (1) Start the UnixBench test inside the virtual machine through Tmux.

[0113] (2) Test the ping packet delay by pinging the virtual machine IP on the host.

[0114] (3) Start dynamically migrating the virtual machine.

[0115] (4) Query the migration progress of the virtual machine. When the speed limit reaches 99%, start the FIO random read and write test and obtain the results, and start obtaining the ping test results during this period. The FIO 4K random read and write test results are as Figure 13 shown, and the ping test results are as Figure 14 shown.

[0116] (5) Check whether the dynamic migration is completed and the total migration time. As Figure 15As shown, the speed has been limited to 99% after 12 hours of migration. A total of 258 rounds have been run, and the migration has not converged yet. Migration is continuing.

[0117] (6) Obtain the test results of UnixBench inside the virtual machine, as Figure 16 shown.

[0118] The comparison results of the test of the solution of this application and the migration process not based on the solution of this application are as follows:

[0119]

[0120] It can be seen from the test comparison results that the availability of the service and the migration success rate of the solution of this application have been significantly improved during the virtual machine data migration process. In this embodiment, a virtual machine data migration device is also provided. This device is used to implement the above-mentioned embodiments and implementation manners, and those that have been described will not be repeated. As used hereinafter, the term "module" can be a combination of software and / or hardware that realizes a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0121] This embodiment provides a virtual machine data migration device, as Figure 7 shown, including:

[0122] A service binding module, configured to obtain a target service and bind the target service to a specified virtual processor, where the specified virtual processor is in the virtual machine;

[0123] A data migration module, configured to control the virtual machine to perform data migration in response to a data migration instruction;

[0124] A first speed limit module, configured to limit the running speed of the specified virtual processor when the virtual machine performs data migration. When the running speed reaches a preset speed, adjust the first step length to a second step length. The preset speed is obtained by limiting the running speed based on the first step length, and the second step length is less than the first step length;

[0125] A second speed limit module, configured to limit the running speed based on the second step length to complete the data migration.

[0126] In one implementation manner, the service binding module further includes:

[0127] A service acquisition subunit, configured to obtain the memory usage of the service on the virtual machine and determine whether the memory usage of the service exceeds a specified memory threshold;

[0128] A service binding subunit, configured to determine the service as the target service and bind the target service to the specified virtual processor when the memory usage exceeds the specified memory threshold.

[0129] In one embodiment, the service binding subunit is further configured to bind the target service to a specified virtual processor in response to a binding instruction for the service when the target service is started.

[0130] In one embodiment, the service binding subunit is further configured to determine the process corresponding to the service in response to a process query instruction for the service after the target service is started; and bind the process to a specified virtual processor in response to a binding instruction for the process.

[0131] In one embodiment, the first speed limiting module includes:

[0132] A speed limiting judgment subunit, configured to obtain the number of dirty pages of a virtual machine during data migration, and judge whether it is necessary to limit the running speed of the virtual machine according to the number of dirty pages;

[0133] A first speed limiting subunit, configured to limit the running speed of a specified virtual processor based on a first step length in response to a speed limit instruction when it is necessary to limit the running speed of the virtual machine;

[0134] A step length adjustment subunit, configured to adjust the first step length to a second step length when the running speed of the specified virtual processor reaches a preset speed, and the second step length is less than the first step length.

[0135] In one embodiment, the speed limiting judgment subunit is further configured to:

[0136] Obtain the number of dirty pages and the amount of data that has been migrated of the virtual machine during data migration, compare the number of dirty pages with the amount of data that has been migrated, and obtain a comparison result;

[0137] Judge whether it is necessary to limit the running speed of the virtual machine according to the comparison result.

[0138] In one embodiment, the second speed limiting module includes:

[0139] A second speed limiting subunit, configured to limit the running speed based on a second step length when the running speed of the specified virtual processor reaches a preset speed;

[0140] A data migration subunit, configured to perform data migration based on the limited running speed and obtain the amount of data to be migrated;

[0141] A comparison subunit, configured to compare the amount of data to be migrated with a data migration threshold, and stop limiting the running speed when the amount of data to be migrated is less than the data migration threshold to complete the data migration.

[0142] The data migration device of the virtual machine in this embodiment is presented in the form of functional units. Here, the unit refers to an ASIC circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0143] The further function descriptions of the above-mentioned respective modules are the same as those in the corresponding embodiments above, and will not be elaborated here.

[0144] An embodiment of the present invention further provides an electronic device having the above Figure 7 shown data migration device of the virtual machine.

[0145] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of an electronic device provided by an alternative embodiment of the present invention. As shown in Figure 8 , the electronic device may include: at least one processor 601, such as a CPU (Central Processing Unit), at least one communication interface 603, a memory 604, and at least one communication bus 602. Among them, the communication bus 602 is used to realize the connection and communication between these components. Among them, the communication interface 603 may include a display screen (Display) and a keyboard (Keyboard). Optionally, the communication interface 603 may further include a standard wired interface and a wireless interface. The memory 604 may be a high-speed RAM memory (Random Access Memory), or a non-volatile memory, such as at least one disk memory. Optionally, the memory 604 may further be at least one storage device located far from the aforementioned processor 601. Among them, the processor 601 may be combined with Figure 7 the device described, and an application program is stored in the memory 604, and the processor 601 calls the program code stored in the memory 604 to execute any of the above method steps.

[0146] Among them, the communication bus 602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus 602 may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 8 only a thick line is shown in

[0147] Among them, the memory 604 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 604 may further include a combination of the above types of memories.

[0148] Among them, the processor 601 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and an NP.

[0149] Among them, the processor 601 may further include a hardware chip. The above hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0150] Optionally, the memory 604 is further configured to store program instructions. The processor 601 may call the program instructions to implement the data migration method of the virtual machine as shown in the embodiments of the present application.

[0151] An embodiment of the present invention also provides a non-transitory computer storage medium, which stores computer-executable instructions that can execute the data migration method of a virtual machine in any of the above method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memories.

[0152] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims

1. A method for data migration of a virtual machine, characterized in that, The method includes: Obtain a target service and bind the target service to a specified virtual processor, where the specified virtual processor is in a virtual machine; In response to a data migration instruction, control the virtual machine to perform data migration; When the virtual machine is performing data migration, limit the running speed of the specified virtual processor. When the running speed reaches a preset speed, adjust the first step length to a second step length. The preset speed is obtained by limiting the running speed based on the first step length, and the second step length is less than the first step length; Limit the running speed based on the second step length to complete the data migration; The limiting the running speed of the specified virtual processor and, when the running speed reaches the preset speed, adjusting the first step length to the second step length includes: Obtain the number of dirty pages of the virtual machine during data migration, and determine whether it is necessary to limit the running speed of the virtual machine according to the number of dirty pages; When it is necessary to limit the running speed of the virtual machine, in response to a speed limit instruction, limit the running speed of the specified virtual processor based on the first step length; When the running speed of the specified virtual processor reaches the preset speed, adjust the first step length to the second step length, where the second step length is less than the first step length.

2. The method according to claim 1, characterized in that, The obtaining the target service and binding the target service to the specified virtual processor includes: Obtain the memory usage of the services on the virtual machine, and determine whether the memory usage of the service exceeds a specified memory threshold; When the memory usage exceeds the specified memory threshold, determine the service as the target service and bind the target service to the specified virtual processor.

3. The method according to claim 2, wherein The binding the target service to the specified virtual processor includes: When the target service starts, in response to a binding instruction for the service, bind the target service to the specified virtual processor.

4. The method according to claim 2, characterized in that The binding the target service to the specified virtual processor includes: After the target service starts, in response to a process query instruction for the service, determine the process corresponding to the service; In response to a binding instruction for the process, bind the process to the specified virtual processor.

5. The method according to claim 1, characterized in that, The obtaining the number of dirty pages of the virtual machine during data migration and determining whether it is necessary to limit the running speed of the virtual machine according to the number of dirty pages includes: Obtain the number of dirty pages and the amount of data that has been migrated during data migration of the virtual machine, compare the number of dirty pages with the amount of data that has been migrated, and obtain a comparison result; Judge whether it is necessary to limit the running speed of the virtual machine according to the comparison result.

6. The method according to claim 1, wherein The limiting the running speed based on the second step length to complete the data migration includes: When the running speed of the specified virtual processor reaches the preset speed, limit the running speed based on the second step length; Perform data migration based on the limited running speed and obtain the amount of data to be migrated; Compare the amount of data to be migrated with the data migration threshold. When the amount of data to be migrated is less than the data migration threshold, stop restricting the running speed to complete the data migration.

7. A data migration device for a virtual machine, characterized in that It includes: A service binding module, configured to obtain a target service and bind the target service to a specified virtual processor, where the specified virtual processor is in a virtual machine; A data migration module, configured to control the virtual machine to perform data migration in response to a data migration instruction; A first speed limit module, configured to limit the running speed of the specified virtual processor when the virtual machine is performing data migration. When the running speed reaches a preset speed, adjust the first step length to a second step length. The preset speed is obtained by limiting the running speed based on the first step length, and the second step length is less than the first step length; A second speed limit module, configured to limit the running speed based on the second step length to complete the data migration; The first speed limit module includes: A speed limit judgment sub-unit, configured to obtain the number of dirty pages during the data migration process of the virtual machine and judge whether it is necessary to limit the running speed of the virtual machine according to the number of dirty pages; A first speed limit sub-unit, configured to limit the running speed of the specified virtual processor based on the first step length in response to a speed limit instruction when it is necessary to limit the running speed of the virtual machine; A step length adjustment sub-unit, configured to adjust the first step length to a second step length when the running speed of the specified virtual processor reaches the preset speed, and the second step length is less than the first step length.

8. An electronic device, characterized in that, It includes: A memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to execute the data migration method of the virtual machine according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the data migration method of the virtual machine according to any one of claims 1-6.

Citation Information

Patent Citations

  • Virtual machine migration method and device

    CN103218260A