Virtual machine fallback method and device, equipment and storage medium
By obtaining and copying virtual machine files on the cloud computing platform and performing fallback and consistency detection in exceptional situations, the problem of virtual machine fallback in the existing technology affecting business continuity is solved, and seamless fallback and data integrity is achieved.
Patent Information
- Application Number
- CN202411875596.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-15
AI Technical Summary
An existing virtual machine fallback method requires restarting the host or shutting down the virtual machine, and cannot guarantee business continuity and data integrity.
By obtaining the virtual machine file from the fallback directory of the cloud computing platform and copying it to the virtual machine directory, after completing the transformation, rolling the file back to the fallback directory under abnormal conditions, applying for disk locks and conducting consistency detection, ensuring that the virtual machine falls back seamlessly.
A seamless fallback of virtual machines is achieved, avoiding the need to restart the host or shut down the virtual machine, ensuring business continuity and data integrity.
Smart Images

Figure CN119829201A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual machine technology, and in particular to a virtual machine rollback method and device, an electronic device, and a storage medium. Background Art
[0002] With the rapid development of cloud computing and virtualization technology, virtual machines (VMs) play an increasingly important role in data centers and enterprise environments. Virtual machines provide a high degree of elasticity and resource management capabilities, but they also pose new challenges to system management and fault recovery. During the life cycle of a virtual machine, upgrades and modifications are common operations to adapt to changes in business needs and technological innovations. However, once unexpected errors or compatibility issues occur during the upgrade or modification process, being able to effectively and quickly roll back to the state before the modification is crucial to ensuring business continuity and data integrity.
[0003] After a virtual machine is transformed, some functions may not work properly or may have compatibility issues, which must be resolved by rolling back to the state before the transformation. Therefore, it is particularly important to provide an effective rollback mechanism to ensure that the integrity of virtual machine services and data is not affected. However, existing virtual machine rollback methods usually require restarting the host or shutting down the virtual machine, which not only reduces the user experience but also fails to ensure business continuity. Summary of the invention
[0004] An embodiment of the present application provides a virtual machine rollback method to solve the problem of how to provide a virtual machine rollback method that does not require restarting the host or shutting down the virtual machine.
[0005] Correspondingly, an embodiment of the present application also provides a virtual machine rollback device, an electronic device and a storage medium to ensure the implementation and application of the above method.
[0006] In order to solve the above problem, an embodiment of the present application discloses a virtual machine rollback method, the method comprising:
[0007] Obtain the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform;
[0008] Copying the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine;
[0009] In the case that the transformed virtual machine has an abnormality, the virtual machine file is copied from the virtual machine directory to a fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk;
[0010] Applying a disk lock for the virtual disk;
[0011] Performing consistency detection on the virtual machine that has applied for the disk lock and the virtual machine that has been transformed;
[0012] When the consistency check passes, it is confirmed that the virtual machine has completed the rollback.
[0013] In an optional embodiment of the present application, the transformed virtual machine has a corresponding storage pool, the virtual machine directory of the transformed virtual machine is set with a corresponding directory lock, and applying for a disk lock for the virtual disk includes:
[0014] Applying the disk lock for all the virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, and obtaining the offset corresponding to the disk lock;
[0015] Determining the operating status of the virtual machine after the transformation;
[0016] When the transformed virtual machine is in a powered-on state, the preset virtual disk is locked using the offset corresponding to the preset virtual disk, the directory lock of the virtual machine directory is released, and the directory lock is removed;
[0017] When the transformed virtual machine is in a shutdown state, removing the directory lock;
[0018] The offset is used to update a preset field in the virtual volume table corresponding to the virtual disk.
[0019] In an optional embodiment of the present application, removing the directory lock includes:
[0020] The storage pool information in the virtual machine configuration table corresponding to the transformed virtual machine, the offset corresponding to the directory lock in the virtual machine configuration table, the virtual machine directory, and the sub-files of the virtual machine directory are deleted.
[0021] In an optional embodiment of the present application, copying the virtual machine file from the virtual machine directory to a fallback directory of the cloud computing platform includes:
[0022] Receive a rollback request sent by the user;
[0023] According to the rollback request, query the storage pool associated with the transformed virtual machine from the virtual machine configuration table to obtain the mount path of the storage pool;
[0024] Querying the virtual machine directory under the mount path to obtain the virtual machine file in the virtual machine directory;
[0025] The virtual machine file is copied from the virtual machine directory to the rollback directory.
[0026] In an optional embodiment of the present application, the cloud computing platform includes a computing node and a management node, the virtual machine is located in the computing node, and the management node is at least used to manage the computing node of the current version and the previous version. Before obtaining the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform, the method further includes:
[0027] Modifying the code corresponding to the computing node to obtain a computing node of a first version;
[0028] Performing interface pre-embedding processing on the computing nodes of the first version and the computing nodes of the historical version to obtain a first version of the cloud computing platform; the first version of the cloud computing platform includes a plurality of pre-embedded computing node interfaces of different versions, and the plurality of pre-embedded computing node interfaces of different versions are used to at least support a virtual machine transformation function and a virtual file rollback function;
[0029] Modify the code corresponding to the management node of the first version of the cloud computing platform to obtain a second version of the cloud computing platform, and use the second version of the cloud computing platform as the upgraded cloud computing platform;
[0030] According to the transformation request sent by the user and received by the upgraded cloud computing platform, query the locked disk of the virtual machine before the transformation;
[0031] Under the mount path of the locked disk, the virtual machine directory is created for the virtual machine before the transformation.
[0032] In an optional embodiment of the present application, after copying the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform, the method further includes:
[0033] Applying a directory lock for the virtual machine directory;
[0034] A consistency check is performed between the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency check passes, it is confirmed that the transformation of the virtual machine before the transformation is completed.
[0035] In an optional embodiment of the present application, the performing consistency check on the virtual machine that has applied for the disk lock and the transformed virtual machine includes:
[0036] When the consistency check fails, it is determined that the virtual machine rollback fails, and the state of the virtual machine is set to a data abnormal state;
[0037] Send an alert message to the user, wherein the alert message includes detailed information of the abnormal data status.
[0038] The embodiment of the present application also discloses a virtual machine rollback device, the device comprising:
[0039] A file acquisition module, used to acquire virtual machine files corresponding to the virtual machine from the fallback directory of the cloud computing platform;
[0040] A virtual machine transformation module, used to copy the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine;
[0041] A file rollback module, used for copying the virtual machine file from the virtual machine directory to the rollback directory of the cloud computing platform when an abnormality occurs in the transformed virtual machine, the virtual machine has a corresponding virtual disk, and the rollback directory is located on the virtual disk;
[0042] A disk lock application module, used for applying for a disk lock for the virtual disk;
[0043] A first detection module is used to perform consistency detection between the virtual machine that has applied for the disk lock and the virtual machine that has been transformed;
[0044] The rollback confirmation module is used to confirm that the virtual machine has completed the rollback when the consistency check passes.
[0045] An embodiment of the present application also discloses an electronic device, including: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes the virtual machine rollback method as described in one or more of the embodiments of the present application.
[0046] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes the virtual machine rollback method as described in one or more of the embodiments of the present application.
[0047] Compared with the prior art, the embodiments of the present application have the following advantages:
[0048] In an embodiment of the present application, the virtual machine file corresponding to the virtual machine is obtained from the fallback directory of the cloud computing platform; the virtual machine file is copied from the fallback directory to the virtual machine directory of the cloud computing platform to obtain the transformed virtual machine; in the event of an abnormality in the transformed virtual machine, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; a disk lock is applied for the virtual disk; a consistency check is performed on the virtual machine to which the disk lock is applied and the transformed virtual machine; when the consistency check passes, it is confirmed that the virtual machine has completed the rollback. In an embodiment of the present application, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, and a disk lock is applied for the virtual disk to perform a consistency check. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business. The virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions without affecting the user's experience, thereby providing a reliable rollback solution for virtual machine transformation. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a flowchart of a step of a virtual machine rollback method embodiment of the present application;
[0050] Figure 2 This is a schematic diagram of steps of another embodiment of a method for rolling back a virtual machine of the present application;
[0051] Figure 3 It is a structural block diagram of an embodiment of a rollback device for a virtual machine of the present application;
[0052] Figure 4 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0054] Reference Figure 1 , is a flowchart of a step of a virtual machine rollback method embodiment of the present application, comprising the following steps:
[0055] Step 101: Obtain a virtual machine file corresponding to a virtual machine from a rollback directory of a cloud computing platform.
[0056] In an embodiment of the present application, a virtual machine is deployed on a virtualization or hyper-convergence environment provided by a cloud computing platform. The virtualization or hyper-convergence environment provides the infrastructure required to run the virtual machine, and the virtual machine is an application instance running on the infrastructure. The virtual machine has corresponding virtual machine files, such as a virtual machine configuration file, an nvram file (Non-Volatile Random Access Memory, a configuration file of non-volatile random access memory), etc.
[0057] A virtual machine has a corresponding virtual disk. A virtual disk is a logical storage unit in virtualized storage and is usually used to store disk files, snapshot files, etc. of the virtual machine.
[0058] A virtual machine also has a corresponding storage pool, which is a logical storage unit in a virtualized environment for storing virtual machine disk files, configuration files, and other related files.
[0059] In an embodiment of the present application, before the virtual machine is modified, the virtual machine files are stored in a fallback directory in the virtual disk, and a corresponding disk lock exists on the virtual disk. In one embodiment, the fallback directory may be the / var / lib directory. When the unmodified virtual machine is in the power-on state, the disk lock locks the virtual disk to ensure a single instance of the virtual machine. All virtual disks of the unmodified virtual machine need to apply for lock information, but at startup, only one virtual disk can be locked, namely the locked disk. When hot migrating an unmodified virtual machine, if the storage pool where the locked disk is located is changed, the locked disk also needs to be locked under the destination storage pool, and the locked disk needs to be released and removed in the source storage pool.
[0060] In step 101, firstly, it is necessary to obtain the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform for virtual machine transformation. In one embodiment, the virtual machine file may include a virtual machine configuration file, an nvram file, etc., and the fallback directory is located in the virtual disk, which may be the / var / lib directory.
[0061] Step 102: Copy the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine.
[0062] In step 102, the virtual machine file is copied from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine.
[0063] Specifically, when creating a virtual machine, you need to select the storage pool where the modified virtual machine is located. The virtual machine directory is located under the mount path of this storage pool. The associated storage pool type can be a local storage pool or a CFS (Cloud File System) storage pool. The uuid (Universally Unique Identifier) of this storage pool is required when applying for a directory lock.
[0064] In one embodiment, you can first query the locked disk corresponding to the virtual machine before the transformation, and query the storage pool where the locked disk is located. Create a virtual machine directory for the virtual machine before the transformation under the mount path of the storage pool. Name it with the internal name of the virtual machine to ensure global uniqueness. It cannot be shared and can only be changed through migration. The storage pool to which it belongs. Copy the virtual machine files from the fallback directory to the virtual machine directory. The virtual machine directory needs to be locked when starting up to ensure a single instance of the virtual machine. When the transformed virtual machine is deleted, the virtual machine directory and sub-files will be deleted synchronously. In addition to configuration files and nvram files, other files related to the transformed virtual machine can also be stored in the virtual machine directory.
[0065] Furthermore, in one embodiment, after the virtual machine files are copied from the rollback directory to the virtual machine directory of the cloud computing platform, the previous disk lock needs to be removed, and the directory lock needs to be reapplied according to the virtual machine directory. If the virtual machine is in the power-on state, the locking interface needs to be called, the directory lock needs to be used to re-lock the virtual machine, and then the disk lock is released and removed; if the virtual machine is in the power-off state, the disk lock is directly removed.
[0066] Step 103: If the transformed virtual machine has an abnormality, copy the virtual machine file from the virtual machine directory to the fallback directory of the cloud computing platform. The virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk.
[0067] In step 103, when an abnormality occurs in the transformed virtual machine, the virtual machine files are copied from the virtual machine directory to the fallback directory of the cloud computing platform. The virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk.
[0068] In this embodiment, if there is an abnormality in the modified virtual machine, such as the function of the virtual machine cannot be used normally, the virtual machine can be rolled back. In the process of rolling back the virtual machine, firstly, the virtual machine file is copied from the virtual machine directory to the rollback directory of the cloud computing platform. The rollback directory is the path where the virtual machine file is stored before the modification, which is located in the virtual disk. In one embodiment, the virtual machine file may include a virtual machine configuration file, an nvram file, etc., and the rollback directory may be the / var / lib directory.
[0069] Step 104: Apply for a disk lock for the virtual disk.
[0070] In step 104, after the virtual machine files are copied from the virtual machine directory to the fallback directory of the virtual disk, a disk lock is applied for the virtual disk.
[0071] Applying a lock means applying for an offset through the disk's uuid and the storage pool's uuid. Removing a lock means removing the applied offset. Locking means applying for a lock through the applied offset and the storage pool's uuid. Releasing a lock means applying for a lock through the offset and the storage pool's uuid.
[0072] In one embodiment, the specific steps of applying for a lock for a virtual disk can be expressed as follows: First, a disk lock is applied for all virtual disks according to a disk identifier corresponding to the virtual disk and a storage pool identifier corresponding to the storage pool, thereby obtaining an offset corresponding to the disk lock. The running state of the transformed virtual machine is determined, that is, whether the transformed virtual machine is in a powered-on state or a powered-off state.
[0073] When the transformed virtual machine is in the power-on state, the preset virtual disk is locked using the offset corresponding to the preset virtual disk, the directory lock of the original virtual machine directory is released, and the directory lock is removed. The preset virtual disk is the locking disk. In one embodiment, the preset virtual disk can be the first virtual disk of the virtual machine. When the transformed virtual machine is in the power-off state, the directory lock can be directly removed. After completing the step of applying for the disk lock, the preset field in the virtual volume table corresponding to the virtual disk is updated using the applied offset.
[0074] Step 105: Perform consistency check on the virtual machine that has applied for the disk lock and the virtual machine that has been transformed.
[0075] In step 105, a consistency check is performed between the virtual machine that has applied for the disk lock and the virtual machine that has been transformed.
[0076] In this embodiment, after the virtual machine rollback is completed, it is necessary to perform a consistency check on the virtual machine that has applied for the disk lock and the virtual machine that has been transformed to ensure the consistency of the virtual machine data before and after the rollback.
[0077] Step 106: When the consistency check passes, confirm that the virtual machine has completed rollback.
[0078] In step 106, when the consistency check passes, it is confirmed that the virtual machine rollback is successful.
[0079] In an embodiment of the present application, the virtual machine file corresponding to the virtual machine is obtained from the fallback directory of the cloud computing platform; the virtual machine file is copied from the fallback directory to the virtual machine directory of the cloud computing platform to obtain the transformed virtual machine; in the event of an abnormality in the transformed virtual machine, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; a disk lock is applied for the virtual disk; a consistency check is performed on the virtual machine to which the disk lock is applied and the transformed virtual machine; when the consistency check passes, it is confirmed that the virtual machine has completed the rollback. In an embodiment of the present application, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, and a disk lock is applied for the virtual disk to perform a consistency check. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business. The virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions without affecting the user's experience, thereby providing a reliable rollback solution for virtual machine transformation.
[0080] In an optional embodiment of the present application, the transformed virtual machine has a corresponding storage pool, the virtual machine directory of the transformed virtual machine is set with a corresponding directory lock, and applying for a disk lock for the virtual disk includes:
[0081] Applying the disk lock for all the virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, and obtaining the offset corresponding to the disk lock;
[0082] Determining the operating status of the virtual machine after the transformation;
[0083] When the transformed virtual machine is in a powered-on state, the preset virtual disk is locked using the offset corresponding to the preset virtual disk, the directory lock of the virtual machine directory is released, and the directory lock is removed;
[0084] When the transformed virtual machine is in a shutdown state, removing the directory lock;
[0085] The offset is used to update a preset field in the virtual volume table corresponding to the virtual disk.
[0086] In this embodiment, there is a corresponding storage pool for the transformed virtual machine, and the virtual machine directory of the transformed virtual machine is set with a corresponding directory lock. When the transformed virtual machine is in the power-on state, the directory lock needs to be used to lock the virtual machine directory to ensure a single instance of the virtual machine.
[0087] In this embodiment, when applying for a disk lock for a virtual disk, first apply for a disk lock for all virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, thereby obtaining an offset corresponding to the disk lock. The lock can be applied using the offset and the storage pool identifier.
[0088] The running state of the transformed virtual machine is determined, that is, whether the transformed virtual machine is in a powered-on state or a powered-off state.
[0089] Since the preset virtual disk needs to be locked when the virtual machine is in the power-on state to ensure a single instance of the virtual machine, if the modified virtual machine is in the power-on state, it is necessary to use the offset corresponding to the preset virtual disk to lock the preset virtual disk, release the directory lock of the original virtual machine directory, and remove the directory lock. The preset virtual disk is the locking disk. In one embodiment, the preset virtual disk can be the first virtual disk of the virtual machine.
[0090] If the modified virtual machine is in the powered-off state, the directory lock can be directly removed without locking the preset virtual disk.
[0091] After completing the step of applying for a disk lock, the preset field in the virtual volume table corresponding to the virtual disk needs to be updated with the offset applied for. The virtual volume table is used to manage and track the database table or data structure of the virtual disk. In one embodiment, the offset obtained by applying for a disk lock can be updated to the offset field in the virtual volume table, and the whether to lock field corresponding to the virtual disk is updated.
[0092] During the rollback process, the embodiment of the present application can ensure the single instance of the virtual machine by locking the preset virtual disk of the virtual machine in the powered-on state; the embodiment of the present application applies for a disk lock for the virtual disk and removes the previous directory lock. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business and realizing the rollback of the virtual machine.
[0093] In an optional embodiment of the present application, removing the directory lock includes:
[0094] The storage pool information in the virtual machine configuration table corresponding to the transformed virtual machine, the offset corresponding to the directory lock in the virtual machine configuration table, the virtual machine directory, and the sub-files of the virtual machine directory are deleted.
[0095] In an embodiment of the present application, when the directory lock is removed, it is also necessary to delete the storage pool information in the virtual machine configuration table corresponding to the transformed virtual machine, the offset corresponding to the directory lock in the virtual machine configuration table, the virtual machine directory, and the sub-files of the virtual machine directory.
[0096] When applying for a disk lock or removing a directory lock, in addition to updating the offset obtained by applying for the disk lock to the offset field in the virtual volume table and updating the lock field corresponding to the virtual disk, you also need to delete the storage pool information in the virtual machine configuration table and the offset corresponding to the directory lock. The virtual machine configuration table stores the configuration information of the virtual machine. In the process of modifying the virtual machine, it is necessary to store the storage pool information and the offset corresponding to the directory lock in the virtual machine configuration table. Therefore, after removing the directory lock, you need to delete the storage pool information in the virtual machine configuration table and the offset corresponding to the directory lock.
[0097] Furthermore, in this embodiment, after the directory lock is removed, the virtual machine directory and the sub-files of the virtual machine directory also need to be deleted to complete the rollback of the virtual machine files.
[0098] The embodiment of the present application implements the rollback of the virtual machine files by deleting the relevant files and information of the virtual machine, thereby completing the rollback of the virtual machine.
[0099] In an optional embodiment of the present application, copying the virtual machine file from the virtual machine directory to a fallback directory of the cloud computing platform includes:
[0100] Receive a rollback request sent by the user;
[0101] According to the rollback request, query the storage pool associated with the transformed virtual machine from the virtual machine configuration table to obtain the mount path of the storage pool;
[0102] Querying the virtual machine directory under the mount path to obtain the virtual machine file in the virtual machine directory;
[0103] The virtual machine file is copied from the virtual machine directory to the rollback directory.
[0104] In this embodiment, the specific steps of copying the virtual machine file from the virtual machine directory to the rollback directory of the cloud computing platform may include the following steps: When an abnormal situation occurs in the virtual machine, a rollback request sent by the user is received, and a rollback function is triggered.
[0105] Since the virtual files of the transformed virtual machine are stored in the virtual machine directory, the storage pool associated with the transformed virtual machine can be queried from the virtual machine configuration table according to the rollback request, the mount path of the storage pool can be obtained, and the virtual machine directory can be queried under the mount path to obtain the virtual machine files in the virtual machine directory, and the virtual machine files can be copied from the virtual machine directory to the rollback directory. In one embodiment, the virtual machine files can include virtual machine configuration files, nvram files, etc., and the rollback directory can be the / var / lib directory.
[0106] The embodiment of the present application copies the virtual machine files from the virtual machine directory to the rollback directory of the cloud computing platform to roll back the virtual machine files to the directory location stored before the transformation, and then applies for a disk lock for the virtual disk, so that the virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions.
[0107] In an optional embodiment of the present application, the cloud computing platform includes a computing node and a management node, the virtual machine is located in the computing node, and the management node is at least used to manage the computing node of the current version and the previous version. Before obtaining the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform, the method further includes:
[0108] Modifying the code corresponding to the computing node to obtain a computing node of a first version;
[0109] Performing interface pre-embedding processing on the computing nodes of the first version and the computing nodes of the historical version to obtain a first version of the cloud computing platform; the first version of the cloud computing platform includes a plurality of pre-embedded computing node interfaces of different versions, and the plurality of pre-embedded computing node interfaces of different versions are used to at least support a virtual machine transformation function and a virtual file rollback function;
[0110] Modify the code corresponding to the management node of the first version of the cloud computing platform to obtain a second version of the cloud computing platform, and use the second version of the cloud computing platform as the upgraded cloud computing platform;
[0111] According to the transformation request sent by the user and received by the upgraded cloud computing platform, query the locked disk of the virtual machine before the transformation;
[0112] Under the mount path of the locked disk, the virtual machine directory is created for the virtual machine before the transformation.
[0113] In this embodiment, the cloud computing platform includes computing nodes and management nodes, the management node provides management functions, and the computing node provides computing functions. The management node and computing node codes are two projects, which can be called through the REST API interface (Representational State Transfer Application Programming Interface, an interface design style based on the HTTP protocol, used for communication between different software systems). The virtual machines on the cloud computing platform are located in the computing nodes, and the management node is used to manage at least the current version and the previous version of the computing nodes.
[0114] In one embodiment, the cloud computing platform version number consists of three digits, which may be a combination of digits such as 6.5.1. If the current version is 6.5.1 and the previous version is 6.5.0, the management node can manage computing nodes of versions 6.5.1 and 6.5.0.
[0115] In the embodiment of the present application, before the virtual machine is modified or rolled back, it is necessary to align the interface support of computing nodes of different versions by pre-embedded interfaces, so that computing nodes of different versions support the virtual machine rollback function consistently. Specifically, in the embodiment, the interface support of computing nodes of different versions can be aligned by the following steps.
[0116] First, the code corresponding to the computing node is modified to obtain the first version of the computing node, and the computing node of the first version is pre-embedded with the computing node of the historical version to complete the first upgrade of the cloud computing platform and obtain the first version of the cloud computing platform. The first version of the cloud computing platform includes several different versions of the pre-embedded computing node interfaces, which can be used to support the virtual machine transformation function and the virtual file rollback function.
[0117] In one embodiment, after the cloud computing platform is upgraded for the first time, several different versions of computing node interfaces that are pre-embedded will not be called, but will be reserved for calls during transformation and rollback after the next upgrade.
[0118] Next, the code corresponding to the management node of the first version of the cloud computing platform is modified to complete the second upgrade of the cloud computing platform, obtain the second version of the cloud computing platform, and use the second version of the cloud computing platform as the upgraded cloud computing platform. For example, if the first version of the cloud computing platform is 6.5.0 and the second version of the cloud computing platform is 6.5.1, the management node can manage the computing nodes of versions 6.5.1 and 6.5.0.
[0119] In one embodiment, the code corresponding to the management node of the first version of the cloud computing platform is modified, mainly to modify the business logic of the modified virtual machine and provide virtual machine modification and rollback functions. In this embodiment, the upgraded cloud computing platform can provide virtual machine modification and rollback functions through several different versions of pre-embedded computing node interfaces.
[0120] After the cloud computing platform upgrade is completed, the virtual machine can be transformed and rolled back. According to the transformation request sent by the user received by the upgraded cloud computing platform, the locked disk of the virtual machine before the transformation is queried, and a virtual machine directory is created for the virtual machine before the transformation under the mount path of the locked disk. In one embodiment, the virtual machine directory is named after the internal name of the virtual machine, which is guaranteed to be globally unique and cannot be shared. The storage pool to which it belongs can only be changed through migration.
[0121] In an optional embodiment, after the virtual machine directory is created, the virtual machine files can be copied from the fallback directory to the virtual machine directory, the previous disk lock can be removed, and the directory lock can be reapplied according to the virtual machine directory to complete the transformation of the virtual machine.
[0122] The embodiment of the present application upgrades the cloud computing platform and, by pre-embedded interfaces, aligns the interface support of computing nodes of different versions, so that computing nodes of different versions have consistent support for the virtual machine fallback function. As a result, the upgraded cloud computing platform can provide virtual machine transformation and fallback functions through the pre-embedded computing node interfaces of several different versions.
[0123] In an optional embodiment of the present application, after copying the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform, the method further includes:
[0124] Applying a directory lock for the virtual machine directory;
[0125] A consistency check is performed between the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency check passes, it is confirmed that the transformation of the virtual machine before the transformation is completed.
[0126] In this embodiment, after the virtual machine files are copied from the rollback directory to the virtual machine directory of the cloud computing platform, a directory lock needs to be applied for the virtual machine directory.
[0127] In one embodiment, the previous disk lock needs to be removed, and the directory lock needs to be re-applied according to the virtual machine directory. If the virtual machine is in the power-on state, the locking interface needs to be called, the directory lock needs to be used to re-lock the virtual machine, and then the disk lock needs to be released and removed; if the virtual machine is in the power-off state, the disk lock needs to be directly removed. Thus, the application of the directory lock is completed.
[0128] A consistency check is performed on the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency check passes, it is confirmed that the transformation of the virtual machine before the transformation is completed.
[0129] The embodiment of the present application completes the transformation of the virtual machine by applying for a directory lock for the virtual machine directory and performing a consistency check.
[0130] In an optional embodiment of the present application, the performing consistency check on the virtual machine that has applied for the disk lock and the transformed virtual machine includes:
[0131] When the consistency check fails, it is determined that the virtual machine rollback fails, and the state of the virtual machine is set to a data abnormal state;
[0132] Send an alert message to the user, wherein the alert message includes detailed information of the abnormal data status.
[0133] In this embodiment, if the consistency check between the virtual machine that has applied for the disk lock and the transformed virtual machine fails, it can be determined that the virtual machine rollback has failed, the virtual machine status is set to a data abnormality status, and an alarm message is sent to the user, including detailed information on the data abnormality status to remind the user to handle it.
[0134] In the embodiment of the present application, when the virtual machine fails to roll back, an alarm message will be sent to the user to remind the user to handle the abnormal situation in time.
[0135] In an optional embodiment of the present application, when a user needs to roll back a virtual machine, the user can be authenticated first. The authentication method includes but is not limited to face authentication, account and password authentication, etc. This embodiment does not impose any restrictions on the authentication method. Only when the user authentication is passed, the user is allowed to issue a rollback request. In one embodiment, the virtual machine file can also be encrypted during the rollback process.
[0136] The embodiments of the present application can ensure that only authorized users and applications can perform rollback operations by strengthening permission control, prevent unauthorized access and operations, and ensure the security of data transmission and storage.
[0137] In an embodiment of the present application, the virtual machine file corresponding to the virtual machine is obtained from the fallback directory of the cloud computing platform; the virtual machine file is copied from the fallback directory to the virtual machine directory of the cloud computing platform to obtain the transformed virtual machine; in the event of an abnormality in the transformed virtual machine, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; a disk lock is applied for the virtual disk; a consistency check is performed on the virtual machine to which the disk lock is applied and the transformed virtual machine; when the consistency check passes, it is confirmed that the virtual machine has completed the rollback. In an embodiment of the present application, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, and a disk lock is applied for the virtual disk to perform a consistency check. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business. The virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions without affecting the user's experience, thereby providing a reliable rollback solution for virtual machine transformation.
[0138] In order to enable those skilled in the art to more clearly understand the technical solution of the embodiment of the present application, a virtual machine rollback method of the embodiment of the present application will be fully described below.
[0139] Reference Figure 2 , is a step diagram of another virtual machine rollback method embodiment of the present application.
[0140] Before rolling back the virtual machine, the cloud computing platform needs to be upgraded and the virtual machine needs to be transformed.
[0141] First, the cloud computing platform is upgraded. The first upgrade modifies the code corresponding to the computing node to obtain the first version of the computing node, and pre-embeds the interface between the first version of the computing node and the historical version of the computing node. The pre-embedded computing node interfaces of several different versions can be used to support the virtual machine transformation function and the virtual file rollback function. The second upgrade modifies the code corresponding to the management node of the first version of the cloud computing platform to obtain the upgraded cloud computing platform. The upgraded cloud computing platform can provide virtual machine transformation and rollback functions through the pre-embedded computing node interfaces of several different versions.
[0142] Secondly, after the cloud computing platform upgrade is completed, the virtual machine is transformed. Query the locked disk corresponding to the virtual machine before the transformation, and query the storage pool where the locked disk is located, and create a virtual machine directory for the virtual machine before the transformation under the mount path of the storage pool. Copy the virtual machine files from the fallback directory to the virtual machine directory, remove the previous disk lock, and re-apply for the directory lock according to the virtual machine directory. Perform a consistency check on the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency check passes, it is confirmed that the transformation of the virtual machine before the transformation has been completed.
[0143] like Figure 2 As shown, when an abnormal situation occurs in the transformed virtual machine, a rollback operation can be performed on the transformed virtual machine. The specific process is as follows:
[0144] Step 201, copy the virtual machine file from the virtual machine directory to the rollback directory on the virtual disk. If it fails, it is determined that the rollback fails; if it succeeds, jump to step 202.
[0145] Step 202: Apply for disk locks for all virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, thereby obtaining the offset corresponding to the disk lock. If it fails, it is determined that the rollback fails and the file is deleted; if it succeeds, jump to step 203.
[0146] Step 203: determine the running state of the modified virtual machine, that is, determine whether the modified virtual machine is in the power-on state or the power-off state. If the modified virtual machine is in the power-on state, jump to step 204; if the modified virtual machine is in the power-off state, jump to step 206.
[0147] Step 204: Use the offset corresponding to the preset virtual disk to lock the preset virtual disk. If it fails, it is determined that the rollback fails, the disk lock is removed, and the file is deleted; if it succeeds, jump to step 205.
[0148] Step 205: Release the directory lock of the original virtual machine directory. If it fails, it is determined that the rollback fails, releases and removes the disk lock, and deletes the file; if it succeeds, jump to step 206.
[0149] Step 206, remove the directory lock. If it fails, it is determined that the rollback fails, and after locking the disk, the disk lock is released and removed to delete the file; if it succeeds, jump to step 207.
[0150] Step 207, save the disk lock information to the database. Update the offset obtained by applying for the disk lock to the offset field in the virtual volume table, and update the lock field corresponding to the virtual disk, delete the storage pool information in the virtual machine configuration table and the offset corresponding to the directory lock. If it fails, it is determined that the rollback fails, apply for a disk lock on the disk, and determine whether the virtual machine is powered on. If it is powered on, lock the disk, thereby releasing and removing the disk lock. If it is powered off, directly remove the disk lock and delete the file; if successful, jump to step 208.
[0151] Step 208: Delete the virtual machine directory and the sub-files of the virtual machine directory.
[0152] Step 209: Perform consistency check on the virtual machine that has applied for the disk lock and the virtual machine that has been transformed. If the consistency check passes, confirm that the virtual machine has completed rollback; if the consistency check fails, jump to step 210.
[0153] Step 210: Set the virtual machine state to a data abnormal state, and send an alarm message to the user.
[0154] In an embodiment of the present application, the virtual machine file corresponding to the virtual machine is obtained from the fallback directory of the cloud computing platform; the virtual machine file is copied from the fallback directory to the virtual machine directory of the cloud computing platform to obtain the transformed virtual machine; in the event of an abnormality in the transformed virtual machine, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; a disk lock is applied for the virtual disk; a consistency check is performed on the virtual machine to which the disk lock is applied and the transformed virtual machine; when the consistency check passes, it is confirmed that the virtual machine has completed the rollback. In an embodiment of the present application, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, and a disk lock is applied for the virtual disk to perform a consistency check. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business. The virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions without affecting the user's experience, thereby providing a reliable rollback solution for virtual machine transformation.
[0155] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0156] On the basis of the above embodiments, this embodiment further provides a virtual machine rollback device, which is applied to electronic devices such as terminal devices and servers.
[0157] Reference Figure 3 , shows a structural block diagram of an embodiment of a virtual machine rollback device of the present application, which may specifically include the following modules:
[0158] The file acquisition module 301 is used to acquire the virtual machine file corresponding to the virtual machine from the rollback directory of the cloud computing platform;
[0159] A virtual machine transformation module 302 is used to copy the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine;
[0160] A file rollback module 303, configured to copy the virtual machine file from the virtual machine directory to a rollback directory of the cloud computing platform when an abnormality occurs in the transformed virtual machine, the virtual machine has a corresponding virtual disk, and the rollback directory is located on the virtual disk;
[0161] A disk lock application module 304 is used to apply for a disk lock for the virtual disk;
[0162] A first detection module 305 is used to perform consistency detection between the virtual machine that has applied for the disk lock and the virtual machine that has been transformed;
[0163] The rollback confirmation module 306 is used to confirm that the virtual machine has completed the rollback when the consistency check passes.
[0164] In an optional embodiment of the present application, the transformed virtual machine has a corresponding storage pool, the virtual machine directory of the transformed virtual machine is set with a corresponding directory lock, and the disk lock application module 304 includes:
[0165] A lock application submodule, used for applying for the disk lock for all the virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, and obtaining the offset corresponding to the disk lock;
[0166] An operation status judgment submodule is used to judge the operation status of the virtual machine after the transformation;
[0167] A first lock removal submodule is used to lock the preset virtual disk using the offset corresponding to the preset virtual disk, release the directory lock of the virtual machine directory, and remove the directory lock when the transformed virtual machine is in a powered-on state;
[0168] A second lock removal submodule is used to remove the directory lock when the transformed virtual machine is in a shutdown state;
[0169] The offset updating submodule is used to update a preset field in the virtual volume table corresponding to the virtual disk using the offset.
[0170] In an optional embodiment of the present application, removing the directory lock includes:
[0171] The storage pool information in the virtual machine configuration table corresponding to the transformed virtual machine, the offset corresponding to the directory lock in the virtual machine configuration table, the virtual machine directory, and the sub-files of the virtual machine directory are deleted.
[0172] In an optional embodiment of the present application, the file rollback module 303 includes:
[0173] The rollback request submodule is used to receive the rollback request sent by the user;
[0174] A mount path acquisition submodule, configured to query the storage pool associated with the transformed virtual machine from the virtual machine configuration table according to the rollback request, and obtain the mount path of the storage pool;
[0175] A virtual machine file acquisition submodule, used to query the virtual machine directory under the mount path and acquire the virtual machine file in the virtual machine directory;
[0176] The virtual machine file copying submodule is used to copy the virtual machine file from the virtual machine directory to the fallback directory.
[0177] In an optional embodiment of the present application, the cloud computing platform includes a computing node and a management node, the virtual machine is located in the computing node, the management node is at least used to manage the computing node of the current version and the previous version, and the device further includes:
[0178] A computing node modification module, used to modify the code corresponding to the computing node to obtain a computing node of a first version;
[0179] A first version update module is used to perform interface pre-embedding processing on the computing nodes of the first version and the computing nodes of the historical version to obtain a first version of the cloud computing platform; the first version of the cloud computing platform includes a plurality of pre-embedded computing node interfaces of different versions, and the plurality of pre-embedded computing node interfaces of different versions are used to support at least a virtual machine transformation function and a virtual file rollback function;
[0180] A second version update module is used to modify the code corresponding to the management node of the first version of the cloud computing platform to obtain a second version of the cloud computing platform, and use the second version of the cloud computing platform as the upgraded cloud computing platform;
[0181] A locked disk query module, used to query the locked disk of the virtual machine before the transformation according to the transformation request sent by the user received by the upgraded cloud computing platform;
[0182] The directory creation module is used to create the virtual machine directory for the virtual machine before the transformation under the mounting path of the locked disk.
[0183] In an optional embodiment of the present application, the device further includes:
[0184] A directory lock application module, used for applying for a directory lock for the virtual machine directory;
[0185] The second detection module is used to perform consistency detection on the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency detection passes, it is confirmed that the transformation of the virtual machine before the transformation is completed.
[0186] In an optional embodiment of the present application, the first detection module 305 includes:
[0187] The abnormality determination submodule is used to determine that the virtual machine rollback fails when the consistency detection fails, and set the state of the virtual machine to a data abnormal state;
[0188] The alarm submodule is used to send an alarm message to the user, wherein the alarm message includes detailed information of the abnormal data status.
[0189] In an embodiment of the present application, the virtual machine file corresponding to the virtual machine is obtained from the fallback directory of the cloud computing platform; the virtual machine file is copied from the fallback directory to the virtual machine directory of the cloud computing platform to obtain the transformed virtual machine; in the event of an abnormality in the transformed virtual machine, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; a disk lock is applied for the virtual disk; a consistency check is performed on the virtual machine to which the disk lock is applied and the transformed virtual machine; when the consistency check passes, it is confirmed that the virtual machine has completed the rollback. In an embodiment of the present application, the virtual machine file is copied from the virtual machine directory to the fallback directory of the cloud computing platform, and a disk lock is applied for the virtual disk to perform a consistency check. During the rollback process, there is no need to restart the host or shut down the virtual machine, thereby ensuring the continuity of the user's business. The virtual machine can seamlessly roll back to the state before the transformation and maintain the normal operation of all functions without affecting the user's experience, thereby providing a reliable rollback solution for virtual machine transformation.
[0190] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.
[0191] The present application embodiment provides one or more machine-readable media on which instructions are stored, and when executed by one or more processors, an electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes various types of devices such as terminal devices and servers (clusters).
[0192] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices and servers (clusters). Figure 4 An exemplary apparatus 400 that may be used to implement various embodiments described in this application is schematically illustrated.
[0193] For one embodiment, Figure 4 An exemplary apparatus 400 is shown having one or more processors 402, a control module (chip set) 404 coupled to at least one of the processor(s) 402, a memory 406 coupled to the control module 404, a non-volatile memory (NVM) / storage device 408 coupled to the control module 404, one or more input / output devices 410 coupled to the control module 404, and a network interface 412 coupled to the control module 404.
[0194] The processor 402 may include one or more single-core or multi-core processors, and the processor 402 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 400 can be used as a terminal device, server (cluster), etc. described in the embodiments of the present application.
[0195] In some embodiments, the apparatus 400 may include one or more computer-readable media (e.g., memory 406 or NVM / storage device 408) having instructions 414 and one or more processors 402 combined with the one or more computer-readable media and configured to execute the instructions 414 to implement a module to perform the actions described in the present disclosure.
[0196] For one embodiment, control module 404 may include any suitable interface controller to provide any suitable interface to at least one of processor(s) 402 and / or any suitable device or component in communication with control module 404 .
[0197] The control module 404 may include a memory controller module to provide an interface to the memory 406. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0198] The memory 406 may be used, for example, to load and store data and / or instructions 414 for the device 400. For one embodiment, the memory 406 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 406 may include a double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).
[0199] For one embodiment, control module 404 may include one or more input / output controllers to provide interfaces to NVM / storage device 408 and input / output device(s) 410 .
[0200] For example, NVM / storage 408 may be used to store data and / or instructions 414. NVM / storage 408 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).
[0201] NVM / storage device 408 may include storage resources that are physically part of the device on which apparatus 400 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 408 may be accessed via input / output device(s) 410 over a network.
[0202] (One or more) input / output devices 410 may provide an interface for the apparatus 400 to communicate with any other appropriate device, and the input / output device 410 may include a communication component, an audio component, a sensor component, etc. The network interface 412 may provide an interface for the apparatus 400 to communicate through one or more networks, and the apparatus 400 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.
[0203] For one embodiment, at least one of the processor(s) 402 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 404. For one embodiment, at least one of the processor(s) 402 may be packaged together with the logic of one or more controllers of the control module 404 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 402 may be integrated on the same die with the logic of one or more controllers of the control module 404. For one embodiment, at least one of the processor(s) 402 may be integrated on the same die with the logic of one or more controllers of the control module 404 to form a system-on-chip (SoC).
[0204] In various embodiments, the device 400 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the device 400 may have more or fewer components and / or different architectures. For example, in some embodiments, the device 400 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0205] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.
[0206] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0207] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0208] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a fallback terminal device of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable virtual machine to generate a machine, so that the instructions executed by the processor of the fallback terminal device of the computer or other programmable virtual machine generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0209] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable virtual machine to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0210] These computer program instructions may also be loaded onto a fallback terminal device of a computer or other programmable virtual machine, so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions executed on the computer or other programmable terminal device for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0211] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0212] Finally, it should be noted that, in this article, 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 "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal 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 terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0213] The above is a detailed introduction to a virtual machine rollback method and device, an electronic device and a storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A virtual machine rollback method, characterized in that: The method comprises: Obtain the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform; Copying the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine; In the case that the transformed virtual machine has an abnormality, the virtual machine file is copied from the virtual machine directory to a fallback directory of the cloud computing platform, the virtual machine has a corresponding virtual disk, and the fallback directory is located on the virtual disk; Applying a disk lock for the virtual disk; Performing consistency detection on the virtual machine that has applied for the disk lock and the virtual machine that has been transformed; When the consistency check passes, it is confirmed that the virtual machine has completed the rollback.
2. The method according to claim 1, characterized in that The transformed virtual machine has a corresponding storage pool, the virtual machine directory of the transformed virtual machine is set with a corresponding directory lock, and applying for a disk lock for the virtual disk includes: Applying the disk lock for all the virtual disks according to the disk identifier corresponding to the virtual disk and the storage pool identifier corresponding to the storage pool, and obtaining the offset corresponding to the disk lock; Determining the operating status of the virtual machine after the transformation; When the transformed virtual machine is in a powered-on state, the preset virtual disk is locked using the offset corresponding to the preset virtual disk, the directory lock of the virtual machine directory is released, and the directory lock is removed; When the transformed virtual machine is in a shutdown state, removing the directory lock; The offset is used to update a preset field in the virtual volume table corresponding to the virtual disk.
3. The method according to claim 2, characterized in that The removing of the directory lock comprises: The storage pool information in the virtual machine configuration table corresponding to the transformed virtual machine, the offset corresponding to the directory lock in the virtual machine configuration table, the virtual machine directory, and the sub-files of the virtual machine directory are deleted.
4. The method according to claim 3, characterized in that The step of copying the virtual machine file from the virtual machine directory to the fallback directory of the cloud computing platform includes: Receive a rollback request sent by the user; According to the rollback request, query the storage pool associated with the transformed virtual machine from the virtual machine configuration table to obtain the mount path of the storage pool; Query the virtual machine directory under the mount path to obtain the virtual machine file in the virtual machine directory; The virtual machine file is copied from the virtual machine directory to the rollback directory.
5. The method according to claim 1, characterized in that The cloud computing platform includes a computing node and a management node, the virtual machine is located in the computing node, and the management node is at least used to manage the computing nodes of the current version and the previous version. Before obtaining the virtual machine file corresponding to the virtual machine from the fallback directory of the cloud computing platform, the method also includes: Modifying the code corresponding to the computing node to obtain a computing node of a first version; Performing interface pre-embedding processing on the computing nodes of the first version and the computing nodes of the historical version to obtain a first version of the cloud computing platform; the first version of the cloud computing platform includes a plurality of pre-embedded computing node interfaces of different versions, and the plurality of pre-embedded computing node interfaces of different versions are used to at least support a virtual machine transformation function and a virtual file rollback function; Modifying the code corresponding to the management node of the first version of the cloud computing platform to obtain a second version of the cloud computing platform, and using the second version of the cloud computing platform as the upgraded cloud computing platform; According to the transformation request sent by the user and received by the upgraded cloud computing platform, query the locked disk of the virtual machine before the transformation; Under the mount path of the locked disk, the virtual machine directory is created for the virtual machine before the transformation.
6. The method according to claim 5, characterized in that After copying the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform, the method further includes: Applying a directory lock for the virtual machine directory; A consistency check is performed between the virtual machine that has applied for the directory lock and the virtual machine before the transformation. When the consistency check passes, it is confirmed that the transformation of the virtual machine before the transformation is completed.
7. The method according to claim 1, characterized in that The performing consistency detection on the virtual machine that has applied for the disk lock and the transformed virtual machine includes: When the consistency check fails, it is determined that the virtual machine rollback fails, and the state of the virtual machine is set to a data abnormal state; Send an alert message to the user, wherein the alert message includes detailed information of the abnormal data status.
8. A virtual machine rollback device, characterized in that: The device comprises: A file acquisition module, used to acquire virtual machine files corresponding to the virtual machine from the fallback directory of the cloud computing platform; A virtual machine transformation module, used to copy the virtual machine file from the rollback directory to the virtual machine directory of the cloud computing platform to obtain a transformed virtual machine; A file rollback module, used for copying the virtual machine file from the virtual machine directory to the rollback directory of the cloud computing platform when an abnormality occurs in the transformed virtual machine, the virtual machine has a corresponding virtual disk, and the rollback directory is located on the virtual disk; A disk lock application module, used for applying for a disk lock for the virtual disk; A first detection module is used to perform consistency detection between the virtual machine that has applied for the disk lock and the virtual machine that has been transformed; The rollback confirmation module is used to confirm that the virtual machine has completed the rollback when the consistency check passes.
9. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, causes the processor to execute the virtual machine rollback method as described in one or more of claims 1-7.
10. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to execute the virtual machine rollback method according to one or more of claims 1-7.