Method for virtual machine cross-platform automatic migration and computer readable storage medium

By building an image chain on the target platform and using Ceph's incremental export and import commands, cross-platform automated migration of virtual machines was achieved, solving the problem of not being able to migrate snapshot data in existing technologies and improving migration efficiency and compatibility.

CN117667350BActive Publication Date: 2025-11-28FUJIAN CENTM INFORMATION
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311677067.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-08
Publication Date
2025-11-28
Estimated Expiration
2043-12-08

AI Technical Summary

Technical Problem

Existing technologies cannot automatically migrate snapshot data when migrating virtual machines across platforms, and require additional intermediate storage, resulting in a time-consuming and unfriendly migration process.

Method used

Create a mirror chain on the target platform that is identical to the source platform, and transfer the data from the source mirror chain to the target mirror chain via streaming. Use Ceph's incremental export and import commands to achieve cross-platform data migration and avoid relying on additional storage.

Benefits of technology

It enables automated migration of virtual machine data between different platforms, is compatible with different virtual machine disk configurations, reduces migration time and storage requirements, and improves migration efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117667350B_ABST
    Figure CN117667350B_ABST
Patent Text Reader

Abstract

The application discloses a virtual machine cross-platform automatic migration method and a computer readable storage medium, and the method comprises the following steps: creating a target virtual machine corresponding to a source virtual machine in a source platform on a target platform, and creating a target image chain corresponding to each source image chain of the source virtual machine on the target platform, wherein the image chain comprises a differential image chain and a normal image chain, the differential image chain comprises a basic image, a differential disk and a differential disk snapshot, the normal image chain comprises a normal virtual disk and a normal virtual disk snapshot, and a target differential disk and a target normal virtual disk in the target image chain are mounted on the target virtual machine; and data in each source image chain is transmitted into the corresponding target image chain in a streaming mode. The application can realize cross-platform automatic migration of virtual machine data containing snapshots without relying on additional intermediate storage.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of cloud computing, and particularly relates to a virtual machine cross-platform automatic migration method and a computer readable storage medium. BACKGROUND

[0002] Virtual machine migration is a requirement that is often encountered when upgrading or there are multiple virtualization platforms and data centers. Virtualization underlying technologies include KVM (Kernel-based Virtual Machine), XEN, VMWARE, etc. The drives of the disks and virtual network cards corresponding to the platforms implemented based on different virtualization technologies are different, and cannot be directly exported for use. There are also many actual environment requirements for migration between virtualization platforms of the same technology. In this scenario, the drives of the platforms between the same technologies (for example, KVM) are compatible.

[0003] The data of the virtual machine itself is generally stored on the storage system corresponding to the virtualization platform, and the virtual machine management data is stored on the virtualization platform. As shown in Figure 1 , the virtual machine data may include snapshot data and multiple snapshots. The disk of the virtual machine may be a normal virtual disk or a cloned differential disk, as shown in Figure 2 and Figure 3 .

[0004] The current virtual machine cross-platform migration method mainly exports the data as an ova format or imports other platforms through an open-source virt-v2v and a tool customized based on virt-v2v. The main disadvantage is that additional storage is generally required, and snapshot data cannot be migrated, and the user-preserved snapshot is valuable data for the user. In addition, this migration is usually very time-consuming and the experience is very poor. SUMMARY

[0005] The technical problem to be solved by the present application is to provide a virtual machine cross-platform automatic migration method and a computer readable storage medium, which can realize cross-platform automatic migration of virtual machine data containing snapshots without relying on additional intermediate storage.

[0006] To solve the above technical problems, the technical scheme adopted by the present application is as follows: a virtual machine cross-platform automatic migration method, comprising:

[0007] create a target virtual machine corresponding to the source virtual machine in the source platform on the target platform, and create a target mirror chain corresponding to each source mirror chain of the source virtual machine on the target platform, wherein the mirror chain includes a differential mirror chain and a normal mirror chain, the differential mirror chain includes a base image, a differential disk and a differential disk snapshot, the normal mirror chain includes a normal virtual disk and a normal virtual disk snapshot, and a target differential disk and a target normal virtual disk in the target mirror chain are mounted on the target virtual machine;

[0008] The data in each source mirror chain is transmitted into the corresponding target mirror chain in a streaming manner.

[0009] The application also provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to realize the method.

[0010] The application has the advantages that the mirror chain is constructed on the target platform, and then the data of the source disk and the source snapshot is directly transmitted into the corresponding target disk and target snapshot in a streaming manner, so that the automatic migration of the virtual machine data on the non-shared storage between the virtualization platforms is realized. The application is compatible with different virtual machine disks, and does not need additional storage, so that the automatic migration of the virtual machine data containing snapshots across platforms is realized. BRIEF DESCRIPTION OF DRAWINGS

