Virtual machine configuration method, storage medium, electronic equipment and program product

By enabling virtual machines and host machines to share directories and VirtioFS drivers, stable and efficient virtual machine configuration is achieved, resolving instability issues caused by IP network communication.

CN118916119APending Publication Date: 2024-11-08BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411102374.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

In existing technologies, when configuring virtual machines via IP network communication, network anomalies can easily lead to instability in the configuration process, affecting configuration efficiency.

Method used

The virtual machine interacts with the target program and the configuration injection program on the host machine, and uses the VirtioFS driver and shared directory to realize information exchange and sharing between the virtual machine and the host machine, avoiding IP network communication, and completing the virtual machine configuration.

Benefits of technology

It improves the stability and efficiency of virtual machine configuration, simplifies the configuration process, and avoids the adverse effects of network communication on configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916119A_ABST
    Figure CN118916119A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of virtualization, and particularly provides a virtual machine configuration method, a storage medium, electronic equipment and a program product, the method is applied to a target program configured in a to-be-configured virtual machine, and after the target program runs, the method comprises the steps that the virtual machine is connected with a first socket in a shared directory of a host machine; sending a configuration request to a configuration injection program of the host machine through the first socket; receiving configuration content which is sent by the configuration injection program and corresponds to the configuration request; and configuring the virtual machine by using the configuration content. Some embodiments of the invention can realize efficient configuration of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of virtualization technology, and in particular to a method, storage medium, electronic device and program product for configuring a virtual machine. Background Art

[0002] A virtual machine is a complete computer system that is simulated by software and has complete hardware system functions and runs in a completely isolated environment. Any work that can be done in a physical computer can also be done in a virtual machine.

[0003] For virtual machines running on cloud platforms, there are usually configuration requirements such as online password modification and online public key addition. An existing technology is to complete the configuration requirements of the virtual machine by communicating with the virtual machine through IP network. However, since network communication is easily affected by external factors and network anomalies occur, the configuration process of the virtual machine is unstable, affecting the configuration efficiency.

[0004] Therefore, how to provide a technical solution for an efficient virtual machine configuration method has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The purpose of some embodiments of the present application is to provide a method, storage medium, electronic device and program product for configuring a virtual machine. The technical solutions of the embodiments of the present application can improve the configuration efficiency and stability of the virtual machine. The configuration method is simple and easy to implement.

[0006] In a first aspect, some embodiments of the present application provide a method for configuring a virtual machine, which is applied to a target program configured in a virtual machine to be configured. After the target program is run, the method includes: connecting the virtual machine to a first socket in a shared directory of a host machine; sending a configuration request to a configuration injection program of the host machine through the first socket; receiving configuration content corresponding to the configuration request sent by the configuration injection program; and configuring the virtual machine using the configuration content.

[0007] Some embodiments of the present application can obtain the configuration content of the virtual machine and complete the configuration of the virtual machine by interacting with the configuration injection program of the host machine through the target program of the virtual machine. The embodiments of the present application can realize the injection of the virtual machine configuration file without IP network communication, complete the configuration requirements, and have high configuration efficiency and configuration stability, and the configuration method is simple and easy to implement.

[0008] In some embodiments, the target program runs while the virtual machine is started; when the virtual machine is started, the virtual machine loads the VirtioFS driver and mounts the shared directory.

[0009] Some embodiments of the present application implement information interaction and sharing between a virtual machine and a host machine through a VirtioFS driver and a shared directory, thereby enabling effective configuration of the virtual machine.

[0010] In some embodiments, during the operation of the virtual machine, the method further includes: receiving a changed configuration item pushed by the configuration injection program; and updating the configuration of the configured virtual machine using the changed configuration item.

[0011] Some embodiments of the present application can achieve timely update of virtual machine configuration by receiving changed configuration items and updating virtual machine configuration.

[0012] In a second aspect, some embodiments of the present application provide a method for configuring a virtual machine, which is applied to a configuration injection program on a host machine, including: receiving a configuration request sent by a target program of the virtual machine; sending configuration content corresponding to the configuration request to the target program, so as to complete the configuration of the virtual machine through the configuration content.

[0013] Some embodiments of the present application can obtain the configuration content of the virtual machine and complete the configuration of the virtual machine by interacting with the configuration injection program of the host machine through the target program of the virtual machine. The embodiments of the present application can realize the injection of the virtual machine configuration file without IP network communication, complete the configuration requirements, have high configuration efficiency, and the configuration method is simple and easy to implement.

[0014] In some embodiments, before receiving the configuration request sent by the target program of the virtual machine, the method also includes: after monitoring the creation event of the virtual machine, creating a second socket under the path of the shared directory of the host machine and the virtual machine, and starting a thread listening to the second socket to process the request sent by the target program; receiving the configuration content sent by the cloud platform.

[0015] The configuration injection program of some embodiments of the present application provides data support for subsequent virtual machine configuration by monitoring virtual machine creation events, configuring sockets, and receiving related configuration content.

[0016] In some embodiments, the method further includes: receiving a changed configuration item of the virtual machine sent by a cloud platform; and pushing the changed configuration item to the target program so that the target program updates the configuration of the virtual machine through the changed configuration item.

[0017] Some embodiments of the present application can complete the timely update of the virtual machine configuration by receiving the changed configuration items of the virtual machine and pushing them to the target program.

[0018] In some embodiments, the host machine is configured with information of the virtual machine and a VirtioFS driver.

[0019] Some embodiments of the present application provide support for virtual machine configuration by configuring virtual machine information and VirtioFS driver.

[0020] In a third aspect, some embodiments of the present application provide a device for configuring a virtual machine, which is applied to a target program configured in a virtual machine to be configured. After the target program is run, it includes: a connection module, configured to connect the virtual machine to a first socket in a shared directory of a host machine; a sending module, configured to send a configuration request to a configuration injection program of the host machine through the first socket; a receiving module, configured to receive configuration content corresponding to the configuration request sent by the configuration injection program; and a configuration module, configured to configure the virtual machine using the configuration content.

[0021] In a fourth aspect, some embodiments of the present application provide a device for configuring a virtual machine, which is applied to a configuration injection program on a host machine, including: a request receiving module, configured to receive a configuration request sent by a target program of the virtual machine; a configuration sending module, configured to send configuration content corresponding to the configuration request to the target program, so as to complete the configuration of the virtual machine through the configuration content.

[0022] In a fifth aspect, some embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the method described in any embodiment of the first aspect.

[0023] In a sixth aspect, some embodiments of the present application provide an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement a method as described in any embodiment of the first aspect.

[0024] In a seventh aspect, some embodiments of the present application provide a computer program product, wherein the computer program product comprises a computer program, wherein the computer program, when executed by a processor, can implement the method described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions of some embodiments of the present application, the drawings required for use in some embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1 A system diagram of a virtual machine configuration provided for some embodiments of the present application;

[0027] Figure 2 One of the flow charts of the method for configuring a virtual machine provided in some embodiments of the present application;

[0028] Figure 3 A second flowchart of a method for configuring a virtual machine provided in some embodiments of the present application;

[0029] Figure 4 A third flowchart of a method for configuring a virtual machine provided in some embodiments of the present application;

[0030] Figure 5 One of the block diagrams of the apparatus composition of the virtual machine configuration provided in some embodiments of the present application;

[0031] Figure 6 A second block diagram of a device configuration for a virtual machine provided in some embodiments of the present application;

[0032] Figure 7 A schematic diagram of an electronic device is provided for some embodiments of the present application. DETAILED DESCRIPTION

[0033] The technical solutions in some embodiments of the present application will be described below in conjunction with the drawings in some embodiments of the present application.

[0034] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0035] In the related art, cloud-init is a tool for initializing a virtual machine. It performs some operations on the virtual machine when the virtual machine starts. It can provide the virtual machine with functions such as initialization password and host name setting. Cloud-init reads relevant data from various data sources and configures the virtual machine accordingly. Common data sources include metadata server services of cloud platforms. Specifically, the cloud-init program accesses the metadata server through the http protocol to obtain the user's virtual machine configuration to complete configuration injection. This method needs to be implemented through network communication and requires the network card of the virtual machine to be started in DHCP mode so that the network card configures its IP address through DHCP. Only in this way can the cloud-init program access the metadata server through the http protocol. However, network communication is easily affected by external signals, and the stability of network communication cannot be guaranteed, which leads to poor stability of virtual machine configuration and configuration efficiency.

[0036] In view of this, some embodiments of the present application provide a method for configuring a virtual machine, which interacts with a configuration injection program of a host machine through a target program of the virtual machine to complete the configuration of the virtual machine. Some embodiments of the present application can implement virtual machine configuration file injection without IP network communication, thereby improving the stability of virtual machine configuration, ensuring the configuration efficiency of the virtual machine, and avoiding the adverse effects of network communication on virtual machine configuration.

[0037] The following is combined with Figure 1 The overall composition structure of the system for configuring a virtual machine provided by some embodiments of the present application is exemplified.

[0038] like Figure 1 As shown, some embodiments of the present application provide a system for configuring a virtual machine, which may include: a virtual machine 100, a host machine 200, and a cloud platform 300. Among them, an Agent program (as a specific example of a target program) is deployed in the virtual machine 100, and a configuration injection program is deployed in the host machine 200. Through the interaction between the Agent program and the configuration injection program, the Agent program can obtain the configuration content of the virtual machine 100, thereby completing the configuration of the virtual machine 100.

[0039] Specifically, after the configuration injection program is deployed on the host machine 200, the events created by the virtual machine 100 can be monitored; a Unix Socket socket is created under the shared directory of the host machine 200 and the virtual machine 100 to enable interaction between the two. The cloud platform 300 can send the configuration content of the virtual machine 100 set by the user to the configuration injection program. After the virtual machine 100 is started, the Virtriofs file system is mounted, and the directory shared by the host machine 200 to the virtual machine 100 is mounted to the virtual machine 100. The Agent process of the virtual machine 100 (that is, the Agent program) interacts with the configuration injection program on the host machine 200 through the Unix Socket socket under the shared directory, and obtains the virtual machine configuration (that is, the configuration content) from the configuration injection program. After the Agent process of the configured virtual machine obtains the virtual machine configuration, the virtual machine can be configured.

[0040] Among them, the VirtioFS used above is a solution for sharing the file system directory on the host machine with the virtual machine. The VirtioFS solution uses the FUSE protocol to communicate between the host and the guest. A fuseserver is implemented on the host side to operate the files on the host, and then the guest kernel is used as a fuse client to mount fuse in the guest. Virtio is used as the transport layer between the server and the client to carry the FUSE protocol, instead of the / dev / fuse device on the traditional structure.

[0041] In some embodiments of the present application, the number of virtual machines 100 and host machines 200 can be set as needed, and the embodiments of the present application are not specifically limited here.

[0042] The following is combined with Figure 2 The implementation process of virtual machine configuration performed by a configuration injection program in the host machine 200 provided in some embodiments of the present application is exemplified.

[0043] Please see attached Figure 2 , Figure 2 A flowchart of a method for configuring a virtual machine is provided for some embodiments of the present application, and the method for configuring a virtual machine may include: S210, receiving a configuration request sent by a target program of the virtual machine. S220, sending configuration content corresponding to the configuration request to the target program, so as to complete the configuration of the virtual machine through the configuration content.

[0044] For example, in some embodiments of the present application, the configuration injection program deployed on the host machine 200 may receive the configuration request sent by the Agent program. The configuration injection program may send the configuration content of the virtual machine added by the user to the Agent program to complete the configuration of the virtual machine.

[0045] In some embodiments of the present application, before executing S210, the method for configuring a virtual machine may further include: after monitoring the creation event of the virtual machine, creating a second socket under the path of the shared directory of the host machine and the virtual machine, and starting a thread that monitors the second socket to process the request sent by the target program; receiving the configuration content sent by the cloud platform. The host machine is configured with information about the virtual machine and a VirtioFS driver.

[0046] For example, in some embodiments of the present application, the host machine 200 adds an XML definition of the virtual machine 100 (as a specific example of the virtual machine's information) and adds a VirtioFS configuration. After the configuration injection program listens to the creation event of the virtual machine 100, it creates a Socket Unix socket (as a specific example of the second socket) under the path of the shared directory of the host machine 200, for example, the path of this example is the / root / shared-files directory, and starts a thread to listen to the created Socket Unix socket, which is responsible for processing the command (that is, the configuration request) passed from the Agent program in the virtual machine 100 from the SocketUnix socket (as a specific example of the first socket). The user adds the configuration content of the virtual machine 100 on the cloud platform 300, and the cloud platform 300 sends the configuration content of the virtual machine to the configuration injection program on the host machine 200. Among them, the configuration content can be set as needed, for example, it can include the password of the virtual machine, the host name of the virtual machine, etc.

[0047] In addition, when creating the virtual machine 100, the VirtioFS definition can be added to the xml of the virtual machine 100 to set the path of the shared directory between the host machine 200 and the virtual machine 100. The added content is as follows:

[0048] <filesystem type='mount'accessmode='passthrough'>

[0049] <driver type='virtiofs' / >

[0050] <binary path=' / usr / libexec / virtiofsd'xattr='on' / >

[0051] <source dir=' root shared-files'>

[0052] <target dir='host-file-share' / >

[0053]

[0054] The value after "source dir" is the path of the shared directory on the host machine 200, and the shared directory path set by the host machine 200 for each virtual machine is different. The above example sets the / root / shared-files directory on the host machine 200 to be shared with the newly created virtual machine 100, where host-file-share is the directory name used to identify the shared directory in the virtual machine 100. It can be considered that host-file-share is an alias for the / root / shared-files directory.

[0055] In some embodiments of the present application, the method for configuring a virtual machine may further include: receiving a changed configuration item of the virtual machine sent by a cloud platform; and pushing the changed configuration item to the target program so that the target program updates the configuration of the virtual machine through the changed configuration item.

[0056] For example, in some embodiments of the present application, if the user changes or adds a virtual machine configuration on the cloud platform 300 during the operation of the virtual machine 100, the cloud platform 300 can push the virtual machine configuration item changed by the user (as a specific example of the changed configuration item) to the configuration injection program on the host machine 200; the configuration injection program then pushes the updated virtual machine configuration item to the Agent program in the virtual machine 100 to complete the update of the configuration of the virtual machine 100.

[0057] The following is combined with Figure 3 The implementation process of virtual machine configuration performed by the Agent program in the virtual machine 100 provided in some embodiments of the present application is exemplified.

[0058] Please see attached Figure 3 , Figure 3 A flow chart of a method for configuring a virtual machine is provided for some embodiments of the present application. The method for configuring a virtual machine may include: the target program runs while the virtual machine is started; when the virtual machine is started, the virtual machine loads the VirtioFS driver and mounts the shared directory.

[0059] For example, in some embodiments of the present application, after the user starts the virtual machine 100, the VirtioFS driver is loaded and mount-t virtiofs host-file-share / mnt is executed. This command mounts the shared directory on the host machine 200 to the / mnt directory in the virtual machine 100. After the shared directory is mounted, there will be a Unix Socket socket file (as a specific example of the first socket) in the / mnt directory in the virtual machine 100. After the user's virtual machine 100 is started, the virtual machine configuration Agent program in the virtual machine 100 is also started with the system.

[0060] The above process is explained below as an example.

[0061] S310, connecting the virtual machine to a first socket in a shared directory of a host machine.

[0062] For example, in some embodiments of the present application, after the Agent program is run, it connects to the Unix Socket under the shared directory (such as / mnt in this example) in the virtual machine 100 to interact with the configuration injection program on the host machine 200.

[0063] S320: Send a configuration request to a configuration injection program of the host machine through the first socket.

[0064] For example, in some embodiments of the present application, an Agent program that configures a virtual machine (ie, a virtual machine to be configured) sends a command to obtain the virtual machine configuration (as a specific example of a configuration request) to a configuration injection program through a Unix Socket.

[0065] S330: Receive configuration content corresponding to the configuration request sent by the configuration injection program.

[0066] For example, in some embodiments of the present application, the Agent program receives the configuration content returned by the configuration injection program.

[0067] S340: Configure the virtual machine using the configuration content.

[0068] For example, in some embodiments of the present application, after the Agent program receives the configuration content of the virtual machine 100 sent by the configuration injection program, it configures the virtual machine 100.

[0069] In some embodiments of the present application, during the operation of the virtual machine, the method for configuring the virtual machine further includes: receiving a changed configuration item pushed by the configuration injection program; and updating the configuration of the virtual machine using the changed configuration item.

[0070] For example, in some embodiments of the present application, the Agent program receives the changed virtual machine configuration items pushed by the configuration injection program, and can update the configuration of the configured virtual machine in a timely manner.

[0071] It should be noted that some embodiments provided in this application can be applied to all virtualization devices running based on QEMU, and by appropriately modifying the cloud-init program, it can support communication through Unix Socket sockets in the shared directory between the host and the virtual machine, obtain the configuration content of the virtual machine and configure the virtual machine.

[0072] The following is combined with Figure 4 The specific process of virtual machine configuration provided by some embodiments of the present application is exemplified.

[0073] Please see attached Figure 4 , Figure 4 A flow chart of a method for configuring a virtual machine provided for some embodiments of the present application. It should be noted that before executing the following method for configuring a virtual machine, a configuration injection program is deployed on the host machine 200, and an XML definition of the virtual machine 100 is added to the host machine 200, a VirtioFS configuration is added, and a shared directory shared on the host machine 200 to the virtual machine 100 is set. When the cloud platform 300 creates the virtual machine 100, the VirtioFS definition is added to the XML of the virtual machine. For specific examples of added content, refer to the method embodiments provided above.

[0074] The above process is explained below as an example.

[0075] S400, the cloud platform creates a virtual machine in response to the user's operation instruction.

[0076] S410, configuring the injection program to monitor a creation event of a virtual machine.

[0077] S420, configure the injection program to create a Socket Unix socket under the path of the shared directory of the host machine and the virtual machine, and start a thread that monitors the Socket Unix socket.

[0078] S430, the configuration injection program receives the configuration content of the virtual machine sent by the cloud platform.

[0079] When the virtual machine starts, the Agent program runs; the virtual machine loads the VirtioFS driver and mounts the shared directory. At this time, there will be a Unix Socket socket under the shared directory.

[0080] S440, the Agent program connects to the Unix Socket in the shared directory.

[0081] S450, the Agent program sends a configuration request to the configuration injection program through the Unix Socket.

[0082] S460, the configuration injection program receives the configuration request sent by the Agent program.

[0083] S470, the configuration injection program sends the configuration content of the virtual machine to the Agent program.

[0084] S480, the Agent program receives the configuration content of the virtual machine and configures the virtual machine.

[0085] It can be understood that the specific implementation process of S410 to S480 can refer to the method embodiment provided above, and in order to avoid repetition, the detailed description is appropriately omitted here.

[0086] Through some of the embodiments of the present application described above, it can be known that the present application uses VirtioFS technology to realize the shared directory between the host and the virtual machine, and the Agent program in the virtual machine communicates with the configuration injection program on the host through UnixSocket under the shared directory to realize the method of online configuration of the virtual machine on the cloud platform. In the present application, the configuration file of the virtual machine is not stored on the metadata server, so no additional server is required to serve as the metadata server. The virtual machine configuration Agent program in the virtual machine communicates with the configuration injection program on the host through Unix Socket under the shared directory, avoiding the problem that the IP network communication method is easily affected by the outside world and causes network disconnection.

[0087] Please refer to Figure 5 , Figure 5 The following is a block diagram of a virtual machine configuration device provided in some embodiments of the present application. It should be understood that the virtual machine configuration device corresponds to the above method embodiment and can execute each step involved in the above method embodiment. The specific functions of the virtual machine configuration device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.

[0088] Figure 5The device for configuring a virtual machine includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the device for configuring the virtual machine. The device for configuring the virtual machine is applied to a target program configured in the virtual machine to be configured. After the target program is run, it includes: a connection module 510, configured to connect the virtual machine to a first socket in a shared directory of a host machine; a sending module 520, configured to send a configuration request to a configuration injection program of the host machine through the first socket; a receiving module 530, configured to receive configuration content corresponding to the configuration request sent by the configuration injection program; and a configuration module 540, configured to configure the virtual machine using the configuration content.

[0089] In some embodiments of the present application, the target program runs while the virtual machine is started; when the virtual machine is started, the virtual machine loads the VirtioFS driver and mounts the shared directory.

[0090] In some embodiments of the present application, the configuration module 540 is configured to receive the changed configuration items pushed by the configuration injection program; and update the configuration of the configured virtual machine using the changed configuration items.

[0091] Please refer to Figure 6 , Figure 6 The following is a block diagram of a virtual machine configuration device provided in some embodiments of the present application. It should be understood that the virtual machine configuration device corresponds to the above method embodiment and can execute each step involved in the above method embodiment. The specific functions of the virtual machine configuration device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here.

[0092] Figure 6 The virtual machine configuration device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the virtual machine configuration device. The virtual machine configuration device is applied to the configuration injection program on the host machine, including: a request receiving module 610, configured to receive a configuration request sent by a target program of the virtual machine; a configuration sending module 620, configured to send configuration content corresponding to the configuration request to the target program, so as to complete the configuration of the virtual machine through the configuration content.

[0093] In some embodiments of the present application, before requesting the receiving module 610, the device for configuring the virtual machine also includes: a monitoring module (not shown in the figure) is configured to create a second socket under the path of the shared directory of the host machine and the virtual machine after monitoring the creation event of the virtual machine, and start a thread listening to the second socket to process the request sent by the target program; receive the configuration content sent by the cloud platform.

[0094] In some embodiments of the present application, the device for configuring a virtual machine also includes: a push module (not shown in the figure), configured to receive changed configuration items of the virtual machine sent by the cloud platform; and push the changed configuration items to the target program so that the target program updates the configuration of the virtual machine through the changed configuration items.

[0095] In some embodiments of the present application, the host machine is configured with information of the virtual machine and a VirtioFS driver.

[0096] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.

[0097] Some embodiments of the present application further provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the operations of the method corresponding to any of the above methods provided in the above embodiments.

[0098] Some embodiments of the present application further provide a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the operations corresponding to any of the above methods provided in the above embodiments.

[0099] like Figure 7 As shown, some embodiments of the present application provide an electronic device 700, which includes: a memory 710, a processor 720, and a computer program stored in the memory 710 and executable on the processor 720, wherein the processor 720 can implement a method as described in any of the above embodiments when reading the program from the memory 710 through a bus 730 and executing the program.

[0100] Processor 720 can process digital signals and can include various computing structures, such as complex instruction set computer structure, reduced instruction set computer structure, or a structure that implements a combination of multiple instruction sets. In some examples, processor 720 can be a microprocessor.

[0101] The memory 710 may be used to store instructions executed by the processor 720 or data related to the execution of instructions. These instructions and / or data may include codes for implementing some or all functions of one or more modules described in the embodiments of the present application. The processor 720 of the disclosed embodiment may be used to execute instructions in the memory 710 to implement the method shown above. The memory 710 includes a dynamic random access memory, a static random access memory, a flash memory, an optical memory, or other memory known to those skilled in the art.

[0102] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0103] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0104] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A method for configuring a virtual machine, characterized in that: The method is applied to a target program configured in a virtual machine to be configured. After the target program is run, the method includes: Connecting the virtual machine to a first socket in a shared directory of a host machine; Sending a configuration request to a configuration injection program of the host machine through the first socket; Receiving configuration content corresponding to the configuration request sent by the configuration injection program; The virtual machine is configured using the configuration content.

