An automatic recovery method, device and equipment of a mirror file and a storage medium

CN115562803BActive Publication Date: 2026-08-28INTEWELL (GUANGZHOU) SOFEWARE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211194081.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-28
Publication Date
2026-08-28
Estimated Expiration
2042-09-28

AI Technical Summary

Technical Problem

若是镜像损坏严重,只能重新安装虚拟机里的系统,那么就需要耗费大量人力精力恢复镜像

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562803B_ABST
    Figure CN115562803B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of mirror image file automatic recovery method, device, equipment and storage medium, the method comprises: when the mirror image system of open source virtual machine Qemu is run, the current state of the mirror image system is inquired;If the current state is abnormal, according to the mirror image recovery logic of pre-configuration, in combination with the mirror image recovery mode of pre-setting, the mirror image file corresponding to the mirror image system is recovered;Based on the mirror image file after recovery, the mirror image system is re-run.Using the method, it can be automatically inquired whether mirror image system is started normally after mirror image system starts, and the mirror image file corresponding to the mirror image system is automatically recovered after determining that the mirror image system is started abnormally.Compared with prior art, manual repair is needed for mirror image file, the present technical solution realizes the automatic repair of mirror image file, improves the reliability of mirror image system, reduces the risk that mirror image system cannot be started, saves manpower cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of virtualization technology, and in particular to an automatic recovery method, apparatus, device, and storage medium for image files. Background Technology

[0002] Qemu (Quick emulator) is a widely used open-source virtual machine on the Linux platform. It provides virtualization services purely in software and, when combined with the Kernel Virtual Machine (KVM) module in the Linux kernel, it can support hardware virtualization. Currently, Qemu+KVM is commonly used to provide virtualization services on the Linux platform.

[0003] The core of a virtual machine is a disk image, which can be understood as the virtual machine's disk, containing the virtual machine's operating system, drivers, and other important files. To run a virtual machine on a host machine, you generally need to create a virtual machine image first and then start the virtual machine. If the image has problems, the virtual machine's system will fail to boot.

[0004] With current technology, if the image is not severely damaged, it can be restored via snapshot using the virtual machine's disk management tool qemu-img, but this requires manual restoration. If the image is severely damaged, the only option is to reinstall the operating system within the virtual machine, which would require a significant amount of manpower and effort to restore the image. Summary of the Invention

[0005] This invention provides an automatic recovery method, apparatus, device, and storage medium for image files, thereby achieving automatic repair of image files, improving the reliability of the image system, reducing the risk of the image system failing to boot, and saving labor costs.

[0006] In a first aspect, embodiments of the present invention provide an automatic recovery method for image files, the method comprising:

[0007] After running the image system of the open-source virtual machine Qemu, query the current status of the image system;

[0008] If the current state is a startup error, then the image file corresponding to the image system is restored according to the pre-configured image recovery logic and the pre-set image recovery method.

[0009] Based on the restored image file, the image system is rerun.

[0010] Furthermore, the step of querying the current status of the image system after running the open-source virtual machine Qemu includes:

[0011] After running the Qemu image system, a status query command is sent to the Qemu.

[0012] The current state of the mirror system is determined based on the data returned in response to the status query command.

[0013] Further, determining the current state of the mirror system based on the data returned in response to the status query command includes:

[0014] If the returned data is not empty, then the current state of the image system is determined to be normal startup.

[0015] If the returned data is empty, then the current state of the image system is determined to be a startup exception.

[0016] Furthermore, the pre-configured image recovery logic includes: image repair cost incrementing logic;

[0017] And / or, the set image recovery methods include: consistency method repair, snapshot method repair and backup method repair.

[0018] Furthermore, the step of restoring the image file corresponding to the image system according to the pre-configured image recovery logic and in combination with the pre-set image recovery method includes:

[0019] Select a consistency method from the image recovery options to restore the image file;

[0020] If the recovery fails, select the snapshot method from the image recovery methods to restore the image file;

[0021] If the recovery still fails, select the backup method from the image recovery methods to restore the image file.

[0022] Further, the step of selecting a snapshot method from the image recovery methods to restore the image file includes:

[0023] Obtain operation permissions for the image file;

[0024] Obtain an image snapshot of the image system;

[0025] The image file is restored based on the image snapshot.

[0026] Further, selecting a backup method from the image recovery methods to restore the image file includes:

[0027] Query the backup image file corresponding to the image system on the local device;

[0028] If the backup image file exists on the local device, then copy the backup image file and replace the original image file;

[0029] Otherwise, obtain the backup image file corresponding to the image system from the external device and replace the image file.

[0030] Secondly, embodiments of the present invention provide an automatic recovery device for image files, the device comprising:

[0031] The status determination module is used to query the current status of the image system after running the Qemu image system;

[0032] The image recovery module is used to recover the image file corresponding to the image system according to the pre-configured image recovery logic and the pre-set image recovery method if the current state is a startup abnormality.

[0033] The rerun module is used to rerun the image system based on the restored image file.

[0034] Thirdly, embodiments of the present invention provide an electronic device, including:

[0035] At least one processor; and

[0036] A memory communicatively connected to the at least one processor; wherein,

[0037] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the automatic recovery method for image files according to any embodiment of the present invention.

[0038] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer instructions, which are used to cause a processor to execute and implement the automatic recovery method for image files as described in any embodiment of the present invention.

[0039] This invention provides an automatic image file recovery method, apparatus, device, and storage medium. The method includes: after running an image system of the open-source virtual machine Qemu, querying the current status of the image system; if the current status is a startup anomaly, then recovering the image file corresponding to the image system according to pre-configured image recovery logic and a pre-set image recovery method; and re-running the image system based on the recovered image file. This technical solution can automatically query whether the image system has started normally after startup, and, upon determining that the image system has started abnormally, automatically recover the image file corresponding to the image system according to pre-configured image recovery logic and sequentially selecting an image recovery method. Compared to existing technologies that require manual repair of image files, this technical solution achieves automatic repair of image files, improves the reliability of the image system, reduces the risk of the image system failing to start, and saves labor costs.

[0040] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0042] Figure 1 This is a flowchart illustrating an automatic recovery method for image files provided in Embodiment 1 of the present invention;

[0043] Figure 2 This is a flowchart illustrating an automatic recovery method for image files provided in Embodiment 2 of the present invention;

[0044] Figure 3 This is a schematic diagram of an automatic recovery device for image files provided in Embodiment 3 of the present invention;

[0045] Figure 4 This is a schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention. Detailed Implementation

[0046] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0047] It should be noted that the terms "original," "target," etc., used in the specification, claims, and accompanying drawings of this invention 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 embodiments of the invention 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 a 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.

[0048] Example 1

[0049] Figure 1 This is a flowchart illustrating an automatic recovery method for image files provided in Embodiment 1 of the present invention. This method is applicable to the automatic recovery of damaged Qemu image files. The method can be executed by an automatic recovery device for image files, which can be implemented in hardware and / or software and is generally integrated into an electronic device.

[0050] like Figure 1 As shown in the figure, the automatic recovery method for image files provided in this embodiment can specifically include the following steps:

[0051] S110. After running the image system of the open-source virtual machine Qemu, query the current status of the image system.

[0052] QEMU is an open-source virtual machine widely used on the Linux platform. It provides virtualization services in a pure software manner. Combined with the KVM module in the Linux kernel, it can support hardware virtualization. Currently, the Linux platform typically uses QEMU+KVM to provide virtualization services: KVM is responsible for CPU and memory virtualization, while QEMU is responsible for device emulation functions, including emulating the Basic Input Output System (BIOS), Peripheral Component Interconnect (PCI) / Peripheral Component Interconnect Express (PCIE) buses, disks, network cards, graphics cards, sound cards, keyboards, mice, etc.

[0053] Qemu has two main operating modes: User mode and System mode. User mode allows Qemu to run Linux programs compiled for different CPUs. System mode allows Qemu to emulate an entire computer system, including the CPU and other peripherals. This makes testing and debugging cross-platform programs easier. It can also be used to virtualize multiple virtual computers on a single host. This embodiment primarily uses System mode.

