Method and apparatus for repairing virtual machine in cloud environment, and electronic device

By creating and mounting the cloud hard disk of the self-generated system image to the master machine in the cloud environment and using the self-generated system image to start the virtual machine, the problem of the virtual machine in the cloud environment being unable to start due to system failures is solved, and an efficient repair process is achieved.

WO2025152682A1PCT designated stage expired Publication Date: 2025-07-24TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Application Number
PCT/CN2024/139826
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-01-18
Filing Date
2024-12-17
Publication Date
2025-07-24

AI Technical Summary

Technical Problem

In a cloud environment, the virtual machine cannot start normally due to system failures such as forgetting passwords, corruption of hard disk data, and loss of boot loading files. The traditional repair method needs to be carried out inside the virtual machine, resulting in the inability to enter single-user mode for repair.

Method used

By receiving console requests, querying the mirror database, creating and mounting the cloud hard disk of the self-generated system image to the master machine, the master machine downloads and mounts it from the image storage warehouse to the target virtual machine, and using the self-generated system image to start the virtual machine for repair.

Benefits of technology

It realizes a virtual machine that can start and repair system failures without entering the virtual machine, improves repair efficiency and security, and avoids the limitations of traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024139826_24072025_PF_FP_ABST
    Figure CN2024139826_24072025_PF_FP_ABST
Patent Text Reader

Abstract

The embodiments of the present application relate to the technical field of virtual machines. Provided are a method and apparatus for repairing a virtual machine in a cloud environment, and an electronic device and a storage medium. The method comprises: receiving a first request, which is sent by a console, wherein the first request is used for requesting the repair of a target virtual machine, and the first request comprises a virtual machine identifier of the target virtual machine; querying a mirror database for a target mirror identifier of a pre-made live CD mirror corresponding to the virtual machine identifier; and creating a target cloud block storage, which is used for storing the live CD mirror corresponding to the target virtual machine identifier, and mounting the target cloud block storage to a host machine, in which the target virtual machine is located, such that the host machine downloads the live CD mirror corresponding to the target mirror identifier from a mirror storage warehouse to the target cloud block storage, mounts the target cloud block storage to the target virtual machine, and starts the target virtual machine by means of the target cloud block storage. By means of the embodiments of the present application, a target cloud block storage, in which a live CD mirror is loaded, is mounted to a target virtual machine, thereby realizing the start of the virtual machine which has a system fault.
Need to check novelty before this filing date? Find Prior Art

Description

Method, device and electronic device for repairing virtual machines in cloud environments

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on January 18, 2024, with application number 202410073153.2 and invention name “Repair method, device and electronic device for virtual machines in cloud environments”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a method, device, electronic device, and computer-readable storage medium for repairing a virtual machine in a cloud environment.

[0003] Background of the Invention

[0004] With the development of cloud computing, virtual machine technology in cloud environments is becoming increasingly widespread and plays a vital role in a wide range of fields. During virtual machine use, various issues can arise, causing the virtual machine to malfunction and necessitate repair. For issues like forgotten passwords and damaged hard disk data, traditional cloud virtual machine repair typically requires booting the virtual machine internally, entering single-user mode, and completing the repair. However, when a virtual machine experiences issues like missing bootloader files, missing critical system files, or damaged or missing dynamic library files, the virtual machine cannot boot internally, making it impossible to enter single-user mode and repair the issue. Summary of the Invention

[0005] The embodiments of the present application provide a cloud environment virtual machine repair method, terminal, server, electronic device, storage medium and computer program product, which can solve at least some of the problems of the prior art.

[0006] The present invention provides a method for repairing a virtual machine in a cloud environment, which is applied to a server and includes:

[0007] receiving a first request sent by a console, where the first request is used to request repair of a target virtual machine, and the first request includes a virtual machine identifier of the target virtual machine;

[0008] Querying the image database for a target image identifier of the self-generated system image corresponding to the virtual machine identifier;

[0009] Create a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier, mount the target cloud hard disk to the host machine where the target virtual machine is located, so that the host machine downloads the pre-made self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk, mounts the target cloud hard disk to the target virtual machine, and starts the target virtual machine through the target cloud hard disk.

[0010] The present application also provides a method for repairing a virtual machine in a cloud environment, which is applied to a host machine and includes:

[0011] Download the self-generated system image corresponding to the target image ID from the image storage warehouse to the target cloud hard disk;

[0012] Mounting the target cloud hard disk to the target virtual machine, and starting the target virtual machine with the system failure through the target cloud hard disk;

[0013] Among them, the target cloud hard disk is created by the server to store the self-generated system image corresponding to the target image identifier and mounted on the parent machine; the target image identifier is obtained by the server from the image database based on the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server to request to repair the target virtual machine.

[0014] The present application also provides a device for repairing a virtual machine in a cloud environment, which is applied to a server and includes the following method:

[0015] a receiving module, configured to receive a first request sent by a console, wherein the first request is used to request repair of a target virtual machine, and the first request includes a virtual machine identifier of the target virtual machine;

[0016] A query module, configured to query an image database for a target image identifier of a pre-made self-generated system image corresponding to the virtual machine identifier;

[0017] A creation module is used to create a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier, mount the target cloud hard disk to the host machine where the target virtual machine is located, so that the host machine downloads the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk, mount the target cloud hard disk to the target virtual machine, and start the target virtual machine through the target cloud hard disk.

[0018] The present application also provides a device for repairing a virtual machine in a cloud environment, which is applied to a host machine and includes the following method:

[0019] The download module is used to download the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk;

[0020] A startup module mounts the target cloud hard disk to a target virtual machine, and starts the target virtual machine with a system failure through the target cloud hard disk;

[0021] Among them, the target cloud hard disk is created by the server to store the self-generated system image corresponding to the target image identifier and mounted on the parent machine; the target image identifier is obtained by the server from the image database based on the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server to request to repair the target virtual machine.

[0022] An embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of the method for repairing a virtual machine in a cloud environment in each embodiment.

[0023] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for repairing a virtual machine in a cloud environment of each embodiment are implemented.

[0024] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of the method for repairing a virtual machine in a cloud environment of each embodiment are implemented.

[0025] Embodiments of the present application

[0026] By creating a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier, a corresponding relationship is established among the target image identifier, the self-generated system image, and the target cloud hard disk, so that the target cloud hard disk can meet the requirements for loading the self-generated system image, and material preparations are made for the mother machine to download the self-generated system image from the image storage warehouse to the target cloud hard disk; by mounting the target cloud hard disk to the mother machine, the mother machine downloads the self-generated system image to the target cloud hard disk, and the target cloud hard disk loaded with the self-generated system image is mounted to the target virtual machine, so that the target virtual machine can be started through the self-generated system image on the target cloud hard disk, thereby starting the target virtual machine and performing a repair operation on the target virtual machine.

[0027] BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments of the present application.

[0029] FIG1 is a schematic diagram of the system structure of a method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0030] FIG2a is a flow chart of a method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0031] FIG2 b is a flow chart of another method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0032] FIG2c is a schematic diagram of a process for creating a Live CD image according to an embodiment of the present application;

[0033] FIG3 is a schematic diagram of a master machine identification list provided in an embodiment of the present application;

[0034] FIG4 is a flow chart of another method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0035] FIG5a is a schematic diagram of a process for detecting a target virtual machine according to an embodiment of the present application;

[0036] FIG5 b is a flow chart illustrating the execution process of the access module in the cloud environment virtual machine repair method provided by an embodiment of the present application;

[0037] FIG6 a is a schematic diagram of a process of stopping and repairing a target virtual machine according to an embodiment of the present application;

[0038] FIG6 b is a schematic diagram of another process of stopping and repairing a target virtual machine according to an embodiment of the present application;

[0039] FIG6 c is a flow chart illustrating the execution process of the access module when stopping repair of a target virtual machine according to an embodiment of the present application;

[0040] FIG7 is a flow chart of a method for repairing a cloud environment virtual machine according to an embodiment of the present application;

[0041] FIG8 is a flow chart of another method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0042] FIG9 is a schematic diagram of a process of stopping and repairing a target virtual machine according to an embodiment of the present application;

