A virtual machine migration method, device, equipment and storage medium
By binding processes to the current CPU before the virtual machine migration task and merging the CPU, the problem of waste of CPU resources and increasing time-consuming migration tasks during the virtual machine migration process is solved, and more efficient migration task execution is achieved.
Patent Information
- Application Number
- CN202111145329.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-09-28
AI Technical Summary
During the virtual machine migration process, the existing technology requires the reservation of part of the CPU resources of the host for migration tasks, resulting in waste of resources and increased time-consuming migration tasks.
Before the host performs a virtual machine migration task, determine the target process that currently uses CPU resources and binds all processes to the CPU currently used by the process. It is determined whether the number of spare CPUs is less than the first predetermined threshold. If so, the target process using different CPUs will be merged to the same CPU and the virtual machine migration task will be continued.
Without affecting the operation of other processes, improve the running speed of virtual machine migration tasks and avoid wasting host CPU resources.
Smart Images

Figure CN113835841B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual machine migration, and more specifically, to a virtual machine migration method, device, equipment and storage medium. Background Art
[0002] In the daily maintenance of the virtualization platform, the life cycle management of virtual machines is often involved, including the startup, suspension, recovery, shutdown, snapshot, migration, etc. of virtual machines; among them, the proportion of migration is very high. This is because in the daily maintenance of virtual machines, due to improper early resource planning, too many virtual machines are often run on one host, causing competition between the host CPU (central processing unit), memory and storage resources, affecting the normal use of virtual machines. At this time, it is necessary to rely on the migration function to manually migrate some virtual machines to hosts with less resource pressure, or rely on the Distributed Resource Scheduler (DRS) to automatically migrate virtual machines in the cluster to achieve the purpose of balanced use of CPU and memory resources between clusters.
[0003] Migration is divided into online computing migration, online storage migration, online computing plus storage migration and offline storage migration. Among them, online computing migration, online storage migration and online computing plus storage migration are the most commonly used migration methods in migration operations. All three involve online migration, that is, when the virtual machine is in the power-on state and there is no internal perception, the memory and storage of the virtual machine are migrated to other hosts and storage pools. The online migration task will occupy part of the CPU resources according to the size and occupation of the virtual machine memory and the usage of the virtual disk. If the resource planning is improper, the migration task and other processes on the host (such as virtual machine processes, virtualization management processes, etc.) may compete for resources, resulting in an increase in the time consumption of the migration task and an increase in the probability of problems during the migration process. To address this problem, virtualization vendors will reserve a part of the CPU resources of the host for exclusive use by the migration task. This method greatly reduces the impact of the migration task on other processes of the host. However, if the host does not have a migration task, the reserved part of the CPU resources will still not be released for use by other processes, resulting in a waste of the host CPU resources. Therefore, how to improve the running speed of the virtual machine migration task and avoid the waste of the host CPU resources without affecting the running of other processes is a problem that technicians in this field need to solve. Summary of the invention
[0004] The purpose of the present invention is to provide a virtual machine migration method, device, equipment and storage medium to improve the running speed of the virtual machine migration task without affecting the running of other processes and avoid wasting the host CPU resources.
[0005] To achieve the above object, the present invention provides a virtual machine migration method, comprising:
[0006] Before the host performs a virtual machine migration task, it determines the target process currently using CPU resources and binds all processes to the CPU currently used by the process.
[0007] Determining whether the number of free CPUs is less than a first predetermined threshold;
[0008] If yes, the target processes using different CPUs are merged into the same CPU, and the step of determining whether the number of free CPUs is less than the first predetermined threshold is continued;
[0009] The virtual machine migration task is executed by utilizing the spare CPU, and after the execution of the virtual machine migration task is completed, the binding relationship between all processes and the CPU is released.
[0010] The step of determining the target process currently using CPU resources includes:
[0011] Determine the CPU resource usage of each process currently in the host;
[0012] The process whose CPU resource usage is greater than the second predetermined threshold is taken as the target process.
[0013] The step of merging target processes using different CPUs into the same CPU includes:
[0014] Determine the target number according to the first predetermined threshold and the number of free CPUs;
[0015] The target processes using different CPUs are merged into the same CPU so that the number of newly added free CPUs after the merger is the target number.
[0016] The step of merging target processes using different CPUs into the same CPU includes:
[0017] Determine the type of each target process; the types include: virtual machine process, host key service process and host other process;
[0018] Determining priority information of the virtual machine migration task;
[0019] According to the priority information and the type of each target process, target processes using different CPUs are merged into the same CPU.
[0020] The step of merging target processes using different CPUs into the same CPU according to the priority information and the type of each target process includes:
[0021] If the priority information is low, other host processes using different CPUs will be merged into the same CPU; if the priority information is medium, the host key service processes and other host processes using different CPUs will be merged into the same CPU; if the priority information is high, all target processes using different CPUs will be merged into the same CPU.
[0022] The step of merging other processes of the host using different CPUs into the same CPU includes: determining processes to be merged whose CPU usage is lower than a third predetermined threshold from other processes of the host; and merging the processes to be merged using different CPUs into the same CPU.
[0023] If, after merging the target processes using different CPUs into the same CPU, the number of free CPUs is still less than the first predetermined threshold, the virtual machine migration method further includes: generating prompt information indicating insufficient CPU resources.
[0024] To achieve the above object, the present invention further provides a virtual machine migration device, comprising:
[0025] A process determination module is used to determine the target process currently using CPU resources before the host executes the virtual machine migration task;
[0026] The binding module is used to bind all processes to the CPU currently used by the process;
[0027] A judging module, used to judge whether the number of free CPUs is less than a first predetermined threshold;
[0028] a merging module, configured to merge target processes using different CPUs into the same CPU when the number of free CPUs is less than a first predetermined threshold, and continue to trigger the judgment module;
[0029] An execution module, used to use the spare CPU to execute the virtual machine migration task;
[0030] The unbinding module is used to unbind all processes from the CPU after the virtual machine migration task is completed.
[0031] To achieve the above object, the present invention further provides an electronic device, comprising:
[0032] Memory for storing computer programs;
[0033] A processor is used to implement the steps of the above-mentioned virtual machine migration method when executing the computer program.
[0034] To achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above virtual machine migration method are implemented.
[0035] It can be seen from the above scheme that a virtual machine migration method provided by an embodiment of the present invention includes: before the host executes the virtual machine migration task, determining the target process currently using CPU resources, and binding all processes to the CPU currently used by the process; judging whether the number of free CPUs is less than a first predetermined threshold; if so, merging the target processes using different CPUs into the same CPU, and continuing to execute the step of judging whether the number of free CPUs is less than the first predetermined threshold; using the free CPU to execute the virtual machine migration task, and after the execution of the virtual machine migration task is completed, releasing the binding relationship between all processes and the CPU. It can be seen that when executing the virtual machine migration task, this scheme does not need to reserve some CPU resources. It only needs to bind all processes to the CPU currently used by the process, and then determine whether the number of free CPUs is less than the first predetermined threshold. If so, the virtual machine migration task is directly executed; otherwise, after merging qualified targets, the CPU is freed up for use exclusively by the virtual machine migration task. In this way, the virtual machine migration task can monopolize some CPU resources during operation, and the binding relationship between all processes and the CPU can be released after the task is completed, so that the scheme can improve the running speed of the virtual machine migration task without affecting the operation of other processes, thereby avoiding the waste of host CPU resources. The present invention also discloses a virtual machine migration device, equipment and storage medium, which can also achieve the above-mentioned effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 A schematic diagram of a virtual machine migration method disclosed in an embodiment of the present invention;
[0038] Figure 2 A schematic diagram of the structure of a virtual machine migration device disclosed in an embodiment of the present invention;
[0039] Figure 3 The present invention is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] The embodiment of the present invention discloses a virtual machine migration method, device, equipment and storage medium, so as to improve the running speed of the virtual machine migration task without affecting the running of other processes and avoid the waste of host CPU resources.
[0042] See also Figure 1 , a flow chart of a virtual machine migration method provided by an embodiment of the present invention includes:
[0043] S101, before the host executes the virtual machine migration task, determine the target process currently using CPU resources, and bind all processes to the CPU currently used by the process;
[0044] It should be noted that this solution does not require pre-reservation of CPU resources specifically for virtual machine migration tasks. Therefore, before executing the virtual machine migration task, this solution first needs to monitor the CPU usage of all processes on the host and capture the target process that is using CPU resources. Specifically, when capturing the target process, this solution does not need to capture all processes. If the CPU resource usage of the captured process is too small, it will cause a lot of time to be spent in process merging. Therefore, in this solution, after determining the CPU resource usage of each process on the host, only the process whose CPU resource usage is greater than the second predetermined threshold is used as the target process. Among them, the second predetermined threshold can be customized according to the actual situation. In this embodiment, the second predetermined threshold can be set to 5%, that is, only the process whose CPU resource usage exceeds 5% can be used as the target process and participate in the subsequent process merging process.
[0045] It can be understood that in order to provide CPU resources specifically for executing virtual machine migration tasks, this solution can also bind all host processes to the current CPU core after determining the host's processes. That is, after binding the processes to the CPU, the host's CPU scheduling can be put in a "static" state, and the processes can no longer be scheduled to other CPUs, thereby ensuring that the free CPU is specifically used to execute virtual machine migration tasks. After the migration is completed, the CPU binding of all processes is released, and the "static" state of CPU scheduling is stopped. In this way, the running speed of the virtual machine migration task can be improved.
[0046] S102, determining whether the number of free CPUs is less than a first predetermined threshold; if so, executing S103; if not, executing S104;
[0047] It should be noted that, before the migration task starts, the scheme first needs to set a first predetermined threshold value N, which is the number of CPUs pre-set for executing the virtual machine migration task, and then determine whether the number of currently available CPUs is less than the first predetermined threshold value. If the number of currently available CPUs is not less than the first predetermined threshold value, the available CPUs are directly used to execute the virtual machine migration task. If the number of currently available CPUs is less than the first predetermined threshold value, it means that there are not enough available CPUs to execute the migration task, which will cause the migration task to run slowly. Therefore, in this scheme, it is necessary to merge the target processes using different CPUs into the same CPU, so as to free up more CPUs for executing the virtual machine migration task. Among them, the first predetermined threshold value N can be set according to the actual situation. In this embodiment, the first predetermined threshold value N can be set to the minimum value of 4 and 10% of the total number of host CPUs. For example, if the host has 16 CPUs, then 10% of the total number of host CPUs is 1.6, which is rounded up to 2<4, so N is 2, and then determine whether the number of available CPUs is less than 2. If it is less than 2, S103 is executed, and if it is not less than 2, S104 is executed.
[0048] S103, merging target processes using different CPUs into the same CPU, and continuing to execute S102;
[0049] In this embodiment, when merging target processes using different CPUs into the same CPU, the target number can be first determined based on the first predetermined threshold and the number of free CPUs, and then the target processes using different CPUs can be merged into the same CPU so that the number of free CPUs newly added after the merger is the target number. For example: the first predetermined threshold is 4, the number of free CPUs is 3, and the target number is 1, that is, only 1 free CPU needs to be merged to meet the execution requirements of the virtual machine migration task. If the first target process uses CPU1 and the second target process uses CPU2, then the first target process and the second target process only need to be merged into the same CPU. For example: the first target process can be merged into CPU2, and then the first target process is bound to CPU2, and the second target process does not need to be changed. At this time, CPU1 is a free CPU and can be used to execute the virtual machine migration task.
[0050] S104: Utilize the spare CPU to execute the virtual machine migration task, and after the virtual machine migration task is completed, release the binding relationship between all processes and the CPU.
[0051] In this embodiment, after merging the target processes using different CPUs into the same CPU, it is necessary to determine whether the number of free CPUs is less than the first predetermined threshold. If the number of free CPUs is still less than the first predetermined threshold at this time, it means that after the process merging, there are still not enough CPUs available to execute the virtual machine migration task. At this time, a prompt message of insufficient CPU resources can be generated. The prompt message is used to prompt the user that the CPU resources are insufficient, the migration task becomes slow, and a certain amount of CPU resources need to be released before the migration task can continue to be executed.
[0052] In summary, it can be seen that when executing the virtual machine migration task, this solution does not need to reserve some CPU resources. It only needs to bind all processes to the CPU currently used by the process, and then determine whether the number of free CPUs is less than the first predetermined threshold. If so, the virtual machine migration task is executed directly. Otherwise, after merging the qualified targets, the CPU is freed up for the virtual machine migration task. In this way, the virtual machine migration task can monopolize some CPU resources during the running process, and then release the binding relationship between all processes and the CPU after the task is completed. This allows the solution to improve the running speed of the virtual machine migration task without affecting the running of other processes, thereby avoiding the waste of host CPU resources.
[0053] Based on the above embodiment, in this embodiment, when merging target processes using different CPUs into the same CPU, different types of target processes may be selected to perform the merging operation according to the priority of the virtual machine migration task. Therefore, in this embodiment, the merging specifically includes the following steps:
[0054] Determine the type of each target process; the type includes: virtual machine process, host key service process and other host processes; determine the priority information of the virtual machine migration task; and merge the target processes using different CPUs into the same CPU according to the priority information and the type of each target process.
[0055] Specifically, in this embodiment, the captured target processes can be divided into three categories: virtual machine processes are class I processes, host key service processes are class II processes, and other host processes are class III processes, where host key service processes include virtualization management processes, virtualization dependent processes, etc. In this solution, the priority information of the virtual machine migration task can be set by the user, and the priority information can be divided into high, medium, and low. If the user does not set it, the priority information of the virtual machine migration task is set to medium by default.
[0056] Furthermore, in this embodiment, if the priority information is low, other host processes using different CPUs will be merged into the same CPU; if the priority information is medium, the host key service processes and other host processes using different CPUs will be merged into the same CPU; if the priority information is high, all target processes using different CPUs will be merged into the same CPU. That is to say: this scheme can merge the CPU resources of the three types of processes of the host according to the priority of the migration task. When the priority of the migration task is low, only type III processes, that is, other processes of the host, can be merged, and then the processes to be merged whose CPU usage is lower than the third predetermined threshold value from other processes of the host are determined, and the processes to be merged using different CPUs are merged into the same CPU; the third predetermined threshold value can be customized according to actual conditions. In this embodiment, the third predetermined threshold value can be set to 50%, that is: in this embodiment, when merging other processes of the host, it is necessary to determine whether the CPU usage rate of other processes of the host exceeds 50%. If not, the two processes are merged into one CPU, thereby freeing up one CPU resource until the number of freed CPUs is not less than the first predetermined threshold value N; when the migration task is medium, all processes except type I virtual machine processes can be merged; when the migration task is high, all host processes can be merged until the free CPU resources meet the conditions.
[0057] It can be seen that in this solution, a virtual machine migration optimization solution based on static CPU scheduling is proposed. In this solution, it is necessary to capture the host process and classify the host process. Before the migration task starts, the CPU scheduling is static by binding the process to the CPU to determine whether the spare CPU meets the migration conditions. If not, the CPU of the process is merged according to the priority of the migration task, and finally the spare CPU is provided to the migration task. In this way, the execution of the migration task can be optimized to the maximum extent without affecting the host process as much as possible. Here, in order to clearly explain this solution, the overall process of this solution is explained through the following embodiments:
[0058] 1) When a migration task occurs, monitor the CPU usage of all processes on the host and capture the target process whose CPU resource usage exceeds 5%;
[0059] 2) The captured target processes are divided into three categories: virtual machine processes are Class I processes, host key service processes are Class II processes, and other host processes are Class III processes;
[0060] 3) The user can set the priority of the migration task, which is divided into high, medium and low. The default priority is medium.
[0061] 4) Bind all processes of the host to the current CPU core through cgroup, so that the CPU scheduling of the host is in a "static" state. For example, processes A, B, and C run on CPU logical cores 3, 7, and 9 respectively. When the CPU scheduling is set to the "static" state, processes A, B, and C are bound to 3, 7, and 9 respectively. At this time, until the migration task is completed, processes A, B, and C can only run on the corresponding bound CPU logical cores and cannot be scheduled to other CPUs;
[0062] 5) Before the migration task starts, determine whether there are free CPUs, and the number of free CPUs is not less than N (the value of N is: 4 or 10% of the total number of host CPUs, whichever is smaller); if it meets the requirements, then these N CPUs are directly allocated to the migration task, and all CPU binding states are released after the task is completed. For example: the host has 16 CPUs in total, then 10% is 1.6, which is rounded up to 2<4, so N is 2; then determine whether the free CPUs are not less than 2;
[0063] 6) If the above conditions are not met, the CPU resources of the three types of processes of the host are merged according to the priority of the migration task: when the migration task is low, only type III processes can be merged, that is, other processes of the host, such as processes D and E are type III processes and the utilization rates of both are less than 50%, process D runs on CPU No. 2, and process E runs on CPU No. 3, then process E is bound from CPU No. 3 to CPU No. 2, and CPU No. 3 is freed up for the migration task until the number of free CPUs is not less than 2; when the migration task is medium, all processes except type 1 virtual machine processes can be merged; when the migration task is high, all host processes can be merged until the free CPU resources are not less than 2.
[0064] 7) If sufficient CPU resources are still not available after step 6, the user is prompted that CPU resources are insufficient and the migration task is slow. Some CPU resources need to be released before the migration task can be continued. After re-execution, steps 1-6 will be repeated until the CPU resources meet the needs of the migration task.
[0065] 8) After the migration is completed, the CPU binding of all processes is released, that is, the "quiescent" state of CPU scheduling is stopped.
[0066] In summary, it can be seen that in this solution, if there is a migration task on the host, all processes on the host will be bound to the currently running CPU logical core, and classified according to the process type, and the CPU logical core being used by the process will be automatically adjusted, so as to free up some CPUs for use exclusively by the migration task. At this time, the CPU scheduling of all processes is in a "static" state; after the migration task is completed, the "static" state of the CPU scheduling of all processes is released, and they continue to be scheduled according to the system kernel CPU scheduling policy, so that the migration task monopolizes some CPU resources during operation, and releases them again after completion, reducing unnecessary waste of host CPU resources.
[0067] The following is an introduction to the migration apparatus, device and medium provided in the embodiments of the present invention. The migration apparatus, device and medium described below and the migration method described above can be referenced to each other.
[0068] See also Figure 2 , a schematic diagram of a virtual machine migration device provided by an embodiment of the present invention includes:
[0069] The process determination module 11 is used to determine the target process currently using CPU resources before the host executes the virtual machine migration task;
[0070] A binding module 12 is used to bind all processes to the CPU currently used by the process;
[0071] A judging module 13 is used to judge whether the number of free CPUs is less than a first predetermined threshold;
[0072] A merging module 14 is used to merge target processes using different CPUs into the same CPU when the number of free CPUs is less than a first predetermined threshold, and continue to trigger the judgment module;
[0073] An execution module 15 is used to use the spare CPU to execute the virtual machine migration task;
[0074] The unbinding module 16 is used to release the binding relationship between all processes and the CPU after the virtual machine migration task is completed.
[0075] The process determination module is specifically used to determine the CPU resource usage of each current process of the host, and take the process whose CPU resource usage is greater than a second predetermined threshold as the target process.
[0076] The merging module is used to determine the target number according to the first predetermined threshold and the number of free CPUs, and merge target processes using different CPUs into the same CPU so that the number of free CPUs added after the merger is the target number.
[0077] The merging module includes:
[0078] A first determination unit is used to determine the type of each target process; the type includes: virtual machine process, host key service process and host other process;
[0079] A second determining unit, configured to determine the priority information of the virtual machine migration task;
[0080] The merging unit is used to merge the target processes using different CPUs into the same CPU according to the priority information and the type of each target process.
[0081] Among them, the merging unit is specifically used to: if the priority information is low, other host processes using different CPUs will be merged into the same CPU; if the priority information is medium, the host key service processes and other host processes using different CPUs will be merged into the same CPU; if the priority information is high, all target processes using different CPUs will be merged into the same CPU.
[0082] The merging module is used to: determine the processes to be merged whose CPU usage is lower than a third predetermined threshold from other processes of the host; and merge the processes to be merged that use different CPUs into the same CPU.
[0083] The device further comprises:
[0084] The information generating module is used to generate a prompt message indicating insufficient CPU resources if the number of available CPUs is still less than the first predetermined threshold after merging target processes using different CPUs into the same CPU.
[0085] See also Figure 3 , a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention includes:
[0086] A memory 21, used for storing computer programs;
[0087] The processor 22 is used to implement the steps of the virtual machine migration method as described in the above method embodiment when executing the computer program.
[0088] In this embodiment, the device may be a PC (Personal Computer), or may be a terminal device such as a smart phone, a tablet computer, a PDA, or a portable computer.
[0089] The device may include a memory 21 , a processor 22 , and a bus 23 .
[0090] Among them, the memory 21 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 21 can be an internal storage unit of the device, such as a hard disk of the device. In other embodiments, the memory 21 can also be an external storage device of the device, such as a plug-in hard disk equipped on the device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 21 can also include both an internal storage unit of the device and an external storage device. The memory 21 can not only be used to store application software and various types of data installed in the device, such as program code for executing the migration method, etc., but also can be used to temporarily store data that has been output or is to be output.
[0091] In some embodiments, the processor 22 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 21, such as program codes for executing migration methods.
[0092] The bus 23 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0093] Furthermore, the device may also include a network interface 24, which may optionally include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the device and other electronic devices.
[0094] Optionally, the device may further include a user interface 25, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 25 may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the device and to display a visual user interface.
[0095] Figure 3 Only the device with components 21-25 is shown, and it can be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation of the device, and may include fewer or more components than shown, or combine certain components, or arrange the components differently.
[0096] The embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the virtual machine migration method described in the above method embodiment are implemented.
[0097] The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0098] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0099] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A virtual machine migration method, characterized in that: include: Before the host performs a virtual machine migration task, it determines the target process currently using CPU resources and binds all processes to the CPU currently used by the process. Determining whether the number of free CPUs is less than a first predetermined threshold; If yes, the target processes using different CPUs are merged into the same CPU, and the step of determining whether the number of free CPUs is less than the first predetermined threshold is continued; Utilize the spare CPU to execute the virtual machine migration task, and after the virtual machine migration task is completed, release the binding relationship between all processes and the CPU; The step of merging target processes using different CPUs into the same CPU includes: Determine the type of each target process; the types include: virtual machine process, host key service process and host other process; Determining priority information of the virtual machine migration task; According to the priority information and the type of each target process, the target processes using different CPUs are merged into the same CPU; The step of merging target processes using different CPUs into the same CPU according to the priority information and the type of each target process includes: If the priority information is low, other host processes using different CPUs are merged into the same CPU; if the priority information is medium, key service processes and other host processes using different CPUs are merged into the same CPU; if the priority information is high, all target processes using different CPUs are merged into the same CPU; The process of merging other processes of the host using different CPUs to the same CPU includes: Determine, from other processes on the host, a process to be merged whose CPU usage is lower than a third predetermined threshold; Merge the processes to be merged that use different CPUs to the same CPU.
2. The virtual machine migration method according to claim 1, characterized in that: The step of determining the target process currently using CPU resources includes: Determine the CPU resource usage of each process currently in the host; The process whose CPU resource usage is greater than the second predetermined threshold is taken as the target process.
3. The virtual machine migration method according to claim 1, characterized in that: The step of merging target processes using different CPUs into the same CPU includes: Determine the target number according to the first predetermined threshold and the number of free CPUs; The target processes using different CPUs are merged into the same CPU so that the number of newly added free CPUs after the merger is the target number.
4. The virtual machine migration method according to any one of claims 1 to 3, characterized in that: If the number of free CPUs is still less than the first predetermined threshold after the target processes using different CPUs are merged into the same CPU, the virtual machine migration method further includes: Generates a prompt message indicating insufficient CPU resources.
5. A virtual machine migration device, characterized in that: include: A process determination module is used to determine the target process currently using CPU resources before the host executes the virtual machine migration task; The binding module is used to bind all processes to the CPU currently used by the process; A judging module, used to judge whether the number of free CPUs is less than a first predetermined threshold; a merging module, configured to merge target processes using different CPUs into the same CPU when the number of free CPUs is less than a first predetermined threshold, and continue to trigger the judgment module; An execution module, used to use the spare CPU to execute the virtual machine migration task; The unbinding module is used to unbind all processes from the CPU after the virtual machine migration task is completed; The step of merging target processes using different CPUs into the same CPU includes: Determine the type of each target process; the types include: virtual machine process, host key service process and host other process; Determining priority information of the virtual machine migration task; According to the priority information and the type of each target process, the target processes using different CPUs are merged into the same CPU; The step of merging target processes using different CPUs into the same CPU according to the priority information and the type of each target process includes: If the priority information is low, other host processes using different CPUs are merged into the same CPU; if the priority information is medium, key service processes and other host processes using different CPUs are merged into the same CPU; if the priority information is high, all target processes using different CPUs are merged into the same CPU; The process of merging other processes of the host using different CPUs to the same CPU includes: Determine, from other processes on the host, a process to be merged whose CPU usage is lower than a third predetermined threshold; Merge the processes to be merged that use different CPUs to the same CPU.
6. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the virtual machine migration method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the virtual machine migration method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Dynamic migration method and device for virtual machines
CN107168786A
Method, apparatus and device for migrating virtual machine
CN109213566A