A method, device, equipment and storage medium for hot migration of virtual machines
By migrating virtual machines on the same host and using identity identifiers and identification codes to generate pipe files, memory data can be directly migrated, solving the problem of network bandwidth and CPU resource constraints in virtual machine hot migration and achieving efficient virtual machine migration.
Patent Information
- Application Number
- CN202010740700.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-28
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-07-28
AI Technical Summary
Existing virtual machine hot migration technology is prone to failure when CPU resources are scarce or busy, and network bandwidth becomes a bottleneck for migration, leading to migration failure or delay, especially in CPU and I/O intensive virtual machines.
Virtual machine migration on the same host is performed by generating pipe files through the assignment of identity identifiers and processed identification codes, directly migrating memory data and avoiding cross-host disk data transfer. The virtual machine manager is used for identification and communication management.
It enables virtual machines to be migrated across hosts without needing to migrate them, only copying memory data, which greatly shortens migration time and avoids network bandwidth pressure and CPU resource consumption.
Smart Images

Figure CN114003335B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of virtualization technology, and in particular to a method, device, equipment and storage medium for hot migration of a virtual machine. Background Art
[0002] In the current wave of mobile Internet and Internet of Everything, data migration to the cloud has been in full swing for both enterprises and individuals. In the cloud environment, the hot migration technology of virtual machines is very complex and is also a frequently used technology. Usually, this technology is mainly used for load balancing, failover, version upgrades, and vulnerability repairs. However, the current hot migration technology of virtual machines is limited to remote migration, that is, migrating the virtual machine to be migrated from one physical server to another remote physical server. The problem is that on the one hand, all the data of the virtual machine must be transmitted through the network, which puts a lot of pressure on the online network bandwidth; on the other hand, the busy virtual machine continuously generates a large amount of data, and when the network bandwidth becomes the bottleneck of migration, the virtual machine migration fails because the data cannot be transmitted. For the above two situations, the current mainstream approach is: Solution 1, compressing the data to be transmitted. The approach of this solution is to compress the data before entering the network for transmission, reduce the size of the data transmitted in the network to improve the transmission efficiency, and thus improve the success rate of virtual machine hot migration. Solution 2: Reduce the data generation rate. This solution aims to slow down the generation of new data by reducing the CPU submission running time of the virtual machine, thereby reducing the amount of data transmitted over the network and improving the success rate of hot migration.
[0003] However, for solution 1, since the compression process itself requires extra time, and compression is a computationally intensive operation, which consumes a lot of CPU resources, if the CPU resources of the current virtual machine are already tight or overloaded, then this solution will undoubtedly make things worse. For solution 2, since it is necessary to reduce the submission running time of the virtual machine CPU to reduce data generation, this solution will gradually make the virtual machine unavailable if the hot migration fails, and will be accompanied by problems such as great delays and packet loss in input / output (IO) requests. Therefore, it cannot be used well for CPU and IO intensive virtual machines. There is currently no effective solution to this problem. Summary of the invention
[0004] In view of this, embodiments of the present invention are intended to provide a method, apparatus, device and storage medium for hot migration of a virtual machine.
[0005] The technical embodiment of the embodiment of the present invention is implemented as follows:
[0006] An embodiment of the present invention provides a method for hot migration of a virtual machine, the method comprising:
[0007] Determine a virtual machine to be migrated and a target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; obtain a first identification file of the virtual machine to be migrated; identify the virtual machine to be migrated according to the first name and the first identification code of the first identification file; assign an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; determine a second identification file of the target virtual machine based on the first name, the identity and the second identification code; identify the target virtual machine according to the second name and the second identification code of the second identification file; generate a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; obtain a migration instruction, and migrate the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction.
[0008] In the above solution, the step of determining the virtual machine to be migrated and the target virtual machine includes:
[0009] The virtual machine to be migrated and a first device simulator of the virtual machine to be migrated are obtained; the first device simulator is uninstalled and a second device simulator is installed based on the obtained operation instruction; and the target virtual machine is created according to the second device simulator.
[0010] In the above solution, the method further includes:
[0011] A second pipe file is determined based on the first name; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively; the third pipe file is determined based on the second name; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively.
[0012] In the above solution, the determining the second identification file of the target virtual machine based on the first name, the identity identifier and the second identification code includes:
[0013] The second name is determined based on the first name and the identity identifier; and the second identification file is determined based on the second name and the second identification code.
[0014] In the above solution, the method further includes:
[0015] Register the second identification file to the management table of the host; create a second resource file of the target virtual machine based on the second identification file and the first resource file of the virtual machine to be migrated; the first resource file includes at least one of the following: a log file, a structured tag file and a connection information file; access the first resource file according to the first name, and access the second resource file according to the second name.
[0016] In the above solution, after obtaining the migration instruction and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction, the method further includes:
[0017] The virtual machine to be migrated is deleted; and the second identification code is updated to the first identification code in the management table of the host.
[0018] An embodiment of the present invention provides a device for hot migration of a virtual machine, the device comprising: a determination unit, an acquisition unit, an allocation unit, a generation unit and a migration unit, wherein:
[0019] The determination unit is used to determine the virtual machine to be migrated and the target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; the acquisition unit is used to obtain a first identification file of the virtual machine to be migrated; and the virtual machine to be migrated is identified according to the first name and the first identification code of the first identification file; the allocation unit is used to allocate an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; the determination unit is also used to determine the second identification file of the target virtual machine based on the first name, the identity and the second identification code; and the target virtual machine is identified according to the second name and the second identification code of the second identification file; the generation unit is used to generate a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; the migration unit is used to obtain a migration instruction, and migrate the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction.
[0020] In the above scheme, the determination unit is also used to obtain the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated; uninstall the first device simulator and install the second device simulator based on the obtained operation instructions; and create the target virtual machine according to the second device simulator.
[0021] In the above scheme, the determination unit is also used to determine the second pipe file based on the first name; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively; the third pipe file is determined based on the second name; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively.
[0022] In the above solution, the determining unit is further used to determine a second name based on the first name and the identity identifier; and determine a second identification file of the target virtual machine according to the second name and the second identification code.
[0023] In the above solution, the device further includes: a registration unit, a creation unit and an access unit, wherein:
[0024] The registration unit is used to register the second identification file into the management table of the host; the creation unit is used to create the second resource file of the target virtual machine based on the second identification file registered by the registration unit and the first resource file of the virtual machine to be migrated; the first resource file includes at least one of the following: a log file, a structured tag file and a connection information file; the access unit is used to access the first resource file according to the first name, and to access the second resource file according to the second name.
[0025] In the above solution, the device further includes an updating unit, which is further used to delete the virtual machine to be migrated; and update the second identification code to the first identification code in the management table of the host.
[0026] An embodiment of the present invention provides a device for hot migration of a virtual machine, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements any step of the above-mentioned method when executing the program.
[0027] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any step of the above-mentioned method is implemented.
[0028] A method, apparatus, device and storage medium for hot migration of a virtual machine provided by an embodiment of the present invention, which includes: determining a virtual machine to be migrated and a target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; obtaining a first identification file of the virtual machine to be migrated; identifying the virtual machine to be migrated according to a first name and a first identification code of the first identification file; assigning an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; determining a second identification file of the target virtual machine based on the first name, the identity and the second identification code; identifying the target virtual machine according to the second name and the second identification code of the second identification file; obtaining a migration instruction, and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction. The technical solution of the embodiment of the present invention is adopted, by allocating an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; the second identification file of the target virtual machine is determined based on the first name, the identity and the second identification code; a first pipe file between the virtual machine to be migrated and the target virtual machine is generated based on the first identification file and the second identification file; a migration instruction is obtained, and the memory data of the virtual machine to be migrated is migrated to the target virtual machine through the first pipe file based on the migration instruction; the migration of virtual machines on the same host is realized, without the need to migrate virtual machines across hosts, and in non-sharing scenarios, there is no need to transmit disk data, only copy memory data, which can greatly shorten the migration time. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 A schematic diagram of a method for hot migration of a virtual machine according to an embodiment of the present invention;
[0030] Figure 2 A schematic diagram of the architecture of a virtual machine manager managing a virtual machine to be migrated and a target virtual machine in a method for hot migration of a virtual machine according to an embodiment of the present invention;
[0031] Figure 3 A schematic diagram of an application scenario of a virtual machine hot migration method according to an embodiment of the present invention;
[0032] Figure 4 A schematic diagram of the structure of a device for hot migration of a virtual machine according to an embodiment of the present invention;
[0033] Figure 5 The present invention is a schematic diagram of a hardware entity structure of a device for hot migration of a virtual machine in an embodiment of the present invention. DETAILED DESCRIPTION
[0034] To make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the specific technical solution of the invention will be further described in detail below in conjunction with the drawings in the embodiments of the present invention. The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0035] This embodiment proposes a method for hot migration of a virtual machine. The method is applied to a device for hot migration of a virtual machine. The function implemented by the method can be implemented by calling a program code by a processor in the device for hot migration of the virtual machine. Of course, the program code can be stored in a computer storage medium. It can be seen that the computing device at least includes a processor and a storage medium. Figure 1 FIG. 1 is a flow chart of a method for implementing hot migration of a virtual machine according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0036] Step S101: Determine a virtual machine to be migrated and a target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host.
[0037] In an embodiment of the present invention, the virtual machine to be migrated and the target virtual machine are located on the same host; wherein the same host can be understood as the same physical machine (host), also known as the same node. Determining the virtual machine to be migrated and the target virtual machine can be determining the virtual machine to be migrated and the target virtual machine on the same physical machine, that is, an environment where the virtual machine to be migrated and the target virtual machine coexist on the same physical machine. Determining the virtual machine to be migrated and the target virtual machine on the same physical machine can be first obtaining the virtual machine to be migrated on the same physical machine, and then creating the target virtual machine. As an example, the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated can be obtained; the first device simulator is uninstalled and the second device simulator is installed based on the obtained operation instruction; the target virtual machine is created according to the second device simulator; wherein the virtual machine to be migrated can be an old version or a low version of the virtual machine; the target virtual machine can be a new version or a high version of the virtual machine; the first device simulator can be an old version or a low version of the virtual machine device simulator, also known as an old version or a low version of Qemu; the second device simulator can be a new version or a high version of the virtual machine device simulator, also known as a new version or a high version of Qemu or a high version of Qemu; the purpose of determining the virtual machine to be migrated and the target virtual machine on the same physical machine can be to upgrade the old version or a low version of the virtual machine to a new version or a high version of the virtual machine. There is a virtual machine manager (Libvirt) on the same physical machine, and the old version or a low version of the virtual machine and the old version or a low version of Qemu can be obtained; based on the user's operation instruction, the old version or a low version of Qemu is uninstalled and the new version or a high version of Qemu is installed; the target virtual machine is created according to the new version or a high version of Qemu; that is, an environment where new and old versions of virtual machines coexist on the same host.
[0038] Step S102: obtaining a first identification file of the virtual machine to be migrated; and identifying the virtual machine to be migrated according to a first name and a first identification code of the first identification file.
[0039] In this embodiment, a first identification file of the virtual machine to be migrated is obtained; wherein the first identification file can be understood as a household register of the virtual machine to be migrated, and is used to identify the virtual machine to be migrated and access the virtual machine to be migrated.
[0040] The virtual machine to be migrated is identified according to the first name and the first identification code of the first identification file; wherein, the first name may be the name (Name) of the virtual machine to be migrated, based on which the user can distinguish different virtual machines on the same host; the first identification code may be the universally unique identifier (Universally Unique Identifier, Uuid) of the virtual machine to be migrated, based on which the machine can distinguish different virtual machines on the same host; generally, for the user, the same Name corresponds to the same virtual machine, and for the machine, the same Uuid corresponds to the same virtual machine.
[0041] In actual applications, if there are two identical virtual machines on the same host, that is, the Name and UUID of the two virtual machines are exactly the same, the virtual machine manager (Libvirt) on the host does not support the migration of the two virtual machines on the host, mainly because it cannot distinguish the virtual machines and access paths on the same host.
[0042] Step S103: assigning an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner.
[0043] In this embodiment, an identity identifier and a second identifier are assigned to the target virtual machine; wherein the identity identifier is an identifier different from the name and the identifier, but can be combined with the name to name different virtual machines; the second identifier is obtained by processing the first identifier in a preset manner; wherein the preset manner may be to hide the first identifier, and the hiding may be understood as a mapping relationship, that is, there is a certain correspondence between the second identifier and the first identifier; as an example, when the first identifier is Uuid, the second identifier may be Shaduuid. In the subsequent migration stage, Libvirt can control the virtual machine to be migrated through Uuid, and control the target virtual machine through Shaduuid; in the subsequent migration completion stage, the virtual machine to be migrated can be deleted, and Shaduuid can be replaced with Uuid.
[0044] Step S104: determining a second identification file of the target virtual machine based on the first name, the identity identifier and the second identification code; and identifying the target virtual machine according to the second name and the second identification code of the second identification file.
[0045] In this embodiment, the second identification file of the target virtual machine is determined based on the first name, the identity and the second identification code; wherein the second identification file can be understood as the household registration book of the target virtual machine, which is used to identify the target virtual machine and access the target virtual machine. As an example, the second identification file of the target virtual machine determined based on the first name, the identity and the second identification code can be determined based on the first name and the identity to determine the second name; the second identification file of the target virtual machine is determined according to the second name and the second identification code; wherein, the second name determined based on the first name and the identity can be combined with the first name and the identity to obtain the combination name of the first name and the identity as the second name, for example, the first name is Name, the identity is ID, then the second name can be ID-Name; the second identification file of the target virtual machine determined according to the second name and the second identification code can be determined according to ID-Name and Shaduuid to determine the second identification file of the target virtual machine, in other words, the second identification file includes ID-Name and Shaduuid, and the target virtual machine is identified according to ID-Name and Shaduuid.
[0046] Step S105: generating a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file.
[0047] In this embodiment, a first pipe file is generated between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; wherein, the first pipe file may be a socket file, which is used to realize communication between virtual machines on the same host, also known as inter-process communication (Unix domain socket). As an example, the first pipe file may be a Unix.socket file.
[0048] As an example, generating the first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file may be identifying the virtual machine to be migrated based on the first identification file; identifying the target virtual machine based on the second identification file; and generating the first pipe file between the virtual machine to be migrated and the target virtual machine. Specifically, the second pipe file may be determined based on the first name of the first identification file; the second pipe file is used to communicate with the virtual machine to be migrated to identify the virtual machine to be migrated; the third pipe file may be determined based on the second name of the second identification file; the third pipe file is used to communicate with the target virtual machine to identify the target virtual machine; and then the first pipe file may be generated between the virtual machine to be migrated and the target virtual machine; wherein the second pipe file and the third pipe file may both be socket files, which are used to implement inter-process communication on the same host and can send or receive data. As an example, the second pipeline file determined according to the first identification file can be the second socket file under the specified path of the first monitor (monitor) determined according to the first identification file, which can be recorded as the monitor.sock file corresponding to the virtual machine to be migrated, that is, the second pipeline file, which can communicate with the virtual machine to be migrated to identify the virtual machine to be migrated, and the second socket file is closely related to the first name in the first identification file; the first monitor is the monitor of the virtual machine to be migrated; the third pipeline file determined according to the second identification file can be the third socket file under the specified path of the second monitor (monitor) determined according to the second identification file, which can be recorded as the monitor.sock file corresponding to the target virtual machine, that is, the third pipeline file, which can communicate with the target virtual machine to identify the target virtual machine, and the third socket file is closely related to the second name in the second identification file; the second monitor is the monitor of the target virtual machine; after identifying the virtual machine to be migrated and the target virtual machine, it is convenient to generate the first pipeline file between the virtual machine to be migrated and the target virtual machine.
[0049] Step S106: obtaining a migration instruction, and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction.
[0050] In this embodiment, the migration instruction may be a migration instruction input by a user; and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction may be sending a migration instruction to the virtual machine to be migrated, and controlling the memory data of the virtual machine to be migrated to be migrated to the target virtual machine through the first pipe file. As an example, Libvirt controls sending the migration instruction to the virtual machine based on the obtained migration instruction, and controls the memory data of the virtual machine to be migrated to be migrated to the target virtual machine through the first pipe file.
[0051] The method for hot migration of a virtual machine provided in an embodiment of the present invention is achieved by assigning an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; the second identification file of the target virtual machine is determined based on the first name, the identity and the second identification code; a first pipe file between the virtual machine to be migrated and the target virtual machine is generated based on the first identification file and the second identification file; a migration instruction is obtained, and the memory data of the virtual machine to be migrated is migrated to the target virtual machine through the first pipe file based on the migration instruction; the migration of virtual machines on the same host is realized, and there is no need to migrate virtual machines across hosts. In a non-shared scenario, there is no need to transmit disk data, and only memory data is copied, which can greatly shorten the migration time.
[0052] In an optional embodiment of the present invention, determining the virtual machine to be migrated and the target virtual machine includes: obtaining the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated; uninstalling the first device simulator and installing the second device simulator based on the obtained operation instructions; and creating the target virtual machine according to the second device simulator.
[0053] In an embodiment of the present invention, the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated are obtained; wherein, the first device simulator can be an old or low version of a virtual machine device simulator, also called an old or low version of Qemu, and the virtual machine to be migrated is created based on an old or low version of Qemu to obtain an old or low version of the Qemu process.
[0054] Uninstall the first device simulator and install the second device simulator based on the obtained operation instructions; wherein the operation instructions are instructions input by the user. As an example, the instructions may be command lines, which may indicate corresponding operations; the second device simulator may be a new or higher version of a virtual machine device simulator, also known as a new or higher version of Qemu.
[0055] Creating the target virtual machine according to the second device simulator can be to create a new version or a higher version of the virtual machine according to the new version or the higher version of Qemu to obtain the new version or the higher version of the Qemu process.
[0056] In actual applications, the virtual machine to be migrated can be an old version or a low version virtual machine, and the target virtual machine can be a new version or a high version virtual machine. The virtual machines stored on the physical machine are generally old version or low version virtual machines, and their activities will not be affected by the operation of uninstalling the old version or low version of Qemu. The virtual machine manager (Libvirt) on the physical machine will first obtain the old version or low version virtual machine and the corresponding old version or low version Qemu. When the user inputs an operation instruction, Libvirt will uninstall the old version or low version Qemu based on the operation instruction input by the user, and install the new version or high version Qemu, and create a new version or high version virtual machine on the same physical machine based on the new version or high version of Qemu, that is, an environment in which the virtual machine to be migrated and the target virtual machine coexist on the same physical machine is realized, preparing for the subsequent upgrading of the old version or low version virtual machine to a new version or high version virtual machine.
[0057] In an optional embodiment of the present invention, determining the second identification file of the target virtual machine based on the first name, the identity and the second identification code includes: determining the second name based on the first name and the identity; determining the second identification file of the target virtual machine based on the second name and the second identification code.
[0058] In an embodiment of the present invention, the second name is determined based on the first name and the identity identifier; wherein the first name may be a name (Name); and the identity identifier may be an identity document (ID). The second name is determined based on the first name and the identity identifier by combining the first name and the identity identifier to obtain a combined name of the first name and the identity identifier as the second name, for example, the second name may be ID-Name.
[0059] Determining the second identification file of the target virtual machine according to the second name and the second identification code can be understood as the second identification file of the target virtual machine including the second name and the second identification code; wherein, the second name can be ID-Name, the second identification code can be Shaduuid, and the second identification file of the target virtual machine can be understood as the household registration book of the target virtual machine.
[0060] In actual applications, Libvirt does not natively support the migration of virtual machines on the same node (physical host), and has imposed multiple restrictions for this purpose, mainly considering that two virtual machines with exactly the same Name and Uuid exist on the same node at the same time, and Libvirt cannot distinguish them. In this embodiment, the first name Name and the first identification code Uuid in the first identification file of the virtual machine to be migrated are kept unchanged on the same host, while the second name in the second identification file of the active target virtual machine is processed as ID-Name and the second identification code is processed as Shaduuid, so that Libvirt can distinguish the virtual machine to be migrated from the target virtual machine.
[0061] In an optional embodiment of the present invention, the generation of the first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file includes: identifying the virtual machine to be migrated based on the first identification file; identifying the target virtual machine based on the second identification file; and generating the first pipe file between the virtual machine to be migrated and the target virtual machine.
[0062] In this embodiment, the virtual machine to be migrated is identified based on the first identification file; the target virtual machine is identified based on the second identification file; the first pipe file between the virtual machine to be migrated and the target virtual machine is generated by determining the second pipe file based on the first name of the first identification file; the second pipe file is used to communicate with the virtual machine to be migrated to identify the virtual machine to be migrated; the third pipe file is determined based on the second name of the second identification file; the third pipe file is used to communicate with the target virtual machine to identify the target virtual machine; and then the first pipe file is generated between the virtual machine to be migrated and the target virtual machine; wherein the name of the second pipe file is closely related to the first name; as an example, the path and name of the second pipe file can be named in the form of Name; the name of the third pipe file is closely related to the second name. As an example, the name of the third pipe file can be named in the form of ID-Name; the second pipe file and the third pipe file can both be socket files, which are used to implement inter-process communication on the same host and can send or receive data. As an example, the second pipeline file determined according to the first identification file can be the second socket file under the specified path of the first monitor (monitor) determined according to the first identification file, which can be recorded as the monitor.sock file corresponding to the virtual machine to be migrated, that is, the second pipeline file, which can communicate with the virtual machine to be migrated to identify the virtual machine to be migrated, and the second socket file is closely related to the first name in the first identification file; the first monitor is the monitor of the virtual machine to be migrated; the third pipeline file determined according to the second identification file can be the third socket file under the specified path of the second monitor (monitor) determined according to the second identification file, which can be recorded as the monitor.sock file corresponding to the target virtual machine, that is, the third pipeline file, which can communicate with the target virtual machine to identify the target virtual machine, and the third socket file is closely related to the second name in the second identification file; the second monitor is the monitor of the target virtual machine; after identifying the virtual machine to be migrated and the target virtual machine, it is convenient to generate the first pipeline file between the virtual machine to be migrated and the target virtual machine.
[0063] In an optional embodiment of the present invention, the method also includes: determining a second pipe file based on the first name of the first identification file; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively; determining the third pipe file based on the second name of the second identification file; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively.
[0064] In this embodiment, the second pipe file is determined based on the first name of the first identification file; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively, and the second pipe file can be named based on the first name of the first identification file; the second pipe file can communicate with both the virtual machine to be migrated and the first device simulator; wherein the second pipe file can be a socket file that can send or receive data; the first device simulator can be an old or low version of Qemu. As an example, the second pipe file determined according to the first identification file can be a second socket file under the specified path of the first monitor (monitor) determined according to the first identification file, which can be recorded as the monitor.sock file corresponding to the virtual machine to be migrated, that is, the second pipe file, which can communicate with the virtual machine to be migrated to identify the virtual machine to be migrated, and the second socket file is closely related to the first name in the first identification file; the first monitor is the monitor of the virtual machine to be migrated.
[0065] The third pipe file is determined based on the second name of the second identification file; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively, and can be named based on the second name of the second identification file; the third pipe file can communicate with the target virtual machine and the second device simulator; wherein the third pipe file can be a socket file, which can send or receive data; the second device simulator can be a new version or a higher version of Qemu. As an example, the third pipe file determined according to the second identification file can be a third socket file under the specified path of the second monitor (monitor) determined according to the second identification file, which can be recorded as the monitor.sock file corresponding to the target virtual machine, that is, the third pipe file, which can communicate with the target virtual machine to identify the target virtual machine, and the third socket file is closely related to the second name in the second identification file; the second monitor is the monitor of the target virtual machine.
[0066] For ease of understanding, an architectural diagram of a virtual machine manager managing a virtual machine to be migrated and a target virtual machine in a method for hot migration of a virtual machine is illustrated here; Figure 2 FIG. 1 is a schematic diagram of an architecture of a virtual machine manager managing a virtual machine to be migrated and a target virtual machine in a method for hot migration of a virtual machine according to an embodiment of the present invention; Figure 2The virtual machine 21 to be migrated is located on a host 29, and a virtual machine monitor 28 is provided in the host 29. The virtual machine manager 20 obtains the virtual machine 21 to be migrated and the first virtual machine device simulator 26 of the virtual machine to be migrated, uninstalls the first virtual machine device simulator 26 and installs the second virtual machine device simulator 27 based on the user's operation instruction, and creates the target virtual machine 22 according to the second virtual machine device simulator 27, that is, the virtual machine 21 to be migrated and the target virtual machine 22 are located on the same host 29; obtains the Name and Uuid of the first identification file of the virtual machine 21 to be migrated, and the virtual machine manager 20 can identify the virtual machine 21 to be migrated through the Name and Uuid of the first identification file, assigns ID and Shaduuid to the target virtual machine 22 to determine the ID-Name and Shaduuid of the second identification file of the target virtual machine 22, and the virtual machine manager 20 uses the second identification file The ID-Name and Shaduuid can identify the target virtual machine 22, and then generate a first pipe file 25 between the virtual machine 21 to be migrated and the target virtual machine 22, allocate the second pipe file 23 according to the Name, and allocate the third pipe file 24 according to the ID-Name; the second pipe file 23 can communicate with the virtual machine 21 to be migrated, and can also communicate with the first device simulator 26; the third pipe file 24 can communicate with the target virtual machine 22, and can also communicate with the second virtual machine device simulator 27; when obtaining the user's migration instruction, the virtual machine manager 20 controls the second pipe file 23 to send a command to the virtual machine 21 to migrate the memory data of the virtual machine to be migrated to the target virtual machine 22, and the command controls the memory data of the virtual machine 21 to be migrated to the target virtual machine 22 through the first pipe file 25 to complete the migration process.
[0067] In an optional embodiment of the present invention, the method also includes: registering the second identification file into the management table of the host; creating a second resource file of the target virtual machine based on the second identification file and the first resource file of the virtual machine to be migrated; the first resource file includes a log file, a structured tag file and a connection information file; accessing the first resource file according to the first name in the first identification file, and accessing the second resource file according to the second name in the second identification file.
[0068] In this embodiment, it is mainly considered that Libvirt manages the virtual machine mainly by managing the management table composed of the identification files corresponding to the virtual machine, and the virtual machine to be migrated already exists in the host and has been registered. The second identification file is registered in the management table of the host; wherein the management table can be a hash table, which can also be called a hash table.
[0069] The first resource file includes at least one of the following: a log file, a structured markup file and a connection information file; wherein the log file can be recorded as a Log file, which is used to display the running status of the virtual machine process to be migrated; the structured markup file can be recorded as an Xml file, which is used to display the structure of the virtual machine to be migrated; the connection information file is recorded as a Connection file, which is used to call a function in the connection information file to clear the abnormal operation when an abnormal operation occurs in the virtual machine process.
[0070] The second resource file of the target virtual machine is created based on the second identification file and the first resource file of the virtual machine to be migrated. Mainly because the naming and path of the resource file are closely related to the identification file, Libvirt can copy the first resource file of the virtual machine to be migrated, and rename and path it with the second identification file, that is, the second resource file, and the second resource file includes a log file, a structured tag file and a connection information file. As an example, Libvirt can create a Log file, an Xml file, and a Connection file for the target virtual machine according to the first resource file of the virtual machine to be migrated, and rename the name using the ID-Name method of the second identification file, and rename the path using the Shaduuid method in the second identification file, thereby avoiding conflicts in access to shared resources when the name and identification code of the virtual machine to be migrated and the target virtual machine are the same (that is, Name and Uuid).
[0071] The first resource file is accessed according to the first name in the first identification file, and the second resource file is accessed according to the second name in the second identification file. It can be understood that Libvirt can distinguish the first resource file and the second resource file by name to solve the problem of conflicting access to shared resources by virtual machines of different versions on the same host.
[0072] In an optional embodiment of the present invention, after obtaining the migration instruction and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction, the method further includes:
[0073] The virtual machine to be migrated is deleted; and the second identification code is updated to the first identification code in the management table of the host.
[0074] In this embodiment, after obtaining the migration instruction and migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction, it can be understood that the migration of the virtual machine to be migrated to the target virtual machine has been completed; deleting the virtual machine to be migrated can be understood as removing the virtual machine to be migrated from the management table.
[0075] Updating the second identification code to the first identification code in the management table of the host can be understood as replacing Shaduuid with Uuid in the management table of the host.
[0076] For ease of understanding, a schematic diagram of an application scenario of a virtual machine hot migration method is provided here; Figure 3 FIG. 1 is a schematic diagram of an application scenario of the method for hot migration of a virtual machine according to an embodiment of the present invention; Figure 3 The virtual machine to be migrated is the old version virtual machine (Old VM); the target virtual machine is the new version virtual machine (New VM); the old version virtual machine 31 and the new version virtual machine 32 are located on the same host 39, the virtual machine monitor 38 in the host 39, the first pipeline file is the first monitor socket file (first monitor.sock); the second pipeline file is the second monitor socket file (second monitor.sock); the first device simulator is the old version virtual machine device simulator (OldQemu); the second device simulator is the new version virtual machine device simulator (New Qemu); the first name in the first identification file of the old version virtual machine 31 is Name, and the first identification code is Uuid; the first monitor.sock file is created according to Name; the second name in the second identification file of the new version virtual machine 32 is ID-Name, and the second identification code is Shaduuid; the second monitor.sock file is created according to ID-Name; the first identification file and the second identification file can be both registered in the management table corresponding to the virtual machine manager 30, in Figure 3The first identification file and the second identification file are not shown; in the case where the old version virtual machine 31 needs to be upgraded to the new version virtual machine 32, the virtual machine manager 30 can distinguish the old version virtual machine 31 and the new version virtual machine 32 by querying the Name and ID-Name in the management table to upgrade the old version virtual machine 31 to the new version virtual machine 32. The specific process is as follows: the virtual machine manager 30 creates a new version virtual machine 32 by installing the new version virtual machine device simulator 37; obtains the Name and Uuid in the first identification file of the old version virtual machine 31, assigns ID and Shaduuid to the new version virtual machine 32 to determine the ID-Name and Shaduuid of the second identification file of the new version virtual machine 32, assigns the first monitor socket file 35 according to the Name, and assigns the second monitor socket file 33 according to the ID-Name; when obtaining the user's migration instruction, the virtual machine manager 30 sends a command to migrate the memory data of the old version virtual machine 31 to the new version virtual machine 32 through the first monitor socket file 35, and the command controls the memory data of the virtual machine 31 to be migrated to the target virtual machine 32 through the first set of monitor socket files 35 to complete the migration process. After the memory data of the old version virtual machine 31 is migrated to the new version virtual machine 32, the virtual machine manager 30 removes the virtual machine to be migrated from the management table, and then replaces Shaduuid with Uuid in the management table of the host.
[0077] This embodiment provides a device for hot migration of a virtual machine. Figure 4 FIG. 1 is a schematic diagram of the structure of a device for hot migration of a virtual machine according to an embodiment of the present invention. Figure 4 As shown, the apparatus 400 includes: a determination unit 401, an acquisition unit 402, an allocation unit 403, a generation unit 404 and a migration unit 405, wherein:
[0078] The determination unit 401 is used to determine the virtual machine to be migrated and the target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; the acquisition unit 402 is used to obtain the first identification file of the virtual machine to be migrated; the virtual machine to be migrated is identified according to the first name and the first identification code of the first identification file; the allocation unit 403 is used to allocate an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; the determination unit 401 is also used to determine the second identification file of the target virtual machine based on the first name, the identity and the second identification code; the target virtual machine is identified according to the second name and the second identification code of the second identification file; the generation unit 404 is used to generate a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; the migration unit 405 is used to obtain a migration instruction, and based on the migration instruction, the memory data of the virtual machine to be migrated is migrated to the target virtual machine through the first pipe file.
[0079] In other embodiments, the determination unit 401 is also used to obtain the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated; uninstall the first device simulator and install the second device simulator based on the obtained operation instructions; and create the target virtual machine according to the second device simulator.
[0080] In other embodiments, the determination unit 401 is also used to determine the second pipe file based on the first name; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively; the third pipe file is determined based on the second name; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively.
[0081] In other embodiments, the determining unit 401 is further configured to determine the second name based on the first name and the identity identifier; and determine a second identification file of the target virtual machine based on the second name and the second identification code.
[0082] In other embodiments, the apparatus 400 further includes: a registration unit, a creation unit and an access unit, wherein:
[0083] The registration unit is used to register the second identification file into the management table of the host; the creation unit is used to create the second resource file of the target virtual machine based on the second identification file registered by the registration unit and the first resource file of the virtual machine to be migrated; the first resource file includes at least one of the following: a log file, a structured tag file and a connection information file; the access unit is used to access the first resource file according to the first name in the first identification file, and to access the second resource file according to the second name in the second identification file.
[0084] In other embodiments, the device 400 further includes an updating unit, further configured to delete the virtual machine to be migrated; and update the second identification code to the first identification code in the management table of the host.
[0085] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present invention, please refer to the description of the method embodiment of the present invention for understanding.
[0086] It should be noted that, in the embodiment of the present invention, if the above-mentioned method of hot migration of virtual machines is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical embodiment of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for enabling a device for hot migration of a virtual machine (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present invention is not limited to any specific combination of hardware and software.
[0087] Correspondingly, an embodiment of the present invention provides a device for hot migration of a virtual machine, including a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the processor executes the program, the steps in the method for hot migration of the virtual machine provided in the above embodiment are implemented.
[0088] Correspondingly, an embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method for hot migration of a virtual machine provided in the above embodiment are implemented.
[0089] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present invention, please refer to the description of the method embodiments of the present invention for understanding.
[0090] It should be noted that Figure 5 FIG. 1 is a schematic diagram of a hardware entity structure of a device for hot migration of a virtual machine in an embodiment of the present invention. Figure 5 As shown, the hardware entity of the virtual machine hot migration device 500 includes: a processor 501 and a memory 503 . Optionally, the virtual machine hot migration device 500 may also include a communication interface 502 .
[0091] It can be understood that the memory 503 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAM bus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 503 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.
[0092] The method disclosed in the above embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. The above processor 501 may be a general-purpose processor, a digital virtual machine hot migration device (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 501 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 503. The processor 501 reads the information in the memory 503 and completes the steps of the above method in combination with its hardware.
[0093] In an exemplary embodiment, the device for hot migration of a virtual machine can be implemented by one or more application-specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field-programmable gate array (FPGA), general-purpose processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.
[0094] In the several embodiments provided by the present invention, it should be understood that the disclosed methods and devices can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another observation, or some features can be ignored or not executed. In addition, the communication connection between the components shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0095] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of this embodiment.
[0096] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), disks or optical disks, etc. Various media that can store program codes.
[0097] Alternatively, if the above-mentioned integrated unit of the embodiment of the present invention is implemented in the form of a software functional unit and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical embodiment of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a device (which can be a personal computer, server, or network device, etc.) for hot migration of a virtual machine to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0098] The present invention is a method, device and computer storage medium based on virtual machine hot migration recorded in the example only takes the embodiment of the present invention as an example, but is not limited to this. As long as it involves the method, device and computer storage medium based on virtual machine hot migration, it is within the protection scope of the present invention.
[0099] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present invention. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present invention, the size of the serial number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention. The serial numbers of the above-mentioned embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.
[0100] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0101] The above is only an embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for hot migration of a virtual machine, characterized in that: The method comprises: Determine a virtual machine to be migrated and a target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; Obtaining a first identification file of the virtual machine to be migrated; identifying the virtual machine to be migrated according to a first name and a first identification code of the first identification file; Allocating an identity and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; Determine a second identification file of the target virtual machine based on the first name, the identity identifier and the second identification code; identify the target virtual machine according to the second name and the second identification code of the second identification file; Generate a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; Obtain a migration instruction, and migrate the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction; The step of determining the virtual machine to be migrated and the target virtual machine includes: Obtain the virtual machine to be migrated and a first device simulator of the virtual machine to be migrated; Uninstalling the first device simulator and installing a second device simulator based on the obtained operation instruction; The target virtual machine is created according to the second device simulator.
2. The method according to claim 1, characterized in that The method further comprises: Determine a second pipe file based on the first name; the second pipe file is used to communicate with the virtual machine to be migrated and the first device simulator respectively; A third pipe file is determined based on the second name; the third pipe file is used to communicate with the target virtual machine and the second device simulator respectively.
3. The method according to claim 1, characterized in that The determining the second identification file of the target virtual machine based on the first name, the identity identifier and the second identification code includes: Determine the second name based on the first name and the identity identifier; The second identification file is determined according to the second name and the second identification code.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Registering the second identification file into the management table of the host; Creating a second resource file of the target virtual machine based on the second identification file and the first resource file of the virtual machine to be migrated; the first resource file includes at least one of the following: a log file, a structured markup file, and a connection information file; The first resource file is accessed according to the first name, and the second resource file is accessed according to the second name.
5. The method according to claim 4, characterized in that After migrating the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction, the method further includes: The virtual machine to be migrated is deleted; and the second identification code is updated to the first identification code in the management table of the host.
6. A device for hot migration of a virtual machine, characterized in that: The device comprises: a determination unit, an acquisition unit, an allocation unit, a generation unit and a migration unit, wherein: The determining unit is used to determine the virtual machine to be migrated and the target virtual machine; the virtual machine to be migrated and the target virtual machine are located on the same host; The obtaining unit is configured to obtain a first identification file of the virtual machine to be migrated; and identify the virtual machine to be migrated according to a first name and a first identification code of the first identification file; The allocation unit is used to allocate an identity identifier and a second identification code to the target virtual machine; the second identification code is obtained by processing the first identification code in a preset manner; The determining unit is further configured to determine a second identification file of the target virtual machine based on the first name, the identity identifier, and the second identification code; and identify the target virtual machine according to the second name and the second identification code of the second identification file; The generating unit is configured to generate a first pipe file between the virtual machine to be migrated and the target virtual machine based on the first identification file and the second identification file; The migration unit is configured to obtain a migration instruction, and migrate the memory data of the virtual machine to be migrated to the target virtual machine through the first pipe file based on the migration instruction; The determining unit is further used to obtain the virtual machine to be migrated and the first device simulator of the virtual machine to be migrated; uninstall the first device simulator and install the second device simulator based on the obtained operation instruction; and create the target virtual machine according to the second device simulator.
7. A device for hot migration of a virtual machine, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps in the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 5 are implemented.