[0043] FIG10 is a flow chart of another method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0044] FIG11 is a flow chart of another method for repairing a cloud environment virtual machine provided in an embodiment of the present application;

[0045] FIG12 is a schematic structural diagram of a cloud environment virtual machine repair device provided by an embodiment of the present application;

[0046] FIG13 is a schematic structural diagram of a cloud environment virtual machine repair device provided by an embodiment of the present application;

[0047] FIG14 is a schematic structural diagram of an electronic device for repairing a cloud environment virtual machine provided in an embodiment of the present application.

[0048] Modes for Carrying Out the Invention

[0049] The following describes the embodiments of the present application in conjunction with the accompanying drawings. It should be understood that the embodiments described below in conjunction with the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0050] Those skilled in the art will understand that, unless otherwise stated, the singular forms "a", "an", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements, and / or components, but do not exclude implementation as other features, information, data, steps, operations, elements, components, and / or combinations thereof supported by the present technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the element can be directly connected or coupled to the other element, or it can refer to the element and the other element establishing a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used here can include wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, for example, "A and / or B" can be implemented as "A", or as "B", or as "A and B".

[0051] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0052] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0053] First, several terms involved in this application are introduced and explained.

[0054] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.

[0055] A virtual machine (VM) is a software-emulated computer system that can run multiple operating systems and applications on a physical computer. A virtual machine abstracts the physical computer's resources, such as the processor, memory, storage, and network, into multiple virtual resources, which each virtual machine can access and use. A virtual machine works by using virtualization software (also known as a hypervisor) to create multiple virtual computers on a physical computer, each capable of running a different operating system and application. Virtualization software abstracts the physical computer's resources, such as the processor, memory, storage, and network, into multiple virtual resources, which each virtual machine can access and use.

[0056] A mother machine, also known as a host machine, is a dedicated physical server with a virtualized environment. Users have exclusive access to the entire physical server's resources, physically isolated from other tenants' servers. After purchasing a mother machine, users can use it through the cloud servers allocated to it. Users can independently plan their physical server resource usage and customize the configuration of virtual machines on the mother machine.

[0057] Console: A cloud environment provides a console, a web-based or application-based user interface for managing cloud computing resources. Through the console, you can create, configure, and manage cloud services such as virtual machines, storage, networks, and databases, as well as access their operational status and performance. The console typically provides an intuitive interface, allowing users to easily perform operations such as creating, deleting, and adjusting resources and viewing data.

[0058] An operating system (OS) is a program that manages hardware and software resources. It handles tasks such as managing and configuring memory, determining the priority of system resource supply and demand, controlling input and output devices, operating networks, and managing file systems. An operating system is an indispensable part of electronic devices.

[0059] An operating system image is a general term for all files of an operating system. When deploying an operating system, the operating system image is usually obtained from an external source such as the Internet, and the operating system is deployed in an electronic device by installing the operating system image.

[0060] A live system image, also known as a Live CD image, is an operating system image that runs on a disc. A Live CD, also translated as a live system, is an operating system (usually including other software) that is pre-stored on a removable storage device and can be booted independently of the computer's hardware (non-hardware-specific), without requiring installation on the computer's local external storage, i.e., the hard drive. Media used include CD-ROMs (Live CDs), DVDs (Live DVDs), flash drives (Live USBs), and even floppy disks. Exiting the live system and restarting the computer restores the original operating system. Live systems operate by moving files originally stored on the hard drive onto a virtual disk in the storage; therefore, the larger the system's storage, the faster its execution.

[0061] Mounting is the process by which the operating system makes computer files and directories on a storage device (such as a hard drive, CD-ROM, or shared resource) accessible to users through the computer's file system. In Windows, mounting typically refers to assigning a drive letter to a disk partition (including virtualized partitions). In Linux, it refers to attaching a device (usually a storage device) to an existing directory.

[0062] The method, device, electronic device, computer-readable storage medium, and computer program product for determining interest tags of an object provided in this application are intended to solve certain technical problems in the prior art.

[0063] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on, or combine with each other, and the same terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0064] Figure 1 is a schematic diagram of the system structure of the method for repairing a cloud environment virtual machine provided by an embodiment of the present application. As shown in Figure 1, the console 101 includes a console operation interface provided by the cloud environment, and the server 102 has multiple application programming interfaces (APIs). The console 101 sends a request instruction to the server 102 to request the repair of the target virtual machine. The server 102 includes an access module and a scheduling module. The access module includes an API for receiving the request instruction of the console 101, which is used to receive the request instruction of the console 101 and pass the request instruction to the scheduling module. The scheduling module receives the request instruction from the access module, creates a target cloud hard disk according to the request instruction, and mounts the target cloud hard disk to the mother machine 103. At the same time, the request instruction is sent to the mother machine 103 where the target virtual machine is located. The mother machine 103 receives the request instruction issued by the scheduling module of the server 102, queries and modifies the configuration file of the target virtual machine according to the request instruction, and finally starts the target virtual machine through the target cloud hard disk.

[0065] The console 101 and the server 102, as well as the server 102 and the host machine 103, can be connected via a communication network. In various embodiments, the communication network can be a wireless network or a wired network.

[0066] In each embodiment, the above-mentioned wireless network or wired network uses standard communication technology and / or protocols. The network is typically the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network). In some embodiments, technologies and / or formats including Hypertext Markup Language (HTML), Extensible Markup Language (XML), etc. are used to represent data exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above-mentioned data communication technologies.

[0067] An embodiment of the present application provides a method for repairing a cloud environment virtual machine. The method is applied to a server. As shown in FIG2 a , the method includes S101 , S102 , and S103 .

[0068] S101: Receive a first request sent by a console, where the first request is used to request repair of a target virtual machine with a system failure, and the first request includes a virtual machine identifier of the target virtual machine.

[0069] In an embodiment of the present application, when a system failure occurs in the target virtual machine, in order to repair the target virtual machine, the console needs to perform a white screen operation. The white screen operation refers to operating on the management page of the cloud environment through the console. The management page of the cloud environment is a visual web page. The management interface of the cloud environment includes a virtual machine option for entering rescue mode. When the console selects the target virtual machine in the virtual machine options, the console sends a first request to the server. The first request includes the virtual machine identifier of the target virtual machine. The server receives the first request sent by the console, obtains the virtual machine identifier from the first request, and determines that the first request is used to request to repair the target virtual machine corresponding to the virtual machine identifier.

[0070] In an embodiment of the present application, the server may include an access module having an API for receiving the first request sent by the console. Therefore, in this embodiment of the present application, the first request sent by the console can be received via the API. In this embodiment of the present application, the access module is composed of a combination of related program codes, which are run on the server.

[0071] S102: Query the image database for a target image identifier of a pre-made self-generated system image corresponding to the virtual machine identifier.

[0072] In the embodiment of the present application, the self-generated system image is a Live CD image, which is an operating system image that can be booted from a cloud hard drive, an optical disc, or a virtual hard drive. In the embodiment of the present application, a Live CD image is pre-produced, and an identifier for the Live CD image is created. The correspondence between the image identifier of the Live CD image and the virtual machine identifier is stored in the image database. In the embodiment of the present application, one image identifier can correspond to multiple virtual machine identifiers, that is, in the embodiment of the present application, one Live CD image can participate in the repair process of multiple virtual machines.

[0073] In this embodiment of the present application, a corresponding Live CD image is configured for the target virtual machine. After receiving the first request, the server obtains the virtual machine identifier in the first request. Based on the virtual machine identifier, the server can query the image database for the corresponding target image identifier, which is then used by the host machine to obtain the Live CD image from the image storage repository using the target image identifier. In this embodiment of the present application, multiple virtual machines can be associated with the same Live CD image.

[0074] In some embodiments, the console may further specify a target image identifier in the first request. In this case, the server may directly receive the target image identifier without querying the target image identifier from the image database.

[0075] In an embodiment of the present application, the image database may be a database specifically used to store Live CD images, or it may be a database used to store all image identifiers in a cloud environment, which is not limited in the present application.

[0076] In the embodiment of the present application, after the server obtains the target image identifier, it sets the state of the target virtual machine to enter the rescue mode.