[0054] Understandably, the architecture typically used on Linux platforms to provide virtualization services, consisting of Qemu and KVM, is a Type 2 Hypervisor (also known as a virtual machine manager). This type of management program cannot be installed locally and requires an operating system to run on the physical host. In this embodiment, an image file is stored on the Linux system. This can be understood as Qemu simulating an empty system on the Linux system, with the image file providing the virtual machine's operating system to support the image system's operation.

[0055] It is understandable that when an image file is corrupted, it cannot support the booting of the image system, leading to boot failure. In this embodiment, a mechanism for determining image corruption is implemented. Based on the Qemu Machine Protocol (QMP), the mechanism calls the Qemu interface to further query the current status of the image system, which includes whether the boot is normal or abnormal.

[0056] QMP is a protocol in the Qemu virtual machine. It is a JSON-based transport protocol that can be used to interact with a Qemu virtual machine instance, such as querying the virtual machine's status.

[0057] Specifically, after running the image system of the open-source virtual machine Qemu, the status of the image file is queried through the QMP command, and the returned data is used to determine whether the image system has started normally.

[0058] S120. If the current status is a startup error, the image file corresponding to the image system will be restored according to the pre-configured image recovery logic and the pre-set image recovery method.

[0059] In this embodiment, if an image system startup anomaly is determined through step S110, automatic recovery of the image file is required to rerun the image system based on the recovered image file. Considering that in existing technologies, when an image file is corrupted, manual recovery is required, resulting in wasted manpower, this embodiment automatically recovers the corresponding image file of the image system using a pre-set image recovery method when an image system startup anomaly is detected.

[0060] The image file is stored in the qcow2 image format, a disk image supported by Qemu. qcow2 can represent a fixed-size block device disk as a single file. Different problems arise from corrupted image files, requiring different image recovery methods for restoration. Preferably, the pre-configured image recovery logic includes: incremental image repair cost logic; and / or, the set image recovery methods include: consistency-based repair, snapshot-based repair, and backup-based repair.

[0061] In this embodiment, the three image recovery methods—consistency repair, snapshot repair, and backup repair—have different costs during recovery. Based on the different costs of these three recovery methods, image recovery logic can be pre-configured to prioritize the recovery methods used, with an increasing repair cost.

[0062] In this embodiment, consistency check recovery performs a consistency check on the image file to determine whether the data in the image file is in a consistent state. Image consistency check recovery can be performed based on the qemu-img tool, specifically by using the image check recovery command to perform a consistency check and recovery on the image file. A snapshot is a point-in-time data copying technology and an important concept in data backup. The purpose of a snapshot is to record and save data information at a specific moment. If a failure occurs later and data recovery is needed, the snapshot can be used to restore the data to its previous state. In this embodiment, a snapshot is created based on the qemu-img tool during the startup and execution of the Qemu image system. Image snapshot recovery can be understood as restoring the image file based on the image snapshot by querying the image snapshot. In this embodiment, backup recovery refers to obtaining the backup image file corresponding to the image file on the local device or external device, replacing the damaged image file with the backup image file, and supporting the image system to run based on the backup image file. It is understood that the cost of backup recovery is greater than snapshot recovery, which is greater than consistency recovery.

[0063] In this embodiment, the least costly repair method is preferred for recovering the image file. For example, if the image file has a consistency issue, consistency recovery is required. If consistency recovery still fails to support the normal startup of the image system, recovery can be performed based on an image snapshot. If no image snapshot exists, or if the image system still fails to start after recovery from an image snapshot, a backup image file needs to be used to replace the original image file to restart the image system. It is understood that if a backup image file is stored on the local device, it will be used to replace the corrupted image file. If no backup image file is stored on the local device, an external device must be used to obtain a backup image file to replace the local image file to support the image system startup.

[0064] S130. Rerun the image system based on the restored image file.

[0065] It is clear that after restoring the image file, the image system can be rerun based on the restored image file to achieve normal startup of the image system and enable subsequent business operations on the system.

