CN115562803A - Automatic recovery method, device, equipment and storage medium for mirror image file - Google Patents

Automatic recovery method, device, equipment and storage medium for mirror image file Download PDF

Info

Publication number
CN115562803A
CN115562803A CN202211194081.4A CN202211194081A CN115562803A CN 115562803 A CN115562803 A CN 115562803A CN 202211194081 A CN202211194081 A CN 202211194081A CN 115562803 A CN115562803 A CN 115562803A
Authority
CN
China
Prior art keywords
mirror image
image file
mirror
recovery
image system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211194081.4A
Other languages
Chinese (zh)
Inventor
苏校
梁宏沛
蒲印
徐春强
靳鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kedong Guangzhou Software Technology Co Ltd
Original Assignee
Kedong Guangzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kedong Guangzhou Software Technology Co Ltd filed Critical Kedong Guangzhou Software Technology Co Ltd
Priority to CN202211194081.4A priority Critical patent/CN115562803A/en
Publication of CN115562803A publication Critical patent/CN115562803A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides an automatic recovery method, a device, equipment and a storage medium of a mirror image file, wherein the method comprises the following steps: after a mirror image system of an open source virtual machine Qemu is operated, inquiring the current state of the mirror image system; if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoration logic and in combination with a preset image restoration mode; and based on the recovered mirror image file, the mirror image system is operated again. By using the method, whether the mirror image system is normally started or not can be automatically inquired after the mirror image system is started, and the mirror image file corresponding to the mirror image system is automatically recovered after the mirror image system is determined to be abnormally started. Compared with the prior art that the mirror image file needs to be manually repaired, the technical scheme realizes automatic repair of the mirror image file, improves the reliability of the mirror image system, reduces the risk that the mirror image system cannot be started, and saves the labor cost.

Description

