Virtual machine cloud hard disk migration method and device, equipment and storage medium
Monitoring the status of virtual machines through Cinder and Nova components and utilizing the data block copy function of libvirt solves the complexity of cloud hard disk migration when the virtual machine is not powered on, enabling direct cross-storage migration and reducing the risk of virtual machine unavailability.
Patent Information
- Application Number
- CN202410866146.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-08-23
AI Technical Summary
When the virtual machine is not powered on, the existing OpenStack cloud disk migration technology cannot directly perform cross-storage migration. Cloud disks need to be manually unmounted and remounted, which is complex and can easily cause the virtual machine to become unavailable.
Obtain the cloud disk migration request through Cinder and Nova components, monitor the status of the virtual machine, start the virtual machine startup process and pause the startup if it is in the shutdown state, and use libvirt to call the data block copy function of the qemu process to perform cloud disk migration in the preset target state. Copy the data and complete the migration operation.
It enables cloud disk migration to be completed directly when the virtual machine is not powered on, reducing the complexity of the migration operation and avoiding the unavailability of the virtual machine due to remounting.
Smart Images

Figure CN118535289A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing technology, and in particular to a virtual machine cloud hard disk migration method, device, equipment and storage medium. Background Art
[0002] OpenStack (cloud platform) is a cloud platform based on virtual machines, which is built through components such as Nova (virtual server deployment and business computing module), Cinder (responsible for providing block storage services, providing stable data block storage services for running instances), glance (image service component), neutron (providing virtual network functions in cloud computing environments), and keystone (managing and verifying user access rights). In the process of using virtual machines, cloud hard disk migration of virtual machines is a relatively common scenario, including two situations: online migration and offline migration. Most users will choose online migration of virtual machine cloud hard disks, but some virtual machines are very sensitive to IO (Input / Output). If online migration is performed when the virtual machine is running, it may cause business or system damage. At this time, many users will consider offline migration of virtual machines. However, the current cloud hard disk migration of OpenStack has an important feature, that is, when the virtual machine is shut down, the cloud hard disk cannot be directly migrated across storage. If you need to migrate the cloud hard disk when the virtual machine is shut down, you need to manually uninstall the cloud hard disk from the virtual machine, perform offline migration across storage, and then remount it to the virtual machine. The relatively complex operation process requires manual observation and judgment of the progress of each process of cloud disk migration to ensure the completeness of the overall migration process. This is likely to consume a lot of human resources, and the disk of the virtual machine may change the drive letter of the cloud disk in the virtual machine due to re-mounting, making the virtual machine unavailable. In addition, by default, the system disk of the virtual machine is not allowed to be unmounted, so when the virtual machine is shut down, the system disk of the virtual machine may not be able to perform cross-storage migration.
[0003] It can be seen that how to directly complete the cross-storage migration of cloud hard disks when the virtual machine is not powered on is a problem that needs to be solved by those skilled in the art. Summary of the invention
[0004] In view of this, the purpose of the embodiments of the present invention is to provide a virtual machine cloud hard disk migration method, device, equipment and storage medium, which can solve the problem of completing the cloud hard disk migration operation when the virtual machine is not powered on. The specific scheme is as follows:
[0005] In a first aspect, the present invention discloses a virtual machine cloud hard disk migration method, which is applied to the OpenStack platform and includes:
[0006] Obtain a cloud hard disk migration request for a target virtual machine through a Cinder component, and create a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine;
[0007] Monitor whether the target virtual machine is in a shutdown state through the Nova component. If the target virtual machine is in a shutdown state, start the corresponding virtual machine startup process based on the virtual machine instance corresponding to the target virtual machine, and perform a virtual machine startup pause operation before the virtual machine startup process is completed, so that the target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the target virtual machine is already in a running state;
[0008] In the preset target state, libvirt is used to call the data block copy function in the running qemu process to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
[0009] Optionally, monitoring whether the target virtual machine is in a shutdown state through the Nova component, if the target virtual machine is in a shutdown state, starting a corresponding virtual machine startup process based on a virtual machine instance corresponding to the target virtual machine, and performing a virtual machine startup pause operation before the virtual machine startup process is completed, so that the target virtual machine enters a preset target state, includes:
[0010] The Nova component is used to monitor whether the target virtual machine is currently in a shutdown state. If the target virtual machine is currently in a shutdown state, the Nova component is used to set the target virtual machine to a target newly added state. The target newly added state is a state pre-added in the Nova component to indicate that a cloud hard disk migration is currently required.
[0011] When it is detected that the target virtual machine has been set to the target newly added state, current state information of the target virtual machine is obtained through libvirt, and based on the current state information, it is verified again whether the actual state of the target virtual machine is the shutdown state;
[0012] If the verification result indicates that the actual state of the target virtual machine is a shutdown state, obtaining device information of the target virtual machine in a first database of the Nova component, and generating first configuration file information of the target virtual machine based on the device information;
[0013] Creating a libvirt virtual machine instance corresponding to the target virtual machine on the host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine;
[0014] Based on the libvirt virtual machine instance, the corresponding virtual machine startup process is started, and a startup pause flag is obtained. Then, before the virtual machine startup process is completed, the startup pause flag is used to perform a virtual machine startup pause operation, so that the current target virtual machine enters a preset target state.
[0015] Optionally, the method further includes:
[0016] When it is detected that the target virtual machine has been set to the target added state, a locking operation is performed on the target virtual machine to obtain a target lock of the target virtual machine;
[0017] If any operation request for the target virtual machine is detected, the lock of the target virtual machine is checked, and when it is checked that the target virtual machine has the target lock, it is determined whether the any operation request is an operation request that requires cloud hard disk migration;
[0018] If the arbitrary operation request is an operation request that requires cloud hard disk migration, the arbitrary operation request is allowed to be executed; otherwise, the arbitrary operation request is prohibited to be executed.
[0019] Optionally, if the target virtual machine is currently in a shutdown state, after the Nova component is used to set the target virtual machine to a target newly added state, the method further includes:
[0020] The target virtual machine is controlled to stop throwing an exception based on a control logic corresponding to the target newly added state.
[0021] Optionally, after copying the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, the step further includes:
[0022] Connecting the input and output interface of the target virtual machine to the target cloud hard disk to obtain new configuration file information generated by the target virtual machine based on the target cloud hard disk;
[0023] After the old configuration file information of the target virtual machine on the host machine is updated by using the new configuration file information, the cloud hard disk to be migrated is uninstalled from the host machine corresponding to the target virtual machine.
[0024] Optionally, after obtaining a cloud hard disk migration request for a target virtual machine through a Cinder component and creating a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine, the method further includes:
[0025] The Cinder component is used to monitor whether the cloud hard disk to be migrated is in a mounted state. If the cloud hard disk to be migrated is in a mounted state, the Nova component is called through a preset command line tool to perform a cloud hard disk migration operation on the target virtual machine based on the cloud hard disk migration request.
[0026] Optionally, after copying the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, the step further includes:
[0027] Using the first cloud hard disk mount information of the target cloud hard disk to replace the second cloud hard disk mount information of the cloud hard disk to be migrated stored in the block device mapping table of the Nova component;
[0028] Sending a cloud hard disk migration completion signal to the Cinder component, and after performing a data update operation on the database information of the second database in the Cinder component based on the cloud hard disk migration completion signal, deleting the cloud hard disk to be migrated through the Cinder component;
[0029] The data update operation is to replace the second hard disk configuration information of the cloud hard disk to be migrated with the first hard disk configuration information of the target cloud hard disk.
[0030] Optionally, calling a data block copy function in the running qemu process through libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine includes:
[0031] In the preset target state, libvirt is used to call the data block copy function in the running qemu process to copy the hard disk data of the cloud hard disk to be migrated to obtain the copied data, and then the corresponding incremental data dirty page is flushed to complete the cloud hard disk migration operation of the target virtual machine.
[0032] In a second aspect, the present invention discloses a virtual machine cloud hard disk migration device, which is applied to the OpenStack platform and includes:
[0033] A target hard disk creation module is used to obtain a cloud hard disk migration request for a target virtual machine through a Cinder component, and create a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine;
[0034] A virtual machine state switching module is used to monitor whether the current target virtual machine is in a shutdown state through the Nova component. If the current target virtual machine is in a shutdown state, the corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine, and the virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state;
[0035] The data transfer module is used to call the data block copy function in the running qemu process through libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
[0036] In a third aspect, the present invention discloses a virtual machine cloud hard disk migration device, comprising:
[0037] Memory, used to store computer programs;
[0038] The processor is used to execute the computer program to implement the steps of migrating the virtual machine cloud hard disk disclosed above.
[0039] In a fourth aspect, the present invention discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of migrating the virtual machine cloud hard disk disclosed above are implemented.
[0040] It can be seen that the present application obtains a cloud hard disk migration request for a target virtual machine through the Cinder component, and creates a target cloud hard disk based on the cloud hard disk migration request and the hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine; monitors whether the current target virtual machine is in a shutdown state through the Nova component, and if the current target virtual machine is in a shutdown state, starts the corresponding virtual machine startup process based on the virtual machine instance corresponding to the target virtual machine, and performs a virtual machine startup pause operation before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein, the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state; in the preset target state, libvirt is used to call the data block copy function in the qemu process that is already in a running state, so as to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
[0041] Beneficial effect: By using the power-on pause flag to power on and pause the target virtual machine, the target virtual machine process is started, but the resources of the target virtual machine are in a paused state and the virtual machine operating system is not entered. At this time, the operating system of the virtual machine will not be loaded, and only the qemu process is created. Then, the data copy function of the qemu process is used to copy the hard disk data of the cloud hard disk to be migrated mounted by the target virtual machine itself to the target cloud hard disk to realize the cloud hard disk migration operation when the virtual machine is shut down. In this way, the cloud hard disk cross-storage migration can be completed directly when the virtual machine is not powered on, and since there is no need to manually unmount and remount the cloud hard disk like the cloud hard disk migration operation when the virtual machine is shut down, the complexity of the cloud hard disk migration operation can be greatly reduced. In addition, it is avoided that the disk of the virtual machine may change the drive letter of the cloud hard disk in the virtual machine due to remounting, resulting in the unavailability of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 A cloud hard disk migration method in a virtual machine shutdown state provided by an embodiment of the present invention;
[0044] Figure 2 A cloud hard disk migration method for a virtual machine in an online state provided by an embodiment of the present invention;
[0045] Figure 3 A virtual machine cloud hard disk migration method provided in an embodiment of the present invention;
[0046] Figure 4 A cloud hard disk migration method when a virtual machine is powered on and paused is provided in an embodiment of the present invention;
[0047] Figure 5 A specific virtual machine cloud hard disk migration method provided by an embodiment of the present invention;
[0048] Figure 6 A schematic diagram of a specific virtual machine cloud hard disk migration device structure provided by an embodiment of the present invention;
[0049] Figure 7 A specific virtual machine cloud hard disk migration device structure diagram provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] The terms "including" and "having" in the specification of the present invention and the above-mentioned drawings, as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0052] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0053] like Figure 1 As shown in the figure, when the virtual machine is powered off, the cloud hard disk cannot be directly migrated across storage. It is necessary to manually uninstall the cloud hard disk from the virtual machine, perform cross-storage offline migration, and then remount it to the virtual machine. The entire operation is relatively complicated and requires manual observation and judgment of the progress of each process to ensure the integrity of the overall migration process. Apart from the complexity of the operation, the drive letter of the cloud hard disk in the virtual machine may change due to the remounting of the virtual machine's disk, causing the virtual machine to become unavailable. In addition, by default, the system disk of the virtual machine is not allowed to be uninstalled, so when the virtual machine is powered off, the system disk of the virtual machine may not be able to perform cross-storage migration. As shown in the figure, Figure 2 As shown, since the cloud hard disk needs to be uninstalled in the current virtual machine shutdown state before the cloud hard disk can be migrated, the existing technology usually adopts the method of virtual machine online migration. Specifically, by creating a cloud hard disk of the target storage backend and mounting the cloud hard disk to the corresponding virtual machine, and then using Nova's migration cloud hard disk swap_volume function, call the block_copy (block copy) of the qemu process through libvirt to migrate the data to the new cloud hard disk, and after the migration is completed, switch the IO of the virtual machine to the new cloud hard disk, and then uninstall and delete the source cloud hard disk to complete the overall cloud hard disk migration action. The key to online migration is to use the block_copy function of qemu, so the qemu process of the virtual machine needs to exist to proceed normally, but when the machine is shut down, the qemu process is closed, so block_copy cannot be called to migrate the cloud hard disk.
[0054] Therefore, the present invention will specifically disclose a virtual machine cloud hard disk migration method, so that the current virtual machine can migrate the cloud hard disk without uninstalling the cloud hard disk when the current virtual machine is shut down.
[0055] See also Figure 3 As shown, an embodiment of the present invention discloses a virtual machine cloud hard disk migration method, which is applied to the OpenStack platform. The method includes:
[0056] Step S11: obtaining a cloud hard disk migration request for a target virtual machine through a Cinder component, and creating a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine.
[0057] In this embodiment, Cinder is the core component of the OpenStack platform that provides block storage services, allowing users to create and manage persistent block devices and attach them to virtual machine instances. When a virtual machine's cloud hard disk migration is required, the Cinder component first receives a cloud hard disk migration request for the target virtual machine, and creates a corresponding new cloud hard disk according to the hard disk parameters of the cloud hard disk to be migrated and the target cloud hard disk type to obtain the target cloud hard disk.
[0058] In this embodiment, the cloud hard disk migration request for the target virtual machine is obtained through the Cinder component, and after the target cloud hard disk migration request and the hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine are created, it includes: monitoring whether the current cloud hard disk to be migrated is in a mounted state through the Cinder component, if the current cloud hard disk to be migrated is in a mounted state, calling the Nova component through a preset command line tool, so as to perform a cloud hard disk migration operation for the target virtual machine based on the cloud hard disk migration request. After the corresponding target cloud hard disk is created, it is necessary to first judge the mounting state of the cloud hard disk to be migrated through the Cinder component. If the cloud hard disk to be migrated is already in a mounted state, calling the Nova component through nova-client to perform the cloud hard disk online migration process. The Nova component is a core component in OpenStack, which is mainly responsible for the life cycle management of virtual machine instances. Its main functions include creating, deleting, starting, stopping, etc. virtual machines. Nova manages computing resources, networks, and storage at the same time, and provides a rich API interface, allowing users to manage and operate virtual machine instances through API calls.
[0059] Step S12: Monitor whether the current target virtual machine is in a shutdown state through the Nova component. If the current target virtual machine is in a shutdown state, start the corresponding virtual machine startup process based on the virtual machine instance corresponding to the target virtual machine, and perform a virtual machine startup pause operation before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state.
[0060] In this embodiment, after receiving the migration cloud hard disk request sent by the Cinder component, the Nova component determines whether the target virtual machine is currently in a shutdown state by querying its own state detection record of the target virtual machine. If the target virtual machine is currently in a shutdown state. Then the virtual machine is controlled not to perform an abnormal operation, and the corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine. It should be noted that the qemu process of the virtual machine is used in the migration process. Therefore, monitoring whether the current target virtual machine is in a shutdown state through the Nova component is to check the qemu process of the virtual machine. If the process does not exist, it is determined that the virtual machine is in a shutdown state. The corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine, and the virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein, the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state. It should be noted that at this time, resources such as the CPU (Central Processing Unit, i.e., central processing unit) of the target virtual machine are in a suspended state. In this way, since the device resources of the target virtual machine are in a suspended state, when the cloud hard disk of the target virtual machine is migrated, no damage to the business or system is caused.
[0061] Step S13: In the preset target state, libvirt is used to call the data block copy function in the running qemu process to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
[0062] In this embodiment, when the target virtual machine is in the target state, the qemu process of the target virtual machine is already in a running state. In fact, the block_copy function of the virtual machine qemu process can be used to copy the data of the source cloud hard disk to the new cloud hard disk. Specifically, in the preset target state, the data block copy function in the qemu process that is already in a running state is called through libvirt to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, including: in the preset target state, the data block copy function in the qemu process that is already in a running state is called through libvirt to copy the hard disk data of the cloud hard disk to be migrated to obtain the copied data, and then the corresponding incremental data dirty pages are flushed to complete the cloud hard disk migration operation of the target virtual machine. Among them, the Libvirt is an open source API (Application Programming Interface) for managing virtualization platforms. Call the virtual machine instance corresponding to the cloud hard disk to be migrated through libvirt, use the block_copy function of the virtual machine qemu process to copy the data of the cloud hard disk to be migrated to the target cloud hard disk, and after the copy is completed, flush the incremental data dirty page. It should be noted that the cloud hard disk data migration can only be performed if the qemu process of the current target virtual machine is in running state. It should be further explained that before calling the virtual machine instance corresponding to the cloud hard disk to be migrated through libvirt, the target cloud hard disk needs to be mounted on the host machine corresponding to the target virtual machine, and the basic information of the target cloud hard disk needs to be initialized.
[0063] In this embodiment, after the hard disk data of the cloud hard disk to be migrated is copied to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, it includes: connecting the input and output interface of the target virtual machine to the target cloud hard disk to obtain the new configuration file information generated by the target virtual machine based on the target cloud hard disk; after the old configuration file information of the target virtual machine on the host machine is updated with the new configuration file information, the cloud hard disk to be migrated is uninstalled from the host machine corresponding to the target virtual machine. Specifically, after the data migration is completed, the device corresponding to the target virtual machine needs to be the target cloud hard disk. At this time, the XML (Extensible Markup Language) information of the virtual machine itself will change (because the corresponding cloud hard disk device has changed). At this time, it is necessary to re-acquire the new configuration file information generated by the target virtual machine for the target cloud hard disk, and then replace the old configuration file information with the new configuration file information, and then uninstall the cloud hard disk to be migrated from the host machine corresponding to the target virtual machine.
[0064] In this embodiment, after the hard disk data of the cloud hard disk to be migrated is copied to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, it includes: using the first cloud hard disk mount information of the target cloud hard disk to replace the second cloud hard disk mount information of the cloud hard disk to be migrated stored in the block device mapping table of the Nova component; sending a cloud hard disk migration completion signal to the Cinder component, and after performing a data update operation on the database information of the second database in the Cinder component based on the cloud hard disk migration completion signal, the cloud hard disk to be migrated is deleted by the Cinder component; wherein the data update operation is to replace the second hard disk configuration information of the cloud hard disk to be migrated with the first hard disk configuration information of the target cloud hard disk. As core components of the OpenStack platform, the Nova component and the Cinder component record the cloud hard disk information corresponding to the target virtual machine. When the cloud hard disk operation of the virtual machine is completed, the Nova component and the Cinder component record information about the cloud hard disk should also be updated accordingly. Therefore. First, the cloud hard disk device corresponding to the virtual machine in the BDM table (Block_device_mapping, i.e., the block device mapping table) of the Nova component is the configuration information of the target cloud hard disk. The configuration information is the cloud hard disk mount information. Then the Cinder component is notified to uninstall the cloud hard disk to be migrated, and the Cinder component is notified to complete the migration of the cloud hard disk, and the post-migration operations can be performed. The Cinder component will then update its own database information, exchange the information of the new and old cloud hard disks, update the information of the cloud hard disk to be migrated to the target cloud hard disk, delete the cloud hard disk to be migrated, and complete the migration of the cloud hard disk.
[0065] It can be seen that in this embodiment, the cloud hard disk migration request for the target virtual machine is obtained through the Cinder component, and the target cloud hard disk is created based on the cloud hard disk migration request and the hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine; the Nova component is used to monitor whether the current target virtual machine is in a shutdown state. If the current target virtual machine is in a shutdown state, the corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine, and the virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the current target virtual machine enters the preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state; in the preset target state, libvirt is used to call the data block copy function in the qemu process that is already in a running state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine. That is, by using the startup pause flag to start and pause the target virtual machine, the target virtual machine process is started, but the resources of the target virtual machine are in a paused state and do not enter the virtual machine operating system. At this time, the operating system of the virtual machine will not be loaded, and only the qemu process is created. Then, the data copy function of the qemu process is used to copy the hard disk data of the cloud hard disk to be migrated mounted by the target virtual machine itself to the target cloud hard disk to realize the cloud hard disk migration operation when the virtual machine is shut down. In this way, the cloud hard disk cross-storage migration can be completed directly when the virtual machine is not turned on, and since there is no need to manually unmount and remount the cloud hard disk like the cloud hard disk migration operation when the virtual machine is shut down, the complexity of the cloud hard disk migration operation can be greatly reduced. In addition, it is avoided that the disk of the virtual machine may change the drive letter of the cloud hard disk in the virtual machine due to remounting, resulting in the unavailability of the virtual machine.
[0066] like Figure 4 As shown, the above embodiment proposes a method for migrating cloud hard disks when OpenStack is shut down, and uses the method of pausing the qemu process when it is powered on to realize the method of online qemu process but not starting the virtual machine operating system, and uses qemu's own block_copy capability to migrate cloud hard disks. By optimizing the current cloud hard disk online migration process of Nova, the restriction that cloud hard disks cannot be migrated online in the power-on state is released, and after the new cloud hard disk is mounted, the qemu process of the virtual machine is checked. If the process does not exist, it is determined that the virtual machine is in the shutdown state, and the current function of Nova is expanded. A new method of starting and pausing is added. The qemu process is pulled up through this method, and then the qemu process is called to copy data. This embodiment will introduce how to enter the newly added power-on and pause state.
[0067] See also Figure 5 As shown, an embodiment of the present invention discloses a specific virtual machine cloud hard disk migration method, which is applied to the OpenStack platform. The method includes:
[0068] Step S21: Monitor whether the current target virtual machine is in a shutdown state through the Nova component. If the current target virtual machine is in a shutdown state, the Nova component is used to set the target virtual machine to a target newly added state; the target newly added state is a state pre-added in the Nova component to characterize the current need for cloud hard disk migration.
[0069] In this embodiment, first, after the Nova component receives the online migration cloud hard disk request sent by the Cinder component, it will determine whether the virtual machine state is shut down. That is, the qemu process of the target virtual machine is checked. If the process does not exist, it is determined that the target virtual machine is in a shut down state. If the target virtual machine is in a shut down state, the Nova component is used to execute the operation of setting the target virtual machine to the target newly added state; the target newly added state is a state pre-added in the Nova component to characterize the current need for cloud hard disk migration. It should be noted that under normal circumstances, only virtual machines in the power-on and paused states can perform online migration of cloud hard disks. When the virtual machine is in a shut down or other state, an exception is directly thrown. Therefore, if the current target virtual machine is in a shut down state, then after the Nova component executes the operation of setting the target virtual machine to the target newly added state, it also includes: based on the control logic corresponding to the target newly added state, the target virtual machine is controlled to stop throwing an exception. That is, by adding a new target state, after the Cinder component notifies the Nova component, the Nova component judges the state of the target virtual machine. If the state of the virtual machine is shutdown, the control logic corresponding to the new state is used to control the target virtual machine to stop throwing exceptions and start the cloud hard disk migration operation of the target virtual machine.
[0070] Further, when it is detected that the target virtual machine has been set to the target newly added state, the target virtual machine is locked to obtain the target lock of the target virtual machine; if any operation request for the target virtual machine is detected, the lock of the target virtual machine is checked, and when it is checked that the target virtual machine has the target lock, it is determined whether the arbitrary operation request is an operation request that requires cloud hard disk migration; if the arbitrary operation request is an operation request that requires cloud hard disk migration, the arbitrary operation request is allowed to be executed, otherwise the arbitrary operation request is prohibited to be executed. That is, the present invention adds a target newly added state by extending the virtual machine state, and after the target virtual machine enters this state, the target virtual machine is automatically locked. When other operations are performed on the target virtual machine subsequently, the lock of the virtual machine will be checked first. When there is a lock, other operations are not allowed. In addition, since the present application automatically locks the virtual machine after the virtual machine enters this state, and each time other operations are performed on the virtual machine, the lock of the virtual machine will be checked first. The target virtual machine can be locked with a corresponding state according to the working state of the target virtual machine, the nature of the virtual machine, or the corresponding usage scenario of the target virtual machine. For example, in the present invention, a biased lock can be added to the target virtual machine. In this way, when the target virtual machine is locked and unlocked after the subsequent cloud hard disk migration is completed, no additional consumption is required. Or a lightweight lock can be added to the target virtual machine, so as to improve the response speed of the target virtual machine access. Different locking mechanisms are considered from the perspective of the virtual machine's response speed to the check or the virtual machine's resource consumption, so as to meet different application scenarios and better meet the user's use requirements for cloud hard disk migration of different virtual machines.
[0071] Step S22: when it is detected that the target virtual machine has been set to the target newly added state, the current state information of the target virtual machine is obtained through libvirt, and based on the current state information, it is verified again whether the actual state of the target virtual machine is the shutdown state.
[0072] In this embodiment, when it is detected that the target virtual machine has been set to the target new state, the current state information of the target virtual machine is obtained through libvirt to check the state of the target virtual machine, and it is determined again whether the target virtual machine is in the shutdown state.
[0073] Step S23: If the verification result indicates that the actual state of the target virtual machine is a shutdown state, the device information of the target virtual machine is obtained from the first database of the Nova component, and the first configuration file information of the target virtual machine is generated based on the device information.
[0074] In this embodiment, if the verification result shows that the actual state of the target virtual machine is the shutdown state, the target virtual machine is controlled by the Nova component to start the migration of the cloud hard disk. The device information of the target virtual machine is obtained in the first database of the Nova component, and the first configuration file information of the target virtual machine is generated based on the device information. That is, the target virtual machine is prepared to be suspended and powered on through the Nova component. The block device information, network information, etc. of the virtual machine are queried through the first database of the Nova component, and XML information is generated according to the information of the virtual machine.
[0075] Step S24: creating a libvirt virtual machine instance corresponding to the target virtual machine on the host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine.
[0076] In this embodiment, a libvirt virtual machine instance corresponding to the target virtual machine is created on the host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine. Specifically, the libvirt virtual machine instance is created on the host machine based on the information of the virtual machine, the block device information, the network information, and the XML file.
[0077] Step S25: starting the corresponding virtual machine startup process based on the libvirt virtual machine instance, and obtaining a startup pause flag, and then performing a virtual machine startup pause operation using the startup pause flag before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state.
[0078] In this embodiment, the corresponding virtual machine startup process is then started based on the libvirt virtual machine instance, and the virtual machine startup pause flag is paused=True, so that the virtual machine enters the preset target state under the control of the startup pause flag. Among them, the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state. In other words, the target virtual machine will be in a startup state but the CPU and other resources are in a paused state, and will not enter the operating system of the target virtual machine, but the qemu process corresponding to the virtual machine already exists.
[0079] In addition, it should be noted that after the target virtual machine completes the cloud hard disk migration operation, it is necessary to reset the state of the target virtual machine from the target newly added state to the shutdown state through the Nova component, and unlock the target virtual machine so that the target virtual machine can perform system process work normally.
[0080] It can be seen that in this embodiment, the Nova component is used to monitor whether the current target virtual machine is in a shutdown state. If the current target virtual machine is in a shutdown state, the Nova component is used to set the target virtual machine to a target newly added state; the target newly added state is a state pre-added in the Nova component to indicate that the current cloud hard disk migration needs to be performed; when it is monitored that the target virtual machine has been set to the target newly added state, the current state information of the target virtual machine is obtained through libvirt, and based on the current state information, it is verified again whether the actual state of the target virtual machine is a shutdown state; if the verification result shows that the actual state of the target virtual machine is a shutdown state, the device information of the target virtual machine is obtained in the first database of the Nova component, and the first configuration file information of the target virtual machine is generated based on the device information; a libvirt virtual machine instance corresponding to the target virtual machine is created on the host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine; based on the libvirt virtual machine instance, the corresponding virtual machine startup process is started, and a startup pause flag is obtained, and then the startup pause flag is used to perform a virtual machine startup pause operation before the virtual machine startup process is completed, so that the current target virtual machine enters the preset target state. That is, independent of Nova's existing mechanism, refer to the process of online migration of cloud hard disks, and optimize it in a targeted manner, add a target newly added state, and set the target virtual machine to the target newly added state. After the target virtual machine enters this state, the virtual machine is automatically locked. When other operations are performed on the target virtual machine subsequently, the lock of the target virtual machine will be checked first. When a lock exists, no other operations are allowed. In this way, by pausing the startup of the target virtual machine, the qume process of the virtual machine has started running, solving the problem that the virtual machine needs to uninstall the cloud hard disk, migrate offline, and then mount it when migrating when it is shut down. And it can avoid performing other operations on the virtual machine to avoid business or system damage caused by online migration.
[0081] See also Figure 6 As shown, the embodiment of the present application discloses a network quality detection device, which includes:
[0082] The target hard disk creation module 11 is used to obtain a cloud hard disk migration request for a target virtual machine through a Cinder component, and create a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine;
[0083] The virtual machine state switching module 12 is used to monitor whether the current target virtual machine is in a shutdown state through the Nova component. If the current target virtual machine is in a shutdown state, the corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine, and the virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state;
[0084] The data transfer module 13 is used to call the data block copy function in the running qemu process through libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
[0085] It can be seen that in this embodiment, the target virtual machine is powered on and paused by using the power-on pause flag, so that the target virtual machine process starts up, but the resources of the target virtual machine are in a paused state and do not enter the virtual machine operating system. At this time, the operating system of the virtual machine will not be loaded, and only the qemu process is created. Then, the hard disk data of the cloud hard disk to be migrated mounted by the target virtual machine itself is copied to the target cloud hard disk using the data copy function of the qemu process to realize the cloud hard disk migration operation of the virtual machine when it is shut down. In this way, the cloud hard disk cross-storage migration can be completed directly when the virtual machine is not powered on, and since there is no need to manually unload and re-mount the cloud hard disk like the cloud hard disk migration operation when the virtual machine is shut down, the complexity of the cloud hard disk migration operation can be greatly reduced. In addition, it is avoided that the disk of the virtual machine may change the drive letter of the cloud hard disk in the virtual machine due to re-mounting, resulting in the unavailability of the virtual machine.
[0086] In some specific embodiments, the virtual machine state switching module 12 may specifically include:
[0087] A state monitoring unit, used to monitor whether the target virtual machine is currently in a shutdown state through the Nova component. If the target virtual machine is currently in a shutdown state, the target virtual machine is set to a target newly added state through the Nova component; the target newly added state is a state pre-added in the Nova component for indicating that a cloud hard disk migration is currently required;
[0088] a state verification unit, configured to obtain current state information of the target virtual machine through libvirt when it is detected that the target virtual machine has been set to the target newly added state, and to verify again whether the actual state of the target virtual machine is a shutdown state based on the current state information;
[0089] a configuration information generating unit, configured to obtain device information of the target virtual machine from a first database of a Nova component if the verification result indicates that the actual state of the target virtual machine is a shutdown state, and generate first configuration file information of the target virtual machine based on the device information;
[0090] A virtual machine instance creation unit, configured to create a libvirt virtual machine instance corresponding to the target virtual machine on a host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine;
[0091] The power-on pause unit is used to start the corresponding virtual machine power-on process based on the libvirt virtual machine instance, obtain a power-on pause flag, and then use the power-on pause flag to perform a virtual machine power-on pause operation before the virtual machine power-on process is completed, so that the current target virtual machine enters a preset target state.
[0092] In some specific embodiments, the virtual machine cloud hard disk migration device may further include:
[0093] A virtual machine locking module, configured to lock the target virtual machine when it is detected that the target virtual machine has been set to the target newly added state, so as to obtain a target lock of the target virtual machine;
[0094] An operation request judgment module, configured to check the lock of the target virtual machine if any operation request for the target virtual machine is detected, and to judge whether the any operation request is an operation request requiring cloud hard disk migration when it is detected that the target virtual machine has the target lock;
[0095] The operation corresponding module is used to allow the execution of any operation request if the any operation request is an operation request requiring cloud hard disk migration, and otherwise prohibit the execution of any operation request.
[0096] In some specific embodiments, the virtual machine cloud hard disk migration device may further include:
[0097] The operation control module is used to control the target virtual machine to stop throwing an exception based on the control logic corresponding to the target newly added state.
[0098] In some specific embodiments, the virtual machine cloud hard disk migration device may further include:
[0099] A cloud hard disk initialization module, used to mount the target cloud hard disk to the host machine corresponding to the target virtual machine, and perform basic information initialization operations on the target cloud hard disk;
[0100] A cloud hard disk connection module, used to connect the input and output interfaces of the target virtual machine to the target cloud hard disk to obtain new configuration file information generated by the target virtual machine based on the target cloud hard disk;
[0101] The cloud hard disk information updating module is used to uninstall the cloud hard disk to be migrated from the host machine corresponding to the target virtual machine after updating the old configuration file information of the target virtual machine on the host machine with the new configuration file information.
[0102] In some specific embodiments, the virtual machine cloud hard disk migration device may further include:
[0103] The hard disk status judgment module is used to monitor whether the current cloud hard disk to be migrated is in a mounted state through the Cinder component. If the current cloud hard disk to be migrated is in a mounted state, the Nova component is called through a preset command line tool to perform a cloud hard disk migration operation on the target virtual machine based on the cloud hard disk migration request.
[0104] In some specific embodiments, the virtual machine cloud hard disk migration device may further include:
[0105] A Nova component information update module, configured to replace the second cloud hard disk mount information of the cloud hard disk to be migrated stored in the block device mapping table of the Nova component with the first cloud hard disk mount information of the target cloud hard disk;
[0106] A Cinder component information update module, used to send a cloud hard disk migration completion signal to the Cinder component, and after performing a data update operation on the database information of the second database in the Cinder component based on the cloud hard disk migration completion signal, delete the cloud hard disk to be migrated through the Cinder component;
[0107] The data update operation is to replace the second hard disk configuration information of the cloud hard disk to be migrated with the first hard disk configuration information of the target cloud hard disk.
[0108] In some specific embodiments, the data transfer module 13 may specifically include:
[0109] The incremental data dirty page flushing unit is used to call the data block copy function in the qemu process that is already in the running state through libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to obtain the copied data, and then flush the corresponding incremental data dirty page to complete the cloud hard disk migration operation of the target virtual machine.
[0110] Figure 7 A structure diagram of a virtual machine cloud hard disk migration device provided by an embodiment of the present invention, such as Figure 7 As shown, the virtual machine cloud hard disk migration device includes: a memory 20 for storing computer programs;
[0111] The processor 21 is used to implement the steps of the virtual machine cloud hard disk migration method in the above embodiment when executing the computer program.
[0112] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0113] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the virtual machine cloud hard disk migration method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include but is not limited to virtual machine cloud hard disk migration, etc.
[0114] In some embodiments, the virtual machine cloud hard disk migration may also include a display screen 22 , an input and output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0115] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the virtual machine cloud hard disk migration device, and may include more or fewer components than shown in the figure.
[0116] It is understandable that if the virtual machine cloud hard disk migration method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the contribution to the current technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk and other media that can store program code.
[0117] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the virtual machine cloud hard disk migration method as described above are implemented.
[0118] The above is a detailed introduction to a virtual machine cloud hard disk migration device provided by an embodiment of the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0119] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0120] The above is a detailed introduction to a virtual machine cloud hard disk migration method provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A virtual machine cloud hard disk migration method, characterized in that: Applied to the OpenStack platform, including: Obtain a cloud hard disk migration request for a target virtual machine through a Cinder component, and create a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine; Monitor whether the target virtual machine is in a shutdown state through the Nova component. If the target virtual machine is in a shutdown state, start the corresponding virtual machine startup process based on the virtual machine instance corresponding to the target virtual machine, and perform a virtual machine startup pause operation before the virtual machine startup process is completed, so that the target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the target virtual machine is already in a running state; In the preset target state, libvirt is used to call the data block copy function in the running qemu process to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
2. The virtual machine cloud hard disk migration method according to claim 1, characterized in that: The Nova component is used to monitor whether the target virtual machine is in a shutdown state. If the target virtual machine is in a shutdown state, a corresponding virtual machine startup process is started based on a virtual machine instance corresponding to the target virtual machine, and a virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the target virtual machine enters a preset target state, including: The Nova component is used to monitor whether the target virtual machine is currently in a shutdown state. If the target virtual machine is currently in a shutdown state, the Nova component is used to set the target virtual machine to a target newly added state. The target newly added state is a state pre-added in the Nova component to indicate that a cloud hard disk migration is currently required. When it is detected that the target virtual machine has been set to the target newly added state, current state information of the target virtual machine is obtained through libvirt, and based on the current state information, it is verified again whether the actual state of the target virtual machine is the shutdown state; If the verification result indicates that the actual state of the target virtual machine is a shutdown state, obtaining device information of the target virtual machine in a first database of the Nova component, and generating first configuration file information of the target virtual machine based on the device information; Creating a libvirt virtual machine instance corresponding to the target virtual machine on the host machine based on the device information of the target virtual machine and the first configuration file information of the target virtual machine; Based on the libvirt virtual machine instance, the corresponding virtual machine startup process is started, and a startup pause flag is obtained. Then, before the virtual machine startup process is completed, the startup pause flag is used to perform a virtual machine startup pause operation, so that the current target virtual machine enters a preset target state.
3. The virtual machine cloud hard disk migration method according to claim 2, characterized in that: Also includes: When it is detected that the target virtual machine has been set to the target added state, a locking operation is performed on the target virtual machine to obtain a target lock of the target virtual machine; If any operation request for the target virtual machine is detected, the lock of the target virtual machine is checked, and when it is checked that the target virtual machine has the target lock, it is determined whether the any operation request is an operation request that requires cloud hard disk migration; If the arbitrary operation request is an operation request that requires cloud hard disk migration, the arbitrary operation request is allowed to be executed; otherwise, the arbitrary operation request is prohibited to be executed.
4. The virtual machine cloud hard disk migration method according to claim 2, characterized in that: If the target virtual machine is currently in a shutdown state, after the Nova component is used to set the target virtual machine to a target newly added state, the method further includes: The target virtual machine is controlled to stop throwing an exception based on a control logic corresponding to the target newly added state.
5. The virtual machine cloud hard disk migration method according to claim 1, characterized in that: After the hard disk data of the cloud hard disk to be migrated is copied to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, the method includes: Connecting the input and output interface of the target virtual machine to the target cloud hard disk to obtain new configuration file information generated by the target virtual machine based on the target cloud hard disk; After the old configuration file information of the target virtual machine on the host machine is updated by using the new configuration file information, the cloud hard disk to be migrated is uninstalled from the host machine corresponding to the target virtual machine.
6. The virtual machine cloud hard disk migration method according to claim 1, characterized in that: After obtaining the cloud hard disk migration request for the target virtual machine through the Cinder component and creating the target cloud hard disk based on the cloud hard disk migration request and the hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine, the following steps are included: The Cinder component is used to monitor whether the cloud hard disk to be migrated is in a mounted state. If the cloud hard disk to be migrated is in a mounted state, the Nova component is called through a preset command line tool to perform a cloud hard disk migration operation on the target virtual machine based on the cloud hard disk migration request.
7. The virtual machine cloud hard disk migration method according to claim 1, characterized in that: After the hard disk data of the cloud hard disk to be migrated is copied to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine, the method includes: Using the first cloud hard disk mount information of the target cloud hard disk to replace the second cloud hard disk mount information of the cloud hard disk to be migrated stored in the block device mapping table of the Nova component; Sending a cloud hard disk migration completion signal to the Cinder component, and after performing a data update operation on the database information of the second database in the Cinder component based on the cloud hard disk migration completion signal, deleting the cloud hard disk to be migrated through the Cinder component; The data update operation is to replace the second hard disk configuration information of the cloud hard disk to be migrated with the first hard disk configuration information of the target cloud hard disk.
8. The method for migrating a virtual machine cloud hard disk according to any one of claims 1 to 7, characterized in that: The calling of the data block copy function in the running qemu process by libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine includes: In the preset target state, libvirt is used to call the data block copy function in the running qemu process to copy the hard disk data of the cloud hard disk to be migrated to obtain the copied data, and then the corresponding incremental data dirty page is flushed to complete the cloud hard disk migration operation of the target virtual machine.
9. A virtual machine cloud hard disk migration device, characterized in that: Applied to the OpenStack platform, including: A target hard disk creation module is used to obtain a cloud hard disk migration request for a target virtual machine through a Cinder component, and create a target cloud hard disk based on the cloud hard disk migration request and hard disk parameters of the cloud hard disk to be migrated corresponding to the target virtual machine; A virtual machine state switching module is used to monitor whether the current target virtual machine is in a shutdown state through the Nova component. If the current target virtual machine is in a shutdown state, the corresponding virtual machine startup process is started based on the virtual machine instance corresponding to the target virtual machine, and the virtual machine startup pause operation is performed before the virtual machine startup process is completed, so that the current target virtual machine enters a preset target state; wherein the preset target state is that the target virtual machine has not entered the operating system but the qemu process of the current target virtual machine is already in a running state; The data transfer module is used to call the data block copy function in the running qemu process through libvirt in the preset target state to copy the hard disk data of the cloud hard disk to be migrated to the target cloud hard disk to complete the cloud hard disk migration operation of the target virtual machine.
10. A virtual machine cloud hard disk migration device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of migrating a virtual machine cloud hard disk as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of migrating the virtual machine cloud hard disk according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Migration method and device applied to physical file data of cloud disk
CN119201005A
Virtual machine instance management method and device, equipment and storage medium
CN119806743A