2. The method according to claim 1, characterized in that The target program runs while the virtual machine is started; when the virtual machine is started, the virtual machine loads the VirtioFS driver and mounts the shared directory.

3. The method according to claim 1 or 2, characterized in that During the operation of the virtual machine, the method further includes: Receiving the changed configuration items pushed by the configuration injection program; The configuration of the configured virtual machine is updated using the changed configuration item.

4. A method for configuring a virtual machine, characterized in that: The method is applied to a configuration injection program on a host machine, and the method comprises: Receiving a configuration request sent by a target program of the virtual machine; The configuration content corresponding to the configuration request is sent to the target program, so as to complete the configuration of the virtual machine through the configuration content.

5. The method according to claim 4, characterized in that Before receiving the configuration request sent by the target program of the virtual machine, the method further includes: After monitoring the creation event of the virtual machine, creating a second socket under the path of the shared directory of the host machine and the virtual machine, and starting a thread monitoring the second socket to process the request sent by the target program; Receive the configuration content sent by the cloud platform.

6. The method according to claim 4 or 5, characterized in that The method further comprises: Receiving a changed configuration item of the virtual machine sent by the cloud platform; The changed configuration item is pushed to the target program so that the target program updates the configuration of the virtual machine through the changed configuration item.

7. The method according to claim 4 or 5, characterized in that The host machine is configured with information of the virtual machine and a VirtioFS driver.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program executes the method according to any one of claims 1 to 7 when executed by a processor.

9. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the computer program executes the method according to any one of claims 1 to 7 when being run by the processor.

10. A computer program product, characterized in that The computer program product comprises a computer program, wherein the computer program executes the method according to any one of claims 1 to 7 when executed by a processor.