Automatic recovery method, device, equipment and storage medium for mirror image file
Technical Field
The present invention relates to the field of virtualization technologies, and in particular, to an automatic recovery method, apparatus, device, and storage medium for an image file.
Background
Qemu (Quick emulator) is an open source Virtual Machine widely used on a Linux platform, can provide virtualization services in a pure software manner, and can realize support for hardware virtualization by combining a Kernel Virtual Machine (KVM) module in a Linux Kernel. Currently, qemu + KVM is commonly used in Linux platforms to provide virtualization services.
The core of a virtual machine is a disk image, which can be understood as a disk of the virtual machine, and important files such as an operating system, a driver and the like of the virtual machine are arranged in the disk. Running a virtual machine on a host typically requires creating a virtual machine image and then starting the virtual machine. If the mirror image has a problem, the system of the virtual machine cannot be started.
In the prior art, if the image is not seriously damaged, snapshot recovery can be performed through a disk management tool qemu-img of the virtual machine, and manual recovery is required. If the image is damaged seriously and only the system in the virtual machine can be reinstalled, a great deal of labor and energy are needed to restore the image.
Disclosure of Invention
The embodiment of the invention provides an automatic recovery method, device, equipment and storage medium of a mirror image file, so as to realize automatic repair of the mirror image file, improve the reliability of a mirror image system, reduce the risk that the mirror image system cannot be started and save the labor cost.
In a first aspect, an embodiment of the present invention provides an automatic recovery method for an image file, where the method includes:
after a mirror image system of an open source virtual machine Qemu is operated, inquiring the current state of the mirror image system;
if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoration logic and in combination with a preset image restoration mode;
and based on the recovered mirror image file, the mirror image system is operated again.
Further, after the mirror system of the open source virtual machine Qemu is operated, querying the current state of the mirror system includes:
after a mirror image system of the Qemu is operated, sending a state query command to the Qemu;
and determining the current state of the mirror image system according to the return data responding to the state inquiry command.
Further, the determining the current state of the mirroring system according to the return data in response to the state query command includes:
if the returned data is non-null data, determining that the current state of the mirror image system is normal in starting;
and if the returned data is null data, determining that the current state of the mirror image system is abnormal in starting.
Further, the preconfigured image restore logic, comprising: mirror image repair cost incremental logic;
and/or the set image recovery mode comprises the following steps: consistent mode repair, snapshot mode repair, and backup mode repair.
Further, the restoring the image file corresponding to the image system according to the pre-configured image restoration logic and in combination with a pre-set image restoration manner includes:
selecting a consistency mode from the mirror image recovery modes to repair and recover the mirror image file;
if the recovery fails, selecting a snapshot mode from the mirror image recovery modes to repair and recover the mirror image file;
and if the recovery fails, selecting a backup mode from the mirror image recovery modes to repair and recover the mirror image file.
Further, the restoring the image file by selecting a snapshot mode to repair from the image restoring modes includes:
acquiring operation authority of the mirror image file;
acquiring a mirror image snapshot of the mirror image system;
and recovering the mirror image file according to the mirror image snapshot.
Further, selecting a backup mode from the image recovery modes to repair and recover the image file, including:
inquiring a backup image file corresponding to the image system in local equipment;
if the backup image file exists in the local equipment, copying the backup image file and replacing the image file;
otherwise, obtaining the backup image file corresponding to the image system from the external equipment and replacing the image file.
In a second aspect, an embodiment of the present invention provides an apparatus for automatically restoring an image file, where the apparatus includes:
the state determining module is used for inquiring the current state of the mirror image system after the Qemu mirror image system is operated;
the mirror image recovery module is used for recovering the mirror image file corresponding to the mirror image system according to a preset mirror image recovery logic and in combination with a preset mirror image recovery mode if the current state is abnormal in starting;
and the rerun module is used for rerun the mirror image system based on the recovered mirror image file.
In a third aspect, an embodiment of the present invention provides an electronic device, including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the first and the second end of the pipe are connected with each other,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a method for automatic recovery of an image file according to any embodiment of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer instructions are stored, and the computer instructions are configured to, when executed, enable a processor to implement the method for automatically restoring an image file according to any embodiment of the present invention.
The embodiment of the invention provides an automatic recovery method, a device, equipment and a storage medium of a mirror image file, wherein the method comprises the following steps: after a mirror image system of an open source virtual machine Qemu is operated, inquiring the current state of the mirror image system; if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoration logic and in combination with a preset image restoration mode; and based on the recovered mirror image file, the mirror image system is operated again. According to the technical scheme, whether the mirror image system is normally started or not can be automatically inquired after the mirror image system is started, and the mirror image files corresponding to the mirror image system are automatically recovered by sequentially selecting the mirror image recovery mode according to the preset mirror image recovery logic after the mirror image system is determined to be abnormally started. Compared with the prior art, the mirror image file needs to be manually repaired, the technical scheme realizes automatic repair of the mirror image file, improves the reliability of the mirror image system, reduces the risk that the mirror image system cannot be started, and saves the labor cost.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present invention, nor do they necessarily limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of an automatic recovery method for an image file according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of an automatic recovery method for an image file according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an automatic recovery apparatus for an image file according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "original", "target", and the like in the description and claims of the present invention and the drawings described above are used for distinguishing similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example one
Fig. 1 is a schematic flowchart of an automatic recovery method for an image file according to an embodiment of the present invention, where the method is applicable to a case of automatically recovering a damaged image file of Qemu, and the method may be executed by an automatic recovery apparatus for an image file, and the automatic recovery apparatus for an image file may be implemented in a form of hardware and/or software and is generally integrated in an electronic device.
As shown in fig. 1, an automatic recovery method for an image file provided in this embodiment may specifically include the following steps:
and S110, after the mirror image system of the open source virtual machine Qemu is operated, inquiring the current state of the mirror image system.
The Qemu is an open source virtual machine widely used on a Linux platform, can provide virtualization services in a pure software mode, and can realize support for hardware virtualization by combining a KVM module in a Linux kernel. Currently, QEMU + KVM is generally adopted in Linux platform to provide virtualization service: the KVM is responsible for virtualizing the CPU and the memory, and the QEMU is responsible for simulating functions of the device, including simulating a Basic Input Output System (BIOS), a local bus standard (PCI)/PCI Express (PCIE) bus, a disk, a network card, a video card, a sound card, a keyboard, a mouse, and the like.
There are two main modes of operation of Qemu: one is User mode simulation mode, i.e., user mode. Qemu can launch Linux programs compiled for different central processors. Another System mode simulates a mode, namely a System mode. Qemu can simulate the whole computer system including CPU and other peripheral devices. It makes it easy to test and debug programs written across platforms. It can also be used to virtualize a number of different virtual computers on a host. In this embodiment, the system mode is mainly used.
It is understood that the architecture formed by providing virtualization services using Qemu + KVM in Linux platforms is Type 2Hypervisor (called a Hypervisor), which cannot be installed locally and requires an operating system to run on a physical host. In this embodiment, the image file is stored in the Linux system, which may be understood as simulating an empty system on the Linux system through Qemu, and the image file provides an operating system of a virtual machine for the empty system, so as to support the operation of the image system.
It can be understood that when the image file is damaged, the image file cannot support the startup of the image system, which may cause an abnormal startup of the image system. In this embodiment, a mirror damage determination mechanism is deployed, and based on a Qemu virtual Machine Protocol (QMP), a Qemu interface is called to further query a current state of a mirror system, where the current state includes normal start and abnormal start.
QMP is a protocol in the Qemu virtual machine, and is a transport protocol based on the JSON format, and may use QMP to interact with an instance of the Qemu virtual machine, for example, to query the relevant state of the virtual machine.
Specifically, after the mirror image system of the open-source virtual machine Qemu is operated, the state of the mirror image file is inquired through a QMP command, and whether the mirror image system is normally started or not is determined according to returned data.
And S120, if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoring logic and by combining a preset image restoring mode.
In this embodiment, if it is determined that the mirror image system is abnormally started through the step S110, the mirror image file needs to be automatically recovered, so as to re-run the mirror image system according to the recovered mirror image file. In the prior art, when the mirror image file is damaged, the mirror image file needs to be restored manually, so that the labor cost is wasted. In this embodiment, when it is detected that the mirror image system is abnormally started, a preset mirror image recovery mode is adopted to automatically recover the mirror image file corresponding to the mirror image system.
The image file is stored in a qcow2 image format and is a disk image supported by Qemu. qcow2 may represent a fixed-size block device disk in the form of a file. If different problems exist in the damaged mirror image file, different mirror image recovery modes are required to be adopted for recovery. Preferably, the preconfigured image recovery logic comprises: mirror image repair cost incremental logic; and/or the set image recovery mode comprises the following steps: consistent mode repair, snapshot mode repair, and backup mode repair.
In this embodiment, three types of image restoration methods, namely, a consistency method restoration method, a snapshot method restoration method, and a backup method restoration method, are different in price when restoration is performed. According to different costs of the three recovery modes, mirror recovery logic can be preset, and priority of using the recovery modes is set through logic with gradually increased repair cost.
In this embodiment, the consistency check recovery can perform consistency check on the image file to determine whether the data of the image file is in a consistent state. The mirror image consistency check recovery can be based on a qemu-img tool for check recovery, and can be embodied as consistency check recovery of a mirror image file through a mirror image check recovery command. The snapshot is a data copying technology based on a time point, and is an important concept in the field of data backup, the purpose of the snapshot is to record and store data information at a certain time, and if certain faults occur later and data needs to be restored, the data can be restored to the state of the previous time point through the snapshot. In this embodiment, a snapshot is created based on a Qemu-img tool during the startup and execution of the Qemu mirroring system. The mirror snapshot recovery method may be understood as a method of recovering a mirror file based on a mirror snapshot by querying the mirror snapshot. In this embodiment, the backup recovery mode refers to obtaining a backup image file corresponding to an image file in the local device or the external device, and replacing the backup image file with a damaged image file to support the image system to run depending on the backup image file. It can be appreciated that backup mode repairs are more costly than snapshot mode repairs than consistent mode repairs.
In this embodiment, the restoration method with low cost is preferentially used to restore the file. Illustratively, if the consistency problem exists in the mirror image file, the consistency recovery needs to be performed on the mirror image file. If the mirror image file still cannot support normal starting of the mirror image system through consistency recovery, recovery can be performed according to the mirror image snapshot, and if the mirror image snapshot does not exist or the mirror image system is still abnormally started after recovery through the mirror image snapshot, the mirror image file needs to be replaced by the backup mirror image file to restart the mirror image system. It can be understood that, if the backup image file is stored in the local device, the backup image file in the local device is preferentially acquired to replace the damaged image file. If the backup image file is not stored in the local device, the backup image file needs to be acquired through the external device to replace the local image file, so as to support the starting of the image system.
And S130, based on the recovered mirror image file, operating the mirror image system again.
It can be clear that, after the mirror image file is recovered, the mirror image system can be operated again based on the recovered mirror image file, so as to realize normal start of the mirror image system, and realize subsequent business operation on the system.
It can be understood that if the current state of the image system is acquired as normal, the starting process of the image file can be continued until the image system is started. For example, the loading of relevant data or drivers, etc. is continued until the mirror system boot is complete. After the system is started, the user can perform processing operation of related services based on the system interface.
The embodiment of the invention provides an automatic recovery method of a mirror image file, which comprises the following steps: firstly, after a mirror image system of an open source virtual machine Qemu is operated, inquiring the current state of the mirror image system; then if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoring logic and in combination with a preset image restoring mode; and finally, based on the recovered mirror image file, operating the mirror image system again. By using the method, whether the mirror image system is normally started or not can be automatically inquired after the mirror image system is started, and the mirror image files corresponding to the mirror image system can be automatically recovered by sequentially selecting a mirror image recovery mode according to the preset mirror image recovery logic after the mirror image system is determined to be abnormally started. Compared with the prior art that the mirror image file needs to be manually repaired, the technical scheme realizes automatic repair of the mirror image file, improves the reliability of the mirror image system, reduces the risk that the mirror image system cannot be started, and saves the labor cost.
Example two
Fig. 2 is a schematic flow chart of an automatic recovery method of an image file according to a second embodiment of the present invention, which is a further optimization of the second embodiment, and in this embodiment, querying a current state of an image system of an open-source virtual machine Qemu after the image system is run is further embodied as: after a mirror image system of the Qemu is operated, sending a state query command to the Qemu; and determining the current state of the mirror image system according to the return data responding to the state inquiry command.
And further, according to a preset mirror image recovery logic, in combination with a preset mirror image recovery mode, recovering the mirror image file corresponding to the mirror image system is embodied as follows: selecting a consistency mode from the mirror image recovery modes to repair and recover the mirror image file; if the recovery fails, selecting a snapshot mode from the mirror image recovery modes to repair and recover the mirror image file; and if the recovery fails, selecting a backup mode from the mirror image recovery modes to repair and recover the mirror image file.
As shown in fig. 2, the second embodiment provides an automatic recovery method of an image file, which specifically includes the following steps:
and S210, after the mirror image system of the Qemu is operated, sending a state query command to the Qemu.
Specifically, after the Qemu mirror system is operated, a state query command is sent to the Qemu to obtain the current state of the mirror system. Wherein the current state of the mirroring system may also be understood as the current state of the virtual machine, i.e. whether the virtual machine is normally booted or abnormally booted.
In this step, the current state of the mirror system is queried through the qmp command. A qmp command is sent to Qemu. For example, the status query command may be expressed as:
{"execute":"query-acpi-ospm-status"}。
s220, determining the current state of the mirror image system according to the returned data responding to the state query command.
In this step, qemu receives the status query command and generates corresponding return data. The current state of the mirroring system can be determined based on the corresponding return data. The current state of the mirror system comprises a normal startup state and an abnormal startup state. It can be appreciated that for startup normal and startup exception, which correspond to different return data, based on the received return data, the current state of the mirroring system can be determined.
Further, according to the returned data in response to the status query command, the current status of the mirroring system is determined, which may be specifically expressed as:
and a1, if the returned data is non-null data, determining that the current state of the mirror image system is normal in starting.
Specifically, if the mirror image system is successfully started, the data of a Central Processing Unit (CPU) is returned, and therefore, if the returned data is non-null data, it is determined that the current state of the mirror image system is normally started.
Illustratively, the return data may be represented as:
{"return":[{"source":0,"status":0,"slot":"0","slot-type":"CPU"},{"source":0,"status":0,"slot":"1","slot-type":"CPU"}]}。
b1, if the returned data is null data, determining that the current state of the mirror image system is abnormal in starting.
Specifically, if the mirror image system is abnormally started, null data is returned, and therefore, if the returned data is null data, the current state of the mirror image system is determined to be abnormally started.
For example, when the boot exception occurs, a prompt of "No bootable devices" appears, and null data is returned: { "return": B }.
It can be understood that steps S210-S220 are steps of determining whether the mirror image system is normally started, and by this step, determining whether the mirror image system is normally started, and if the mirror image system is abnormally started, it may be determined that the mirror image file is damaged, and the mirror image file needs to be recovered through the following steps.
And S230, if the current state is abnormal starting, selecting a consistency mode from the image recovery modes to repair and recover the image file.
Specifically, if the mirror image system is abnormally started, a consistency mode is selected from the mirror image recovery modes to repair and recover the mirror image file. Consistency check is required to be carried out on the mirror image file firstly, whether the consistency problem exists is judged, and if the consistency problem exists, consistency recovery is carried out on the mirror image file.
In this step, the mirroring system is restarted after the consistency restoration of the mirroring file is performed. And qmp communication needs to be established, whether the mirror image system is started successfully is inquired, if the mirror image system is started successfully, CPU data is returned, and the starting process is completed. If the mirror image system is abnormally started, the mirror image file needs to be recovered in other modes.
The qmp connection can be established in various ways, for example, only the qmp option needs to be added to the virtual machine starting option, and then the qmp connection can be established.
Further, the step of selecting a consistency mode from the mirror image recovery modes to repair and recover the mirror image file may be expressed as: carrying out consistency check on the mirror image file; and if the consistency problem exists, restoring the mirror image file according to the consistency problem.
Specifically, if the mirror image system is abnormally started, mirror image consistency check needs to be performed on the mirror image file based on qemu-img, and whether the consistency problem exists is judged. Illustratively, the consistency check may be performed by qemu-img check. And if the consistency problem exists in the mirror image file, restoring the mirror image file. For example, the command for image detection repair may be expressed as:
qemu-img check-fqcow2-r all Win10_64bit_legacy_1.2.qcow2。
s240, if the recovery fails, selecting a snapshot mode from the mirror image recovery modes to repair and recovering the mirror image file.
In this embodiment, if the mirror image file is failed to be repaired in a consistent manner and the mirror image system is abnormally started, the mirror image file corresponding to the mirror image system may be restored according to a snapshot restoration manner. It can be understood that before the mirror image file is restored based on the snapshot restoration method, since the mirror image file cannot be modified or deleted by other programs when the mirror image file is occupied by operations such as reading and writing by the Qemu process, the Qemu process needs to be stopped (for example, the Qemu is closed) first to obtain the operation permission of the mirror image file.
When the mirror image file is operated, a mirror image snapshot can be created, and an exemplary command for creating the mirror image snapshot can be represented as:
qemu-img snapshot-c sys_recovery Win10_64bit_legacy_1.2.qcow2。
after the operation authority of the mirror image file is obtained, whether a mirror image file snapshot exists or not can be inquired, and if the mirror image file snapshot exists, the mirror image file can be recovered based on a qemu-img command. And after the recovery is finished, restarting the mirror image system and acquiring the current state of the mirror image system so as to judge whether the mirror image system is normally started. If the mirror image system is still abnormally started, whether the backup mirror image file exists needs to be inquired, and the backup mirror image file is copied to replace the mirror image file. It can be understood that if the image snapshot is not queried, the backup image file needs to be directly acquired, and the image file is replaced based on the image backup file.
Further, a snapshot mode is selected from the mirror image recovery modes to repair and recover the mirror image file, which can be specifically expressed as:
and a2, acquiring the operation authority of the mirror image file.
Specifically, when the image file is occupied by operations such as reading and writing by the Qemu process, the image file cannot be modified or deleted by other programs, so the Qemu process needs to be stopped first (for example, the Qemu is closed) to obtain the operation authority of the image file.
And b2, acquiring a mirror image snapshot of the mirror image system.
Specifically, whether a mirror image snapshot exists is inquired, and if yes, the mirror image snapshot is acquired.
And c2, recovering the mirror image file according to the mirror image snapshot of the mirror image system.
Specifically, the mirror image file is restored according to the mirror image snapshot. For example, the command for mirror snapshot recovery may be expressed as:
qemu-img snapshot-a sys_recovery Win10_64bit_legacy_1.2.qcow2。
and after the recovery is finished, restarting the mirror image system and acquiring the current state of the mirror image system so as to judge whether the mirror image system is normally started. And if the mirror image system is normally started, finishing the system starting process. And if the mirror image system fails to be started, determining that the repair fails according to the snapshot mode.
And S250, if the recovery fails, selecting a backup mode from the mirror image recovery modes to repair and recover the mirror image file.
In this embodiment, if the mirror image file is failed to be repaired in the snapshot manner and the mirror image system is still abnormally started, the backup manner needs to be selected from the mirror image recovery manners to repair the mirror image file. Specifically, whether a backup image file exists is queried, so that the backup image file is copied to replace the image file. It can be understood that if the file snapshot is not found, the mirror image backup file needs to be directly acquired, and the mirror image file is replaced based on the mirror image backup file.
Further, according to the backup recovery method, recovering the image file corresponding to the image system includes:
and a3, inquiring backup image files corresponding to the image system in the local equipment.
Specifically, whether the backup image file is stored in the local device is queried.
And b3, if the backup image file exists in the local equipment, copying the backup image file and replacing the image file.
Specifically, if the backup image file exists in the local device, the backup image file is copied and the damaged image file is replaced.
Illustratively, the backup may be represented as:
cp Win10_64bit_legacy_1.2.qcow2 Win10_64bit_legacy_1.2.qcow2.bak。
the recovery can be expressed as:
cp Win10_64bit_legacy_1.2.qcow2.bak Win10_64bit_legacy_1.2.qcow2。
and c3, if not, obtaining the backup image file corresponding to the image system from the external equipment and replacing the image file.
In this step, when there is no backup image file corresponding to the image system in the local device, the insertion of the external device is prompted. The external device may be a device such as a U-disk or a mobile hard disk that can be accessed through an interface, and the backup image file should be stored in the external device. And when the external equipment is detected to be accessed, acquiring a backup image file corresponding to the image file from the external equipment, and copying the backup image file to the storage position of the damaged image file to replace the damaged image file.
In this optional embodiment, after it is determined that the mirror image system is abnormally started, the mirror image file corresponding to the mirror image system is automatically recovered. The automatic restoration of the mirror image file is realized, the reliability of the mirror image system is improved, the risk that the mirror image system cannot be started is reduced, and the labor cost is saved.
And S260, based on the recovered mirror image file, operating the mirror image system again.
In this embodiment, the mirror image system may be re-run based on the recovered mirror image file, so as to complete the start process of the mirror image system.
The embodiment embodies the query step of the current state of the mirror image system and the step of restoring the mirror image file corresponding to the mirror image system according to the preset mirror image restoration logic and in combination with the set mirror image restoration mode. Through a mirror image damage checking mechanism and aiming at the problems of mirror image files, based on mirror image repair cost increasing logic, a repair mode with low repair cost is preferentially selected, the mirror image files are sequentially recovered in different modes according to cost increasing, whether the mirror image system is normally started or not can be automatically inquired after the mirror image system is started, and the mirror image files corresponding to the mirror image system are automatically recovered after the mirror image system is determined to be abnormally started. Compared with the prior art, the mirror image file needs to be manually repaired, the technical scheme realizes automatic repair of the mirror image file, improves the reliability of the mirror image system, reduces the risk that the mirror image system cannot be started, and saves the labor cost.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an automatic recovery device for an image file according to a third embodiment of the present invention, which is applicable to a case of automatically recovering a damaged image file of Qemu, and the device may be implemented in a form of hardware and/or software and is generally integrated in an electronic device. As shown in fig. 3, the apparatus includes: a state determination module 31, a mirror restore module 32, and a rerun module 33, wherein,
the state determining module 31 is configured to query a current state of the mirror image system after the mirror image system of Qemu is operated;
the mirror image recovery module 32 is configured to, if the current state is the startup abnormality, recover the mirror image file corresponding to the mirror image system according to a preset mirror image recovery logic in combination with a preset mirror image recovery mode;
and a rerun module 33, configured to rerun the image system based on the recovered image file.
The embodiment of the invention provides an automatic recovery device of a mirror image file, which comprises: the state determining module is used for inquiring the current state of the mirror image system after the Qemu mirror image system is operated; the mirror image recovery module is used for recovering a mirror image file corresponding to the mirror image system according to a preset mirror image recovery logic and in combination with a preset mirror image recovery mode if the current state is abnormal in starting; and the rerun module is used for rerun the mirror image system based on the recovered mirror image file. By using the device, whether the mirror image system is normally started or not can be automatically inquired after the mirror image system is started, and after the mirror image system is determined to be abnormally started, the mirror image recovery mode is sequentially selected to automatically recover the mirror image files corresponding to the mirror image system according to the preset mirror image recovery logic. Compared with the prior art that the mirror image file needs to be manually repaired, the technical scheme realizes automatic repair of the mirror image file, improves the reliability of the mirror image system, reduces the risk that the mirror image system cannot be started, and saves the labor cost.
Further, the state determining module 31 includes:
the command sending unit is used for sending a state query command to the Qemu after the mirror image system of the Qemu is operated;
and the state determining unit is used for determining the current state of the mirror image system according to the return data responding to the state inquiry command.
Further, the state determination unit is specifically configured to:
if the returned data is non-null data, determining that the current state of the mirror image system is normal in starting;
and if the returned data is null data, determining that the current state of the mirror image system is abnormal in starting.
Further, the preconfigured image restore logic comprising: mirror image repair cost incremental logic;
and/or the set image recovery mode comprises the following steps: consistent mode repair, snapshot mode repair, and backup mode repair.
Further, the image recovery module 32 includes:
the first recovery unit is used for selecting a consistency mode from the image recovery modes to repair and recover the image file;
the second recovery unit is used for selecting a snapshot mode from the mirror image recovery modes to repair and recover the mirror image file if the recovery fails;
and the third recovery unit is used for selecting a backup mode from the mirror image recovery modes to repair and recover the mirror image file if the recovery fails.
Further, the second recovery unit is specifically configured to:
acquiring operation authority of the mirror image file;
acquiring a mirror image snapshot of a mirror image system;
and recovering the mirror image file according to the mirror image snapshot.
Further, the third recovery unit is specifically configured to:
inquiring a backup image file corresponding to an image system in local equipment;
if the backup image file exists in the local equipment, copying the backup image file and replacing the image file;
otherwise, obtaining the backup image file corresponding to the image system from the external equipment and replacing the image file.
The automatic recovery device for the image file provided by the embodiment of the invention can execute the automatic recovery method for the image file provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 40 includes at least one processor 41, and a memory communicatively connected to the at least one processor 41, such as a Read Only Memory (ROM) 42, a Random Access Memory (RAM) 43, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 41 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 42 or the computer program loaded from a storage unit 48 into the Random Access Memory (RAM) 43. In the RAM 43, various programs and data necessary for the operation of the electronic apparatus 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other via a bus 44. An input/output (I/O) interface 45 is also connected to bus 44.
A plurality of components in the electronic device 40 are connected to the I/O interface 45, including: an input unit 46 such as a keyboard, a mouse, etc.; an output unit 47 such as various types of displays, speakers, and the like; a storage unit 48 such as a magnetic disk, an optical disk, or the like; and a communication unit 49 such as a network card, modem, wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
Processor 41 may be a variety of general 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 specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. Processor 41 performs the various methods and processes described above, such as an automatic restore of an image file.
In some embodiments, the method for automatic recovery of an image file may be implemented as a computer program tangibly embodied on 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 onto the electronic device 40 via the ROM 42 and/or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the automatic restore method of an image file described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to perform an automatic restore method of the image file by any other suitable means (e.g., by way of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing 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, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a 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 acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired results of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An automatic recovery method of an image file is characterized by comprising the following steps:
after a mirror image system of an open source virtual machine Qemu is operated, inquiring the current state of the mirror image system;
if the current state is abnormal starting, restoring the image file corresponding to the image system according to a preset image restoration logic and in combination with a set image restoration mode;
and based on the recovered mirror image file, the mirror image system is operated again.
2. The method according to claim 1, wherein the querying the current state of the mirror system of the active virtual machine Qemu after running the mirror system comprises:
after a mirror image system of an open source virtual machine Qemu is operated, sending a state query command to the Qemu;
and determining the current state of the mirror image system according to the return data responding to the state inquiry command.
3. The method of claim 2, wherein determining the current state of the mirrored system based on the returned data in response to the state query command comprises:
if the returned data is non-null data, determining that the current state of the mirror image system is normal in starting;
and if the returned data is null data, determining that the current state of the mirror image system is abnormal in starting.
4. The method of claim 1, wherein the preconfigured image restore logic comprises: mirror image repair cost incremental logic;
and/or the set image recovery mode comprises the following steps: consistent mode repair, snapshot mode repair, and backup mode repair.
5. The method according to claim 4, wherein the restoring the image file corresponding to the image system according to the pre-configured image restoration logic and in combination with a set image restoration manner comprises:
selecting a consistency mode from the mirror image recovery modes to repair and recover the mirror image file;
if the recovery fails, selecting a snapshot mode from the mirror image recovery modes to repair and recover the mirror image file;
and if the recovery fails, selecting a backup mode from the mirror image recovery modes to repair and recover the mirror image file.
6. The method of claim 5, wherein the restoring the image file in the selected snapshot mode repair from the image restoration modes comprises:
acquiring operation authority of the mirror image file;
acquiring a mirror image snapshot of the mirror image system;
and recovering the mirror image file according to the mirror image snapshot.
7. The method of claim 5, wherein the selecting the backup manner to restore from the image restoration manner to restore the image file comprises:
inquiring a backup image file corresponding to the image system in local equipment;
if the backup image file exists in the local equipment, copying the backup image file and replacing the image file;
otherwise, acquiring a backup image file corresponding to the image system from the external equipment and replacing the image file.
8. An apparatus for automatically restoring an image file, comprising:
the state determining module is used for inquiring the current state of a mirror image system of the open-source virtual machine Qemu after the mirror image system is operated;
the mirror image recovery module is used for recovering the mirror image file corresponding to the mirror image system according to a preset mirror image recovery logic and in combination with a preset mirror image recovery mode if the current state is abnormal in starting;
and the rerun module is used for rerun the mirror image system based on the recovered mirror image file.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the method for automatic restoration of an image file according to any one of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to implement the method for automatically restoring an image file according to any one of claims 1 to 7 when executed.
CN202211194081.4A 2022-09-28 2022-09-28 Automatic recovery method, device, equipment and storage medium for mirror image file Pending CN115562803A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211194081.4A CN115562803A (en) 2022-09-28 2022-09-28 Automatic recovery method, device, equipment and storage medium for mirror image file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211194081.4A CN115562803A (en) 2022-09-28 2022-09-28 Automatic recovery method, device, equipment and storage medium for mirror image file

Publications (1)

Publication Number Publication Date
CN115562803A true CN115562803A (en) 2023-01-03

Family

ID=84742995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211194081.4A Pending CN115562803A (en) 2022-09-28 2022-09-28 Automatic recovery method, device, equipment and storage medium for mirror image file

Country Status (1)

Country Link
CN (1) CN115562803A (en)

Similar Documents

Publication Publication Date Title
US10353779B2 (en) Systems and methods for detection of firmware image corruption and initiation of recovery
US8423991B2 (en) Embedded network device and firmware upgrading method
CN103150231B (en) The method of computer booting and computer system
US10303458B2 (en) Multi-platform installer
US20080115134A1 (en) Repair of system defects with reduced application downtime
US20100115257A1 (en) Systems and Methods to Provide Failover Support for Booting Embedded Hypervisor From an Internal Non-Volatile Memory Card
US20220214945A1 (en) System Booting Method and Apparatus, Node Device, and Computer-Readable Storage Medium
US20200218545A1 (en) Information handling system adaptive component reset
CN115794257B (en) System starting method, device, electronic equipment and storage medium
CN110825419B (en) Firmware refreshing method and device, electronic equipment and storage medium
CN111124728A (en) Automatic service recovery method, system, readable storage medium and server
US10204011B1 (en) Techniques for partially restarting a computing device in response to a configuration change
CN104461402A (en) Method for adjusting disk sequence among multiple controllers under linux system
CN113315675B (en) White box switch U-Boot automatic testing method, system and storage medium
CN104657232A (en) BIOS automatic recovery system and BIOS automatic recovery method
TW202131170A (en) Firmware corruption recovery
CN116880877A (en) Virtual machine enhancement tool upgrading method and device, computer equipment and storage medium
CN115454515A (en) System processing method and device and electronic equipment
US10496307B1 (en) Reaching a normal operating mode via a fastboot procedure
CN115562803A (en) Automatic recovery method, device, equipment and storage medium for mirror image file
US11354109B1 (en) Firmware updates using updated firmware files in a dedicated firmware volume
CN114116330A (en) Server performance test method, system, terminal and storage medium
CN114860322A (en) Substrate management controller, control method and electronic equipment
CN113342365A (en) Operating system deployment method, device, equipment and computer-readable storage medium
KR102423056B1 (en) Method and system for swapping booting disk

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination