Method, device, storage medium and electronic equipment for rebuilding virtual machine
By disconnecting the virtual machine from the system volume, performing rewrite processing, and updating the mount relationship, the problem of low virtual machine reconstruction efficiency is solved, and efficient and secure virtual machine reconstruction is achieved.
Patent Information
- Application Number
- CN202510827302.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-06-19
AI Technical Summary
Existing technologies are inefficient in rebuilding virtual machines, and cannot efficiently complete the re-initialization and reconfiguration of virtual machines.
By disconnecting the target virtual machine from the system volume, rewriting is performed and the mount relationship is updated, avoiding the creation of a new system volume and ensuring data security and consistency.
It improves the efficiency of virtual machine reconstruction, ensures data security and system consistency, avoids the risk of data corruption, and achieves effective virtual machine reconstruction.
Smart Images

Figure CN120723377B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud and edge computing, and more specifically, to a method, apparatus, storage medium, and electronic device for rebuilding a virtual machine. Background Technology
[0002] With the rapid development of cloud computing and virtualization technologies, virtual machines have become an indispensable component of modern data centers and cloud computing environments. Virtual machines offer flexible resource allocation, efficient isolation mechanisms, and convenient management, enabling users to run multiple independent operating system instances on the same physical server.
[0003] Virtual machine rebuilding refers to the process of reinitializing, configuring, or restoring a virtual machine during its lifecycle, based on user needs or system status. Currently, related technologies typically create a new system volume to replace the original system volume mounted on the virtual machine during rebuilding, resulting in low rebuilding efficiency.
[0004] There is currently no effective solution to the aforementioned problems in the relevant technologies. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, storage medium, and electronic device for rebuilding virtual machines, so as to solve the problem of low rebuilding efficiency in related technologies.
[0006] To achieve the above objectives, according to one aspect of this application, a method for rebuilding a virtual machine is provided. The method includes: upon receiving a rebuild request for a target virtual machine, creating a first mount relationship, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of a target system volume to which the target virtual machine is mounted; disconnecting the connection between the target virtual machine and the target system volume; rewriting data in the target system volume based on a target file to obtain an updated target system volume, wherein the target file refers to a file required for rebuilding the target virtual machine; reconnecting the updated target system volume to the target virtual machine; updating the first mount relationship based on the connection information generated by the reconnection; and deleting the historical mount relationship between the target virtual machine and the target system volume to complete the rebuilding of the target virtual machine.
[0007] Furthermore, the virtual machine reconstruction method also includes: locking the target interface through the virtual machine management module before disconnecting the target virtual machine from the target system volume, so as to preserve the device path of the target system volume in the target virtual machine, wherein the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
[0008] Furthermore, the virtual machine reconstruction method also includes: extracting a target identifier from the reconstruction request before rewriting the data in the target system volume based on the target file to obtain the updated target system volume; and determining the virtual machine image file matching the target identifier, or the virtual machine snapshot file matching the target identifier, or the system volume snapshot file matching the target identifier as the target file.
[0009] Furthermore, the virtual machine reconstruction method also includes: after creating the first mount relationship, setting the volume status of the target system volume to the first volume status, wherein the first volume status indicates that the target system volume is in a pending state; after deleting the historical mount relationship between the target virtual machine and the target system volume, setting the volume status of the target system volume to the second volume status, and unlocking the target interface through the virtual machine management module to activate the device path, wherein the second volume status indicates that the target system volume is in a used state.
[0010] Furthermore, the virtual machine reconstruction method also includes: in the event that the connection between the target virtual machine and the target system volume fails to be disconnected, unlocking the target interface through the virtual machine management module and deleting the first mount relationship.
[0011] Furthermore, the virtual machine reconstruction method also includes: before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, generating a memory snapshot file of the target virtual machine at the target time, and generating a system volume snapshot file of the target system volume at the target time; if the rewriting process of the data in the target system volume based on the target file fails, rolling back the target virtual machine and the target system volume based on the memory snapshot file and the system volume snapshot file at the target time; reconnecting the rolled-back target system volume and the rolled-back target virtual machine, and unlocking the target interface through the virtual machine management module and deleting the first mount relationship.
[0012] Furthermore, the virtual machine reconstruction method also includes: if the deletion of historical mount relationships fails, repeating the step of deleting historical mount relationships until the number of repetitions reaches a preset retry threshold, and then adding a first mark to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be reconstructed.
[0013] To achieve the above objectives, according to another aspect of this application, a virtual machine reconstruction apparatus is provided. The apparatus includes: a creation module, configured to, upon receiving a reconstruction request for a target virtual machine, create a first mount relationship, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted; a first processing module, configured to disconnect the connection between the target virtual machine and the target system volume, and rewrite data in the target system volume based on a target file to obtain an updated target system volume, wherein the target file refers to the file required for reconstructing the target virtual machine; and a second processing module, configured to reconnect the updated target system volume and the target virtual machine, update the first mount relationship based on the connection information generated by the reconnection, and delete the historical mount relationship between the target virtual machine and the target system volume to complete the reconstruction of the target virtual machine.
[0014] Furthermore, the virtual machine reconstruction device also includes: a third processing module, used to lock the target interface through the virtual machine management module to preserve the device path of the target system volume in the target virtual machine, wherein the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
[0015] Furthermore, the virtual machine reconstruction apparatus also includes: an extraction module for extracting a target identifier from the reconstruction request; and a determination module for determining a virtual machine image file matching the target identifier, or a virtual machine snapshot file matching the target identifier, or a system volume snapshot file matching the target identifier as the target file.
[0016] Furthermore, the virtual machine reconstruction device also includes: a first setting module, used to set the volume status of the target system volume to a first volume status, wherein the first volume status indicates that the target system volume is in a pending state; and a second setting module, used to set the volume status of the target system volume to a second volume status and unlock the target interface through the virtual machine management module to activate the device path, wherein the second volume status indicates that the target system volume is in a usage state.
[0017] Furthermore, the virtual machine reconstruction device also includes a fourth processing module, used to unlock the target interface and delete the first mount relationship through the virtual machine management module in the event that the connection between the target virtual machine and the target system volume fails to be disconnected.
[0018] Furthermore, the virtual machine reconstruction device also includes: a generation module, used to generate a memory snapshot file of the target virtual machine at the target time, and to generate a system volume snapshot file of the target system volume at the target time; a fifth processing module, used to perform rollback processing on the target virtual machine and the target system volume based on the memory snapshot file and the system volume snapshot file at the target time if the rewrite processing of the data in the target system volume based on the target file fails; and a sixth processing module, used to reconnect the rolled-back target system volume and the rolled-back target virtual machine, and to unlock the target interface and delete the first mount relationship through the virtual machine management module.
[0019] Furthermore, the virtual machine reconstruction device also includes: a seventh processing module, used to repeatedly execute the step of deleting the historical mount relationship when the deletion of the historical mount relationship fails, until the number of repetitions reaches a preset retry threshold, and then add a first mark to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be reconstructed.
[0020] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to execute the above-described virtual machine reconstruction method.
[0021] To achieve the above objectives, according to another aspect of this application, an electronic device is provided, comprising a memory storing an executable program; and a processor for running the program, wherein the program executes the virtual machine reconstruction method described above during runtime.
[0022] To achieve the above objectives, according to another aspect of this application, a computer program product is provided, including computer instructions that, when executed by a processor, implement the steps of the virtual machine reconstruction method described above.
[0023] In this embodiment, upon receiving a rebuild request for the target virtual machine, the connection between the target virtual machine and its mounted target system volume is disconnected, and the target system volume is rewritten. This achieves two goals: firstly, the necessary files for rebuilding are written to the original mounted system volume of the target virtual machine, avoiding the creation of a new system volume and improving rebuild efficiency; secondly, it avoids the risk of data corruption that may occur during operations involving the target virtual machine and the target system volume, ensuring data security and consistency. By reconnecting the updated target system volume to the target virtual machine, updating the first mount relationship accordingly, and deleting historical mount relationships, old data is cleaned up, and the latest mount information of the target virtual machine and the target system volume is maintained. This achieves effective rebuilding of the target virtual machine, ensuring system consistency and stability.
[0024] Therefore, the method provided in this application achieves the purpose of rewriting the system volume that the virtual machine has been mounted to rebuild the virtual machine, realizes the technical effect of improving the rebuilding efficiency, and solves the technical problem of low rebuilding efficiency in related technologies. Attached Figure Description
[0025] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0026] Figure 1 This is a hardware structure block diagram of a computer terminal provided according to an embodiment of this application;
[0027] Figure 2 This is a flowchart of the virtual machine reconstruction method provided in the embodiments of this application. Figure 1 ;
[0028] Figure 3 This is a flowchart of the virtual machine reconstruction method provided in the embodiments of this application. Figure 2 ;
[0029] Figure 4 This is a schematic diagram of a virtual machine reconstruction apparatus provided according to an embodiment of this application;
[0030] Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] It should be noted that the information collected in this application (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, and they do not violate public order and good morals. Corresponding access points are provided for users to choose to authorize or refuse. For example, interfaces are set up between this system and relevant users or organizations, providing users with corresponding access points to choose to agree to or refuse automated decision-making results; if the user chooses to refuse, the process proceeds to the expert decision-making stage.
[0034] Example 1
[0035] According to an embodiment of this application, an embodiment of a virtual machine reconstruction method is also provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0036] The method embodiment provided in Embodiment 1 of this application can be executed on a mobile terminal, computer terminal, or similar computing device. Figure 1 A hardware block diagram of a computer terminal (or mobile device) for implementing a virtual machine reconstruction method is shown. Figure 1As shown, the computer terminal 10 (or mobile device) may include one or more processors 102 (shown as 102a, 102b, ..., 102n in the figure) 102 (processor 102 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 10 may also include... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0037] It should be noted that the aforementioned one or more processors 102 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 10 (or mobile device). As involved in the embodiments of this application, the data processing circuits serve as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).
[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the virtual machine reconstruction method in this embodiment. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, thereby realizing the virtual machine reconstruction method described above. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0039] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 10. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.
[0040] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 10 (or mobile device).
[0041] Under the aforementioned operating environment, this application provides the following: Figure 2 The virtual machine reconstruction method is shown. Figure 2 This is a flowchart of the virtual machine reconstruction method provided in the embodiments of this application. Figure 1 .
[0042] Step S201: Upon receiving a rebuild request for the target virtual machine, a first mount relationship is created, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted.
[0043] Optionally, the target cloud platform can be used as the execution entity of this application to execute the above-described virtual machine reconstruction method. The target cloud platform includes at least a computing service, a block storage service, and a hypervisor module. The computing service is responsible for managing the lifecycle of the cloud host; the computing service can also be called a computing component. The block storage service is responsible for managing the storage resources of the cloud host (such as system volumes, data volumes, etc.); the block storage service can also be called a block storage component. The hypervisor module is responsible for abstracting physical resources (such as CPU, memory, storage, and network) and providing a virtualized runtime environment for the cloud host; the hypervisor module can also be called a virtualization management program. The cloud host is a virtual server provided to the user by the target cloud platform; the cloud host can also be called a virtual machine. In this embodiment, the target virtual machine refers to the virtual machine to be reconstructed in the target cloud platform. Optionally, the target cloud platform may also include a message bus, which is used for information exchange between the computing service and the block storage service.
[0044] Optionally, when it is necessary to rebuild a virtual machine (i.e., the target virtual machine), the user can initiate a rebuild request to the target cloud platform. The rebuild request includes the identifier of the virtual machine to be rebuilt. The computing service can identify the target virtual machine from multiple virtual machines in the target cloud platform based on the identifier.
[0045] In an optional embodiment, when initiating a rebuild request, the user can also specify that the identifier of any one of the three files—the virtual machine image file, the virtual machine snapshot file, and the system volume snapshot file—be added to the rebuild request as a target identifier. This allows the target cloud platform to determine the file required to rebuild the virtual machine based on the target identifier, and then use that file to restore the target virtual machine to its previous or desired state, thereby achieving the rebuild of the target virtual machine. The virtual machine snapshot file includes volume snapshot files of all volumes mounted on the virtual machine (i.e., system volume and data volume).
[0046] Optionally, upon receiving a rebuild request, the compute service may create an empty mount (i.e., the first mount relationship described above). An empty mount includes at least the virtual machine identifier of the target virtual machine (i.e., the first identifier) and the volume identifier of the target system volume to which the target virtual machine is mounted (i.e., the second identifier). The empty mount lacks connection information between the target virtual machine and the target system volume.
[0047] In an optional embodiment, upon receiving a rebuild request, the computing service may mark the target virtual machine as having a first virtual machine state, which indicates that the target virtual machine is to be rebuilt. The first virtual machine state may be represented as "Rebuilding". If the target virtual machine is operating normally, it is in a second virtual machine state, which indicates that the target virtual machine is operating. The second virtual machine state may be represented as "Active".
[0048] In an optional embodiment, upon receiving a rebuild request, the compute service may invoke the block storage service to set the volume status of the target system volume to a first volume status, where the first volume status indicates that the target system volume is in a pending state, and can be represented as reserved. When the target system volume is operating normally, the target system volume is in a second volume status, where the second volume status indicates that the target system volume is operational, and can be represented as in-use.
[0049] Step S202: Disconnect the connection between the target virtual machine and the target system volume, and rewrite the data in the target system volume based on the target file to obtain the updated target system volume. Here, the target file refers to the file required to rebuild the target virtual machine.
[0050] Optionally, the compute service can invoke the block storage service to disconnect the physical connection between the target virtual machine and the target system volume. This means the target virtual machine is temporarily unable to access the data on the target system volume. Afterward, the block storage service overwrites the existing data on the target system volume with the contents of the target file to obtain an updated target system volume.
[0051] The target file can be one of the following: a virtual machine image file, a virtual machine snapshot file, or a system volume snapshot file. The block storage service can determine the target file based on the target identifier in the rebuild request.
[0052] For example, the compute service calls the target interface of the block storage service (e.g., the volume-reimage API) to perform data rewriting of the target system volume based on the ID of the virtual machine image file, virtual machine snapshot file, or system volume snapshot file.
[0053] It's worth noting that by adding a "volume-reimage" API on the storage service side, it's possible to overwrite image data on a specified volume. The compute service can support this protocol through micro-version upgrades, thereby unifying the volume reimage interaction process between the compute and storage services and improving cross-service compatibility. It also supports future expansion with other storage drivers, enhancing system flexibility.
[0054] Step S203: Reconnect the updated target system volume and the target virtual machine, update the first mount relationship based on the connection information generated by the reconnection, and delete the historical mount relationship between the target virtual machine and the target system volume to complete the reconstruction of the target virtual machine.
[0055] Optionally, after completing the rewrite process, the block storage service can send a notification to the compute service to inform it that the rewrite process is complete. For example, the block storage service can send a volume-reimaged event to the compute service after completing the rewrite.
[0056] Optionally, after receiving the notification, the compute service calls the block storage service to reconnect the updated target system volume and the target virtual machine. After the reconnection is completed, the block storage service obtains the connection information between the updated target system volume and the target virtual machine and sends the connection information to the compute service.
[0057] Optionally, the compute service loads the connection information into the first mount relationship to update the first mount relationship and deletes the historical mount relationship between the target virtual machine and the target system volume, thereby replacing the original mount relationship between the target virtual machine and the target system volume. Here, the historical mount relationship refers to the mount relationship between the target virtual machine and the target system volume before reconstruction.
[0058] Optionally, after deleting the historical mount relationship between the target virtual machine and the target system volume, the volume status of the target system volume can be restored to the second volume status.
[0059] It's worth noting that by introducing a "volume-reimaged" external event notification mechanism to replace the traditional polling method for querying task status, asynchronous state synchronization between services is achieved, thus avoiding the problems of high communication overhead and high response latency caused by the traditional polling mechanism. This reduces redundant interactions between computing and storage services, lowering system overhead. State synchronization latency is reduced from the second level to the event-triggered level, improving reconstruction efficiency. Through the design of an atomic operation process (a four-level operation chain of "creating an empty mount - securely detaching the volume - storage-focused mirroring volume - event-triggered remounting of the volume"), the atomicity of each stage ensures transaction integrity during the reconstruction process.
[0060] In this embodiment, upon receiving a rebuild request for the target virtual machine, the connection between the target virtual machine and its mounted target system volume is disconnected, and the target system volume is rewritten. This achieves two goals: firstly, the necessary files for rebuilding are written to the original mounted system volume of the target virtual machine, avoiding the creation of a new system volume and improving rebuild efficiency; secondly, it avoids the risk of data corruption that may occur during operations involving the target virtual machine and the target system volume, ensuring data security and consistency. By reconnecting the updated target system volume to the target virtual machine, updating the first mount relationship accordingly, and deleting historical mount relationships, old data is cleaned up, and the latest mount information of the target virtual machine and the target system volume is maintained. This achieves effective rebuilding of the target virtual machine, ensuring system consistency and stability.
[0061] Therefore, the method provided in this application achieves the purpose of rewriting the system volume that the virtual machine has been mounted to rebuild the virtual machine, realizes the technical effect of improving the rebuilding efficiency, and solves the technical problem of low rebuilding efficiency in related technologies.
[0062] Optionally, in the virtual machine reconstruction method provided in this application embodiment, before disconnecting the connection between the target virtual machine and the target system volume, the method further includes: locking the target interface through the virtual machine management module to retain the device path of the target system volume in the target virtual machine, wherein the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
[0063] Optionally, the compute service can invoke the virtual machine management module to lock the target interface to preserve the device path of the target system volume within the target virtual machine. The target interface refers to the logical interface used by the target virtual machine to connect to the target system volume. For example, if the target interface is a SCSI (Small Computer System Interface) slot associated with the target system volume, the virtual machine management module can set this slot to "occupied" or "unavailable" to prevent other devices or operations from occupying the slot, thereby locking it.
[0064] The aforementioned device path is an identifier used by the operating system to identify and access hardware or virtual devices. In a virtualized environment, when a physical or virtual SCSI device is added to a virtual machine, it is assigned to one of the slots, thus acquiring a fixed "location" or "address". For example, the first virtual hard disk (e.g., the target system volume) might be inserted into the first slot of the SCSI controller, and therefore acquire the device path / dev / vda.
[0065] Optionally, after disconnecting the target virtual machine from the target system volume, the target virtual machine retains the aforementioned device path but marks it as "unavailable".
[0066] For example, when the SCSI controller of the hypervisor creates an empty attachment, it reserves a logical slot in the virtual device tree. Even if the physical volume is detached, the virtual machine can still see the device node (such as / dev / vda), but the status is marked as "unavailable".
[0067] It should be noted that when a physical volume is detached and remounted, the device path (such as / dev / vda) may change, causing the hard-coded path in the virtual machine configuration file to become invalid, requiring manual intervention to repair. Therefore, by locking the target interface, even if the physical connection between the target system volume and the target virtual machine is separated, the target virtual machine can still retain the original device node. This can solve the device path drift problem in traditional methods, avoid configuration failure or data access failure caused by path changes, eliminate the need to manually update the cloud host configuration file, reduce the complexity of operation and maintenance, and thus improve reconstruction efficiency.
[0068] Optionally, in the virtual machine reconstruction method provided in this application embodiment, before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, the method further includes: extracting a target identifier from the reconstruction request; and determining the virtual machine image file matching the target identifier, or the virtual machine snapshot file matching the target identifier, or the system volume snapshot file matching the target identifier as the target file.
[0069] Optionally, after receiving a reconstruction request, the computing service can extract the target identifier from the reconstruction request. For example, the computing service can determine the identifier at a specific location in the reconstruction request as the target identifier, or the computing service can find the target identifier based on a specific field indication in the reconstruction request.
[0070] Optionally, a virtual machine image file is a file containing the complete virtual machine configuration and system state, often used for initial deployment or restoring a virtual machine to its initial state. A virtual machine snapshot file is a snapshot of the virtual machine's system state at a specific point in time. This file includes snapshots of all volumes mounted on the virtual machine (i.e., system volumes and data volumes) at that point in time, used to restore the virtual machine to its most recent stable state. A system volume snapshot file is a snapshot specifically for the virtual machine's system volume; it is a snapshot of the system volume at a specific point in time, used to restore system volume data without affecting non-system volume data.
[0071] Optionally, after determining the target identifier, the target processing system can identify the virtual machine image file, virtual machine snapshot file, or system volume snapshot file that matches the target identifier as the target file. For example, based on the target identifier, a search can be performed in the virtual machine image file library, virtual machine snapshot file library, and system volume snapshot file library to find the corresponding file. Each target identifier uniquely corresponds to one file.
[0072] It should be noted that the above method enables the accurate determination of the files required for the image.
[0073] Optionally, in the virtual machine reconstruction method provided in this application embodiment, after creating the first mount relationship, the method further includes: setting the volume status of the target system volume to a first volume status, wherein the first volume status indicates that the target system volume is in a pending state; after deleting the historical mount relationship between the target virtual machine and the target system volume, the method further includes: setting the volume status of the target system volume to a second volume status, and unlocking the target interface through the virtual machine management module to activate the device path, wherein the second volume status indicates that the target system volume is in a used state.
[0074] Optionally, after creating the first mount relationship, the block storage service sets the volume status of the target system volume to the first volume status, which can be represented as reserved.
[0075] Optionally, after deleting the historical mount relationship between the target virtual machine and the target system volume, the block storage service sets the volume status of the target system volume to a second volume status, which can be represented as in-use.
[0076] Optionally, the computing service can send an instruction to the virtual machine management module to activate the device path. After receiving the instruction, the virtual machine management module unlocks the target interface to activate the device path.
[0077] After deleting the historical mount relationship between the target virtual machine and the target system volume, the compute service can restore the target virtual machine to a second virtual machine state. This second virtual machine state indicates that the target virtual machine is operational and can be represented as "Active". A second marker is then added to the target virtual machine to mark it as a successfully rebuilt virtual machine; this second marker can be represented as "rebuild succeeded".
[0078] It should be noted that by explicitly updating the target system's volume status, it is possible to ensure that the system's operation permissions and behaviors on the volume are correctly standardized at different stages, preventing data risks caused by state confusion. By deleting historical mount relationships and then activating the device path, the smooth operation of the target virtual machine after reconstruction is guaranteed.
[0079] In an optional embodiment, for the four-level operation chain of "creating an empty mount → safely detaching the volume → re-imaging → remounting" in this application, each stage has a rollback compensation mechanism.
[0080] Optionally, for Phase 1 - Creating an empty mount, the rollback compensation can be: if creating an empty mount fails (e.g., the storage service is unavailable), the compute service restores the target virtual machine state to active, and the cloud host task state is set to rebuildfailed (i.e., a first flag is added to it).
[0081] It should be noted that by designing a four-level operation chain of "creating an empty mount → safely detaching the volume → remapping → remounting", each stage has atomicity guarantees and rollback compensation mechanisms, which can avoid data corruption caused by operation interruption in traditional methods (such as the inability to roll back when volume remapping is interrupted).
[0082] Optionally, in the virtual machine reconstruction method provided in this application embodiment, the method further includes: in the event that the connection between the target virtual machine and the target system volume fails to be disconnected, unlocking the target interface through the virtual machine management module and deleting the first mount relationship.
[0083] Optionally, for Phase 2 - Secure Separation Volume, the rollback compensation can be as follows: If the separation of the volume fails (e.g., storage network interruption), the compute service reactivates the reserved device path, the volume status is restored to in-use, the block storage service deletes the empty mount record (i.e., the first mount relationship), the compute service restores the target virtual machine status to active, and the target virtual machine task status is set to rebuild failed (i.e., the first mark is added to it).
[0084] It should be noted that the above method enables the design of a compensation mechanism for the volume separation stage, thereby avoiding data corruption caused by operation interruption in traditional methods.
[0085] Optionally, in the virtual machine reconstruction method provided in this application embodiment, before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, the method further includes: generating a memory snapshot file of the target virtual machine at the target time, and generating a system volume snapshot file of the target system volume at the target time; wherein, the method further includes: if the rewriting process of the data in the target system volume based on the target file fails, performing rollback processing on the target virtual machine and the target system volume based on the memory snapshot file and the system volume snapshot file at the target time; reconnecting the rolled-back target system volume and the rolled-back target virtual machine, and unlocking the target interface through the virtual machine management module and deleting the first mount relationship.
[0086] Optionally, for Phase 3 remapping execution, before the block storage service performs remapping (i.e., rewrite processing), the compute service can request the virtual machine management module to freeze the target virtual machine state and generate a memory snapshot file of the target virtual machine at the current time (i.e., the target time). Simultaneously, the block storage service creates a system volume snapshot file of the target system volume at the current time (i.e., the target time), forming a cross-service consistency recovery point (anchor point). If an anomaly occurs during volume remapping, it can automatically roll back to the anchor point state. Based on volume snapshot chain technology, only differing data is saved, reducing storage occupancy.
[0087] The aforementioned memory snapshot file at the target time may include the running state of the target virtual machine, the application state, and all memory data at the target time. The aforementioned system volume snapshot file at the target time may include the data stored in the target system volume and its metadata state at the target time.
[0088] For Phase 3 reimage execution, the rollback compensation can be as follows: If the reimage fails (e.g., due to disk failure), the target virtual machine is rolled back to its pre-operation state based on the memory snapshot file and the system volume snapshot file at the target time. Afterwards, the target virtual machine reconnects to the system volume, the compute service reactivates the reserved device path, the block storage service deletes the empty mount record, the volume status is restored to in-use, the compute service restores the cloud host status to active, and the cloud host task status is set to rebuildfailed.
[0089] Optionally, during anomaly rollback, only the differential data is saved based on the volume snapshot chain, instead of a full snapshot. This reduces storage footprint by more than 50% compared to traditional full snapshots. Rollback speed is improved, reducing business downtime.
[0090] It should be noted that the above method implements a compensation mechanism for the re-image execution phase, thereby avoiding data corruption caused by operation interruption in traditional methods. Through cross-service consistency anchors (memory snapshots + volume snapshots), it can be ensured that the system and storage states are completely consistent after an abnormal rollback, thus improving the reliability of virtual machine reconstruction and rollback.
[0091] Optionally, in the virtual machine reconstruction method provided in this application embodiment, if the deletion of historical mount relationships fails, the step of deleting historical mount relationships is repeated until the number of repetitions reaches a preset retry threshold, and then a first mark is added to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be reconstructed.
[0092] Optionally, for Phase 4 - Remount, the rollback compensation can be as follows: If remount fails (e.g., mount record replacement fails, i.e., the deletion of the historical mount relationship fails), the compute service can continuously retry deleting the historical mount relationship. If the maximum number of retries is exceeded (i.e., the preset retry threshold, such as 6 times), the compute service marks the cloud host reconstruction as failed (i.e., adds the first mark), and can set the virtual machine status of the target virtual machine to the third virtual machine status. The third virtual machine status represents the failure of the target virtual machine, and the third virtual machine status can be ERROR.
[0093] It should be noted that the above method enables the design of a compensation mechanism for the remounting phase, thereby improving the automation and success rate of the reconstruction process, and thus improving the reliability of reconstruction.
[0094] In one alternative embodiment, Figure 3 This is a flowchart of the virtual machine reconstruction method provided in the embodiments of this application. Figure 2 ,like Figure 3 As shown, the target cloud platform can achieve virtual machine reconstruction through the following steps:
[0095] Step 1, Initialization Phase;
[0096] Step 1.1: The user initiates a rebuild request, specifying any rebuild template source ID from the cloud host image (i.e., virtual machine image file), cloud host snapshot (i.e., virtual machine snapshot file), or system volume snapshot (i.e., system volume snapshot file).
[0097] Step 1.2: The compute component creates an empty mount (empty=True), the cloud host status is Rebuilding, and the block storage component marks the system volume mounted on the cloud host as reserved.
[0098] Step 2, reserve device paths;
[0099] Step 2.1: The compute component calls the hypervisor layer (i.e., the virtual machine management module) to lock the SCSI slot and reserve the device path.
[0100] Step 2.2: The compute service calls the block storage service to separate the connection between the cloud host and the system volume. The cloud host still retains the device node ( / dev / vda) but marks it as "unavailable".
[0101] Step 3, re-image execution;
[0102] The compute service calls the volume-reimage API of the block storage service to perform data rewriting of the system volume based on the cloud host image, cloud host snapshot, or system volume snapshot ID.
[0103] Step 4, Event Synchronization and Recovery;
[0104] Step 4.1: After the block storage service completes the reimage, it sends a volume-reimaged event to the compute service.
[0105] Step 4.2: The compute service calls the block storage service to connect the cloud host and the system volume. The compute service replaces the mount record (i.e., updates the first mount relationship and deletes the historical mount relationship). The volume status is restored to in-use. The compute service requests the hypervisor to activate the device path.
[0106] Step 4.3: Activate the device path in the hypervisor layer.
[0107] Step 4.4: Complete the cloud host reconstruction. The computing service will restore the cloud host status to active, and the cloud host task status will be set to rebuild succeed.
[0108] Therefore, the method provided in this application achieves the purpose of rewriting the system volume that the virtual machine has been mounted to rebuild the virtual machine, realizes the technical effect of improving the rebuilding efficiency, and solves the technical problem of low rebuilding efficiency in related technologies.
[0109] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0110] Example 2
[0111] This application also provides a virtual machine reconstruction apparatus. It should be noted that the virtual machine reconstruction apparatus of this application can be used to execute the virtual machine reconstruction method provided in this application. The virtual machine reconstruction apparatus provided in this application will be described below.
[0112] According to embodiments of this application, an apparatus for implementing the above-described virtual machine reconstruction method is also provided, such as... Figure 4 As shown, the device includes:
[0113] The creation module 401 is used to create a first mount relationship upon receiving a rebuild request for the target virtual machine, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted.
[0114] The first processing module 402 is used to disconnect the connection between the target virtual machine and the target system volume, and rewrite the data in the target system volume based on the target file to obtain the updated target system volume. The target file refers to the file required to rebuild the target virtual machine.
[0115] The second processing module 403 is used to reconnect the updated target system volume and the target virtual machine, update the first mount relationship based on the connection information generated by the reconnection, and delete the historical mount relationship between the target virtual machine and the target system volume to complete the reconstruction of the target virtual machine.
[0116] In this embodiment, upon receiving a rebuild request for the target virtual machine, the connection between the target virtual machine and its mounted target system volume is disconnected, and the target system volume is rewritten. This achieves two goals: firstly, the necessary files for rebuilding are written to the original mounted system volume of the target virtual machine, avoiding the creation of a new system volume and improving rebuild efficiency; secondly, it avoids the risk of data corruption that may occur during operations involving the target virtual machine and the target system volume, ensuring data security and consistency. By reconnecting the updated target system volume to the target virtual machine, updating the first mount relationship accordingly, and deleting historical mount relationships, old data is cleaned up, and the latest mount information of the target virtual machine and the target system volume is maintained. This achieves effective rebuilding of the target virtual machine, ensuring system consistency and stability.
[0117] Therefore, the method provided in this application achieves the purpose of rewriting the system volume that the virtual machine has been mounted to rebuild the virtual machine, realizes the technical effect of improving the rebuilding efficiency, and solves the technical problem of low rebuilding efficiency in related technologies.
[0118] Optionally, in the virtual machine reconstruction apparatus provided in the embodiments of this application, the virtual machine reconstruction apparatus further includes: a third processing module, used to lock the target interface through the virtual machine management module to retain the device path of the target system volume in the target virtual machine, wherein the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
[0119] Optionally, in the virtual machine reconstruction apparatus provided in this application embodiment, the virtual machine reconstruction apparatus further includes: an extraction module, used to extract a target identifier from the reconstruction request; and a determination module, used to determine the virtual machine image file matching the target identifier, or the virtual machine snapshot file matching the target identifier, or the system volume snapshot file matching the target identifier as the target file.
[0120] Optionally, in the virtual machine reconstruction apparatus provided in this application embodiment, the virtual machine reconstruction apparatus further includes: a first setting module, used to set the volume state of the target system volume to a first volume state, wherein the first volume state indicates that the target system volume is in a pending state; and a second setting module, used to set the volume state of the target system volume to a second volume state, and unlock the target interface through the virtual machine management module to activate the device path, wherein the second volume state indicates that the target system volume is in a usage state.
[0121] Optionally, in the virtual machine reconstruction apparatus provided in this application embodiment, the virtual machine reconstruction apparatus further includes: a fourth processing module, used to unlock the target interface and delete the first mount relationship through the virtual machine management module when the connection between the target virtual machine and the target system volume fails to be disconnected.
[0122] Optionally, in the virtual machine reconstruction apparatus provided in this application embodiment, the virtual machine reconstruction apparatus further includes: a generation module, used to generate a memory snapshot file of the target virtual machine at a target time, and to generate a system volume snapshot file of the target system volume at the target time; a fifth processing module, used to perform rollback processing on the target virtual machine and the target system volume based on the memory snapshot file and the system volume snapshot file at the target time if the rewrite processing of the data in the target system volume based on the target file fails; and a sixth processing module, used to reconnect the rolled-back target system volume and the rolled-back target virtual machine, and to unlock the target interface and delete the first mount relationship through the virtual machine management module.
[0123] Optionally, in the virtual machine reconstruction apparatus provided in this application embodiment, the virtual machine reconstruction apparatus further includes: a seventh processing module, used to repeatedly execute the step of deleting the historical mount relationship when the deletion of the historical mount relationship fails, until the number of repetitions reaches a preset retry threshold, and add a first mark to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be reconstructed.
[0124] It should be noted that the creation module 401, the first processing module 402, and the second processing module 403 mentioned above correspond to steps S201 to S203 in Embodiment 1. The three modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in Embodiment 1. It should be noted that the above modules or units can be hardware or software components stored in memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above modules can also be part of a device and run in the computer terminal 10 provided in Embodiment 1.
[0125] Example 3
[0126] Embodiments of this application may provide an electronic device. Figure 5 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 5 As shown, the electronic device may include: one or more ( Figure 5 (Only one is shown) processor 1002, memory 1004, memory controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0127] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the above-described methods. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0128] The processor can invoke information and applications stored in memory via a transmission device to perform the following steps: Upon receiving a rebuild request for the target virtual machine, a first mount relationship is created, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted; the connection between the target virtual machine and the target system volume is disconnected, and the data in the target system volume is rewritten based on the target file to obtain an updated target system volume, wherein the target file refers to the file required to rebuild the target virtual machine; the updated target system volume and the target virtual machine are reconnected, the first mount relationship is updated based on the connection information generated by the reconnection, and the historical mount relationship between the target virtual machine and the target system volume is deleted to complete the rebuild of the target virtual machine.
[0129] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: before disconnecting the connection between the target virtual machine and the target system volume, the target interface is locked through the virtual machine management module to preserve the device path of the target system volume in the target virtual machine, where the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
[0130] The processor can also invoke information and applications stored in memory via a transmission device to perform the following steps: extracting a target identifier from the reconstruction request before rewriting the data in the target system volume based on the target file to obtain an updated target system volume; identifying a virtual machine image file matching the target identifier, or a virtual machine snapshot file matching the target identifier, or a system volume snapshot file matching the target identifier as the target file.
[0131] The processor can also access information and applications stored in memory via a transmission device to perform the following steps: after creating the first mount relationship, the volume status of the target system volume is set to the first volume status, where the first volume status indicates that the target system volume is in a pending state; after deleting the historical mount relationship between the target virtual machine and the target system volume, the volume status of the target system volume is set to the second volume status, and the target interface is unlocked through the virtual machine management module to activate the device path, where the second volume status indicates that the target system volume is in a used state.
[0132] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: The virtual machine reconstruction method also includes: in the event that the connection between the target virtual machine and the target system volume fails to be disconnected, unlocking the target interface through the virtual machine management module and deleting the first mount relationship.
[0133] The processor can also invoke information and applications stored in memory via the transmission device to perform the following steps: before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, generate a memory snapshot file of the target virtual machine at the target time, and generate a system volume snapshot file of the target system volume at the target time; if the rewrite process of the data in the target system volume based on the target file fails, roll back the target virtual machine and the target system volume based on the memory snapshot file and the system volume snapshot file at the target time; reconnect the rolled-back target system volume and the rolled-back target virtual machine, and unlock the target interface through the virtual machine management module and delete the first mount relationship.
[0134] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: if the deletion of the historical mount relationship fails, repeat the step of deleting the historical mount relationship until the number of repetitions reaches the preset retry threshold, and add a first mark to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be rebuilt.
[0135] In this embodiment, upon receiving a rebuild request for the target virtual machine, the connection between the target virtual machine and its mounted target system volume is disconnected, and the target system volume is rewritten. This achieves two goals: firstly, the necessary files for rebuilding are written to the original mounted system volume of the target virtual machine, avoiding the creation of a new system volume and improving rebuild efficiency; secondly, it avoids the risk of data corruption that may occur during operations involving the target virtual machine and the target system volume, ensuring data security and consistency. By reconnecting the updated target system volume to the target virtual machine, updating the first mount relationship accordingly, and deleting historical mount relationships, old data is cleaned up, and the latest mount information of the target virtual machine and the target system volume is maintained. This achieves effective rebuilding of the target virtual machine, ensuring system consistency and stability.
[0136] Therefore, the method provided in this application achieves the purpose of rewriting the system volume that the virtual machine has been mounted to rebuild the virtual machine, realizes the technical effect of improving the rebuilding efficiency, and solves the technical problem of low rebuilding efficiency in related technologies.
[0137] Those skilled in the art will understand that Figure 5 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 5This does not limit the structure of the aforementioned electronic device. For example, electronic devices may also include components that are more... Figure 5 The more or fewer components shown (such as network interfaces, display devices, etc.), or having the same Figure 5 The different configurations shown.
[0138] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0139] Example 4
[0140] Embodiments of this application also provide a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the virtual machine reconstruction method provided in Embodiment 1.
[0141] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0142] This application also provides a computer program product, which, when executed on a data processing device, is adapted to perform the steps of a virtual machine reconstruction method.
[0143] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0144] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0145] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of units or modules may be electrical or other forms.
[0146] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0147] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0148] If the integrated unit is implemented as 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 this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0149] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for rebuilding a virtual machine, characterized in that, include: Upon receiving a rebuild request for the target virtual machine, a first mount relationship is created, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted; Disconnect the connection between the target virtual machine and the target system volume, and rewrite the data in the target system volume based on the target file to obtain the updated target system volume. The target file refers to the file required to rebuild the target virtual machine. The updated target system volume and the target virtual machine are reconnected. The first mount relationship is updated based on the connection information generated by the reconnection, and the historical mount relationship between the target virtual machine and the target system volume is deleted to complete the reconstruction of the target virtual machine.
2. The method according to claim 1, characterized in that, Before disconnecting the target virtual machine from the target system volume, the method further includes: The target interface is locked by the virtual machine management module to preserve the device path of the target system volume in the target virtual machine, wherein the target interface refers to the logical interface used by the target virtual machine to connect to the target system volume.
3. The method according to claim 1, characterized in that, Before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, the method further includes: Extract the target identifier from the reconstruction request; The virtual machine image file that matches the target identifier, or the virtual machine snapshot file that matches the target identifier, or the system volume snapshot file that matches the target identifier, is determined as the target file.
4. The method according to claim 2, characterized in that, After creating the first mount relationship, the method further includes: Set the volume state of the target system volume to a first volume state, wherein the first volume state indicates that the target system volume is in a pending state; After deleting the historical mount relationship between the target virtual machine and the target system volume, the method further includes: Set the volume status of the target system volume to the second volume status, and unlock the target interface through the virtual machine management module to activate the device path, wherein the second volume status indicates that the target system volume is in use.
5. The method according to claim 2, characterized in that, The method further includes: If the connection between the target virtual machine and the target system volume fails to be disconnected, the target interface is unlocked through the virtual machine management module, and the first mount relationship is deleted.
6. The method according to claim 2, characterized in that, Before rewriting the data in the target system volume based on the target file to obtain the updated target system volume, the method further includes: Generate a memory snapshot file of the target virtual machine at the target time, and generate a system volume snapshot file of the target system volume at the target time; The method further includes: If the rewrite process of the data in the target system volume based on the target file fails, the target virtual machine and the target system volume are rolled back based on the memory snapshot file and the system volume snapshot file at the target time. Reconnect the rolled-back target system volume and the rolled-back target virtual machine, unlock the target interface through the virtual machine management module, and delete the first mount relationship.
7. The method according to claim 2, characterized in that, The method further includes: If the deletion of the historical mount relationship fails, the step of deleting the historical mount relationship is repeated until the number of repetitions reaches a preset retry threshold. Then, a first mark is added to the target virtual machine, wherein the first mark is used to mark the target virtual machine as a virtual machine that failed to be rebuilt.
8. A virtual machine reconstruction apparatus, characterized in that, include: A creation module is used to create a first mount relationship upon receiving a rebuild request for a target virtual machine, wherein the first mount relationship includes at least a first identifier of the target virtual machine and a second identifier of the target system volume to which the target virtual machine is mounted; The first processing module is used to disconnect the connection between the target virtual machine and the target system volume, and rewrite the data in the target system volume based on the target file to obtain the updated target system volume. The target file refers to the file required to rebuild the target virtual machine. The second processing module is used to reconnect the updated target system volume and the target virtual machine, update the first mount relationship based on the connection information generated by the reconnection, and delete the historical mount relationship between the target virtual machine and the target system volume to complete the reconstruction of the target virtual machine.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium resides to perform the virtual machine reconstruction method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, executes the virtual machine reconstruction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Volume-started virtual machine reconstruction method, terminal and readable storage medium
CN111240807A
System and method for realizing cross-cloud rapid recovery of virtual machine based on cloud platform volume
CN112506616A