[0066] Understandably, if the current status of the image system indicates normal startup, the image file startup process can continue until the image system completes startup. This includes loading relevant data or drivers until the image system finishes startup. Once the system has started, users can perform relevant business operations through the system interface.

[0067] This invention provides an automatic image file recovery method. The method includes: first, after running an image system of the open-source virtual machine Qemu, querying the current status of the image system; then, if the current status is a startup error, restoring the image file corresponding to the image system according to pre-configured image recovery logic and a pre-set image recovery method; finally, re-running the image system based on the restored image file. Using this method, after the image system starts, it can automatically query whether the image system has started normally, and if it is determined that the image system has started abnormally, it can automatically restore the image file corresponding to the image system according to the pre-configured image recovery logic and sequentially select the image recovery method. Compared to existing technologies that require manual repair of image files, this technical solution achieves automatic repair of image files, improves the reliability of the image system, reduces the risk of the image system failing to start, and saves labor costs.

[0068] Example 2

[0069] Figure 2 This is a flowchart illustrating an automatic recovery method for image files provided in Embodiment 2 of the present invention. This embodiment is a further optimization of the above embodiment. In this embodiment, querying the current status of the image system after running the open-source virtual machine Qemu image system is further specified as follows: after running the Qemu image system, a status query command is sent to Qemu; the current status of the image system is determined based on the return data in response to the status query command.

[0070] Furthermore, the recovery of the image file corresponding to the image system is further specified according to the pre-configured image recovery logic and the pre-set image recovery method as follows: select the consistency method from the image recovery methods to repair and recover the image file; if the recovery fails, select the snapshot method from the image recovery methods to repair and recover the image file; if the recovery still fails, select the backup method from the image recovery methods to repair and recover the image file.

[0071] like Figure 2 As shown in the figure, this embodiment 2 provides an automatic recovery method for image files, which specifically includes the following steps:

[0072] S210. After running the Qemu image system, send a status query command to Qemu.

[0073] Specifically, after running the Qemu image system, a status query command is sent to Qemu to obtain the current status of the image system. The current status of the image system can also be understood as the current status of the virtual machine, that is, whether the virtual machine has started normally or abnormally.

[0074] In this step, the current status of the image system is queried using the `qmp` command. The `qmp` command is sent to Qemu. For example, the status query command can be represented as:

[0075] {"execute":"query-acpi-ospm-status"}.

[0076] S220. Determine the current status of the image system based on the data returned in response to the status query command.

[0077] In this step, Qemu receives a status query command and generates corresponding return data. Based on this return data, the current status of the image system can be determined. The current status of the image system includes normal startup and abnormal startup. It is known that the return data for normal startup and abnormal startup are different; based on the received return data, the current status of the image system can be determined.

[0078] Furthermore, based on the data returned in response to the status query command, the current status of the image system is determined, which can be specifically described as follows:

[0079] a1. If the returned data is not empty, then the current state of the image system is determined to be normal startup.

[0080] Specifically, if the image system starts successfully, it will return data from the Central Processing Unit (CPU). Therefore, if the returned data is not empty, it is determined that the current state of the image system is normal startup.

[0081] For example, the returned data can be represented as:

[0082] {"return":[{"source":0,"status":0,"slot":"0","slot-type":"CPU"},{"source":0,"status":0,"slot":"1","slot-type":"CPU"}]}.

[0083] b1. If the returned data is empty, then the current state of the image system is determined to be a startup exception.

[0084] Specifically, if the image system fails to start, it will return empty data. Therefore, if the returned data is empty, it is determined that the current state of the image system is a startup failure.

[0085] For example, when a startup exception occurs, the message "No bootable devices" appears and empty data will be returned: {"return":[]}.

[0086] It is understandable that steps S210-S220 are steps to determine whether the image system is starting normally. By using these steps to determine whether the image system is starting normally, if the startup is abnormal, it can be determined that the image file is corrupted and needs to be restored through the following steps.

[0087] S230. If the current status is startup error, select the consistency method from the image recovery methods to restore the image file.

[0088] Specifically, if the image system fails to start, the consistency method should be selected in the image recovery settings to restore the image file. A consistency check must first be performed on the image file to determine if any consistency issues exist. If any are found, the file will be restored to consistency.