[0077] S103. Create a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier according to the target image identifier, and mount the target cloud hard disk to the host computer where the target virtual machine is located, so that the host computer downloads the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk, mounts the target cloud hard disk to the target virtual machine, and starts the target virtual machine through the target cloud hard disk.

[0078] In an embodiment of the present application, after the server obtains the target image identifier, it applies for the target cloud hard disk from the system cloud hard disk in the cloud environment. The system cloud hard disk creates a target cloud hard disk for the server, which is used to store the Live CD image corresponding to the target image identifier.

[0079] In an embodiment of the present application, after the server creates the target cloud hard disk, it mounts the target cloud hard disk to the host machine where the target virtual machine is located. That is, it determines which host machine the target virtual machine is generated by, and then mounts the target cloud hard disk to the determined host machine, so that after the host machine mounts the cloud hard disk, it can download the Live CD image file corresponding to the target image identifier in the image storage warehouse, download the Live CD image file to the target cloud hard disk, and start the target virtual machine after mounting the target cloud hard disk to the target virtual machine.

[0080] In an embodiment of the present application, the server includes a scheduling module, which is used to apply for a target cloud hard disk and mount the target cloud hard disk to the mother machine. The scheduling module has an API for calling the cloud hard disk. In an embodiment of the present application, the scheduling module is composed of relevant program codes, and these program codes run on the server. Please refer to FIG. 2b, which exemplarily shows a schematic flowchart of another method for repairing a cloud environment virtual machine provided by an embodiment of the present application.

[0081] In an embodiment of the present application, before querying the target image identifier in the image database, it further includes creating a Live CD image, storing the created Live CD image in the image storage repository, and generating a corresponding target image identifier. Taking the operating system in the Live CD image as the centos7.x system as an example, the process of creating the Live CD image is as follows: Prepare the build environment, download the standard centos7.x system from the official website, install the optical disc operating system tool livecd-tool package on the centos7.x system, and the command is "yum install -y livecd-tools". At the same time, install third-party tools or programs that may be used when repairing the target virtual machine to improve the repair ability of the target virtual machine; download the official centos7.x system startup plugin kickstart, and modify the plugin as needed to be able to customize the Live CD image; build the Live CD image through the following command "livecd-creator -v --config centos7livecd.cfg --cache / var / cache / livecd --name test-livecd", generate a Live CD image named "test-livecd" through the above command, and check and test the image; after the test passes, store the Live CD image in the image storage repository and generate a corresponding image identifier, for example, generate an image identifier "img202310010000.iso" according to the date, and store the image identifier in the image database. As shown in FIG. 2c, it exemplarily shows a schematic flowchart of creating a Live CD image provided by an embodiment of the present application.

[0082] In an embodiment of the present application, by receiving a first request sent by a console, a virtual machine identifier of a target virtual machine is obtained to determine the target virtual machine where a system failure occurs; by querying the target image identifier corresponding to the virtual machine identifier based on the virtual machine identifier and the target image identifier in the image database, the target image identifier is used to determine the self-generated system image corresponding to the target virtual machine; a target cloud hard disk is created through the target image identifier, so that the target image identifier, the self-generated system image and the target cloud hard disk have a corresponding relationship, so that the target cloud hard disk can meet the requirements for loading the self-generated system image, and make material preparations for the mother machine to download the self-generated system image from the image storage warehouse to the target cloud hard disk; by mounting the target cloud hard disk to the mother machine, the mother machine downloads the self-generated system image to the target cloud hard disk, and the target cloud hard disk loaded with the self-generated system image is mounted on the target virtual machine, so that the target virtual machine with the system failure is started through the self-generated system image on the target cloud hard disk, and the target virtual machine with the system failure is started, so that the target virtual machine with the system failure can be repaired.

[0083] Based on the above embodiments, in some embodiments, the target image identifier in the embodiments of the present application includes information for indicating the occupied space of the corresponding Live CD image;

[0084] Create a target cloud disk based on the target image ID and mount it to the host computer where the target virtual machine resides, including:

[0085] S201: Determine the occupied space of the corresponding self-generated system image according to the target image identifier, and create a target cloud hard disk with a storage space no less than the occupied space;

[0086] S202: Query a parent machine identifier corresponding to a virtual machine identifier in a parent machine identifier list, where the parent machine identifier list includes a correspondence between virtual machine identifiers and parent machine identifiers;

[0087] S203: Mount the target cloud hard disk to the host machine corresponding to the host machine identifier.

[0088] In an embodiment of the present application, the target image identifier includes information about the occupied space of the corresponding Live CD image. Therefore, when the server creates a cloud hard disk, it creates a target cloud hard disk with a storage space greater than or equal to the occupied space of the Live CD image indicated by the target image identifier, thereby avoiding the situation where the cloud hard disk storage space is too small, making it impossible for the subsequent host machine to download the corresponding Live CD image to the target cloud hard disk.

[0089] In an embodiment of the present application, after the server creates the target cloud hard disk, it mounts the target cloud hard disk to the host machine where the virtual machine is located. In an embodiment of the present application, a host machine identification list is preset, as shown in FIG3 , which exemplarily shows a schematic diagram of the host machine identification list provided in an embodiment of the present application. In FIG3 , virtual machines 001 and 002 are generated by host machine a through virtualization technology. If the identifier of the target virtual machine is 001, the corresponding host machine identifier can be determined as a through the host machine identification list, thereby determining the host machine where the target virtual machine is located. The server can obtain from the list which host machine the target virtual machine is generated by, that is, the host machine identification list includes the virtual machine identifier of the target virtual machine and the corresponding relationship between the host machine identifier of the target virtual machine. Therefore, the server obtains the host machine identifier based on the virtual machine identifier, thereby determining the host machine where the target virtual machine is located.

[0090] In an embodiment of the present application, after the server determines the parent machine identifier, it mounts the cloud hard drive to the parent machine. In an embodiment of the present application, the cloud hard drive can be mounted to the parent machine via the Internet Small Computer System Interface (iSCSI) protocol. The iSCSI protocol can be used to mount a remote cloud hard drive to the parent machine, enabling data sharing and access. Through the iSCSI protocol, the parent machine can access the target cloud hard drive just like accessing a local disk.

[0091] Based on the above embodiments, in some embodiments, when creating a target cloud hard disk according to the occupied space of the Live CD image indicated by the target image identifier, the embodiment of the present application also creates a cloud hard disk identifier of the target cloud hard disk;

[0092] Furthermore, the target cloud hard disk is mounted to the host machine corresponding to the target identifier, and then the following steps are also included:

[0093] Sending a second request to the host machine, the second request being used to request the host machine to download the Live CD image corresponding to the target image identifier to the target cloud hard disk corresponding to the cloud hard disk identifier, mount the target cloud hard disk to the target virtual machine, and start the target virtual machine through the target cloud hard disk;

[0094] The second request includes the virtual machine identifier, the target image identifier, and the cloud hard disk identifier of the target cloud hard disk.

[0095] In an embodiment of the present application, the server applies for a target cloud hard disk in the system cloud hard disk. At this time, the system cloud hard disk creates a target cloud hard disk for the server and also creates a corresponding cloud hard disk identifier for the target cloud hard disk. It should be understood that when the server performs an operation on a cloud hard disk, it needs to execute the instruction corresponding to the cloud hard disk, and the instruction must include the corresponding cloud hard disk identifier so that the server can understand which cloud hard disk is being operated on. Therefore, in an embodiment of the present application, a corresponding cloud hard disk identifier is also created for the target cloud hard disk when the target cloud hard disk is created. After the cloud hard disk identifier of the target cloud hard disk is created, the virtual machine identifier of the target virtual machine and the corresponding cloud hard disk identifier are stored in the cloud hard disk database, that is, the correspondence between the virtual machine identifier and the cloud hard disk identifier is stored in the cloud hard disk database.

[0096] As shown in Figure 4, Figure 4 exemplifies a flow chart of another method for repairing a cloud environment virtual machine proposed in an embodiment of the present application. Through steps S101, S102, and S103, the server receives a first request sent by the console, and the server queries the target image identifier of the Live CD image corresponding to the virtual machine identifier in the image database. The server creates a target cloud hard disk based on the target image identifier, and then includes the server mounting the target cloud hard disk to the corresponding mother machine. At this time, the server sends a second request to the mother machine, and the second request includes the virtual machine identifier, the target image identifier, and the cloud hard disk identifier. The mother machine downloads the Live CD image to the target cloud hard disk through the target image identifier and the cloud hard disk identifier. The mother machine mounts the target cloud hard disk to the target virtual machine and starts the target virtual machine through the target cloud hard disk.

[0097] By passing the virtual machine identifier, target image identifier, and cloud hard disk identifier obtained by the server to the master machine, the master machine can, after obtaining this information, download the Live CD image corresponding to the target image to the target cloud hard disk corresponding to the cloud hard disk identifier, mount the target cloud hard disk to the target virtual machine corresponding to the virtual machine identifier, and start the target virtual machine through the target cloud hard disk.

[0098] Based on the above embodiments, as an embodiment, searching the image database for the target image identifier of the Live CD image corresponding to the virtual machine identifier also includes:

[0099] S401, determining whether the target virtual machine is in a first state, the first state being a shutdown state or a running state;

[0100] S402: If it is determined that the target virtual machine is in the first state, determining whether the complexity of the startup password of the target virtual machine meets a preset condition, where the startup password of the target virtual machine is set by the console when sending the first request;

[0101] S403: If it is determined that the complexity of the startup password of the target virtual machine meets the preset condition, query the image database for a target image identifier of the native system image corresponding to the virtual machine identifier of the target virtual machine.

[0102] As shown in Figure 5a, it exemplarily shows a flow chart of detecting a target virtual machine provided by an embodiment of the present application. In the embodiment of the present application, the server receives the virtual machine identifier sent by the console, and queries the image identifier corresponding to the Live CD image corresponding to the virtual machine identifier in the image database according to the virtual machine identifier. Before this, the server needs to judge the first state of the target virtual machine corresponding to the virtual machine identifier. The first state includes the shutdown state and the running state. Only when the state of the target virtual machine is the first state can the relevant repair operations be performed on the target virtual machine. It should be understood that when the target virtual machine is in a state other than the first state, there may be subtasks, so the rescue mode cannot be entered, and therefore the relevant repair operations cannot be performed.

[0103] In an embodiment of the present application, after the server determines that the target virtual machine is in the first state, it further determines whether the complexity of the target virtual machine's startup password meets a preset condition. When the console first requests the server, a startup password is set for the target virtual machine. To ensure the security of the target virtual machine repair process, the server verifies the complexity of the startup password. If the complexity of the startup password is low, it indicates that the startup password is set too simply, making the target virtual machine vulnerable to illegal attacks and unable to ensure the security of the repair process.

[0104] In an embodiment of the present application, the server includes an access module, and steps S401 to S403 are executed by the access module. As shown in Figure 5b, it exemplarily shows a flow chart of the execution process of the access module in the repair method of the cloud environment virtual machine provided by the embodiment of the present application. In an embodiment of the present application, the access module is responsible for receiving the first request sent by the console, determining the status of the target virtual machine, and checking the complexity of the startup password of the target virtual machine, obtaining the target image identifier corresponding to the virtual machine identifier, updating the target virtual machine status to the rescue mode, and sending the virtual machine identifier, the target image identifier and the startup password of the target virtual machine to the scheduling module.

[0105] Through the embodiment of the present application, the server determines the status of the target virtual machine before querying the target image identifier corresponding to the virtual machine identifier, thereby avoiding performing repair operations on the target virtual machine when the target virtual machine runs the subtask, which affects the operation of the subtask; and verifies the complexity of the startup password of the target virtual machine to prevent the complexity of the startup password from being low and being attacked by illegal programs when the target virtual machine is repaired, thereby ensuring the security of the repair process.

[0106] Based on the above embodiments, in some embodiments, after determining whether the complexity of the startup password of the target virtual machine meets a preset condition, the following steps are further included:

[0107] If the complexity of the startup password of the target virtual machine does not meet the preset conditions, a message indicating that the target virtual machine has failed to enter the rescue mode is sent to the console, instructing the console to reset the startup password of the target virtual machine.

[0108] In an embodiment of the present application, when the complexity of the startup password of the target virtual machine does not meet the preset conditions, it means that the complexity of the startup password is low, that is, the console set a relatively simple startup password for the target virtual machine. The server will send a message to the console that the target virtual machine failed to enter the rescue mode, that is, the server cannot continue to perform the operation of repairing the virtual machine, and prompts the console to reset the startup password of the target virtual machine.

[0109] Through the embodiments of the present application, when the complexity of the startup password of the target virtual machine does not meet the preset conditions, timely feedback can be given to the console, so that the console can reset the startup password in time, avoiding the inability to repair the target virtual machine in time due to the low complexity of the startup password.

[0110] Based on the above embodiments, in some embodiments, the target cloud hard disk is mounted to the host machine where the target virtual machine is located, and then the following steps are further included:

[0111] S601: Receive a third request sent by a console, where the third request is used to request to stop repairing a target virtual machine, and the third request includes a virtual machine identifier of the target virtual machine;

[0112] S602: Query the parent machine identifier corresponding to the virtual machine identifier in the parent machine identifier list. Based on the parent machine identifier, send a fourth request to the parent machine, so that the parent machine corresponding to the parent machine identifier detaches the target cloud hard disk mounted on the target virtual machine and sends the cloud hard disk identifier to the server. The fourth request includes the virtual machine identifier and the cloud hard disk identifier.

[0113] S603: Receive the cloud hard disk identifier sent by the master machine, and delete the native system image in the target cloud hard disk according to the cloud hard disk identifier.

[0114] As shown in Figure 6a, it exemplifies a flow chart of stopping and repairing a target virtual machine provided in an embodiment of the present application. In this embodiment of the present application, the server mounts the target cloud hard disk to obtain the host machine where the target virtual machine is located, and then receives a third request sent by the console. The third request includes the virtual machine identifier of the target virtual machine. The third request is used to request the server to exit the rescue mode of the target virtual machine based on the virtual machine identifier, that is, to stop repairing the target virtual machine.

[0115] In an embodiment of the present application, after receiving the virtual machine identifier, the server first determines the state of the target virtual machine corresponding to the virtual machine identifier. If the state of the target virtual machine is in rescue mode, that is, the target virtual machine is in the repair process, then the mother machine identifier corresponding to the virtual machine identifier is queried from the mother machine identifier list to find the mother machine where the target virtual machine corresponding to the virtual machine identifier is located, that is, to determine which mother machine virtualized the target virtual machine. The cloud hard disk identifier is then determined by the virtual machine identifier. The server queries the cloud hard disk identifier corresponding to the virtual machine identifier from the cloud hard disk database. After determining the mother machine identifier and the cloud hard disk identifier, a fourth request is sent to the mother machine corresponding to the mother machine identifier. The fourth request includes the virtual machine identifier and the cloud hard disk identifier, so that the mother machine determines the target virtual machine based on the virtual machine identifier and unmounts the target cloud hard disk previously mounted on the target virtual machine.

[0116] In an embodiment of the present application, after the server sends the fourth request to the mother machine, it receives the cloud hard disk identifier sent back by the mother machine, so that the server can delete the content in the target cloud hard disk, that is, delete the Live CD image in the target cloud hard disk, clear the content in the target cloud hard disk, and then return the target cloud hard disk to the system cloud hard disk.

[0117] As shown in Figure 6b, Figure 6b exemplarily shows another flow chart of stopping and repairing the target virtual machine provided in an embodiment of the present application. In the embodiment of the present application, the server includes an access module and a scheduling module, wherein the access module is used to receive the virtual machine identifier of the target virtual machine sent by the console, and pass the virtual machine identifier to the scheduling module, the scheduling module obtains the cloud hard disk identifier in the cloud hard disk database according to the virtual machine identifier, and sends the virtual machine identifier and the cloud hard disk identifier to the mother machine, so that the mother machine unmounts the target cloud hard disk on the target virtual machine, the scheduling module receives the cloud hard disk identifier returned by the mother machine, deletes the Live CD image in the target cloud hard disk, and returns the target cloud hard disk to the system cloud hard disk.

[0118] As shown in Figure 6c, the embodiment of Figure 6c is a flow diagram illustrating the execution process of the access module when stopping the repair of the target virtual machine provided in an embodiment of the present application. The access module is configured to receive the third request sent by the console, check whether the target virtual machine is in rescue mode, and if the check passes, send the virtual machine identifier of the target virtual machine to the scheduling module.

[0119] Through the embodiment of the present application, the target virtual machine is exited from rescue mode, that is, the repair operation on the target virtual machine is terminated. By receiving the third request from the console, the virtual machine identifier is obtained, and based on the virtual machine identifier, the host machine corresponding to the target virtual machine is determined, and a fourth request is sent to the host machine, so that the host machine detaches the target cloud hard disk on the target virtual machine, receives the cloud hard disk identifier of the target cloud hard disk sent back by the host machine, and clears the content in the target cloud hard disk and returns the target cloud hard disk to the system cloud hard disk.

[0120] An embodiment of the present application provides a method for repairing a cloud environment virtual machine. The method is applied to a host machine. As shown in FIG7 , the method includes S701 and S702 .

[0121] S701. Download the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk;

[0122] In an embodiment of the present application, the target cloud hard disk is created by the server according to the target image identifier and mounted to the mother machine; the target image identifier is obtained by the server from the image database according to the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server to request to repair the target virtual machine with a system failure. The mother machine downloads the Live CD image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk according to the target image identifier. The target cloud hard disk is mounted on the mother machine, and the mother machine can manage the target cloud hard disk like managing its own hard disk, and download the Live CD image to the target cloud hard disk. It should be understood that the target cloud hard disk is mounted on the mother machine at this time, and the server remotely mounts the target cloud hard disk to the mother machine through the iSCSI protocol to achieve data sharing and access.

[0123] In the embodiment of the present application, the Live CD image in the image storage warehouse is produced by a server and stored in the image storage warehouse, and a target image identifier is generated and stored in the image database.

[0124] S702: Mount the target cloud hard disk to the target virtual machine, and start the target virtual machine with the system failure through the target cloud hard disk.

[0125] In this embodiment of the present application, the parent machine downloads the Live CD image corresponding to the target image identifier to the target cloud hard disk and then mounts the target cloud hard disk to the target virtual machine corresponding to the virtual machine identifier. The console sends the virtual machine identifier to the server, which in turn sends the virtual machine identifier to the parent machine. The parent machine determines the target virtual machine to be repaired based on the virtual machine identifier and then mounts the target cloud hard disk containing the Live CD image to the target virtual machine.

[0126] After the target cloud hard disk is mounted to the target virtual machine, the target cloud hard disk is used as the boot disk for starting the target virtual machine. The target virtual machine is started based on the target cloud hard disk. After the target virtual machine is started, relevant repair operations can be performed for the system failure of the target virtual machine. It should be understood that before the target cloud hard disk is mounted to the target virtual machine, the target virtual machine has its own system disk. After the system disk fails, the target virtual machine cannot be started. Through the embodiment of the present application, the target cloud hard disk is used as the boot disk. At this time, the system disk of the target virtual machine is used as an ordinary hard disk of the target virtual machine. After the target cloud hard disk starts the virtual machine, relevant repair operations can be performed on the system disk of the target virtual machine.

[0127] Through the embodiment of the present application, the Live CD image corresponding to the target image identifier is downloaded to the target cloud hard disk, and a boot disk capable of starting the target virtual machine with a system failure is constructed. By mounting the target cloud hard disk loaded with the Live CD image to the target virtual machine, the target cloud hard disk can start the target virtual machine, thereby solving the problem that the target virtual machine cannot start due to a system failure and realizing the repair of the target virtual machine with a system failure.

[0128] Based on the above embodiments, in some embodiments, downloading the Live CD image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk also includes:

[0129] Receive a second request sent by the server, where the second request is used to request the host machine to download the Live CD image corresponding to the target image identifier to the target cloud hard disk corresponding to the cloud hard disk identifier, mount the target cloud hard disk to the target virtual machine, and start the target virtual machine through the target cloud hard disk;

[0130] The second request includes the virtual machine identifier, the target image identifier, and the cloud hard disk identifier of the target cloud hard disk.

[0131] In this embodiment of the present application, before downloading the Live CD image from the image storage repository to the target cloud hard drive, the parent machine receives a second request from the server. The second request includes a virtual machine identifier, a target image identifier, and a cloud hard drive identifier. The parent machine includes an agent component capable of receiving the second request from the server. The agent component on the parent machine is an agent software module running on the parent machine and is used to manage and execute specific tasks.

[0132] The virtual machine ID is sent by the console to the server and is the virtual machine ID of the target virtual machine of the system failure; the target image ID is the target image ID corresponding to the virtual machine ID queried by the server in the image database based on the virtual machine ID, and the target image ID corresponds to a Live CD image; the cloud hard disk ID is the cloud hard disk ID of the target cloud hard disk used to load the Live CD image.

[0133] Through the embodiment of the present application, a second request sent by the server is received, and the virtual machine identifier, target image identifier, and cloud hard disk identifier are obtained. The mother machine is used to download the Live CD image to the target cloud hard disk according to the three identifiers, and mount the target cloud hard disk to the target virtual machine, and start the target virtual machine based on the target cloud hard disk. That is, the virtual machine identifier, target image identifier, and cloud hard disk identifier in the present application have a corresponding relationship, which provides a systematic method for starting the target virtual machine in the event of a system failure.

[0134] Based on the above embodiments, in some embodiments, downloading the Live CD image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk also includes:

[0135] S901. Determine whether the target cloud hard disk has been mounted to the host computer based on the cloud hard disk identifier.

[0136] S902: If it is determined that the target cloud hard disk has been mounted, search the image storage warehouse for the native system image corresponding to the target image identifier;

[0137] S903: Download the self-generated system image to the target cloud hard disk.

[0138] In the embodiment of the present application, before downloading the Live CD image to the target cloud hard disk, the master machine further checks whether the target cloud hard disk is mounted on the master machine. The master machine queries whether the target cloud hard disk is mounted on itself based on the cloud hard disk identifier.

[0139] If the master machine determines that the target cloud hard drive is mounted on the master machine, it then downloads the Live CD image corresponding to the target image identifier from the image storage warehouse and downloads it to the target cloud hard drive. As an optional embodiment of the present application, when the master machine checks whether the target cloud hard drive is mounted, it obtains the storage address of the target cloud hard drive and, based on the storage address, downloads the Live CD image to the target cloud hard drive.

[0140] Through the embodiment of the present application, when the parent machine downloads the Live CD image to the target cloud hard disk, it checks whether the target cloud hard disk is mounted. Taking into account the possibility that the server may fail to mount the target cloud hard disk to the parent machine, it ensures that the target cloud hard disk is mounted to the parent machine, and then downloads the Live CD image from the image storage warehouse to the target cloud hard disk, thereby preventing the occurrence of failure in downloading the Live CD.

[0141] Based on the above embodiments, in some embodiments, mounting a target cloud hard disk to a target virtual machine and starting the target virtual machine with a system failure through the target cloud hard disk includes:

[0142] S1001. If it is determined that the target virtual machine is in a running state, shut down the target virtual machine;

[0143] S1002. Obtain a configuration file of the target virtual machine based on the virtual machine identifier, and add the cloud hard disk identifier to the configuration file to mount the target cloud hard disk to the target virtual machine.

[0144] S1003. In the configuration file, the priority of the target cloud hard disk is set to the highest priority among the priorities of the boot hard disks capable of booting the target virtual machine. The boot hard disk is a hard disk capable of booting the target virtual machine.

[0145] S1004. Start the target virtual machine through the target cloud hard disk.

[0146] In an embodiment of the present application, when the parent machine mounts the target cloud hard disk to the target virtual machine, it first determines the state of the target virtual machine. Based on the virtual machine identifier, the parent machine determines the target virtual machine with the system failure and the state of the target virtual machine at that time. Before the server sends the third request to the parent machine, the server determines that the state of the target virtual machine is the first state, which is either the shutdown state or the running state. The parent machine then determines the state of the target virtual machine again. If the state of the target virtual machine is the running state, the target virtual machine is shut down.

[0147] In an embodiment of the present application, the parent machine shuts down the target virtual machine by calling the virtualization interface libvirt API. The libvirt API is a toolkit for managing virtualization platforms. It provides a stable, secure and scalable interface for managing virtualization platforms (including virtual machines, storage and networks). It can be used to perform various virtualization management tasks, such as creating, starting, stopping and managing virtual machines, managing storage volumes and network interfaces, and configuring virtualization hosts.

[0148] In the embodiment of the present application, after the host machine shuts down the target virtual machine, it obtains the target virtual machine's configuration file based on the virtual machine identifier, calls the libvirt API again to obtain the target virtual machine's XML configuration file, and modifies the target virtual machine's XML configuration file based on the agent component on the host machine.

[0149] In the embodiment of the present application, two modifications are made to the XML configuration file of the target virtual machine. The first modification is used to mount the target cloud hard disk to the target virtual machine. The modification process is to add a target cloud hard disk identifier under the devices tag in the XML; the second modification is used to set the priority of the target cloud hard disk for starting the target virtual machine to the highest level of the priority of each cloud hard disk for starting the target virtual machine. The modification process is to set the boot order of the target cloud hard disk in the XML configuration file to 1 and the boot order of the system disk of the target virtual machine to 9.

[0150] It should be understood that the embodiment of the present application is intended to start the target virtual machine based on the target cloud hard disk. Before this, the startup disk of the target virtual machine is the system disk of the target virtual machine. In the embodiment of the present application, the priority of the target cloud hard disk to start the target virtual machine is set to the highest priority, so that the target virtual machine is no longer started by the system disk. At this time, the system disk is used as an ordinary hard disk of the target virtual machine, and finally the host machine calls the libvirt API to start the target virtual machine.

[0151] Through the embodiment of the present application, the target virtual machine xml configuration file is modified, and the target cloud hard disk is mounted to the target virtual machine, so that the target virtual machine can be started based on the Live CD image on the target cloud hard disk.

[0152] Based on the above embodiments, as an embodiment, starting the target virtual machine through the target cloud hard disk includes:

[0153] S1101, injecting the user name and the startup password of the target virtual machine into the self-generated system image;

[0154] S1102: Start the target virtual machine. The user name and the startup password of the target virtual machine are carried in the second request sent by the server.

[0155] In an embodiment of the present application, a target virtual machine is started based on a target cloud hard disk. The cloud server initialization tool cloudinit is used to inject the username and startup password corresponding to the target virtual machine into the Live CD image in the target cloud hard disk. The username and startup password are carried by the server when sending the second request to the host machine, and are also carried by the console when sending the first request to the server. The username and startup password are injected into the Live CD image through cloudinit, and the libvirt API is called to start the target virtual machine.

[0156] After the target virtual machine is started, the user can enter the username and password into the target virtual machine. The server verifies the username and startup password entered by the user. If the username and startup password entered by the user are consistent with the username and password injected into the Live CD image, the verification is passed, and the user can now perform specific repair operations on the target virtual machine. Please refer to Figure 8 for details. Figure 8 exemplarily shows a flow chart of another method for repairing a cloud environment virtual machine provided by an embodiment of the present application. When the method for repairing a cloud environment virtual machine is applied to the mother machine, the mother machine receives the second request sent by the scheduling module of the server, checks whether the target cloud hard disk is mounted on the mother machine, and after the check is passed, downloads the Live CD image from the image storage warehouse to the target cloud hard disk, calls the libvirt API to shut down the target virtual machine, calls the libvirt API to obtain the XML configuration file of the target virtual machine, modifies the XML configuration file, injects the username and startup password of the target virtual machine into the Live CD image through the cloudinit component, and finally calls the libvirt API to start the target virtual machine.

[0157] Based on the above embodiments, in some embodiments, starting the target virtual machine through the target cloud hard disk further includes:

[0158] S1201. Receive a fourth request sent by the server. The fourth request is used to request the host computer to detach the target cloud hard disk from the target virtual machine. The fourth request includes a virtual machine identifier and a cloud hard disk identifier. The virtual machine identifier is carried in the third request sent by the console to the server.

[0159] S1202: Unmount the target cloud hard disk on the target virtual machine according to the virtual machine ID and the cloud hard disk ID.

[0160] S1203: Send the cloud hard disk identifier to the server, so that the server deletes the native system image in the target cloud hard disk.

[0161] In an embodiment of the present application, the mother machine receives a fourth request sent by the server, which includes a virtual machine identifier and a cloud hard disk identifier. The agent component of the mother machine can receive the fourth request and obtain the virtual machine identifier and cloud hard disk identifier in the fourth request. The virtual machine identifier is carried in the third request sent by the console to the server, and the cloud hard disk identifier is obtained by the server based on the correspondence between the virtual machine identifier and the cloud hard disk identifier in the cloud hard disk database. The fourth request is used to request the mother machine to exit the rescue mode of the target virtual machine and request the mother machine to return the target cloud hard disk.

[0162] In the embodiment of the present application, after the parent machine obtains the virtual machine identifier, it determines the target virtual machine and the target cloud hard disk corresponding to the cloud hard disk identifier, and unmounts the target cloud hard disk on the target virtual machine.

[0163] In an embodiment of the present application, after the mother machine unmounts the target cloud hard disk, it returns the target cloud hard disk and sends the cloud hard disk identifier to the server so that the server can clear the Live CD image in the unmounted target cloud hard disk and return the target cloud hard disk to the system cloud hard disk.

[0164] Through the embodiment of the present application, the target virtual machine is exited from the rescue mode, that is, the repair operation on the target virtual machine is terminated. Therefore, the embodiment of the present application realizes a systematic repair process of the target virtual machine.

[0165] Based on the above embodiments, in some embodiments, detaching a target cloud hard disk from a target virtual machine according to a virtual machine identifier and a cloud hard disk identifier includes:

[0166] S1301. Shut down the target virtual machine corresponding to the virtual machine identifier;

[0167] S1302: Obtain the configuration file of the target virtual machine. Delete the cloud hard disk identifier in the configuration file so that the parent machine can detach the target cloud hard disk from the target virtual machine. In addition, restore the priority of each boot hard disk of the target virtual machine in the configuration file.

[0168] As shown in Figure 9, Figure 9 exemplarily shows a flow chart of stopping and repairing the target virtual machine provided in an embodiment of the present application. In the embodiment of the present application, after the mother machine receives the fourth request, it calls the libvirt API to shut down the target virtual machine, and then obtains the xml configuration file of the target virtual machine by calling the libvirt API. After the mother machine obtains the xml configuration file of the target virtual machine, it modifies the configuration file according to the cloud hard disk identifier. The modification includes two parts. The first is to delete the disk label corresponding to the target cloud hard disk according to the cloud hard disk identifier, which is used to unmount the target cloud hard disk on the target virtual machine; the second is to set the boot order of the system disk of the target virtual machine to 1, which is used to restore the startup order of the system disk of the target virtual machine.

[0169] After the target virtual machine's XML configuration file is modified, the host machine can call the libvirt API to start the target virtual machine. At this time, the target virtual machine is started through the system disk.

[0170] Through the embodiment of the present application, the XML configuration file of the target virtual machine is modified again, so that the target virtual machine unmounts the target cloud hard disk and restores the startup order of the system disk of the target virtual machine, so that the repaired target virtual machine can be started according to the system disk.

[0171] As shown in FIG10 , it exemplarily shows a flow chart of another method for repairing a virtual machine in a cloud environment provided in an embodiment of the present application. In an embodiment of the present application, the method for repairing a cloud environment is applied to a server in a cloud environment, specifically as follows:

[0172] S1401. Receive a first request sent by a console, where the first request includes a virtual machine identifier of a target virtual machine;

[0173] S1402, determining whether the target virtual machine is in the first state;

[0174] S1403: If it is determined that the target virtual machine is in the first state, determine whether the complexity of the startup password of the target virtual machine meets a preset condition;

[0175] S1404: If the complexity of the startup password of the target virtual machine meets the preset conditions, the target image ID of the self-generated system image corresponding to the virtual machine ID is searched in the image database.

[0176] S1405: If the complexity of the startup password of the target virtual machine does not meet the preset condition, send a message to the console indicating that the target virtual machine has failed to enter the rescue mode, instructing the console to reset the startup password of the target virtual machine;

[0177] S1406: Determine the occupied space of the native system image based on the target image identifier, and create a target cloud hard disk based on the occupied space;

[0178] S1407. Search the host machine identifier list for the host machine identifier corresponding to the virtual machine identifier.

[0179] S1408. Mount the target cloud hard disk to the host machine corresponding to the host machine ID.

[0180] S1409: Send a second request to the parent machine, where the second request includes the virtual machine identifier, the target image identifier, and the cloud hard disk identifier of the target cloud hard disk;

[0181] S1410. Receive a third request sent by the console, where the third request includes a virtual machine identifier of a target virtual machine;

[0182] S1411. Search the host machine identifier list for the host machine identifier corresponding to the virtual machine identifier.

[0183] S1412: Send a fourth request to the master machine based on the master machine identifier, where the fourth request includes the virtual machine identifier and the cloud hard disk identifier.

[0184] S1413: Receive the cloud hard disk identifier sent by the host computer and delete the native system image in the target cloud hard disk.

[0185] Steps S1401 to S1405 and step S1410 are executed by the access module in the server, and steps S1406 to S1409 and steps S1411 to S1413 are executed by the scheduling module in the server.

[0186] FIG11 is a flow chart showing another method for repairing a virtual machine in a cloud environment provided by an embodiment of the present application. As shown in FIG11 , the cloud environment repair method provided in the embodiment of the present application is applied to the host machine where the target virtual machine is located, as follows:

[0187] S1501. Receive a second request sent by the server, where the second request includes a virtual machine identifier, a target image identifier, and a cloud hard disk identifier of a target cloud hard disk;

[0188] S1502: Determine whether the target cloud hard disk has been mounted to the host machine.

[0189] S1503: If it is determined that the target cloud hard disk is mounted, download the self-generated system image to the target cloud hard disk;

[0190] S1504: Determine whether the target virtual machine is in a running state;

[0191] S1505: If it is determined that the target virtual machine is in a running state, shut down the target virtual machine;

[0192] S1506. Obtain a configuration file of the target virtual machine according to the virtual machine identifier;

[0193] S1507: Add a cloud hard disk identifier to the configuration file to mount the target cloud hard disk to the target virtual machine.

[0194] S1508. Set the priority of the target cloud hard disk in the configuration file to the highest priority among the priorities of the boot hard disks that start the target virtual machine.

[0195] S1509: Inject the user name and the startup password of the target virtual machine into the self-generated system image;

[0196] S1510: Start the target virtual machine through the target cloud hard disk.

[0197] S1511. Receive a fourth request sent by the server, where the fourth request includes a virtual machine identifier and a cloud hard disk identifier.

[0198] S1512: Unmount the target cloud hard disk on the target virtual machine based on the virtual machine ID and the cloud hard disk ID.

[0199] S1513: Send the cloud hard disk identifier of the target cloud hard disk to the server.

[0200] The embodiment of the present application provides a cloud environment virtual machine repair device, as shown in FIG12, the cloud environment virtual machine repair device may include: a receiving module 1001, a query module 1002 and a creation module 1003, wherein:

[0201] A receiving module 1001 is configured to receive a first request sent by a console, where the first request is used to request repair of a target virtual machine with a system failure, and the first request includes a virtual machine identifier of the target virtual machine;

[0202] A query module 1002 is configured to query an image database for a target image identifier of a pre-made self-generated system image corresponding to a virtual machine identifier;

[0203] Creation module 1003 is used to create a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier according to the target image identifier, mount the target cloud hard disk to the host machine where the target virtual machine is located, so that the host machine downloads the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk, mount the target cloud hard disk to the target virtual machine, and start the target virtual machine through the target cloud hard disk.

[0204] The embodiment of the present application provides a cloud environment virtual machine repair device, as shown in FIG13, the cloud environment virtual machine repair device may include: a download module 1101, a startup module 1102, wherein,

[0205] The download module 1101 is used to download the self-generated system image corresponding to the target image identifier from the image storage warehouse to the target cloud hard disk;

[0206] The startup module 1102 mounts the target cloud hard disk to the target virtual machine and starts the target virtual machine with the system failure through the target cloud hard disk;

[0207] Among them, the target cloud hard disk is created by the server to store the self-generated system image corresponding to the target image identifier and mounted on the mother machine; the target image identifier is obtained by the server from the image database based on the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server to request to repair the target virtual machine.

[0208] In an optional embodiment, an electronic device is provided, as shown in FIG14 , and the electronic device 4000 shown in FIG14 includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0209] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0210] Bus 4002 may include a path for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, for example. Bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, FIG14 shows a single thick line, but this does not imply that there is only one bus or only one type of bus.

[0211] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.

[0212] The memory 4003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.

[0213] The electronic device package may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device shown in FIG14 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0214] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented. Compared with the prior art, the present invention can achieve the following: by receiving the first request sent by the console, the virtual machine identifier of the target virtual machine is obtained to determine the target virtual machine where the system failure occurs; by querying the target image identifier corresponding to the virtual machine identifier according to the virtual machine identifier and the target image identifier in the image database through the obtained virtual machine identifier, so as to determine the self-generated system image corresponding to the target virtual machine; by creating a target cloud hard disk through the target image identifier, the target image identifier, the self-generated system image and the target cloud hard disk have a corresponding relationship, so that the target cloud hard disk can meet the requirements for loading the self-generated system image, and make material preparations for the mother machine to download the self-generated system image from the image storage warehouse to the target cloud hard disk; by mounting the target cloud hard disk to the mother machine, the mother machine downloads the self-generated system image to the target cloud hard disk, and the target cloud hard disk loaded with the self-generated system image is mounted on the target virtual machine, so that the target virtual machine with the system failure is started through the self-generated system image on the target cloud hard disk, and the target virtual machine with the system failure is started, so that the target virtual machine with the system failure can be repaired.

[0215] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0216] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor. Compared with the prior art, it can achieve: by receiving a first request sent by a console, obtaining a virtual machine identifier of a target virtual machine to determine the target virtual machine with a system failure; by querying the target image identifier corresponding to the virtual machine identifier according to the virtual machine identifier and the target image identifier in the image database, for determining the self-generated system image corresponding to the target virtual machine; creating a target cloud hard disk by the target image identifier, so that the target image identifier, the self-generated system image and the target cloud hard disk have a corresponding relationship, so that the target cloud hard disk can meet the requirements for loading the self-generated system image, and prepare materials for the mother machine to download the self-generated system image from the image storage warehouse to the target cloud hard disk; by mounting the target cloud hard disk to the mother machine, so that the mother machine downloads the self-generated system image to the target cloud hard disk, and mounting the target cloud hard disk with the self-generated system image to the target virtual machine, so that the target virtual machine with the system failure can be started by the self-generated system image on the target cloud hard disk, so as to start the target virtual machine with the system failure, thereby enabling the target virtual machine to be repaired.

[0217] The terms "first," "second," "third," "fourth," "1," "2," and the like (if any) in the specification and claims of this application and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the application described herein can be implemented in an order other than that shown or described in the drawings.

[0218] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the order of implementation of these steps is not limited to the order indicated by the arrows. Unless otherwise clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart can include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage in these sub-steps or stages can also be executed at different times respectively. Under different scenarios at the execution time, the execution order of these sub-steps or stages can be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0219] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0220] The above description is only an optional implementation method for some implementation scenarios of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of this application, the use of other similar implementation methods based on the technical ideas of this application also falls within the protection scope of the embodiments of this application.

[0221] In conclusion, the scope of the claims should not be limited to the exemplary embodiments described above, but should be given the broadest interpretation of the specification as a whole.

Claims

1. A method for repairing a virtual machine in a cloud environment, which is executed by a server. The server has a communication connection with a mother machine running a virtual machine. The method includes: Receiving a first request sent by a console. The first request is used to request the repair of a target virtual machine, and the first request includes the virtual machine identifier of the target virtual machine; Querying in an image database for a target image identifier of a pre-made self-generated system image corresponding to the virtual machine identifier; Creating a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier, mounting the target cloud hard disk to the mother machine where the target virtual machine is located, so that the mother machine downloads the self-generated system image corresponding to the target image identifier from an image storage repository to the target cloud hard disk, mounting the target cloud hard disk to the target virtual machine, and starting the target virtual machine through the target cloud hard disk.

