CN114327748B - Virtual machine interaction method and device, nonvolatile storage medium and processor - Google Patents
Virtual machine interaction method and device, nonvolatile storage medium and processor Download PDFInfo
- Publication number
- CN114327748B CN114327748B CN202111450646.6A CN202111450646A CN114327748B CN 114327748 B CN114327748 B CN 114327748B CN 202111450646 A CN202111450646 A CN 202111450646A CN 114327748 B CN114327748 B CN 114327748B
- Authority
- CN
- China
- Prior art keywords
- virtual machine
- target
- script file
- proxy service
- host
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 49
- 230000003993 interaction Effects 0.000 title claims abstract description 35
- 238000013515 script Methods 0.000 claims abstract description 176
- 230000015654 memory Effects 0.000 claims abstract description 46
- 230000006870 function Effects 0.000 claims abstract description 20
- 239000003795 chemical substances by application Substances 0.000 description 14
- 238000012545 processing Methods 0.000 description 14
- 238000010586 diagram Methods 0.000 description 7
- 230000008569 process Effects 0.000 description 7
- 238000007726 management method Methods 0.000 description 6
- 238000004891 communication Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 238000012423 maintenance Methods 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000005034 decoration Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000010295 mobile communication Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000012790 confirmation Methods 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
- 230000002085 persistent effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Images
Landscapes
- Stored Programmes (AREA)
Abstract
The invention discloses a virtual machine interaction method, a virtual machine interaction device, a nonvolatile storage medium and a processor. Wherein, the method comprises the following steps: a first proxy service in the first host calls a target script file according to the API call request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host; the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel; the second proxy service stores the target script file into a virtual machine memory of the target virtual machine and executes the target script file. The invention solves the technical problem that a plurality of virtual machines in a virtualization cluster are difficult to manage and control conveniently.
Description
Technical Field
The invention relates to the technical field of virtualization, in particular to a virtual machine interaction method, a virtual machine interaction device, a non-volatile storage medium and a processor.
Background
In the virtualization platform, the virtual machine and the host are in an isolated state, and the platform cannot directly read Guest OS information of the virtual machine or modify the configuration of the OS. A common way to solve these problems is to install a proxy tool (vmtools) service inside the virtual machine, which receives instructions from the platform and then performs corresponding operations in the virtual machine.
In addition, the self-defined operation can be written into the script, the script is forwarded to the host machine where the virtual machine is located in the form of the message, then the script is forwarded to the virtual machine through the program on the host machine, and the script is executed in the virtual machine, so that a certain function is realized. However, for a virtualization cluster including multiple hosts and a large number of virtual machines, data such as script files needs to be manually sent to the virtual machines in a message form to complete configuration, and the method is not efficient and convenient.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a virtual machine interaction method and device, a nonvolatile storage medium and a processor, which are used for at least solving the technical problem that a plurality of virtual machines in a virtualization cluster are difficult to manage and control conveniently.
According to an aspect of an embodiment of the present invention, a virtual machine interaction method is provided, including: calling a target script file by a first proxy service in a first host according to an API (application programming interface) calling request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host; the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel; and the second proxy service stores the target script file into a virtual machine memory of the target virtual machine and executes the target script file.
Optionally, before invoking the target script file, at least one of the following steps is further included: receiving the API call request by a first proxy service in the first host; or, a third proxy service in a second host receives the API call request, where the first host and the second host belong to the same virtualization cluster; the second host reads the API call request to obtain the target virtual machine corresponding to the API call request; and under the condition that the target virtual machine corresponds to the first host, the third proxy service sends the API call request to the first proxy service of the first host.
Optionally, the API call request is a RESTful API type request, and the API call request includes: the unique identifier of the target virtual machine, the storage path of the target script file and the parameters of the target script file; the first proxy service in the first host calls a target script file according to the API call request, and the method comprises the following steps: the first proxy service reads the unique identifier of the target virtual machine included in the API call request, and judges whether the first host corresponds to the target virtual machine or not according to the unique identifier; sending the API call request to an API interface of the virtualization cluster under the condition that the first host corresponds to the target virtual machine; and the API interface returns the target script file to the first proxy service based on the storage path of the target script file included in the API calling request.
Optionally, the sending, by the first proxy service, the target script file to a second proxy service in the target virtual machine through a data channel includes: the first proxy service stores the target script file into a host memory of the first host and calculates a first hash value of the target script file; and comparing the first hash value of the target script file with a second hash value of a previous script file sent to the target virtual machine by the first proxy service, and sending the target script file to the second proxy service in the target virtual machine through a data channel by the first proxy service under the condition that the first hash value is different from the second hash value.
Optionally, in a case that the first hash value is the same as the second hash value, the first proxy service sends an instruction to a second proxy service in the target virtual machine for instructing the second proxy service to execute the previous script file.
Optionally, before the second proxy service stores the object script file in a memory of a virtual machine, the method further includes: and the second proxy service stores the target script file into a disk of the target virtual machine.
Optionally, the sending, by the first proxy service, the target script file to a second proxy service in the target virtual machine through a data channel includes: establishing the data channel between the first host and the target virtual machine through a virtio-serial; and the first proxy service sends the target script file to a second proxy service in the target virtual machine through the data channel.
According to another aspect of the embodiments of the present invention, there is also provided a virtual machine interaction apparatus, including: the calling module is used for calling a target script file by a first proxy service in a first host according to an API calling request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host; the sending module is used for sending the target script file to a second proxy service in the target virtual machine through a data channel by the first proxy service; and the execution module is used for storing the target script file into a virtual machine memory of the target virtual machine by the second proxy service and executing the target script file.
According to another aspect of the embodiment of the present invention, a nonvolatile storage medium is further provided, where the nonvolatile storage medium includes a stored program, and when the program runs, a device where the nonvolatile storage medium is located is controlled to execute any one of the above virtual machine interaction methods.
According to still another aspect of the embodiments of the present invention, there is further provided a processor, where the processor is configured to execute a program, where the program executes the virtual machine interaction method described in any one of the above.
In the embodiment of the invention, the host in the virtualization cluster calls the script file based on the API call request, the first proxy service in the first host calls the target script file executed in the target virtual machine in the first host according to the API call request, the first proxy service sends the target script file to the second proxy service in the target virtual machine through the data channel, and then the second proxy service stores the target script file in the virtual machine memory of the target virtual machine and executes the target script file, so that the aim of controlling the massive virtual machines in the virtualization cluster to execute the script file to update functions is fulfilled, the technical effect of improving the convenience of managing and controlling the virtual machines in the virtualization cluster is achieved, and the technical problem that a plurality of virtual machines in the virtualization cluster are difficult to manage and control conveniently is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 shows a hardware configuration block diagram of a computer terminal for implementing a virtual machine interaction method;
FIG. 2 is a flowchart illustrating a virtual machine interaction method according to an embodiment of the present invention;
FIG. 3 is an architecture diagram of a virtual machine operation and maintenance management system according to an alternative embodiment of the present invention;
FIG. 4 is a flow diagram providing for interaction with a virtual machine in accordance with an alternative embodiment of the present invention;
fig. 5 is a block diagram of a virtual machine interaction apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in other sequences than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, partial terms or terms appearing in the description of the embodiments of the present application are applied to the following explanations:
the RESTful API, i.e. a presentation layer State transformation API interface, is an API interface having a REST (Representational State Transfer, REST for short) architecture style, where RESTful indicates that a resource is located by a URL, an operation is described by a HTTP verb (GET, POST, PUT, DELETE), and HTTP is used as a transmission protocol.
The virtio-serial is a uniform virtual IO interface drive on the virtual machine platform and is used for transmitting messages between the virtual machine and the host, no requirement is made on network setting of the virtual machine and the host, and the efficiency is higher. The virtio virtual machine is used without paying attention to how to create various virtual hardware devices (such as a disk, a network card, a display card and the like), and unified virtual devices can be used.
The virtual cluster is composed of a plurality of physical machines, virtual software is installed in the physical machines to run the virtual machines, and virtual platform software is deployed in the virtual cluster at the same time to manage the virtual machines in a unified mode. The physical machines and the virtual machines are connected through a network to form a cluster, and the virtual machines can run on any one physical machine in the cluster.
In accordance with an embodiment of the present invention, there is provided a method embodiment of virtual machine interaction, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
The method provided by the first embodiment of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Fig. 1 shows a hardware configuration block diagram of a computer terminal for implementing the virtual machine interaction method. As shown in fig. 1, the computer terminal 10 may include one or more (shown as 102a, 102b, \ 8230; \8230;, 102 n) processors 102 (the processors 102 may include, but are not limited to, processing devices such as a microprocessor MCU or a programmable logic device FPGA, etc.), and memory 104 for storing data. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial BUS (USB) port (which may be included as one of the ports of the BUS), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computer terminal 10 may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors 102 and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuit may be a single stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computer terminal 10. As referred to in the embodiments of the application, the data processing circuit acts as a processor control (e.g. selection of a variable resistance termination path connected to the interface).
The memory 104 may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the virtual machine interaction method in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the virtual machine interaction method of the application program. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the computer terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with the user interface of the computer terminal 10.
Different virtual machine tools are generally installed in existing relatively mature virtualization platforms, and the functions of the tools are generally divided into two types: first, get the Geust OS information of VM (virtual machine, VM for short), such as: version of OS, network IP address, disk information, etc., and second, guest OS is configured, for example: host names, IP addresses, user passwords, etc. are modified, and these functions are updated as the virtual machine tool is released. The virtual machine tool provides a channel for interaction between the VM and the host machine, so that the VM is easy to manage and use and the performance of the VM can be improved.
However, virtual machine workers on a specific virtualization platform have fixed functions, which can meet most requirements for daily configuration and management of virtual machines, but users cannot implement some customized functions according to requirements, and cannot modify, improve and optimize existing functions, so that the virtual machine tool functions are relatively limited.
The method can realize user-defined operations in the virtual machine by means of script files, realizes user-defined configuration and VM management by writing scripts, the scripts mainly comprise shell (Linux), powershell (Windows), bat (Windows) and Python, the scripts are transmitted to the VM to be executed, and the scripts can be divided into three types according to functions: 1. obtaining OS information, for example; acquiring an IP address, a DNS address or CPU/MEM performance data and the like; 2. configuring the VM, such as: modifying account passwords, host names, IP addresses and the like; 3. the VM is managed. Which comprises the following steps: shutdown, restart, installing/uninstalling software, etc. However, the virtualized cluster includes a mass virtual machine, and how to perform unified and convenient operation and maintenance management on the mass virtual machine becomes a problem.
Fig. 2 is a schematic flowchart of a virtual machine interaction method provided in an embodiment of the present invention, and as shown in fig. 2, the method includes the following steps:
step S202, the first proxy service in the first host calls the target script file according to the API call request. The target script file can be written and stored in advance by a user, the first proxy service calls according to the API call request, and after the target script file is sent to the target virtual machine corresponding to the first host, the target script file is executed by the target virtual machine to realize functions. The first proxy service is a special process for processing data interaction related transactions between the host and the virtual machine.
Alternatively, the first host may be one of the hosts in the virtualization cluster, which host runs the target virtual machine, so that the target virtual machine corresponds to the first host. Through the step, when a user wants to run and manage the virtual machines, the script file does not need to be written for each virtual machine in sequence and the host or the virtual machine sent by the script file is appointed, the script file only needs to be stored to a preset path after being written, then the host automatically calls the target script file according to the API call request and sends the target script file to the target virtual machine in order to write the API call request corresponding to different virtual machines.
And step S204, the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel.
Alternatively, the second proxy service may be a proxy service pre-installed in the target virtual machine, and similar to the first proxy service, the second proxy service is also a special process for processing data interaction related transactions between the host and the virtual machine.
In step S206, the second proxy service stores the target script file in the virtual machine memory of the target virtual machine, and executes the target script file.
Through the steps, the host in the virtualization cluster calls the script file based on the API call request, the first proxy service in the first host calls the target script file executed in the target virtual machine in the first host according to the API call request, the first proxy service sends the target script file to the second proxy service in the target virtual machine through the data channel, the second proxy service stores the target script file in the virtual machine memory of the target virtual machine and executes the target script file, and the purpose of controlling the massive virtual machines in the virtualization cluster to execute the script file to update functions is achieved, so that the technical effect of improving convenience of management and control of the virtual machines in the virtualization cluster is achieved, and the technical problem that a plurality of virtual machines in the virtualization cluster are difficult to manage and control conveniently is solved. The RESTful adopted by the invention is a design specification, the API designed according to the specification has a clear structure, is easy to understand and use, is convenient to expand, and can easily realize the function of configuring the virtual machine by only sending a simple http request.
As an alternative embodiment, the API call request is a RESTful API type request, and the API call request includes: the unique identification of the target virtual machine, the storage path of the target script file and the parameters of the target script file; the first proxy service in the first host calls the target script file according to the API call request, and the method comprises the following steps: the first proxy service reads the unique identifier of the target virtual machine included in the API call request, and judges whether the first host corresponds to the target virtual machine or not according to the unique identifier; under the condition that the first host machine corresponds to the target virtual machine, an API call request is sent to an API interface of the virtualization cluster; and the API interface returns the target script file to the first proxy service based on the storage path of the target script file included in the API calling request.
Optionally, the unique identifier of the target virtual machine may be a uuid of the virtual machine, the storage path of the target script file may be a path for storing the target script file after the target script file is written by the user, and the parameter of the target script file may be a parameter that needs to be transmitted into the target virtual machine for configuring the target virtual machine.
Optionally, the first proxy service may first read the unique identifier of the target virtual machine included in the API call request to perform a determination, that is, determine whether the target virtual machine is located in the first host, and if the first host does not have the virtual machine, the first proxy service may search which host has the target virtual machine in the virtualized cluster and send the API call request to the corresponding host. And if the target virtual machine is positioned in the first host, the first proxy service sends the API call request to an API interface unified by the virtualization cluster, and the API interface calls the target script file according to the storage path of the target script file stored in the API call request. Through the optional embodiment, as long as the user stores the written script file under one path, only the RESTful API needs to be edited and sent to the proxy service in the host machine when the virtual machine is maintained and managed, the proxy service completes the confirmation and distribution of the script file, the process does not need manual operation of the user, and the labor cost of maintaining the cluster by the user is reduced.
As an alternative embodiment, before invoking the target script file, at least one of the following steps is further included: a first proxy service in a first host receives an API call request; or, a third proxy service in the second host receives the API call request, wherein the first host and the second host belong to the same virtualization cluster; the second host reads the API call request to obtain a target virtual machine corresponding to the API call request; and under the condition that the target virtual machine corresponds to the first host, the third proxy service sends the API call request to the first proxy service of the first host.
It should be noted that, in this embodiment, the target virtual machine does not exist in the second host, and therefore, after finding the problem, the proxy service of the host may search in the virtualization cluster to determine that the target virtual machine is in the first host, and then send the API call request to the first host, so that automatic distribution of the call request is achieved, and it is not necessary for a user to carefully monitor the IP address of the virtual machine in each call request and send the call request to the host corresponding to the IP address.
As an optional embodiment, the first proxy service sends the target script file to the second proxy service in the target virtual machine through a data channel, and a data channel may be established between the first host and the target virtual machine through virtio-serial; and sending the target script file to a second proxy service in the target virtual machine by the first proxy service through the data channel. The data channel established between the virtual machine and the host machine through the virtio-serial can realize the communication between the host machine and the virtual machine, and is more efficient than the virtual hardware device alone.
As an alternative embodiment, the first proxy service sends the target script file to the second proxy service in the target virtual machine through the data channel, which may be as follows: the first proxy service stores the target script file into a host memory of a first host and calculates a first hash value of the target script file; and comparing the first hash value of the target script file with a second hash value of a previous script file sent to the target virtual machine by the first proxy service, and sending the target script file to the second proxy service in the target virtual machine by the first proxy service through a data channel under the condition that the first hash value is different from the second hash value.
As an alternative embodiment, in the case that the first hash value is the same as the second hash value, the first proxy service sends an instruction to the second proxy service in the target virtual machine for instructing the second proxy service to execute the previous script file.
Optionally, when the first proxy service sends the script file to the target virtual machine for the first time, the first proxy service may cache the script file in a memory of the first host, then calculate a hash value of the script file by using an MD5 hash algorithm, and then send the script file to the virtual machine, where the script file is a previous script file. When the first proxy service sends the target script file to the target virtual machine, the first proxy service may cache the target script file in a memory of the first host, then calculate a first hash value of the target script file by using the MD5 hash algorithm, then compare the first hash value with a hash value of a previous script file, and determine whether the first hash value is the same script file. If the two script files are the same by comparing the hash values, the same file does not need to be sent to the target virtual machine again, at this time, the target script file in the memory can be directly deleted, and then an instruction for executing the previous script file is sent to the target virtual machine, so that resource loss caused by repeated sending of the files is reduced.
As an alternative embodiment, before the second proxy service stores the target script file in the memory of the virtual machine, the second proxy service may also store the target script file in a disk of the target virtual machine. Alternatively, the second proxy service may be responsible for receiving the target script file and saving (i.e., persisting) the file to a particular path in the disk of the target virtual machine, and then saving the file to the virtual machine memory. Therefore, when the virtual machine fails, is shut down and the like, the target script file can be directly recovered from a specific path in the disk without retransmitting the file from the host, so that data is not lost, and the overall efficiency is improved.
Fig. 3 is an architecture diagram of operation and maintenance management of a virtual machine according to an alternative embodiment of the present invention, and as shown in fig. 3, a virtualized cluster may include one RESTful API interface and multiple hosts, such as a first host and a second host, where at least one virtual machine may exist in each host. The first host runs a first proxy service, the target virtual machine in the first host runs a second proxy service, the first proxy service and the second proxy service can interact by unix socket and virtio-serial, the first proxy service receives a target script file through RESTful API and sends the file to the second proxy service, and the second proxy service is responsible for receiving and executing the target script file in the virtual machine. In the whole framework, only one proxy service needs to be installed in the host of the virtualization cluster, and the corresponding proxy service is installed in the virtual machine, so that the virtual machine is convenient and flexible.
Fig. 4 is a flowchart of interaction with a virtual machine according to an alternative embodiment of the present invention, and as shown in fig. 4, the alternative process may include the following steps:
s1, compiling a script file and storing the script file into a preset path;
s2, receiving a RESTful API request by an agent service agentB of the host, and calling a script file;
s3, an agent service agent B in the host receives the script file and then sends the script file to an agent A in the virtual machine, wherein the agent B refers to the agent service in the host, and the agent A refers to the agent service in the virtual machine;
s4, after the agent A receives the script file, executing the script file;
s5, the agent A judges whether the script file is normally executed, if not, the executed error information is written into an error file of a disk of the virtual machine, and if so, the operation enters S6;
s6, judging whether the execution of the script file is overtime or not, wherein the execution of the script file is provided with overtime time, if the execution time exceeds the overtime time, the agent A finishes the process of executing the script file and records the error information into the error file of the disk, and if the execution time does not exceed the overtime time, the normal execution of the script file is indicated, and the step S7 is executed;
s7, recording the normal execution information of the script file into a normal execution file of a virtual machine disk;
s8, agent B of the host polls and reads the files recorded in the virtual machines, and when the files are read, the normally executed files or the error files are returned to the agent B.
In this optional embodiment, it is only necessary to install agent proxy service programs on the host machine and the virtual machine, respectively, and it is not necessary to install other module components, where the agent program in the virtual machine is mainly responsible for receiving data, executing scripts, and storing execution results, and the agent program in the host machine is responsible for forwarding and processing RESTful API requests, and reading and returning API request results. After a user finishes configuring the script and calls a RESTful API request, a host machine agent program reads the script and caches the content in a memory, then data is sent to the agent program in the virtual machine through virtual interface equipment in the virtual machine in a socket mode, and the agent program in the virtual machine firstly persists the data, namely the data is stored as the script and is stored in a specific path. The script data can be cached, if the script is not modified, the agent program can directly fetch the data from the memory, and the speed of the agent program for responding and processing the request is improved. After the virtual machine agent program is executed, the result is also persisted to the disk, so that if the virtual machine fails, is shut down and the like, the data can be ensured not to be lost.
According to an embodiment of the present invention, there is further provided a virtual machine interaction apparatus for implementing the virtual machine interaction method, where fig. 5 is a block diagram of a structure of the virtual machine interaction apparatus provided according to the embodiment of the present invention, and as shown in fig. 5, the virtual machine interaction apparatus includes: the calling module 52, the sending module 54 and the executing module 56 are described below.
A calling module 52, configured to call, by a first proxy service in the first host, a target script file according to the API call request, where the target script file is executed by a target virtual machine to implement a function, and the target virtual machine corresponds to the first host;
a sending module 54, connected to the calling module 52, for sending the target script file to the second proxy service in the target virtual machine through the data channel by the first proxy service;
and an executing module 56, connected to the sending module 54, for storing the target script file into the virtual machine memory of the target virtual machine by the second proxy service, and executing the target script file.
It should be noted here that the invoking module 52, the sending module 54 and the executing module 56 correspond to steps S202 to S206 in embodiment 1, and the three modules are the same as the corresponding steps in the implementation example and application scenario, but are not limited to the disclosure in embodiment 1. It should be noted that the above modules may be operated in the computer terminal 10 provided in embodiment 1 as a part of the apparatus.
An embodiment of the present invention may provide a computer device, and optionally, in this embodiment, the computer device may be located in at least one network device of a plurality of network devices of a computer network. The computer device includes a memory and a processor.
The memory may be configured to store software programs and modules, such as program instructions/modules corresponding to the virtual machine interaction method and apparatus in the embodiments of the present invention, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, so as to implement the virtual machine interaction method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory located remotely from the processor, and these remote memories may be connected to the computer terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor can call the information and application program stored in the memory through the transmission device to execute the following steps: a first proxy service in the first host calls a target script file according to the API call request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host; the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel; the second proxy service stores the target script file into a virtual machine memory of the target virtual machine and executes the target script file.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a non-volatile storage medium, and the storage medium may include: flash disks, read-Only memories (ROMs), random Access Memories (RAMs), magnetic or optical disks, and the like.
Embodiments of the present invention also provide a non-volatile storage medium. Optionally, in this embodiment, the nonvolatile storage medium may be configured to store the program code executed by the virtual machine interaction method provided in embodiment 1.
Optionally, in this embodiment, the nonvolatile storage medium may be located in any one of computer terminals in a computer terminal group in a computer network, or in any one of mobile terminals in a mobile terminal group.
Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: calling a target script file by a first proxy service in the first host according to the API calling request, wherein the target script file is executed by a target virtual machine to realize a function, and the target virtual machine corresponds to the first host; the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel; the second proxy service stores the target script file into a virtual machine memory of the target virtual machine and executes the target script file.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be an indirect coupling or communication connection through some interfaces, units or modules, and may be electrical or in other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a non-volatile memory storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk, and various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.
Claims (9)
1. A virtual machine interaction method is characterized by comprising the following steps:
calling a target script file by a first proxy service in a first host according to an API (application programming interface) calling request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host;
the first proxy service sends the target script file to a second proxy service in the target virtual machine through a data channel;
the second proxy service stores the target script file into a virtual machine memory of the target virtual machine and executes the target script file;
the API call request is a RESTful API type request, and the API call request comprises:
the unique identifier of the target virtual machine, the storage path of the target script file and the parameters of the target script file;
the first proxy service in the first host calls a target script file according to the API call request, and the method comprises the following steps:
the first proxy service reads the unique identifier of the target virtual machine included in the API call request, and judges whether the first host corresponds to the target virtual machine or not according to the unique identifier;
sending the API call request to an API interface of a virtualization cluster under the condition that the first host machine corresponds to the target virtual machine;
the API interface returns the target script file to the first proxy service based on the storage path of the target script file included in the API call request;
before the target script file is called, the method further comprises the following steps:
receiving the API call request by a third proxy service in a second host, wherein the first host and the second host belong to the same virtualization cluster;
the second host reads the API call request to obtain the target virtual machine corresponding to the API call request;
and under the condition that the target virtual machine corresponds to the first host, the third proxy service sends the API call request to the first proxy service of the first host.
2. The method of claim 1, prior to invoking the target script file, further comprising:
a first proxy service in the first host receives the API call request.
3. The method of claim 1, wherein the first proxy service sending the target script file to a second proxy service in the target virtual machine via a data channel comprises:
the first proxy service stores the target script file into a host memory of the first host and calculates a first hash value of the target script file;
and comparing the first hash value of the target script file with a second hash value of a previous script file sent to the target virtual machine by the first proxy service, and sending the target script file to the second proxy service in the target virtual machine through a data channel by the first proxy service under the condition that the first hash value is different from the second hash value.
4. The method of claim 3, wherein in the case that the first hash value is the same as the second hash value, the first proxy service sends an instruction to a second proxy service in the target virtual machine for instructing the second proxy service to execute the prior script file.
5. The method of claim 3, further comprising, prior to the second proxy service storing the object script file in virtual machine memory: and the second proxy service stores the target script file into a disk of the target virtual machine.
6. The method of claim 1, wherein the first proxy service sending the target script file to a second proxy service in the target virtual machine via a data channel comprises:
establishing the data channel between the first host and the target virtual machine through virtio-serial;
and the first proxy service sends the target script file to a second proxy service in the target virtual machine through the data channel.
7. A virtual machine interaction apparatus, comprising:
the calling module is used for calling a target script file by a first proxy service in a first host according to an API calling request, wherein the target script file is executed by a target virtual machine to realize functions, and the target virtual machine corresponds to the first host;
the first sending module is used for sending the target script file to a second proxy service in the target virtual machine through a data channel by the first proxy service;
the execution module is used for storing the target script file into a virtual machine memory of the target virtual machine by the second proxy service and executing the target script file;
wherein the API call request is a RESTful API type request, and the API call request comprises: the unique identifier of the target virtual machine, the storage path of the target script file and the parameters of the target script file;
the calling module comprises:
a reading unit, configured to read, by the first proxy service, a unique identifier of the target virtual machine included in the API call request, and determine, according to the unique identifier, whether the first host corresponds to the target virtual machine;
a sending unit, configured to send the API call request to an API interface of a virtualization cluster when the first host corresponds to the target virtual machine;
a returning unit, configured to return, by the API interface, the target script file to the first proxy service based on the storage path of the target script file included in the API call request;
the device further comprises: a distribution module, wherein the distribution module is configured to perform the following steps before invoking the target script file:
receiving the API call request by a third proxy service in a second host, wherein the first host and the second host belong to the same virtualization cluster;
the second host reads the API call request to obtain the target virtual machine corresponding to the API call request;
and under the condition that the target virtual machine corresponds to the first host, the third proxy service sends the API call request to the first proxy service of the first host.
8. A non-volatile storage medium, comprising a stored program, wherein when the program runs, a device where the non-volatile storage medium is located is controlled to execute the virtual machine interaction method according to any one of claims 1 to 6.
9. A processor, configured to execute a program, wherein the program executes to perform the virtual machine interaction method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111450646.6A CN114327748B (en) | 2021-11-29 | 2021-11-29 | Virtual machine interaction method and device, nonvolatile storage medium and processor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111450646.6A CN114327748B (en) | 2021-11-29 | 2021-11-29 | Virtual machine interaction method and device, nonvolatile storage medium and processor |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114327748A CN114327748A (en) | 2022-04-12 |
CN114327748B true CN114327748B (en) | 2022-10-18 |
Family
ID=81048147
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111450646.6A Active CN114327748B (en) | 2021-11-29 | 2021-11-29 | Virtual machine interaction method and device, nonvolatile storage medium and processor |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114327748B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103780674A (en) * | 2013-11-13 | 2014-05-07 | 南京中兴新软件有限责任公司 | Virtual machine communication method and apparatus based on hardware simulation |
CN106470155A (en) * | 2015-08-14 | 2017-03-01 | 中国电信股份有限公司 | A kind of retransmission method of virtual-machine data, SDN controller and SDN system |
CN107273186A (en) * | 2017-06-28 | 2017-10-20 | 深信服科技股份有限公司 | Access method, physical host and the virtual machine of virtual machine server |
CN109857514A (en) * | 2018-12-20 | 2019-06-07 | 中国电子科技集团公司第十五研究所 | Cross-platform cross commercialization is from the complicated huge information system mixed deployment system of primary climate |
CN110865867A (en) * | 2015-12-21 | 2020-03-06 | 华为技术有限公司 | Method, device and system for discovering application topological relation |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107657172A (en) * | 2016-07-25 | 2018-02-02 | 腾讯科技(深圳)有限公司 | Code process method, apparatus and system |
US10747562B2 (en) * | 2017-04-26 | 2020-08-18 | Vmware, Inc. | Nested hypervisor to run virtual machines on public clouds |
US10903985B2 (en) * | 2017-08-25 | 2021-01-26 | Keysight Technologies Singapore (Sales) Pte. Ltd. | Monitoring encrypted network traffic flows in a virtual environment using dynamic session key acquisition techniques |
CN110297690A (en) * | 2019-06-28 | 2019-10-01 | 深圳前海微众银行股份有限公司 | Virtual machine application method, device, equipment and readable storage medium storing program for executing based on cloud computing |
US11544092B2 (en) * | 2019-08-15 | 2023-01-03 | Raytheon Company | Model specific register (MSR) instrumentation |
-
2021
- 2021-11-29 CN CN202111450646.6A patent/CN114327748B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103780674A (en) * | 2013-11-13 | 2014-05-07 | 南京中兴新软件有限责任公司 | Virtual machine communication method and apparatus based on hardware simulation |
CN106470155A (en) * | 2015-08-14 | 2017-03-01 | 中国电信股份有限公司 | A kind of retransmission method of virtual-machine data, SDN controller and SDN system |
CN110865867A (en) * | 2015-12-21 | 2020-03-06 | 华为技术有限公司 | Method, device and system for discovering application topological relation |
CN107273186A (en) * | 2017-06-28 | 2017-10-20 | 深信服科技股份有限公司 | Access method, physical host and the virtual machine of virtual machine server |
CN109857514A (en) * | 2018-12-20 | 2019-06-07 | 中国电子科技集团公司第十五研究所 | Cross-platform cross commercialization is from the complicated huge information system mixed deployment system of primary climate |
Also Published As
Publication number | Publication date |
---|---|
CN114327748A (en) | 2022-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11243792B2 (en) | Image file conversion method and apparatus | |
US20200201686A1 (en) | Method and Apparatus for Accessing Desktop Cloud Virtual Machine, and Desktop Cloud Controller | |
US8555048B2 (en) | Computer system for booting a system image by associating incomplete identifiers to complete identifiers via querying storage locations according to priority level where the querying is self adjusting | |
WO2017185954A1 (en) | Method, host, and system for implementing usb device management | |
TWI492064B (en) | Cloud system and the boot up and deployment method for the cloud system | |
US11210132B2 (en) | Virtual machine migration in virtualization environment having different virtualization systems | |
CN108089913B (en) | Virtual machine deployment method of super-fusion system | |
WO2018192478A1 (en) | Cloud management platform, virtual machine management method, system thereof | |
CN105450759A (en) | System mirror image management method and device | |
US10936352B2 (en) | High performance application delivery to VDI desktops using attachable application containers | |
US9058205B2 (en) | Automatically performing operations on applications based on dependencies on other applications | |
US8893114B1 (en) | Systems and methods for executing a software package from within random access memory | |
CN113626133B (en) | Virtual machine control method, device, equipment and computer readable storage medium | |
WO2022199335A1 (en) | Method, apparatus and device for controlling firmware upgrade of server component, and storage medium | |
CN114637549A (en) | Data processing method, system and storage medium for service grid-based application | |
US11321109B2 (en) | Container engine for selecting driver based on container metadata | |
CN114995888A (en) | Intelligent network card deployment method, device and medium | |
CN112559114A (en) | Virtual machine generation method and device | |
WO2024124912A1 (en) | Data synchronization method and apparatus for redundant firmware, and non-volatile readable storage medium | |
CN114327748B (en) | Virtual machine interaction method and device, nonvolatile storage medium and processor | |
US11263039B2 (en) | High performance attachable writeable volumes in VDI desktops | |
CN115469964A (en) | Method and device for determining mapping relation between block device and virtual machine disk character | |
WO2018028321A1 (en) | Method and apparatus for managing virtual external storage device, and terminal | |
WO2017096889A1 (en) | Method and device for upgrading and downgrading system | |
CN113934443A (en) | Software upgrading system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address |
Address after: 8b, building 1, No. 48, Zhichun Road, Haidian District, Beijing 100086 Patentee after: Beijing Zhiling Haina Technology Co.,Ltd. Country or region after: China Address before: 100089 8th floor, block a, Yingdu building, a48 Zhichun Road, Haidian District, Beijing Patentee before: Beijing zhilinghaina Technology Co.,Ltd. Country or region before: China |
|
CP03 | Change of name, title or address |