[0011] Figure 1 a schematic diagram of the data of the virtual machine;

[0012] Figure 2 a schematic diagram of the data of the differential disk;

[0013] Figure 3 a schematic diagram of the data of the normal virtual disk;

[0014] Figure 4 a flowchart of the virtual machine cross-platform automatic migration method of the application;

[0015] Figure 5 a schematic diagram of the virtual machine cross-platform migration of the first embodiment of the application;

[0016] Figure 6 a method flowchart of the first embodiment of the application. DETAILED DESCRIPTION

[0017] The technical content, purposes and effects of the application will be described in detail below in combination with the embodiments and the drawings.

[0018] Please refer to Figure 4 A virtual machine cross-platform automatic migration method comprises the following steps:

[0019] create a target virtual machine corresponding to the source virtual machine in the source platform on the target platform, and create a target image chain corresponding to each source image chain of the source virtual machine on the target platform, wherein the image chain comprises a differential image chain and a normal image chain, the differential image chain comprises a base image, a differential disk and a differential disk snapshot, the normal image chain comprises a normal virtual disk and a normal virtual disk snapshot, and a target differential disk and a target normal virtual disk in the target image chain are mounted on the target virtual machine;

[0020] respectively transmit data in each source image chain to the corresponding target image chain through streaming.

[0021] From the above description, the beneficial effects of the present application are that cross-platform automatic migration of virtual machine data containing snapshots can be realized without relying on additional intermediate storage.

[0022] Further, the creation of a target virtual machine corresponding to the source virtual machine in the source platform on the target platform and the creation of a target image chain corresponding to each source image chain of the source virtual machine on the target platform are specifically:

[0023] shut down the source virtual machine to be migrated in the source platform;

[0024] create a target virtual machine on the target platform, the configuration of the target virtual machine being consistent with the configuration of the source virtual machine;

[0025] obtain each source differential image chain and each source normal image chain of the source virtual machine;

[0026] transmit the base image in each source differential image chain to the target platform, and create a target differential disk corresponding to the source differential disk in each source differential image chain on the target platform according to the base image;

[0027] create a target normal virtual disk corresponding to the source normal virtual disk in each source normal image chain on the target platform;

[0028] mount the target differential disk and the target normal virtual disk to the target virtual machine, and create a target differential disk snapshot corresponding to each source differential disk snapshot in each source differential image chain and a target normal virtual disk snapshot corresponding to each source normal virtual disk snapshot in each source normal image chain on the target platform.

[0029] From the above description, by constructing an image chain on the target platform that is the same as the source platform, different virtual machine disk situations can be compatible, and subsequent data transmission can be directly transmitted in a streaming manner without additional storage.

[0030] Further, before creating a target virtual machine on the target platform, further comprising:

[0031] The account and storage space of the target platform are checked, and if the check is passed, the step of creating a target virtual machine on the target platform is executed.

[0032] As can be seen from the above description, by checking whether the account of the target platform is correct and whether the storage space is sufficient, it is ensured that an empty virtual machine and an image chain can be imaged on the target platform subsequently.

[0033] Further, the base image in each source difference image chain is transmitted to the target platform, and a target difference disk corresponding to the source difference disk in each source difference image chain is created on the target platform according to the base image, specifically:

[0034] If the base image in a source difference image chain does not exist on the target platform, the base image in the source difference image chain is transmitted to the target platform, and a target difference disk corresponding to the source difference disk in the source difference image chain is created on the target platform according to the base image in the source difference image chain.

[0035] If the base image in a source difference image chain exists on the target platform, a target difference disk corresponding to the source difference disk in the source difference image chain is created on the target platform according to the base image in the source difference image chain.

[0036] As can be seen from the above description, when the base images in multiple difference image chains are the same, the base image only needs to be transmitted once, which can save transmission resources and improve transmission efficiency.

[0037] Further, the data in each source image chain is transmitted to the corresponding target image chain, specifically:

[0038] The data in the source difference disk and the source difference disk snapshot of the same source difference image chain are sequentially transmitted to the target difference disk and the target difference disk snapshot in the corresponding target difference image chain.

[0039] The data in the source normal virtual disk and the source normal virtual disk snapshot of the same source normal image chain are sequentially transmitted to the target normal virtual disk and the target normal virtual disk snapshot in the corresponding target normal image chain.

[0040] As can be seen from the above description, since the disk snapshot data is protected by default, the data with a child snapshot cannot overwrite the parent snapshot data, therefore, for the data in the same image chain, the data transmission needs to be performed according to the hierarchical order in the image chain.

[0041] Further, the data in the source differential disk and the source differential disk snapshot of the same source differential mirror chain is sequentially transmitted to the target differential disk and the target differential disk snapshot in the corresponding target differential mirror chain, and specifically:

[0042] The data in the source differential disk and the source differential disk snapshot of the same source differential mirror chain is sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command of Ceph;

[0043] The data is sequentially imported from the standard input to the target differential disk and the target differential disk snapshot in the target differential mirror chain corresponding to the same source differential mirror chain on the target platform through the incremental import command of Ceph.

[0044] Further, the data in the source ordinary virtual disk and the source ordinary virtual disk snapshot of the same source ordinary mirror chain is sequentially transmitted to the target ordinary virtual disk and the target ordinary virtual disk snapshot in the corresponding target ordinary mirror chain, and specifically:

[0045] The data in the source ordinary virtual disk and the source ordinary virtual disk snapshot of the same source ordinary mirror chain is sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command of Ceph;

[0046] The data is sequentially imported from the standard input to the target ordinary virtual disk and the target ordinary virtual disk snapshot in the target ordinary mirror chain corresponding to the same source ordinary mirror chain on the target platform through the incremental import command of Ceph.

[0047] As can be seen from the above description, the incremental export command and the incremental import command based on Ceph are used to realize the export and import of the data of each layer of the mirror chain, thereby realizing the cross-platform and cross-storage streaming transmission of the virtual machine data, without the need for additional storage, and realizing the full automation of the virtual machine migration; meanwhile, by using the incremental export and import mode, the amount of data to be transmitted can be reduced, the migration time consumption can be shortened, and the migration efficiency can be improved.

[0048] The application further provides a computer readable storage medium having a computer program stored thereon, and the program is executed by a processor to realize the method.

[0049] Embodiment one

[0050] Please refer to Figures 5-6 The embodiment one of the application is a virtual machine cross-platform automatic migration method, which can be applied to the migration of virtual machines between different KVM platforms.

[0051] As Figure 5 shown Figure 5In the prior art, the ordinary disk refers to an ordinary virtual disk, and the embodiment provides a special migration service by modifying an interface of a virtualization platform, creates a target virtual machine on a target platform through the interface in an asynchronous task scheduling manner, creates an image chain identical to that of a source platform on a storage system of the target platform, and then implements export and import of disk data and snapshot data based on a Ceph incremental export command and an incremental import command, so as to realize direct transmission of data flow across platforms and further realize migration automation.

[0052] Specifically, as shown in Figure 6 , the method comprises the following steps:

[0053] S1: shutting down a source virtual machine to be migrated in a source platform. The virtual machine to be migrated in the source platform needs to be shut down and cannot be started again and data cannot be written in the migration process, and then an interface calling account of a target platform is filled in, a storage selection is verified, and a migration task is submitted.

[0054] Further, the account of the target platform and the storage space are verified, that is, whether the account of the target platform is correct and whether the storage space is sufficient are verified, so as to ensure that an empty virtual machine and an image chain can be imaged on the target platform subsequently.

[0055] S2: creating a target virtual machine on the target platform, wherein the configuration of the target virtual machine is consistent with that of the source virtual machine, that is, the ID and configuration of the target virtual machine are consistent with those of the source virtual machine by default.

[0056] S3: acquiring each source differential image chain and each source ordinary image chain of the source virtual machine. That is, the image chain of the virtual machine to be migrated is acquired, in the embodiment, the image chain comprises a differential image chain and an ordinary image chain, the differential image chain comprises a base image, a differential disk and a differential disk snapshot (for reference to Figure 2 ), and the ordinary image chain comprises an ordinary virtual disk and an ordinary virtual disk snapshot (for reference to Figure 3 ).

[0057] S4: transmitting the base image in each source differential image chain to the target platform, and creating a target differential disk corresponding to the source differential disk in each source differential image chain on the target platform according to the base image.

[0058] That is, if the base image exists in the image chain, the base image needs to be transmitted first, and then a cloned differential disk is created on the target platform through the interface.

[0059] Further, the base images in multiple differential image chains can be identical (for example, the base images of three differential image chains in Figure 2 are identical), and the base image needs to be transmitted only once.

[0060] Specifically, if the base image in a source differential image chain does not exist on the target platform, the base image in the source differential image chain is first transmitted to the target platform, and then the target differential disk corresponding to the source differential disk in the source differential image chain is created on the target platform according to the base image. If the base image in a source differential image chain already exists on the target platform, the target differential disk corresponding to the source differential disk in the source differential image chain is directly created on the target platform according to the base image.

[0061] S5: creating target normal virtual disks corresponding to the source normal virtual disks in each source normal image chain on the target platform; wherein the ID and configuration of the target normal virtual disk are consistent with those of the source normal virtual disk corresponding thereto.

[0062] S6: mounting the target differential disk and the target normal virtual disk to the target virtual machine, and creating target differential disk snapshots corresponding to the source differential disk snapshots in each source differential image chain and target normal virtual disk snapshots corresponding to the source normal virtual disk snapshots in each source normal image chain on the target platform. That is, if there is a snapshot in the image chain, the corresponding virtual machine snapshot is created through the interface.

[0063] Wherein the ID and configuration of the target differential disk snapshot are consistent with those of the source differential disk snapshot corresponding thereto, and the ID and configuration of the target normal virtual disk snapshot are consistent with those of the source normal virtual disk snapshot corresponding thereto.

[0064] S7: based on the incremental export command and the incremental import command of Ceph, the data in each source image chain is transmitted to the corresponding target image chain in a streaming manner.

[0065] In this embodiment, the data of different image chains can be transmitted concurrently, and the disk data and snapshot data in the same image chain need to be transmitted in sequence, because the disk snapshot data is protected by default, and the data with a child snapshot cannot be written to the parent snapshot data. Moreover, the data transmission in this embodiment is performed in a streaming manner.

[0066] Specifically, the data in the source differential disk and the source differential disk snapshot of the same source differential image chain are sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command (rbd export-diff) of Ceph; and the data is sequentially imported from the standard input to the target differential disk and the target differential disk snapshot in the target differential image chain corresponding to the same source differential image chain on the target platform through the incremental import command (rbd import-diff) of Ceph.

[0067] Similarly, data in the source common virtual disk and the source common virtual disk snapshot of the same source common image chain are sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command (rbd export-diff) of Ceph; and the data is sequentially imported into the target common virtual disk and the target common virtual disk snapshot in the target common image chain corresponding to the same source common image chain from the standard input through the incremental import command (rbd import-diff) of Ceph on the target platform.

[0068] The standard input and the standard output refer to the standard input and the standard output of the Linux system, the standard input refers to a manner in which a user or a program sends data to the Linux system, and the standard output refers to a manner in which the Linux system sends data to the outside world.

[0069] In an actual application scenario, the sizes and orders of the layers in each source image chain of the source virtual machine can be acquired through the command rbd du of Ceph, then the data of each layer is sequentially acquired and streamed according to the order of the chain, the data of the layer is acquired to the standard output through rbd export-diff on the source platform, and the data is imported from the standard input to the corresponding target layer through rbd import-diff on the target platform. During the transmission process, the source platform ensures that the data is sequentially read through the disk or the snapshot, and the transmission is performed in the preset fragmentation size, if an exception is returned in the transmission of a fragment, the transmission is terminated, and the migration task fails. The target platform ensures that the data is sequentially imported through the disk or the snapshot, and the corresponding data is written by a sub-process asynchronously, the source platform notifies that the transmission is completed, and then the corresponding sub-process is closed and terminated, and the same transmission does not repeat the sub-process. The transmission of the disk and the snapshot data in different image chains can be concurrent, and the migration efficiency is improved.

[0070] The embodiment can realize the cross-platform automatic migration of the virtual machine between KVM virtualization platforms and on the non-shared Ceph storage without relying on additional storage; and the embodiment only transmits the actual data of the disk and the snapshot, and the data in different image chains can be transmitted concurrently, and the migration efficiency is high.

[0071] Embodiment two

[0072] The embodiment is a computer readable storage medium corresponding to the above-mentioned embodiment, and the computer program is stored on the computer readable storage medium, the program is executed by the processor to realize each step of the virtual machine cross-platform automatic migration method in the above-mentioned embodiment, and the same technical effect can be achieved, which will not be repeated here.

[0073] In summary, the application provides a kind of virtual machine cross-platform automated migration method and computer readable storage medium, by building the same mirror chain as source platform on target platform, then the data of source disk and source snapshot is transmitted to corresponding target disk and target snapshot, thereby realizing the automated migration of virtual machine data between virtualization platforms, on non-shared storage.The application can be compatible with different virtual machine disk cases, and does not require additional storage, to realize cross-platform automated migration of virtual machine data containing snapshots.

[0074] The above is only an embodiment of the application, and does not limit the patent scope of the application, and any equivalent transformation, direct or indirect application in related technical fields using the content of the application specification and drawings are also included in the patent protection scope of the application.

Claims

1. A virtual machine cross-platform automatic migration method, characterized in that, The method comprises the following steps: creating a target virtual machine corresponding to a source virtual machine in a source platform on a target platform, and creating a target image chain corresponding to each source image chain of the source virtual machine on the target platform, wherein the image chain comprises a differential image chain and a normal image chain, the differential image chain comprises a base image, a differential disk and a differential disk snapshot, the normal image chain comprises a normal virtual disk and a normal virtual disk snapshot, and a target differential disk and a target normal virtual disk in the target image chain are mounted on the target virtual machine; transmitting data in each source image chain to a corresponding target image chain by streaming; the step of creating a target virtual machine corresponding to a source virtual machine in a source platform on a target platform, and creating a target image chain corresponding to each source image chain of the source virtual machine on the target platform comprises the following steps: shutting down a source virtual machine to be migrated in the source platform; creating a target virtual machine on the target platform, wherein the configuration of the target virtual machine is consistent with the configuration of the source virtual machine; obtaining each source differential image chain and each source normal image chain of the source virtual machine; transmitting a base image in each source differential image chain to the target platform, and creating a target differential disk corresponding to a source differential disk in each source differential image chain on the target platform according to the base image; creating a target normal virtual disk corresponding to a source normal virtual disk in each source normal image chain on the target platform; mounting the target differential disk and the target normal virtual disk to the target virtual machine, and creating a target differential disk snapshot corresponding to each source differential disk snapshot in each source differential image chain and a target normal virtual disk snapshot corresponding to each source normal virtual disk snapshot in each source normal image chain on the target platform; the step of transmitting data in each source image chain to a corresponding target image chain by streaming comprises the following steps: sequentially transmitting data in a source differential disk and a source differential disk snapshot of a same source differential image chain to a target differential disk and a target differential disk snapshot in a corresponding target differential image chain; sequentially transmitting data in a source normal virtual disk and a source normal virtual disk snapshot of a same source normal image chain to a target normal virtual disk and a target normal virtual disk snapshot in a corresponding target normal image chain.

2. The virtual machine cross-platform automated migration method of claim 1, wherein, Before the step of creating a target virtual machine on a target platform, the method further comprises the following step: verifying an account and a storage space of the target platform, and if the verification is passed, executing the step of creating a target virtual machine on the target platform.

3. The virtual machine cross-platform automated migration method of claim 1, wherein, the step of transmitting a base image in each source differential image chain to the target platform, and creating a target differential disk corresponding to a source differential disk in each source differential image chain on the target platform according to the base image comprises the following steps: if a base image in a source differential image chain does not exist on the target platform, transmitting the base image in the source differential image chain to the target platform, and creating a target differential disk corresponding to a source differential disk in the source differential image chain on the target platform according to the base image in the source differential image chain. If the target platform has a base image in a source differential image chain, a target differential disk corresponding to a source differential disk in the source differential image chain is created on the target platform according to the base image in the source differential image chain.

4. The virtual machine cross-platform automated migration method of claim 1, wherein, The data in the source differential disk and the source differential disk snapshot of the same source differential image chain are sequentially transmitted to the target differential disk and the target differential disk snapshot in the corresponding target differential image chain, and the specific process is as follows: The data in the source differential disk and the source differential disk snapshot of the same source differential image chain are sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command of Ceph. The data is sequentially imported from the standard input to the target differential disk and the target differential disk snapshot in the target differential image chain corresponding to the same source differential image chain on the target platform through the incremental import command of Ceph.

5. The virtual machine cross-platform automated migration method of claim 1, wherein, The data in the source ordinary virtual disk and the source ordinary virtual disk snapshot of the same source ordinary image chain are sequentially transmitted to the target ordinary virtual disk and the target ordinary virtual disk snapshot in the corresponding target ordinary image chain, and the specific process is as follows: The data in the source ordinary virtual disk and the source ordinary virtual disk snapshot of the same source ordinary image chain are sequentially acquired on the source platform, and the sequentially acquired data is exported to the standard output through the incremental export command of Ceph. The data is sequentially imported from the standard input to the target ordinary virtual disk and the target ordinary virtual disk snapshot in the target ordinary image chain corresponding to the same source ordinary image chain on the target platform through the incremental import command of Ceph.

6. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to realize the method of any one of claims 1-5.

Citation Information

Patent Citations

  • With-snapshot virtual machine whole machine dynamic migration method and device

    CN106227587A

  • Live migration of virtual disks

    US20140297979A1