A method, device, equipment and storage medium for virtual machine cross-storage migration
By migrating virtual machines across storage units on a disk basis, and updating the xml file after the migration is completed, the problem of data loss and inconsistency under abnormal circumstances during the virtual machine migration process is solved, and data security and integrity are achieved.
Patent Information
- Application Number
- CN202210868207.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-07-22
AI Technical Summary
During the cross-storage migration process of virtual machines, abnormal situations such as power outages or network outages may occur, resulting in data loss or inconsistency between upper and lower layer data.
Migrate on a disk basis, and update the xml file after the migration is completed to facilitate directional rollback under abnormal circumstances to avoid data loss or data inconsistency. Specific steps include calling qemu monitor for supervision when receiving the migration instruction, calling drive mirror for data migration, performing a complete operation when the source disk migration is completed, transferring the IO path to the destination disk, and updating the disk path in the xml file. , if an exception occurs, the unupdated disk path will be rolled back.
Under abnormal circumstances, unfinished migration tasks can be effectively rolled back to avoid data loss or data inconsistency between the upper and lower layers, ensuring the integrity and data security of the virtual machine migration process.
Smart Images

Figure CN115016900B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a method, system, device and storage medium for virtual machine cross-storage migration. Background Art
[0002] A virtual machine is a computer system with complete hardware functions that runs on a physical server. It can provide the same functions and properties as a physical server, and has the advantages of strong portability, convenient operation, easy management, and effective space saving. With the rapid development of the cloud computing era, more and more enterprises and government units are choosing virtualization to run their business systems, and virtual machines have become the most important operation and maintenance objects in data centers.
[0003] As the volume of business increases, the number of virtual machines also increases, and the demand for storage capacity also gradually increases. In order to avoid data loss, operation and maintenance personnel often need to migrate virtual machines from storage spaces with insufficient remaining space to storage spaces with sufficient remaining space. Virtual machine cross-storage migration technology is also an important means to ensure the successful migration of virtual machines from old storage spaces to new storage spaces.
[0004] In the prior art, when performing cross-storage migration of a virtual machine, specifically, after receiving the cross-storage migration task issued by the virtual machine, each source disk before the cross-storage migration of the virtual machine is locked first to prevent the process of the cross-storage migration of the virtual machine from being interfered with by other processes, and the function module monitor in qemu will monitor the migration status of each disk during the entire cross-storage migration process, and then update each disk path pointed to in the xml file from each source disk to the destination disk, call the drive mirror function inside qemu to migrate the data in the source disk to the destination disk, and the block job complete in qemu will complete the source disk with a normal drive mirror process, switch the IO path in the virtual machine from the completed source disk to the destination disk, and perform the drive mirror operation on the next source disk until all source disks are completed, uninstall each source disk lock, and delete the source disk to realize the cross-storage migration of the virtual machine from the source disk to the destination disk.
[0005] However, during the cross-storage migration process, abnormal situations such as power outages or network disconnections may occur, and the time of the abnormal situation cannot be predicted. If an abnormal situation occurs during the drive mirror process, the drive mirror process fails, or the drive mirror process is normal but an abnormal situation occurs before the complete operation, that is, all source disks are not completed, the virtual machine will roll back to the original storage path of the disk, but at this time, each disk path in the XML file has pointed to the destination disk, resulting in inconsistency between the upper and lower layer data; however, if only some source disks are completed, the IO path corresponding to the completed source disk is switched to the destination disk, and an abnormal situation occurs at this time, the virtual machine will roll back due to migration failure, and the destination disk that has completed the migration will be deleted during the rollback, which will cause data loss; in addition, if all source disks are completed, an abnormal situation occurs when the lock of the source disk needs to be uninstalled, and when the virtual machine rolls back, all destination disks will be deleted, resulting in all data loss.
[0006] Therefore, providing a migration method that is not affected by abnormal situations during the cross-storage migration of virtual machines is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0007] The purpose of the present invention is to provide a method, system, device and storage medium for virtual machine cross-storage migration, in which migration is performed in disk units, and an XML file is updated after the migration is completed, so that the disk can be rolled back in a targeted manner when an abnormal situation occurs, avoiding data loss or inconsistency between upper and lower data.
[0008] In order to solve the above technical problems, the present invention provides a method for cross-storage migration of a virtual machine, wherein the virtual machine corresponds to multiple source disks, and each source disk corresponds to a destination disk one by one, and the method comprises:
[0009] When receiving the migration instruction, call qemu monitor to monitor the migration process;
[0010] Invoke drive mirror to migrate data in the current source disk to the corresponding current destination disk;
[0011] When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0012] Update the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0013] If an abnormal situation occurs, each of the source disks corresponding to the unupdated disk paths will be rolled back until each of the disk paths in the xml file is updated to each of the destination disks.
[0014] Preferably, before calling qemu monitor to monitor the migration process, the process further includes:
[0015] Locking each of the source disks;
[0016] After updating the disk path corresponding to the current source disk in the xml file to the current destination disk, the method further includes:
[0017] The lock of the current source disk is uninstalled, and the current source disk is deleted.
[0018] Preferably, before the lock of the current source disk is uninstalled and the current source disk is deleted, the method further includes:
[0019] Determine whether the current source disk is locked normally;
[0020] If so, the process proceeds to the step of uninstalling the lock of the current source disk and deleting the current source disk.
[0021] Preferably, after determining whether the current source disk is locked normally, the method further includes:
[0022] If not, an alarm is issued and the current source disk is retained.
[0023] Preferably, before updating the disk path corresponding to the current source disk in the xml file to the current destination disk, the method further includes:
[0024] If the abnormal situation occurs, the current source disk is rolled back.
[0025] Preferably, after rolling back the current source disk, the method further includes:
[0026] After the abnormal situation is recovered, the process returns to the step of invoking drive mirror to migrate the data in the current source disk to the corresponding current destination disk.
[0027] Preferably, before calling drive mirror to migrate data in the current source disk to the corresponding current destination disk, the method further includes:
[0028] S201: setting the first source disk as the current source disk according to the order of the source disks;
[0029] S202: Entering the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk;
[0030] S203: When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0031] S204: updating the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0032] S205: setting the next source disk of the current source disk as the current source disk in the order of the source disks, until all the disk paths in the XML file are updated to the destination disks.
[0033] In order to solve the above technical problems, the present invention provides a method for cross-storage migration of a virtual machine, wherein the virtual machine corresponds to multiple source disks, and each source disk corresponds to a destination disk one by one, and the method comprises:
[0034] The first calling unit is used to call qemu monitor to monitor the migration process when receiving the migration instruction;
[0035] The second calling unit is used to call the drive mirror to migrate the data in the current source end disk to the corresponding current destination end disk;
[0036] The third calling unit is used to call block job complete to perform a complete operation on the current source disk when the qemu monitor determines that the migration of the current source disk is completed, and transfer the IO path corresponding to the current source disk to the current destination disk;
[0037] A path updating unit, used for updating the disk path corresponding to the current source disk in the XML file to the current destination disk;
[0038] The directional rollback unit is used to roll back each of the source disks corresponding to the unupdated disk paths when an abnormal situation occurs, until each of the disk paths in the XML file is updated to each of the destination disks.
[0039] To solve the above technical problems, the present invention provides a virtual machine cross-storage migration device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus;
[0040] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operations of the virtual machine cross-storage migration method as described above.
[0041] In order to solve the above technical problems, the present invention provides a computer-readable storage medium, in which at least one executable instruction is stored. When the executable instruction runs on a virtual machine cross-storage migration device / apparatus, the virtual machine cross-storage migration device / apparatus performs the operations of the virtual machine cross-storage migration method as described above.
[0042] The present application provides a virtual machine cross-storage migration method, system, device and storage medium, which relates to the field of information technology and is used for cross-storage migration of virtual machines. When a migration instruction is received, the migration process is supervised; at the same time, the data in the current source disk is migrated to the corresponding current destination disk; when the migration of the current source disk is completed, the current source disk is completed, and the IO path corresponding to the current source disk is transferred to the current destination disk; the disk path corresponding to the current source disk in the xml file is updated to the current destination disk; and if an abnormality occurs, each source disk corresponding to the unupdated disk path is rolled back until all disk migrations are completed. Migration is performed in disk units, and the xml file is updated after the migration is completed, so that the disk can be rolled back in a targeted manner when an abnormality occurs, avoiding data loss or inconsistency between upper and lower data. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 A schematic diagram of a flow chart of a virtual machine cross-storage migration method provided by the present invention;
[0045] Figure 2 A specific flow chart of a virtual machine cross-storage migration method provided by the present invention;
[0046] Figure 3 A schematic diagram of the structure of an embodiment of a virtual machine cross-storage migration device provided by the present invention;
[0047] Figure 4 A schematic diagram of the structure of an embodiment of a virtual machine cross-storage migration device provided by the present invention. DETAILED DESCRIPTION
[0048] The core of the present invention is to provide a virtual machine cross-storage migration method, system, device and storage medium, in which migration is performed in disk units, and the XML file is updated after the migration is completed, so that the disk can be rolled back in a targeted manner when an abnormal situation occurs, avoiding data loss or inconsistency between upper and lower data.
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Please refer to Figure 1 , Figure 1 A flow chart of a virtual machine cross-storage migration method provided by the present invention is provided, wherein the virtual machine corresponds to multiple source disks, and each source disk corresponds to a destination disk one by one, and the method comprises:
[0051] S101: upon receiving a migration instruction, calling qemu monitor to monitor the migration process;
[0052] Considering that in the prior art, when performing cross-storage migration of virtual machines, it is usually necessary to directly modify the disk paths in the xml file to the destination disk after receiving the migration instruction, and then migrate the data in each source disk to each destination disk. However, if an abnormal situation such as power outage or network disconnection occurs during the process, the destination disk will be deleted during rollback. Since the disk path in the xml file has been modified to the destination disk, but there is no relevant data in the destination disk, it will cause inconsistency between the upper and lower layer data. In addition, if a part of the source disk has completed data migration when an abnormal situation occurs, the data of the source disk will be deleted, and the destination disk will be deleted during rollback, resulting in data loss.
[0053] In order to solve the above technical problems, in this embodiment, after receiving the migration instruction, qemumonitor is first called to monitor the migration process to determine whether there is any abnormality in the entire migration process or whether the migration is successful.
[0054] S102: calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk;
[0055] In this embodiment, the disk path in the XML file is not modified before data migration. Instead, the drive mirror is called to migrate the data in the current source disk to the destination disk corresponding to the current source disk in units of disks. If an abnormal situation occurs at this time, although the destination disk is deleted after rollback, the corresponding data is still retained in the source disk, and the disk path in the XML file is still the source disk. There is no inconsistency between the upper and lower layer data, the virtual machine can still be used normally, and data migration can still be performed normally after the abnormal situation is eliminated.
[0056] S103: When qemu monitor determines that the migration of the current source disk is completed, block job complete is called to complete the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0057] When the data in a source disk is migrated to the corresponding destination disk, that is, when the data in the current source disk is migrated to the destination disk, qemu monitor will detect the migration completion during the monitoring process, and call block job complete to complete the current source disk, and transfer the IO path corresponding to the current source disk to the current destination disk. If an abnormal situation occurs at this time, the source disk can be rolled back. After deleting the destination disk, the disk path in the xml file has not been modified, and the inconsistency of the upper and lower layer data will not be caused.
[0058] S104: Update the disk path corresponding to the current source disk in the XML file to the current destination disk;
[0059] After the current source disk data migration is completed, the disk path corresponding to the current source disk in the xml file is updated to the current destination disk, thereby completing the data migration of the current source disk.
[0060] S105: If an abnormal situation occurs, roll back each source disk corresponding to the unupdated disk path, and return to step S202 until each disk path in the XML file is updated to each destination disk.
[0061] If an abnormal situation occurs during the migration process, when rolling back, only the source disks corresponding to the disk paths that have not been updated will be rolled back, that is, the source disks that have not completed data migration will be rolled back, and the destination disks that have not completed data migration will be deleted. The source disks whose data migration has been completed, that is, the disk paths in the xml file have been modified, do not need to be modified, and the corresponding destination disks do not need to be deleted, thereby ensuring that the destination disks that have completed data migration are consistent with the disk paths in the xml file, the virtual machine can still be used normally, and normal data migration can continue after the abnormal situation is resolved to ensure the completion of the migration.
[0062] As a preferred embodiment, before updating the disk path corresponding to the current source disk in the XML file to the current destination disk, it also includes:
[0063] If an abnormal situation occurs, the current source disk will be rolled back.
[0064] Specifically, for example, after the migration of the first source disk is completed, the second source disk is called in sequence for data migration. If an abnormality occurs during the migration of the data of the second source disk, only the second source disk is rolled back, and the first source disk and the destination disk remain in the same state after the migration, and no inconsistency in the upper and lower layer data or data loss will be caused.
[0065] In summary, in this application, migration is performed on a disk basis, and the XML file is updated after the migration is completed, so that the disk can be rolled back in a targeted manner when an abnormal situation occurs, avoiding data loss or inconsistency between upper and lower data.
[0066] Based on the above embodiments:
[0067] As a preferred embodiment, before calling qemu monitor to monitor the migration process, the following steps are also included:
[0068] Lock each source disk;
[0069] After updating the disk path corresponding to the current source disk in the xml file to the current destination disk, it also includes:
[0070] Unlock the current source disk and delete the current source disk.
[0071] In this embodiment, after receiving the migration instruction and before migrating the data, each source disk is locked first to avoid other interferences during the data migration process and affect the normal progress of the data migration. After the source disk is locked, the data cannot be modified unless the data is migrated.
[0072] Accordingly, each time a source disk is migrated, the lock of the source disk is uninstalled and the current source disk is deleted, that is, the disk is no longer called by the virtual machine in the current migration process to ensure that the source disk can be called by other processes.
[0073] Based on this, the present embodiment can ensure that the data migration process is carried out normally, and ensure that the source disk is put back into use after the migration.
[0074] As a preferred embodiment, before the lock of the current source disk is uninstalled and the current source disk is deleted, the method further includes:
[0075] Determine whether the current source disk is locked normally;
[0076] If yes, proceed to the step of uninstalling the lock of the current source disk and deleting the current source disk.
[0077] In this embodiment, before uninstalling the lock of the current source disk, it is first determined whether the current source disk is locked normally. If it is locked normally, the lock of the current source disk can be uninstalled, thereby avoiding data loss caused by directly deleting the source disk when the source disk is not locked normally.
[0078] As a preferred embodiment, after determining whether the current source disk is locked normally, the method further includes:
[0079] If not, an alarm will be issued and the current source disk will be retained.
[0080] If the current source disk is not locked normally, that is, the lock resource of the current source disk cannot be accessed normally, it may be due to abnormal failure of the current source disk or other situations. At this time, the source disk cannot be deleted directly. Instead, an alarm prompt is issued first to allow technicians to repair the source disk and perform other maintenance operations, and the current source disk is retained to avoid data loss.
[0081] As a preferred embodiment, after rolling back the current source disk, the method further includes:
[0082] After the abnormal situation is recovered, return to the step of calling drive mirror to migrate the data in the current source end disk to the corresponding current destination end disk.
[0083] In this embodiment, after the current source disk is rolled back, if the abnormal situation is recovered, the data in the current source disk can be migrated again to ensure the normal completion of data migration without causing data loss or inconsistency between upper and lower layer data.
[0084] As a preferred embodiment, before calling drive mirror to migrate data in the current source end disk to the corresponding current destination end disk, the method further includes:
[0085] S201: setting the first source disk as the current source disk according to the order of the source disks;
[0086] S202: Entering the step of calling drive mirror to migrate data in the current source disk to the corresponding current destination disk;
[0087] S203: When qemu monitor determines that the migration of the current source disk is completed, block job complete is called to complete the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0088] S204: Update the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0089] S205: Set the next source disk of the current source disk as the current source disk in the order of the source disks, and return to step S202 until all disk paths in the xml file are updated to the destination disks.
[0090] Please refer to Figure 2 , Figure 2 A specific flow chart of a virtual machine cross-storage migration method provided by the present invention.
[0091] This embodiment provides a specific process for data migration, that is, after the migration of one source disk is completed, the data migration of the next source disk is carried out, and the data migration based on virtual machines in the prior art is changed to data migration based on disks. When an abnormal situation occurs, a certain disk can be rolled back in a targeted manner, thereby ensuring the security of the data of the source disk that has been migrated and improving the efficiency of data migration.
[0092] Please refer to Figure 3 , Figure 3 A schematic diagram of the structure of an embodiment of a virtual machine cross-storage migration device provided by the present invention. Figure 3 As shown, the device 300 includes: a first calling unit 310 , a second calling unit 320 , a third calling unit 330 , a path updating unit 340 and a directional rollback unit 350 .
[0093] In an optional manner, the virtual machine cross-storage migration device 300 is also used to lock each of the source disks before calling qemu monitor to supervise the migration process; after updating the disk path corresponding to the current source disk in the xml file to the current destination disk, it also includes: uninstalling the lock of the current source disk and deleting the current source disk.
[0094] In an optional manner, the virtual machine cross-storage migration device 300 is also used to determine whether the current source disk is locked normally before uninstalling the lock of the current source disk and deleting the current source disk; if so, the step of uninstalling the lock of the current source disk and deleting the current source disk is entered.
[0095] In an optional manner, after determining whether the current source disk is locked normally, the virtual machine cross-storage migration device 300 is further configured to issue an alarm if not and retain the current source disk.
[0096] In an optional manner, before the virtual machine cross-storage migration device 300 updates the disk path corresponding to the current source disk in the XML file to the current destination disk, it is also used to roll back the current source disk if the abnormal situation occurs.
[0097] In an optional manner, after rolling back the current source disk, the virtual machine cross-storage migration device 300 is further used to return to the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk after the abnormal situation is recovered.
[0098] In an optional manner, before calling the drive mirror to migrate the data in the current source disk to the corresponding current destination disk, the virtual machine cross-storage migration device 300 is further used to perform the following steps:
[0099] S201: setting the first source disk as the current source disk according to the order of the source disks;
[0100] S202: Entering the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk;
[0101] S203: When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0102] S204: updating the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0103] S205: setting the next source disk of the current source disk as the current source disk in the order of the source disks, and returning to step S202 until all the disk paths in the xml file are updated to the destination disks.
[0104] For an introduction to a virtual machine cross-storage migration device 300 provided by the present invention, please refer to the above method embodiment, and the present invention will not be repeated here.
[0105] Please refer to Figure 4 , Figure 4 This is a schematic diagram of the structure of an embodiment of a virtual machine cross-storage migration device provided by the present invention. The specific embodiment of the present invention does not limit the specific implementation of the virtual machine cross-storage migration device.
[0106] like Figure 4 As shown, the virtual machine cross-storage migration device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0107] The processor 402, the communication interface 404, and the memory 406 communicate with each other via the communication bus 408. The communication interface 404 is used to communicate with other devices such as a client or other server network elements. The processor 402 is used to execute the program 410, which can specifically execute the relevant steps in the above-mentioned XXXX method embodiment.
[0108] Specifically, the program 410 may include program code including computer executable instructions.
[0109] The processor 402 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiment of the present invention. The one or more processors included in the virtual machine cross-storage migration device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0110] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0111] Program 410 may be specifically invoked by processor 402 to enable the virtual machine to perform the following operations across storage migration devices:
[0112] When receiving the migration instruction, call qemu monitor to monitor the migration process;
[0113] Invoke drive mirror to migrate data in the current source disk to the corresponding current destination disk;
[0114] When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0115] Update the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0116] If an abnormal situation occurs, each of the source disks corresponding to the unupdated disk paths will be rolled back until each of the disk paths in the xml file is updated to each of the destination disks.
[0117] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0118] Before calling qemu monitor to supervise the migration process, it is also used to lock each of the source disks; after updating the disk path corresponding to the current source disk in the xml file to the current destination disk, it also includes: uninstalling the lock of the current source disk and deleting the current source disk.
[0119] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0120] Before uninstalling the lock of the current source disk and deleting the current source disk, it is also used to determine whether the current source disk is locked normally; if so, entering the step of uninstalling the lock of the current source disk and deleting the current source disk.
[0121] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0122] After determining whether the current source disk is locked normally, if not, an alarm is issued and the current source disk is retained.
[0123] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0124] The disk path corresponding to the current source disk in the xml file is updated to before the current destination disk, and is also used to roll back the current source disk if the abnormal situation occurs.
[0125] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0126] After rolling back the current source disk, the method is further used to return to the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk after the abnormal situation is recovered.
[0127] In an optional manner, the program 410 is called by the processor 402 to enable the virtual machine to perform the following operations across the storage migration device:
[0128] Before calling drive mirror to migrate data in the current source disk to the corresponding current destination disk, it is also used to perform the following steps:
[0129] S201: setting the first source disk as the current source disk according to the order of the source disks;
[0130] S202: Entering the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk;
[0131] S203: When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0132] S204: updating the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0133] S205: setting the next source disk of the current source disk as the current source disk in the order of the source disks, and returning to step S202 until all the disk paths in the xml file are updated to the destination disks.
[0134] For an introduction to a virtual machine cross-storage migration device provided by the present invention, please refer to the above method embodiment, and the present invention will not be repeated here.
[0135] An embodiment of the present invention provides a computer-readable storage medium, which stores at least one executable instruction. When the executable instruction runs on a virtual machine cross-storage migration device / apparatus, the virtual machine cross-storage migration device / apparatus executes the virtual machine cross-storage migration method in any of the above-mentioned method embodiments.
[0136] The executable instructions may be specifically used to enable the virtual machine to perform the following operations across storage migration devices / apparatuses:
[0137] When receiving the migration instruction, call qemu monitor to monitor the migration process;
[0138] Invoke drive mirror to migrate data in the current source disk to the corresponding current destination disk;
[0139] When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0140] Update the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0141] If an abnormal situation occurs, each of the source disks corresponding to the unupdated disk paths will be rolled back until each of the disk paths in the xml file is updated to each of the destination disks.
[0142] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0143] Before calling qemu monitor to supervise the migration process, it is also used to lock each of the source disks; after updating the disk path corresponding to the current source disk in the xml file to the current destination disk, it also includes: uninstalling the lock of the current source disk and deleting the current source disk.
[0144] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0145] Before uninstalling the lock of the current source disk and deleting the current source disk, it is also used to determine whether the current source disk is locked normally; if so, entering the step of uninstalling the lock of the current source disk and deleting the current source disk.
[0146] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0147] After determining whether the current source disk is locked normally, if not, an alarm is issued and the current source disk is retained.
[0148] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0149] The disk path corresponding to the current source disk in the xml file is updated to before the current destination disk, and is also used to roll back the current source disk if the abnormal situation occurs.
[0150] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0151] After rolling back the current source disk, the method is further used to return to the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk after the abnormal situation is recovered.
[0152] In an optional manner, the executable instruction enables the virtual machine to perform the following operations across the storage migration device / apparatus:
[0153] Before calling drive mirror to migrate data in the current source disk to the corresponding current destination disk, it is also used to perform the following steps:
[0154] S201: setting the first source disk as the current source disk according to the order of the source disks;
[0155] S202: Entering the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk;
[0156] S203: When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk;
[0157] S204: updating the disk path corresponding to the current source disk in the xml file to the current destination disk;
[0158] S205: setting the next source disk of the current source disk as the current source disk in the order of the source disks, and returning to step S202 until all the disk paths in the xml file are updated to the destination disks.
[0159] For an introduction to a computer-readable storage medium provided by the present invention, please refer to the above method embodiment, and the present invention will not be repeated here.
[0160] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants 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 statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0161] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for migrating a virtual machine across storages, It is characterized in that The virtual machine corresponds to multiple source disks, and each source disk corresponds to a destination disk one by one. The method includes: When receiving the migration instruction, call qemu monitor to monitor the migration process; Invoke drive mirror to migrate data in the current source disk to the corresponding current destination disk; When the qemu monitor determines that the migration of the current source disk is completed, the block job complete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk; Update the disk path corresponding to the current source disk in the xml file to the current destination disk; If an abnormal situation occurs, each of the source disks corresponding to the unupdated disk paths will be rolled back until each of the disk paths in the xml file is updated to each of the destination disks.
2. The method for cross-storage migration of a virtual machine according to claim 1, It is characterized in that Before calling qemu monitor to monitor the migration process, it also includes: Locking each of the source disks; After updating the disk path corresponding to the current source disk in the xml file to the current destination disk, the method further includes: The lock of the current source disk is uninstalled, and the current source disk is deleted.
3. The method for cross-storage migration of a virtual machine according to claim 2, It is characterized in that Before the lock of the current source disk is uninstalled and the current source disk is deleted, the method further includes: Determine whether the current source disk is locked normally; If so, the process proceeds to the step of uninstalling the lock of the current source disk and deleting the current source disk.
4. The method for cross-storage migration of a virtual machine according to claim 3, It is characterized in that After determining whether the current source disk is locked normally, the method further includes: If not, an alarm is issued and the current source disk is retained.
5. The method for cross-storage migration of a virtual machine according to claim 1, It is characterized in that Before updating the disk path corresponding to the current source disk in the XML file to the current destination disk, it also includes: If the abnormal situation occurs, the current source disk is rolled back.
6. The method for cross-storage migration of a virtual machine according to claim 5, It is characterized in that After rolling back the current source disk, the following steps are also included: After the abnormal situation is recovered, the process returns to the step of invoking drive mirror to migrate the data in the current source disk to the corresponding current destination disk.
7. The method for cross-storage migration of a virtual machine according to any one of claims 1 to 6, It is characterized in that Before calling drivemirror to migrate the data in the current source disk to the corresponding current destination disk, the method further includes: S201: setting the first source disk as the current source disk according to the order of the source disks; S202: Entering the step of calling drive mirror to migrate the data in the current source disk to the corresponding current destination disk; S203: When the qemu monitor determines that the migration of the current source disk is completed, block jobcomplete is called to perform a complete operation on the current source disk, and the IO path corresponding to the current source disk is transferred to the current destination disk; S204: updating the disk path corresponding to the current source disk in the xml file to the current destination disk; S205: setting the next source disk of the current source disk as the current source disk in the order of the source disks, and returning to step S202 until all the disk paths in the xml file are updated to the destination disks.
8. A method for migrating a virtual machine across storages, It is characterized in that The virtual machine corresponds to multiple source disks, and each source disk corresponds to a destination disk one by one. The method includes: The first calling unit is used to call qemu monitor to monitor the migration process when receiving the migration instruction; The second calling unit is used to call the drive mirror to migrate the data in the current source end disk to the corresponding current destination end disk; The third calling unit is used to call block job complete to perform a complete operation on the current source disk when the qemu monitor determines that the migration of the current source disk is completed, and transfer the IO path corresponding to the current source disk to the current destination disk; A path updating unit, used for updating the disk path corresponding to the current source disk in the XML file to the current destination disk; The directional rollback unit is used to roll back each of the source disks corresponding to the unupdated disk paths when an abnormal situation occurs, until each of the disk paths in the XML file is updated to each of the destination disks.
9. A virtual machine cross-storage migration device, It is characterized in that include: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation of the virtual machine cross-storage migration method as described in any one of claims 1-7.
10. A computer-readable storage medium, It is characterized in that The storage medium stores at least one executable instruction, and when the executable instruction runs on the virtual machine cross-storage migration device / apparatus, the virtual machine cross-storage migration device / apparatus performs the operation of the virtual machine cross-storage migration method as described in any one of claims 1-7.