[0089] In this step, after performing consistency repair on the image file, the image system is restarted. QMP communication needs to be established to check if the image system started successfully. If the image system started successfully, CPU data is returned, completing the startup process. If the image system fails to start, other methods are needed to restore the image file.

[0090] There are several ways to establish a QMP connection. For example, you can establish a QMP connection simply by adding the QMP option to the virtual machine startup options.

[0091] Furthermore, the steps for selecting a consistency method from the image recovery methods to repair the image file can be described as follows: perform a consistency check on the image file; if a consistency problem exists, then restore the image file according to the consistency problem.

[0092] Specifically, if the image system fails to boot, a consistency check needs to be performed on the image file using qemu-img to determine if any consistency issues exist. For example, a consistency check can be performed using qemu-img check. If a consistency issue is found, the image file needs to be restored. For example, the command for image detection and repair can be described as follows:

[0093] qemu-img check-fqcow2-r all Win10_64bit_legacy_1.2.qcow2.

[0094] S240. If the recovery fails, select the snapshot method from the image recovery methods to repair and restore the image file.

[0095] In this embodiment, if the image file repair fails using the consistency method and the image system fails to start, the image file corresponding to the image system can be restored using the snapshot recovery method. It is understood that before restoring the image file using the snapshot recovery method, since the image file cannot be modified or deleted by other programs while it is being read and written by the Qemu process, the Qemu process needs to be stopped (e.g., Qemu is closed) to obtain operation permissions for the image file.

[0096] When working with image files, you can create image snapshots. For example, the command to create an image snapshot can be expressed as:

[0097] qemu-img snapshot-c sys_recovery Win10_64bit_legacy_1.2.qcow2.

[0098] After obtaining operation permissions for the image file, you can check if a snapshot of the image file exists. If a snapshot exists, you can restore the image file using the `qemu-img` command. After restoration, restart the image system and obtain its current status to determine if it has started normally. If the image system still fails to start, you need to check if a backup image file exists and copy it to replace the original image file. Alternatively, if no snapshot is found, you need to directly obtain the backup image file and replace the original image file with it.

[0099] Furthermore, selecting the snapshot method from the image recovery options to restore the image file can be specifically described as follows:

[0100] a2. Obtain operation permissions for the image file.

[0101] Specifically, since the image file cannot be modified or deleted by other programs while it is being read and written by the Qemu process, it is necessary to stop the Qemu process (e.g., close Qemu) to obtain operation permissions for the image file.

[0102] b2. Obtain a snapshot of the image system.

[0103] Specifically, check if an image snapshot exists; if it does, retrieve the image snapshot.

[0104] c2. Restore the image file based on the image snapshot of the image system.

[0105] Specifically, the image file is restored based on the image snapshot. For example, the command for restoring an image snapshot can be expressed as:

[0106] qemu-img snapshot-a sys_recovery Win10_64bit_legacy_1.2.qcow2.

[0107] After the recovery is complete, restart the image system and obtain its current status to determine if it started normally. If the image system starts normally, the system startup process is complete. If the image system fails to start, the snapshot-based repair method has failed.

[0108] S250. If the recovery still fails, select the backup method from the image recovery methods to repair and restore the image file.

[0109] In this embodiment, if repairing the image file via snapshot fails and the image system still fails to start, it is necessary to select the backup method from the image recovery options to restore the image file. Specifically, this involves checking if a backup image file exists and copying the backup image file to replace the original image file. It is understood that if no file snapshot is found, it is necessary to directly obtain the image backup file and replace the original image file based on the backup file.

[0110] Furthermore, based on the backup and recovery method, the image file corresponding to the image system is restored, including:

[0111] a3. Query the backup image file corresponding to the image system on the local device.

[0112] Specifically, check if a backup image file is stored on the local device.

[0113] b3. If a backup image file exists on the local device, copy the backup image file and replace the original image file.

[0114] Specifically, if a backup image file exists on the local device, the backup image file is copied and the corrupted image file is replaced.

[0115] For example, a backup can be represented as:

[0116] cp Win10_64bit_legacy_1.2.qcow2 Win10_64bit_legacy_1.2.qcow2.bak.

[0117] Recovery can be represented as:

[0118] cp Win10_64bit_legacy_1.2.qcow2.bak Win10_64bit_legacy_1.2.qcow2.

[0119] c3. Otherwise, obtain the backup image file corresponding to the image system from the external device and replace the image file.

[0120] In this step, if the local device does not have a backup image file corresponding to the image system, a prompt will appear to insert an external device. The external device can be a USB flash drive or external hard drive, or any device that can be connected via an interface. The external device should contain the backup image file. Upon detecting the external device, the system retrieves the backup image file corresponding to the image file from the external device and copies it to the storage location of the corrupted image file to replace it.

[0121] In this optional embodiment, after determining that the image system has an abnormal startup, the corresponding image file is automatically restored. This achieves automatic repair of the image file, improves the reliability of the image system, reduces the risk of the image system failing to start, and saves labor costs.

[0122] S260. Rerun the image system based on the restored image file.

[0123] In this embodiment, the image system can be rerun based on the restored image file to enable the image system to complete the boot process.

[0124] This embodiment details the steps for querying the current status of the image system and, based on pre-configured image recovery logic and set image recovery methods, the steps for restoring the corresponding image file of the image system. Through an image corruption detection mechanism and addressing problems with the image file, and based on an increasing image repair cost logic, it prioritizes repair methods with lower repair costs, and uses different methods in ascending order of cost to restore the image. After the image system starts, it can automatically check whether the image system has started normally, and if it is determined that the image system has started abnormally, it can automatically restore the corresponding image file. Compared to existing technologies that require manual repair of image files, this technical solution achieves automatic repair of image files, improves the reliability of the image system, reduces the risk of the image system failing to start, and saves labor costs.

[0125] Example 3

[0126] Figure 3 This is a schematic diagram of an automatic image file recovery device provided in Embodiment 3 of the present invention. It is applicable to the automatic recovery of damaged Qemu image files. This device can be implemented in hardware and / or software and is generally integrated into electronic devices. Figure 3 As shown, the device includes: a status determination module 31, an image restoration module 32, and a rerun module 33, wherein,

[0127] The status determination module 31 is used to query the current status of the image system after running the Qemu image system;

[0128] The image recovery module 32 is used to recover the image file corresponding to the image system according to the pre-configured image recovery logic and the pre-set image recovery method if the current state is a startup error.

[0129] Rerun module 33, used to rerun the image system based on the restored image file.

[0130] This invention provides an automatic image file recovery device, comprising: a status determination module for querying the current status of the image system after running a Qemu image system; an image recovery module for recovering the image file corresponding to the image system according to pre-configured image recovery logic and pre-set image recovery methods if the current status is a startup error; and a rerun module for rerunning the image system based on the recovered image file. Using this device, after the image system starts, it can automatically query whether the image system has started normally, and if it is determined that the image system has started abnormally, it can automatically recover the image file corresponding to the image system according to the pre-configured image recovery logic and sequentially select image recovery methods. Compared with the prior art, which requires manual repair of image files, this technical solution achieves automatic repair of image files, improves the reliability of the image system, reduces the risk of the image system failing to start, and saves labor costs.

[0131] Furthermore, the state determination module 31 includes:

[0132] The command sending unit is used to send status query commands to Qemu after the Qemu image system is running;

[0133] The status determination unit is used to determine the current status of the image system based on the data returned in response to the status query command.

[0134] Furthermore, the state determination unit is specifically used for:

[0135] If the returned data is not empty, then the current status of the image system is determined to be normal startup.

[0136] If the returned data is empty, then the current state of the image system is determined to be a startup exception.

[0137] Furthermore, the pre-configured image recovery logic includes: image repair cost incrementing logic;

[0138] And / or, the image recovery methods set include: consistency method repair, snapshot method repair and backup method repair.

[0139] Furthermore, the image recovery module 32 includes:

[0140] The first recovery unit is used to select a consistency method from the image recovery methods to restore the image file;