2. The method according to claim 1, wherein The target image identifier includes information for indicating the occupied space of the self-generated system image; Creating a target cloud hard disk for storing the self-generated system image corresponding to the target image identifier and mounting the target cloud hard disk to the mother machine where the target virtual machine is located includes: Determining the occupied space of the self-generated system image according to the information for indicating the occupied space of the self-generated system image in the target image identifier, and creating a target cloud hard disk with a storage space not less than the occupied space; Querying in a mother machine identifier list for a mother machine identifier corresponding to the virtual machine identifier. The mother machine identifier list includes the correspondence between the virtual machine identifier and the mother machine identifier; Mounting the target cloud hard disk to the mother machine corresponding to the mother machine identifier.

3. The method according to claim 1 or 2, further comprising: Creating a cloud hard disk identifier for the target cloud hard disk; The mounting of the target cloud hard disk to the mother machine corresponding to the mother machine identifier further includes: Sending a second request to the mother machine. The second request is used to request the mother machine to download the self-generated system image corresponding to the target image identifier to the target cloud hard disk corresponding to the cloud hard disk identifier, mount the target cloud hard disk to the target virtual machine, and start the target virtual machine through the target cloud hard disk; wherein the second request includes the virtual machine identifier, the target image identifier, and the cloud hard disk identifier of the target cloud hard disk.

4. The method according to claim 1, further including: Before querying in the image database for a target image identifier of the self-generated system image corresponding to the virtual machine identifier, determining whether the target virtual machine is in a first state. The first state is a shutdown state or a running state; If it is determined that the target virtual machine is in the first state, then determining whether the complexity of the startup password of the target virtual machine meets a preset condition. The startup password of the target virtual machine is set by the console when sending the first request; If it is determined that the complexity of the startup password of the target virtual machine meets the preset condition, then querying in the image database for a target image identifier of the self-generated system image corresponding to the virtual machine identifier.

5. The method according to claim 4, wherein Further including: If the complexity of the startup password of the target virtual machine does not meet the preset condition, send a failure message for the target virtual machine to enter the rescue mode to the console, instructing the console to reset the startup password of the target virtual machine.

6. The method according to claim 1, wherein, Further comprising: Receiving a third request sent by the console, the third request being used to request to stop repairing the target virtual machine, and the third request includes the virtual machine identifier of the target virtual machine; Querying the host identifier corresponding to the virtual machine identifier in the host identifier list, and according to the host identifier, sending a fourth request to the host, so that the host corresponding to the host identifier unmounts the target cloud disk mounted by the target virtual machine, and sends the target cloud disk to the server, and the fourth request includes the virtual machine identifier and the cloud disk identifier; Receiving the cloud disk identifier sent by the host, and deleting the self-generated system image in the target cloud disk according to the cloud disk identifier.

7. A method for repairing a virtual machine in a cloud environment, which is executed by a host running a virtual machine, and the method includes: Downloading the self-generated system image corresponding to the target image identifier from the image storage repository to the target cloud disk; Mounting the target cloud disk to the target virtual machine, and starting the target virtual machine with system failure through the target cloud disk; Wherein, the target cloud disk is created by the server for storing the self-generated system image corresponding to the target image identifier and is mounted on the host; the target image identifier is queried by the server from the image database according to the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server for requesting to repair the target virtual machine.

8. The method according to claim 7, further comprising: In response to the second request sent by the server, executing the step of downloading the self-generated system image corresponding to the target image identifier from the image storage repository to the target cloud disk, wherein the second request is used to request the host to download the self-generated system image corresponding to the target image identifier to the target cloud disk corresponding to the cloud disk identifier, and mount the target cloud disk to the target virtual machine, and start the target virtual machine through the target cloud disk; Wherein, the second request includes the virtual machine identifier, the target image identifier, and the cloud disk identifier of the target cloud disk.

9. The method according to claim 8, further comprising: Before downloading the self-generated system image corresponding to the target image identifier from the image storage repository to the target cloud disk, judging whether the target cloud disk has been mounted to the host according to the cloud disk identifier; If it is determined that the target cloud disk has been mounted, searching for the self-generated system image corresponding to the target image identifier in the image storage repository; Downloading the self-generated system image to the target cloud disk.

10. The method according to claim 9, wherein The step of mounting the target cloud disk to the target virtual machine and starting the target virtual machine with system failure through the target cloud disk includes: If it is determined that the target virtual machine is in a running state, shutting down the target virtual machine; Obtain the configuration file of the target virtual machine according to the virtual machine identifier, and add the cloud disk identifier to the configuration file so that the target cloud disk is mounted to the target virtual machine; Set the priority of the target cloud disk in the configuration file to the highest priority among the priorities of each boot disk for starting the target virtual machine, where the boot disk is a disk with the function of starting the target virtual machine; Start the target virtual machine through the target cloud disk.

11. The method according to claim 10, wherein, The starting the target virtual machine through the target cloud disk includes: Inject the username and the startup password of the target virtual machine into the self-generated system image; Power on the target virtual machine, where the username and the startup password of the target virtual machine are carried in the second request sent by the server.

12. The method according to claim 10, further comprising: Receive a fourth request sent by the server, where the fourth request is used to request the host machine to unmount the target cloud disk from the target virtual machine, and the fourth request includes the virtual machine identifier and the cloud disk identifier, and the virtual machine identifier is carried in a third request sent by the console to the server; Unmount the target cloud disk on the target virtual machine according to the virtual machine identifier and the cloud disk identifier; Send the cloud disk identifier to the server so that the server deletes the self-generated system image in the target cloud disk.

13. The method according to claim 12, wherein, The unmounting the target cloud disk on the target virtual machine according to the virtual machine identifier and the cloud disk identifier includes: Shut down the target virtual machine corresponding to the virtual machine identifier; Obtain the configuration file of the target virtual machine, and in the configuration file, delete the cloud disk identifier so that the cloud disk identifier unmounts the target cloud disk on the target virtual machine, and restore the priorities of each boot disk for starting the target virtual machine in the configuration file.

14. A repair device for a virtual machine in a cloud environment, comprising: A receiving module, configured to receive a first request sent by a console, where the first request is used to request to repair a target virtual machine, and the first request includes the virtual machine identifier of the target virtual machine; A query module, configured to query a target image identifier of a pre-made self-generated system image corresponding to the virtual machine identifier in an image database; A creation module, configured to create a target cloud disk for storing the self-generated system image corresponding to the target image identifier, mount the target cloud disk to the host machine where the target virtual machine is located, so that the host machine downloads the self-generated system image corresponding to the target image identifier to the target cloud disk from an image storage repository, mount the target cloud disk to the target virtual machine, and start the target virtual machine through the target cloud disk.

15. A repair device for a virtual machine in a cloud environment, comprising: A download module, configured to download a self-generated system image corresponding to a target image identifier from an image storage repository to a target cloud disk; A start module, which mounts the target cloud disk to a target virtual machine and starts the target virtual machine with a system failure through the target cloud disk; Among them, the target cloud hard disk is created by the server for storing the self-generated system image corresponding to the target image identifier and mounted on the mother machine; the target image identifier is obtained by the server querying from the image database according to the virtual machine identifier of the target virtual machine; the virtual machine identifier of the target virtual machine is carried in the first request, and the first request is sent by the controller to the server for requesting to repair the target virtual machine.

16. An electronic device, comprising a memory, a processor, and a computer program stored on the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1-13.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-13.

18. A computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1-13.

Citation Information

Patent Citations

  • Method and device for repairing virtual machine in cloud environment and electronic equipment

    CN117591247A

  • Method for repairing virtual machine under desktop cloud environment

    CN102662783A

  • Cloud host rescue method, device and equipment based on OpenStack cluster and storage medium

    CN115437749A

  • Recovery Environment for a Virtual Machine

    US20170315859A1

Cited By

  • Virtual machine recovery method and electronic equipment

    CN121433811A

  • Virtual machine recovery method and electronic device

    CN121433811B