[0141] The second recovery unit is used to select a snapshot method from the image recovery methods to restore the image file if the recovery fails.

[0142] The third recovery unit is used to select a backup method from the image recovery methods to restore the image file if the recovery still fails.

[0143] Furthermore, the second recovery unit is specifically used for:

[0144] Obtain permission to operate on the image file;

[0145] Obtain an image snapshot of the image system;

[0146] Restore the image file based on the image snapshot.

[0147] Furthermore, the third recovery unit is specifically used for:

[0148] Queries the backup image file corresponding to the mirror system on the local device;

[0149] If a backup image file exists on the local device, copy the backup image file and replace the original image file;

[0150] Otherwise, obtain the backup image file corresponding to the image system from the external device and replace the image file.

[0151] The automatic image file recovery device provided in this embodiment of the invention can execute the automatic image file recovery method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.

[0152] Example 4

[0153] Figure 4This is a schematic diagram of an electronic device according to Embodiment 4 of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0154] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0155] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0156] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the automatic recovery method of image files.

[0157] In some embodiments, the automatic recovery method for image files may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the automatic recovery method for image files described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to perform the automatic recovery method for image files by any other suitable means (e.g., by means of firmware).

[0158] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0159] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0160] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0161] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0162] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0163] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0164] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0165] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for automatically restoring an image file, characterized in that, include: After running the image system of the open-source virtual machine Qemu, query the current status of the image system; If the current state is a startup error, then the image file corresponding to the image system is restored according to the pre-configured image recovery logic and the set image recovery method. Based on the restored image file, rerun the image system; The pre-configured image recovery logic includes: image repair cost incrementing logic; And / or, the set image recovery methods include: consistency method repair, snapshot method repair and backup method repair; The step of restoring the image file corresponding to the image system according to the pre-configured image recovery logic and the set image recovery method includes: Select a consistency method from the image recovery options to restore the image file; If the recovery fails, select the snapshot method from the image recovery methods to restore the image file; If the recovery still fails, select the backup method from the image recovery methods to restore the image file.

2. The method according to claim 1, characterized in that, The step of querying the current status of the image system after running the open-source virtual machine Qemu includes: After running the image system of the open-source virtual machine Qemu, a status query command is sent to the Qemu. The current state of the mirror system is determined based on the data returned in response to the status query command.

3. The method according to claim 2, characterized in that, Determining the current state of the mirror system based on the data returned in response to the status query command includes: If the returned data is not empty, then the current state of the image system is determined to be normal startup. If the returned data is empty, then the current state of the image system is determined to be a startup exception.

4. The method according to claim 1, characterized in that, The step of selecting a snapshot method from the image recovery methods to restore the image file includes: Obtain operation permissions for the image file; Obtain an image snapshot of the image system; The image file is restored based on the image snapshot.

5. The method according to claim 1, characterized in that, The step of selecting a backup method from the image recovery methods to restore the image file includes: Query the backup image file corresponding to the image system on the local device; If the backup image file exists on the local device, then copy the backup image file and replace the original image file; Otherwise, obtain the backup image file corresponding to the image system from the external device and replace the image file.

6. An automatic recovery device for image files, characterized in that, include: The status determination module is used to query the current status of the image system after running the open-source virtual machine Qemu; The image recovery module is used to recover the image file corresponding to the image system according to the pre-configured image recovery logic and the pre-set image recovery method if the current state is a startup abnormality. The rerun module is used to rerun the image system based on the restored image file; The pre-configured image recovery logic includes: image repair cost incrementing logic; And / or, the set image recovery methods include: consistency method repair, snapshot method repair and backup method repair; The image recovery module includes: The first recovery unit is used to select a consistency method from the image recovery methods to restore the image file; The second recovery unit is used to select a snapshot method from the image recovery methods to restore the image file if the recovery fails. The third recovery unit is used to select a backup method from the image recovery methods to restore the image file if the recovery still fails.

7. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the automatic recovery method for the image file according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the automatic recovery method for the image file as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Virtual machine mirror file processing method and device

    CN109144776A

  • Abnormity recovery method and device

    CN111427721A