Virtual machine control method and device, electronic equipment and storage medium

The virtual machine monitor application controls the virtual machine to pause and determines the status of the input and output tasks, and enables the online turn-on or turn off of the kernel IO acceleration function, which solves the problem that the virtual machine cannot be migrated after the kernel IO acceleration function is turned on, and improves the performance and function selection experience of the virtual machine.

CN119829217APending Publication Date: 2025-04-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202412000469.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

In KVM virtualization environment, after the kernel IO acceleration function is enabled, the Qemu application cannot record dirty data during the virtual machine operation, resulting in the virtual machine migration operation being unable to be performed.

Method used

The virtual machine monitor application controls the virtual machine to pause operation and determines whether the issuance input and output task execution has been completed in response to the switching instructions of the input and output task acceleration function. According to the switch instructions, determine the receiver end of the input and output task and establish a data connection between the virtual machine and the receiver end, so as to enable or close the kernel IO acceleration function online.

Benefits of technology

It realizes switching between virtual machine migration, disk snapshot and other management functions and kernel IO acceleration functions according to the switch instructions of the IO task acceleration function, improves the efficiency of the virtual machine to handle input and output tasks, optimizes resource utilization, and ensures the stable operation and function selection experience of the virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829217A_ABST
    Figure CN119829217A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a virtual machine control method and device, electronic equipment and a storage medium. A virtual machine monitor application program responds to a switch instruction of an input and output task acceleration function to control a virtual machine to stop running, and whether an issued input and output task of the virtual machine is executed or not is judged; then, under the condition that the issued input and output task is executed, determining an input and output task receiving end through the virtual machine monitor application program according to the switching instruction, and establishing data connection between the virtual machine and the input and output task receiving end; according to the IO task acceleration function switching method and device, the IO task acceleration function switching instruction is added to the virtual machine, and then the virtual machine is controlled to recover running through the virtual machine monitor application program, so that switching between management functions such as virtual machine migration and disk snapshot and the kernel IO acceleration function is achieved according to the IO task acceleration function switching instruction, namely online opening or closing of the kernel IO acceleration function is achieved, and the efficiency of processing input and output tasks by the virtual machine is improved; and the function selection experience of the virtual machine is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtual machines, and in particular to a virtual machine control method and device, electronic equipment, and storage medium. Background Art

[0002] In modern computing environments, virtualization technology is one of the key technologies to improve resource utilization, achieve resource isolation and security. Especially in cloud computing and data center scenarios, virtual machine (VM) performance optimization is crucial for operational efficiency and resource management. In the KVM (Kernel-based Virtual Machine) virtualization environment, IO operations performed inside the virtual machine are generally forwarded through the Qemu (Quick Emulator) application, so that the Qemu application can perceive all IO operations of the virtual machine, so that it can perform management tasks such as migration and snapshots, and can record all IO operations, so as to maintain dirty data in the virtual machine migration process.

[0003] In actual applications, if the IO operations of the virtual machine are all forwarded by the Qemu application, it will affect the performance of the virtual machine. Therefore, there is a kernel IO acceleration function (which can be called input and output task acceleration function). This function is to unload the IO forwarding function in the block device simulation module to the kernel's vhost-blk (Virtio Host Block, kernel unloading module), shortening the IO path of the virtual machine and avoiding system calls and other operations in the IO forwarding function. Thereby improving the performance of the virtual machine.

[0004] However, if the kernel IO acceleration function is turned on, that is, the virtual machine uses vhost-blk, the IO path of the virtual machine is unloaded from the Qemu application to the kernel; the Qemu application can no longer record dirty data during the operation of the virtual machine, and the virtual machine migration operation cannot be performed. In other words, it is difficult for users to select the required functions in real time according to actual needs during actual use. Summary of the invention

[0005] In view of the above problems, a virtual machine control method and device, electronic device, and storage medium are proposed to overcome the above problems or at least partially solve the above problems, including:

[0006] A virtual machine control method, the method comprising:

[0007] Responding to the switch instruction of the input / output task acceleration function through the virtual machine monitor application, controlling the virtual machine to suspend operation, and determining whether the issued input / output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction;

[0008] In the case that the issued input / output task has been executed, the virtual machine monitor application determines the input / output task receiving end according to the switch instruction and establishes a data connection between the virtual machine and the input / output task receiving end; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module;

[0009] When the data connection has been established, the virtual machine is controlled to resume operation through the virtual machine monitor application.

[0010] Optionally, determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction through the virtual machine monitor application includes:

[0011] Determining, by the virtual machine monitor application, the kernel unloading module as the input / output task receiving end when the switch instruction is the opening instruction;

[0012] A first data connection between the block device simulation module and the virtual machine is disconnected through the virtual machine monitor application, and a second data connection between the virtual machine and the kernel unloading module is established.

[0013] Optionally, determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction through the virtual machine monitor application includes:

[0014] Determining, by the virtual machine monitor application, the block device simulation module as the input / output task receiving end when the switch instruction is the closing instruction;

[0015] The second data connection between the virtual machine and the kernel unloading module is disconnected through the virtual machine monitor application, and the first data connection between the block device simulation module and the virtual machine is established.

[0016] Optionally, the first data connection is a virtual queue configured to communicate between the virtual machine and the block device simulation module, and disconnecting the first data connection between the block device simulation module and the virtual machine, and establishing a second data connection between the virtual machine and the kernel unloading module, includes:

[0017] The virtual queue is subjected to a first switching process by the virtual machine monitor application, and the second data connection is established according to the virtual queue after the first switching process is completed.

[0018] Optionally, after disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes:

[0019] The interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the block device simulation module are subjected to a second switching process by the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the kernel unload module.

[0020] Optionally, the second data connection is a virtual queue configured to communicate between the virtual machine and the kernel unloading module, and disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing the first data connection between the block device simulation module and the virtual machine includes:

[0021] The virtual queue is subjected to a third switching process by the virtual machine monitor application, and the first data connection is established according to the virtual queue after the third switching process is completed.

[0022] Optionally, after disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing the first data connection between the block device simulation module and the virtual machine, the method further includes:

[0023] A fourth switching process is performed on the interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the kernel unload module through the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the block device simulation module.

[0024] Optionally, before the virtual machine monitor application responds to a switch instruction of the input / output task acceleration function to control the virtual machine to suspend operation and determines whether the issued input / output tasks of the virtual machine have been completed, the method further includes:

[0025] The virtual machine monitoring command data is obtained through the virtual machine monitor application, and the switch instruction of the input and output task acceleration function is determined according to the virtual machine monitoring command data.

[0026] Optionally, the determining whether the issued input and output tasks of the virtual machine have been completed includes:

[0027] The virtual machine monitor application program responds to the triggering operation of the interrupt request file descriptor to determine that the issued input and output tasks of the virtual machine have been completed.

[0028] Optionally, the trigger operation is a trigger operation that is automatically executed after the sent input / output task in the underlying file system is completed.

[0029] Optionally, the block device simulation module is provided with a virtual machine monitor machine protocol command interface, and the obtaining of virtual machine monitor command data includes:

[0030] The virtual machine monitor command data is obtained through the virtual machine monitor application according to the virtual machine monitor machine protocol command interface.

[0031] Optionally, establishing the second data connection according to the virtual queue after completing the first switching process includes:

[0032] The virtual queue after completing the first switching process is configured as the second data connection through the virtual machine monitor application.

[0033] Optionally, establishing the first data connection according to the virtual queue after completing the third switching process includes:

[0034] The virtual queue after completing the third switching process is configured as the first data connection through the virtual machine monitor application.

[0035] Optionally, after disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes:

[0036] The input and output task processing function of the kernel unloading module is enabled through the virtual machine monitor application.

[0037] Optionally, the determining whether the issued input and output tasks of the virtual machine have been completed includes:

[0038] The virtual machine monitor application determines whether there is any running input / output task in the kernel unloading module, and when there is no running input / output task in the kernel unloading module, determines that the issued input / output task of the virtual machine has been executed.

[0039] Optionally, the kernel unloading module is provided with a query interface, and the determining, through the virtual machine monitor application, whether there is an input and output task running in the kernel unloading module includes:

[0040] The virtual machine monitor application determines whether there is an input / output task running in the kernel unloading module according to the query interface.

[0041] A virtual machine control device, the device comprising:

[0042] A switch instruction response module, used to respond to the switch instruction of the input and output task acceleration function through the virtual machine monitor application, control the virtual machine to suspend operation, and determine whether the issued input and output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction;

[0043] a data connection establishing module, used for determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end through the virtual machine monitor application according to the switch instruction when the issued input / output task has been executed; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module;

[0044] The virtual machine recovery module is used to control the virtual machine to recover through the virtual machine monitor application when the data connection has been established.

[0045] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the virtual machine control method as described above when executed by the processor.

[0046] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the virtual machine control method described above is implemented.

[0047] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the computer program implements the virtual machine control method as described above.

[0048] The embodiments of the present invention have the following advantages:

[0049] In an embodiment of the present invention, a virtual machine monitor application is used to control the virtual machine to suspend operation in response to a switch instruction of an input / output task acceleration function, and to determine whether the input / output task that has been issued to the virtual machine has been executed; wherein the switch instruction includes any one of an on instruction and a off instruction; then, when the issued input / output task has been executed, the virtual machine monitor application determines the input / output task receiving end according to the switch instruction and establishes a data connection between the virtual machine and the input / output task receiving end; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module; and then, the virtual machine monitor application is used to control the virtual machine to resume operation, thereby realizing the switching of management functions such as virtual machine migration and disk snapshot and the kernel IO acceleration function according to the switch instruction of the IO task acceleration function, that is, the online opening or closing of the kernel IO acceleration function, thereby improving the efficiency of the virtual machine in processing input / output tasks; optimizing resource utilization, ensuring the stable operation of the virtual machine; and improving the function selection experience of the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0051] Figure 1 It is a schematic diagram of the input and output flow of a virtual machine in the related technology provided by the present invention;

[0052] Figure 2 It is a schematic diagram of the input and output flow of a virtual machine after the kernel IO acceleration function is turned on in the related technology provided by the present invention;

[0053] Figure 3 is a flowchart of a virtual machine control method provided by some embodiments of the present invention;

[0054] Figure 4 It is an example diagram of actual implementation of the present invention provided by some embodiments of the present invention;

[0055] Figure 5 It is a structural schematic diagram of a virtual machine control device provided by some embodiments of the present invention.

[0056] Explanation of the accompanying drawings: 1-virtual machine exit event (vmexit), 2-event file descriptor (eventfd, Eventfiledescriptor)), 3-input and output stream virtual queue (virt-queue), 4-direct write event & asynchronous event (Write Direct&asynchronous), 5-interrupt event, asynchronous input / output event file descriptor (interrupt, aio eventfd (Asynchronous I / O event filedescriptor)) 6-interrupt stream virtual queue (virt-queue), 7-interrupt request file descriptor (IRQ filedescriptor), 8-interrupt injection (irq injection). DETAILED DESCRIPTION

[0057] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] In a KVM virtualization environment, IO operations performed inside a virtual machine are generally forwarded through the Qemu application, so that the Qemu application can perceive all IO operations of the virtual machine and perform management tasks such as migration and snapshots.

[0059] In practical applications, such as Figure 1 The figure shows the input and output flow diagram of the virtual machine in the related art, in which the block device simulation module in the Qemu application can record all IO operations, so as to maintain the dirty data in the virtual machine migration process; if the IO operations of the virtual machine are all forwarded by the Qemu application, it will affect the performance of the virtual machine. Therefore, there is a kernel IO acceleration function, which is to unload the IO forwarding function in the block device simulation module to the vhost-blk of the kernel, shorten the IO path of the virtual machine, and avoid system calls and other operations in the IO forwarding function. Thereby improving the performance of the virtual machine.

[0060] However, if Figure 2 The figure shows the input and output flow of the virtual machine after the kernel IO acceleration function is turned on. Figure 2It can be seen from the content that if the kernel IO acceleration function is turned on, that is, the virtual machine uses vhost-blk, the IO path of the virtual machine is unloaded from the Qemu application to the kernel; the Qemu application can no longer record dirty data during the operation of the virtual machine, and the virtual machine migration operation cannot be performed. In other words, it is difficult for users to select the required functions in real time according to actual needs during actual use.

[0061] In the embodiment of the present invention, based on the core technical concept of realizing online opening or closing of the kernel IO acceleration function, the virtual machine control method in the related art is improved. The present invention will be described in detail below with reference to the accompanying drawings:

[0062] Reference Figure 3 , shows a flowchart of a virtual machine control method provided by some embodiments of the present invention, which may specifically include the following steps:

[0063] Step 301, controlling the virtual machine to suspend operation in response to a switch instruction of an input / output task acceleration function through a virtual machine monitor application, and determining whether the issued input / output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction;

[0064] In a specific implementation, the block device simulation module in the virtual machine monitor application of the present invention can provide an interface for switching the kernel IO acceleration function externally, and the interface can be provided in the form of a qmp (QEMU Machine Protocol) command, and the qmp command can be specifically:

[0065] virsh qemu-monitor-command i-00000x'{"execute":"switch_vhost_blk","arguemnts":{"node-name":"drive-virtio-disk1-1","on-off":"off"}}';

[0066] Wherein, virsh qemu-monitor-command is a program for sending commands to Qemu, i-00000x is the name of the virtual machine; switch_vhost_blk is a command name newly provided by the present invention, i.e., switching the vhost_blk state;

[0067] This command can include two parameters, where the value of the node-name parameter is drive-virtio-disk1-1, which can be obtained through the query-block command; indicating that Qemu needs to switch the vhost-blk state of the drive-virtio-disk1-1 disk

[0068] The value of the On-off parameter can be on or off, where on indicates that the kernel IO acceleration function needs to be enabled, and off indicates that Qemu needs to disable the kernel IO acceleration function.

[0069] Furthermore, based on the above content, the block device simulation module in the virtual machine monitor application can determine whether the kernel IO acceleration function needs to be turned on or off according to the virtual machine monitoring command data obtained by the interface, that is, determine whether the received switch instruction of the input and output task acceleration function is an on instruction or a off instruction. When the block device simulation module receives the qmp command for setting the kernel IO acceleration function, if the kernel IO acceleration function needs to be turned on, the block device simulation module needs to complete the configuration of the vhost-blk module. At this time, the block device simulation module in the Qemu application can control the virtual machine to pause the operation to stop the input and output task issuance operation of the virtual machine, and can further determine whether the input and output tasks that have been issued by the virtual machine have been executed, thereby facilitating the subsequent data connection establishment process between the virtual machine and the input and output task receiving end corresponding to the switch instruction.

[0070] In some embodiments of the present invention, the step of controlling the virtual machine to suspend operation in response to a switch instruction of the input / output task acceleration function by the virtual machine monitor application and determining whether the issued input / output task of the virtual machine has been completed further includes:

[0071] The virtual machine monitoring command data is obtained through the virtual machine monitor application, and the switch instruction of the input and output task acceleration function is determined according to the virtual machine monitoring command data.

[0072] In actual applications, the block device simulation module can provide an interface for switching the kernel IO acceleration function. The interface can be provided in the form of a qmp (QEMU Machine Protocol) command. The qmp command can be specifically:

[0073] virsh qemu-monitor-command i-00000x'{"execute":"switch_vhost_blk","arguemnts":{"node-name":"drive-virtio-disk1-1","on-off":"off"}}';

[0074] Wherein, virsh qemu-monitor-command is a program for sending commands to Qemu, i-00000x is the name of the virtual machine; switch_vhost_blk is a command name newly provided by the present invention, i.e., switching the vhost_blk state;

[0075] This command can include two parameters, where the value of the node-name parameter is drive-virtio-disk1-1, which can be obtained through the query-block command; indicating that Qemu needs to switch the vhost-blk state of the drive-virtio-disk1-1 disk

[0076] The value of the On-off parameter can be on or off, where on indicates that the kernel IO acceleration function needs to be enabled, and off indicates that Qemu needs to disable the kernel IO acceleration function.

[0077] Furthermore, based on the above content, the block device simulation module can determine whether the kernel IO acceleration function needs to be turned on or off according to the virtual machine monitoring command data obtained by the interface, that is, determine whether the received switch instruction of the input and output task acceleration function is an on instruction or a off instruction. When the block device simulation module receives the qmp command to set the kernel IO acceleration function, if the kernel IO acceleration function needs to be turned on, the block device simulation module needs to complete the configuration of the vhost-blk module. At this time, the block device simulation module in the Qemu application can control the virtual machine to suspend operation to stop the input and output task issuance operation of the virtual machine, thereby facilitating the subsequent data connection establishment process between the virtual machine and the input and output task receiving end corresponding to the switch instruction and avoiding unnecessary resource consumption.

[0078] In some embodiments of the present invention, the block device simulation module is provided with a virtual machine monitor machine protocol command interface, and the obtaining of virtual machine monitor command data includes:

[0079] The virtual machine monitor command data is obtained through the virtual machine monitor application according to the virtual machine monitor machine protocol command interface.

[0080] In practical applications, as mentioned above, the block device simulation module can provide an interface for switching the kernel IO acceleration function. The interface can be provided in the form of a qmp (QEMU Machine Protocol) command. The qmp command can be specifically:

[0081] virsh qemu-monitor-command i-00000x'{"execute":"switch_vhost_blk","arguemnts":{"node-name":"drive-virtio-disk1-1","on-off":"off"}}';

[0082] Wherein, virsh qemu-monitor-command is a program for sending commands to Qemu, i-00000x is the name of the virtual machine; switch_vhost_blk is a command name newly provided by the present invention, i.e., switching the vhost_blk state;

[0083] This command can include two parameters, where the value of the node-name parameter is drive-virtio-disk1-1, which can be obtained through the query-block command; indicating that Qemu needs to switch the vhost-blk state of the drive-virtio-disk1-1 disk

[0084] The value of the On-off parameter can be on or off, where on indicates that the kernel IO acceleration function needs to be enabled, and off indicates that Qemu needs to disable the kernel IO acceleration function.

[0085] Furthermore, based on the above content, the block device simulation module can determine whether the kernel IO acceleration function needs to be turned on or off according to the virtual machine monitoring command data obtained by the interface, that is, determine whether the received switch instruction of the input and output task acceleration function is an on instruction or a off instruction. When the block device simulation module receives the qmp command to set the kernel IO acceleration function, if the kernel IO acceleration function needs to be turned on, the block device simulation module needs to complete the configuration of the vhost-blk module. At this time, the block device simulation module in the Qemu application can control the virtual machine to suspend operation to stop the input and output task issuance operation of the virtual machine, thereby facilitating the subsequent data connection establishment process between the virtual machine and the input and output task receiving end corresponding to the switch instruction.

[0086] Step 302, when the issued input / output task has been executed, the virtual machine monitor application determines the input / output task receiving end according to the switch instruction and establishes a data connection between the virtual machine and the input / output task receiving end; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module;

[0087] In a specific implementation, when the input and output tasks have been issued and have been completed, the input and output task receiving end can be determined according to the switch instruction by the virtual machine monitor application and a data connection can be established between the virtual machine and the input and output task receiving end;

[0088] In one example, if Figure 4 As shown, when the switch instruction is an on instruction, the kernel unloading module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the block device simulation module can be switched to use the virtual queue for communication between the virtual machine and the kernel unloading module, that is, the virtual queue (first data connection) originally used for communication between the virtual machine and the block device simulation module can be switched to a virtual queue (second data connection) used for communication between the virtual machine and the kernel unloading module, so as to realize the disconnection of the first data connection and the establishment of the second data connection;

[0089] Furthermore, the interrupt request file descriptor (irqfd) and the event file descriptor (eventfd) used for communication between KVM and the block device simulation module can be switched so that the interrupt request file descriptor and the event file descriptor can be used for communication between the kernel-based virtual machine and the kernel unload module, that is, the eventfd and irqfd used by KVM to communicate with the block device simulation module are changed to communicate with the vhost-blk module.

[0090] In one example, if the received qmp command indicates that the kernel IO acceleration function needs to be turned off, that is, when the switch instruction is a turn-off instruction, the block device simulation module can determine the block device simulation module itself as the input and output task receiving end after the virtual machine is paused, and determine whether the input and output tasks in the kernel unloading module have been completed; when the input and output tasks in the kernel unloading module have been completed, the second data connection between the virtual machine and the kernel unloading module can be disconnected through the block device simulation module, and a first data connection between the block device simulation module and the virtual machine can be established; for example, the virt-queue (virtual queue) can also be set, and the virtual queue used for communication between the virtual machine and the kernel unloading module can be switched to use the virtual queue for communication between the virtual machine and the block device simulation module, that is, the virtual queue can be subjected to a third switching process to change the data receiving end or the data output end of the virtual queue, and the first data connection can be established according to the virtual queue after the third switching process is completed; the virtual queue (second data connection) originally used for communication between the virtual machine and the kernel unloading module can also be directly switched to the virtual queue (first data connection) used for communication between the virtual machine and the block device simulation module to achieve the establishment of the first data connection and the disconnection of the second data connection.

[0091] Specifically, regarding the step in which the block device simulation module determines whether the input and output tasks in the kernel unload module have been completed, the vhost-blk module can provide a query interface for the block device simulation module to use. The query interface can add the following command:

[0092] VHOST_BLK_GET_INFLIGHT_IOR(VHOST_VIRTIO,0x51,__u64);

[0093] The block device simulation module can obtain the completion status of the input and output tasks running in the vhost-blk module by calling this command. Since the virtual machine has been paused and no new IO will be issued, the number of IOs running in the vhost-blk module is gradually reduced. After the block device simulation module waits for all IOs in the vhost-blk module to complete, it can disconnect the second data connection and establish the first data connection. You can also refer to the previous steps to change the eventfd and irqfd that originally communicated with the vhost-blk module to communicate with the block device simulation module.

[0094] In some embodiments of the present invention, determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction by the virtual machine monitor application includes:

[0095] Determining, by the virtual machine monitor application, the kernel unloading module as the input / output task receiving end when the switch instruction is the opening instruction;

[0096] A first data connection between the block device simulation module and the virtual machine is disconnected through the virtual machine monitor application, and a second data connection between the virtual machine and the kernel unloading module is established.

[0097] In the specific implementation, Figure 4 As shown, in the case where the switch instruction is an on instruction, the kernel unloading module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the block device simulation module can be switched to use the virtual queue for communication between the virtual machine and the kernel unloading module. That is, the virtual queue (first data connection) originally used for communication between the virtual machine and the block device simulation module can be switched to a virtual queue (second data connection) used for communication between the virtual machine and the kernel unloading module, thereby realizing the disconnection of the first data connection and the establishment of the second data connection, thereby ensuring the normal activation of the IO acceleration function.

[0098] In some embodiments of the present invention, determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction by the virtual machine monitor application includes:

[0099] Determining, by the virtual machine monitor application, the block device simulation module as the input / output task receiving end when the switch instruction is the closing instruction;

[0100] The second data connection between the virtual machine and the kernel unloading module is disconnected through the virtual machine monitor application, and the first data connection between the block device simulation module and the virtual machine is established.

[0101] In a specific implementation, if the received qmp command indicates that the kernel IO acceleration function needs to be turned off, that is, when the switch instruction is a turn-off instruction, the block device simulation module can determine whether the input and output tasks in the kernel unloading module have been completed after the virtual machine is paused, and determine the block device simulation module itself as the input and output task receiving end; when the input and output tasks in the kernel unloading module have been completed, the second data connection between the virtual machine and the kernel unloading module can be disconnected through the block device simulation module, and a first data connection between the block device simulation module and the virtual machine can be established; for example, the virt-queue (virtual queue) can also be set, and the virtual queue used for communication between the virtual machine and the kernel unloading module can be switched to use the virtual queue for communication between the virtual machine and the block device simulation module, that is, the virtual queue can be subjected to a third switching process to change the data receiving end or the data output end of the virtual queue, and the first data connection can be established according to the virtual queue after the third switching process is completed; the virtual queue (second data connection) originally used for communication between the virtual machine and the kernel unloading module can also be directly switched to the virtual queue (first data connection) used for communication between the virtual machine and the block device simulation module to achieve the establishment of the first data connection and the disconnection of the second data connection.

[0102] In some embodiments of the present invention, the first data connection is a virtual queue configured to communicate between the virtual machine and the block device simulation module, and disconnecting the first data connection between the block device simulation module and the virtual machine, and establishing a second data connection between the virtual machine and the kernel unload module, includes:

[0103] The virtual queue is subjected to a first switching process by the virtual machine monitor application, and the second data connection is established according to the virtual queue after the first switching process is completed.

[0104] In actual applications, the first data connection can be a virtual queue configured for communication between the virtual machine and the block device simulation module, so that when the switch instruction is an on instruction, the kernel unloading module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the block device simulation module can be switched to use the virtual queue for communication between the virtual machine and the kernel unloading module; that is, the virtual queue can be subjected to a first switching process to change the data receiving end or the data output end of the virtual queue, and the second data connection can be opened according to the virtual queue after the first switching process is completed; or the virtual queue originally used for communication between the virtual machine and the block device simulation module (first data connection) can be directly switched to the virtual queue used for communication between the virtual machine and the kernel unloading module (second data connection), thereby realizing the closing of the first data connection and the opening of the second data connection.

[0105] In some embodiments of the present invention, establishing the second data connection according to the virtual queue after completing the first switching process includes:

[0106] The virtual queue after completing the first switching process is configured as the second data connection through the virtual machine monitor application.

[0107] In actual applications, as mentioned above, when the switch instruction is an on instruction, the kernel unloading module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the block device simulation module can be switched to use the virtual queue for communication between the virtual machine and the kernel unloading module; that is, the virtual queue can be subjected to a first switching process to change the data receiving end or the data output end of the virtual queue, and a second data connection can be opened according to the virtual queue after the first switching process is completed; or the virtual queue originally used for communication between the virtual machine and the block device simulation module (first data connection) can be directly switched to a virtual queue used for communication between the virtual machine and the kernel unloading module (second data connection), thereby realizing the closing of the first data connection and the opening of the second data connection.

[0108] In some embodiments of the present invention, after disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes:

[0109] The interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the block device simulation module are subjected to a second switching process by the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the kernel unload module.

[0110] In practical applications, when the switch instruction is an on instruction, the kernel unloading module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the block device simulation module can be switched to use the virtual queue for communication between the virtual machine and the kernel unloading module, that is, the virtual queue (first data connection) originally used for communication between the virtual machine and the block device simulation module can be switched to a virtual queue (second data connection) used for communication between the virtual machine and the kernel unloading module, so as to realize the closing of the first data connection and the opening of the second data connection;

[0111] Furthermore, the interrupt request file descriptor (irqfd) and the event file descriptor (eventfd) used for communication between KVM and the block device simulation module can be switched so that the interrupt request file descriptor and the event file descriptor can be used for communication between the kernel-based virtual machine and the kernel unload module, that is, the eventfd and irqfd used by KVM to communicate with the block device simulation module are changed to communicate with the vhost-blk module; the communication requirements after the IO acceleration function is switched are guaranteed, thereby enhancing the flexibility and configurability of the system.

[0112] In some embodiments of the present invention, the determining whether the issued input and output tasks of the virtual machine have been completed includes:

[0113] The virtual machine monitor application program responds to the triggering operation of the interrupt request file descriptor to determine that the issued input and output tasks of the virtual machine have been completed.

[0114] In a specific implementation, the virtual machine's sent input and output tasks can be sent to the underlying file system, and after the underlying file system completes these input and output tasks, an interrupt can be configured through irqfd; the operation of configuring the interrupt is automatically executed by the pre-configured irqfd, which can automatically execute the triggering operation of irqfd after the sent input and output tasks in the underlying file system are completed, so as to notify the block device simulation module that the virtual machine's sent input and output tasks have been completed.

[0115] In some embodiments of the present invention, the trigger operation is a trigger operation that is automatically executed after the sent input and output tasks in the underlying file system are completed.

[0116] In actual applications, the virtual machine's sent input and output tasks can be sent to the underlying file system, and after the underlying file system completes these input and output tasks, an interrupt can be configured through irqfd; the operation of configuring the interrupt is automatically executed by the pre-configured irqfd, which can automatically execute the triggering operation of irqfd after the sent input and output tasks in the underlying file system are completed, so as to notify the block device simulation module that the virtual machine's sent input and output tasks have been completed.

[0117] In some embodiments of the present invention, after disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes:

[0118] The input and output task processing function of the kernel unloading module is enabled through the virtual machine monitor application.

[0119] In actual applications, after disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the block device simulation module can create an input and output task processing thread in the kernel unloading module to implement input and output task processing functions, such as forwarding input and output tasks.

[0120] In some embodiments of the present invention, the second data connection is a virtual queue configured to communicate between the virtual machine and the kernel unloading module, and disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing the first data connection between the block device simulation module and the virtual machine includes:

[0121] The virtual queue is subjected to a third switching process by the virtual machine monitor application, and the first data connection is established according to the virtual queue after the third switching process is completed.

[0122] In a specific implementation, if the received qmp command indicates that the kernel IO acceleration function needs to be turned off, that is, when the switch instruction is a turn-off instruction, the block device simulation module can determine whether the input and output tasks in the kernel unloading module have been completed after the virtual machine is paused, and determine the block device simulation module itself as the input and output task receiving end; when the input and output tasks in the kernel unloading module have been completed, the second data connection between the virtual machine and the kernel unloading module can be disconnected through the block device simulation module, and a first data connection between the block device simulation module and the virtual machine can be established; for example, the virt-queue (virtual queue) can also be set, and the virtual queue used for communication between the virtual machine and the kernel unloading module can be switched to use the virtual queue for communication between the virtual machine and the block device simulation module, that is, the virtual queue can be subjected to a third switching process to change the data receiving end or the data output end of the virtual queue, and the first data connection can be established according to the virtual queue after the third switching process is completed; the virtual queue (second data connection) originally used for communication between the virtual machine and the kernel unloading module can also be directly switched to the virtual queue (first data connection) used for communication between the virtual machine and the block device simulation module to achieve the establishment of the first data connection and the disconnection of the second data connection.

[0123] In some embodiments of the present invention, after disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing the first data connection between the block device simulation module and the virtual machine, the method further includes:

[0124] A fourth switching process is performed on the interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the kernel unload module through the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the block device simulation module.

[0125] In actual applications, when the switch instruction is a shutdown instruction, the block device simulation module can be determined as the input and output task receiving end, and then the virt-queue (virtual queue) can be set. For example, the virtual queue used for communication between the virtual machine and the kernel unloading module can be switched to use the virtual queue for communication between the virtual machine and the block device simulation module. That is, the virtual queue (second data connection) originally used for communication between the virtual machine and the kernel unloading module can be switched to a virtual queue (first data connection) used for communication between the virtual machine and the block device simulation module, thereby realizing the establishment of the first data connection and the disconnection of the second data connection.

[0126] Furthermore, the interrupt request file descriptor (irqfd) and the event file descriptor (eventfd) used for KVM to communicate with the kernel unload module can be switched so that the interrupt request file descriptor and the event file descriptor can be used for the kernel-based virtual machine to communicate with the block device simulation module, that is, the eventfd and irqfd used by KVM to communicate with the vhost-blk module are changed to communicate with the block device simulation module; thereby enhancing the flexibility and configurability of the system.

[0127] In some embodiments of the present invention, establishing the first data connection according to the virtual queue after completing the third switching process includes:

[0128] The virtual queue after completing the third switching process is configured as the first data connection through the virtual machine monitor application.

[0129] In actual applications, virt-queue (virtual queue) can also be set, and the virtual queue used for communication between the virtual machine and the kernel unloading module can be switched so that the virtual queue can be used for communication between the virtual machine and the block device simulation module, that is, the virtual queue can be subjected to a third switching process to change the data receiving end or the data output end of the virtual queue, and a first data connection can be established according to the virtual queue after the third switching process is completed; or the virtual queue originally used for communication between the virtual machine and the kernel unloading module (second data connection) can be directly switched to the virtual queue used for communication between the virtual machine and the block device simulation module (first data connection), thereby realizing the establishment of the first data connection and the disconnection of the second data connection.

[0130] In some embodiments of the present invention, the determining whether the issued input and output tasks of the virtual machine have been completed includes:

[0131] The virtual machine monitor application determines whether there is any running input / output task in the kernel unloading module, and when there is no running input / output task in the kernel unloading module, determines that the issued input / output task of the virtual machine has been executed.

[0132] In actual applications, the vhost-blk module can provide a query interface for the block device simulation module to use. The query interface can add the following commands:

[0133] VHOST_BLK_GET_INFLIGHT_IOR(VHOST_VIRTIO,0x51,__u64);

[0134] The block device simulation module can obtain the completion status of the input and output tasks running in the vhost-blk module by calling this command. Since the virtual machine has been paused and no new IO will be issued, the number of IOs running in the vhost-blk module is gradually reduced. After the block device simulation module waits for all IOs in the vhost-blk module to complete, it can be determined that the input and output tasks issued by the virtual machine have been executed, so that the second data connection can be disconnected and the first data connection can be established. The eventfd and irqfd that originally communicated with the vhost-blk module can also be changed to communicate with the block device simulation module by referring to the aforementioned steps.

[0135] In some embodiments of the present invention, the kernel unloading module is provided with a query interface, and the determining, by the virtual machine monitor application, whether there is an input and output task running in the kernel unloading module includes:

[0136] The virtual machine monitor application determines whether there is an input / output task running in the kernel unloading module according to the query interface.

[0137] In actual applications, the vhost-blk module can provide a query interface for the block device simulation module to use. The query interface can add the following commands:

[0138] VHOST_BLK_GET_INFLIGHT_IOR(VHOST_VIRTIO,0x51,__u64);

[0139] The block device simulation module can obtain the completion status of the input and output tasks running in the vhost-blk module by calling this command. Since the virtual machine has been paused and no new IO will be issued, the number of IOs running in the vhost-blk module is gradually reduced. After the block device simulation module waits for all IOs in the vhost-blk module to complete, it can be determined that the input and output tasks issued by the virtual machine have been executed, so that the second data connection can be disconnected and the first data connection can be established. The eventfd and irqfd that originally communicated with the vhost-blk module can also be changed to communicate with the block device simulation module by referring to the aforementioned steps.

[0140] Step 303: When the data connection has been established, the virtual machine is controlled to resume operation through the virtual machine monitor application.

[0141] In a specific implementation, the virtual machine can be controlled to resume operation after step 302 is executed, and the input and output task issuance operation of the virtual machine can be restored. When the switch instruction of the input and output task acceleration function is an on instruction, the input and output task can be issued to the kernel unloading module. The subsequent IO issued by the virtual machine will notify the vhost-blk module through eventfd. The vhost-blk module can execute the IO issued by the virtual machine according to the set virtual queue and input and output task processing thread. The Qemu application is no longer aware of it. When the switch instruction of the input and output task acceleration function is a off instruction, the corresponding function of the Qemu application can be restored, that is, the Qemu application can record dirty data during the operation of the virtual machine and can perform virtual machine migration operations.

[0142] Through the virtual machine control method provided by the present invention, when the user needs high-performance IO, the kernel IO acceleration function can be turned on online, and the IO stream of the virtual machine can be unloaded from the Qemu application to the vhost-blk kernel module, thereby reducing the IO path and improving the IO performance; and when the user needs to use virtualization management functions such as migration and snapshot, the kernel IO acceleration function can be turned off online, and the IO stream of the virtual machine can be re-transferred to the Qemu application, so that the Qemu application can monitor and record the IO process of the virtual machine, so that the virtual machine migration, snapshot and other operations can be performed; that is, the user can choose between the IO performance acceleration and management functions of the virtual machine according to actual needs. And when the user is in the process of switching the kernel IO acceleration function, the virtual machine is not shut down, so it will not affect the normal operation of the user's virtual machine business.

[0143] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0144] Reference Figure 5 , shows a schematic diagram of the structure of a virtual machine control device provided by some embodiments of the present invention, which may specifically include the following modules:

[0145] The switch instruction response module 501 is used to respond to the switch instruction of the input and output task acceleration function through the virtual machine monitor application, control the virtual machine to suspend operation, and determine whether the issued input and output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction;

[0146] The data connection establishing module 502 is used to determine the input / output task receiving end and establish a data connection between the virtual machine and the input / output task receiving end according to the switch instruction through the virtual machine monitor application program when the issued input / output task has been executed; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module;

[0147] The virtual machine resuming operation module 503 is used to control the virtual machine to resume operation through the virtual machine monitor application when the data connection has been established.

[0148] In some embodiments of the present invention, the data connection establishing module 502 includes:

[0149] The input / output task receiving end determines a first submodule, which is used to determine the kernel unloading module as the input / output task receiving end through the virtual machine monitor application when the switch instruction is the opening instruction;

[0150] The data connection establishes a first submodule, which is used to disconnect the first data connection between the block device simulation module and the virtual machine through the virtual machine monitor application, and to establish a second data connection between the virtual machine and the kernel unloading module.

[0151] In some embodiments of the present invention, the data connection establishing module 502 includes:

[0152] The input / output task receiving end determines a second submodule, which is used to determine the block device simulation module as the input / output task receiving end through the virtual machine monitor application when the switch instruction is the closing instruction;

[0153] The data connection establishing second submodule is used to disconnect the second data connection between the virtual machine and the kernel unloading module through the virtual machine monitor application, and to establish the first data connection between the block device simulation module and the virtual machine.

[0154] In some embodiments of the present invention, the first data connection is a virtual queue configured to communicate between the virtual machine and the block device simulation module, and the data connection establishes a first submodule, including:

[0155] The first switching processing unit is used to perform a first switching process on the virtual queue through the virtual machine monitor application, and establish the second data connection according to the virtual queue after completing the first switching process.

[0156] In some embodiments of the present invention, the data connection establishing module 502 includes:

[0157] The second switching processing submodule is used to perform a second switching process on the interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the block device simulation module through the virtual machine monitor application, so as to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the kernel unloading module.

[0158] In some embodiments of the present invention, the second data connection is a virtual queue configured to communicate between the virtual machine and the kernel unloading module, and the data connection establishes a second submodule, including:

[0159] The third switching processing unit is used to perform a third switching process on the virtual queue through the virtual machine monitor application, and establish the first data connection according to the virtual queue after completing the third switching process.

[0160] In some embodiments of the present invention, the data connection establishing module 502 includes:

[0161] A fourth switching processing submodule is used to perform a fourth switching processing on the interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the kernel unloading module through the virtual machine monitor application, so as to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the block device simulation module.

[0162] In some embodiments of the present invention, the device further comprises:

[0163] The switch instruction determination module is used to obtain virtual machine monitoring command data through the virtual machine monitor application, and determine the switch instruction of the input and output task acceleration function according to the virtual machine monitoring command data.

[0164] In some embodiments of the present invention, the switch instruction response module 501 includes:

[0165] The first submodule for determining the completion of execution is used to determine that the issued input and output tasks of the virtual machine have been completed in response to the triggering operation of the interrupt request file descriptor through the virtual machine monitor application.

[0166] In some embodiments of the present invention, the switch instruction determination module includes:

[0167] The monitoring command data acquisition submodule is used to acquire the virtual machine monitoring command data through the virtual machine monitor application according to the virtual machine monitor machine protocol command interface.

[0168] In some embodiments of the present invention, the first switching processing unit includes:

[0169] The second data connection configuration subunit is used to configure the virtual queue after completing the first switching process as the second data connection through the virtual machine monitor application.

[0170] In some embodiments of the present invention, the third switching processing unit includes:

[0171] The first data connection configuration subunit is used to configure the virtual queue after completing the third switching process as the first data connection through the virtual machine monitor application.

[0172] In some embodiments of the present invention, the data connection establishing module 502 includes:

[0173] The input / output task processing function activation module is used to activate the input / output task processing function of the kernel unloading module through the virtual machine monitor application.

[0174] In some embodiments of the present invention, the switch instruction response module 501 includes:

[0175] The second submodule for determining the completion of execution is used to determine whether there are any running input and output tasks in the kernel unloading module through the virtual machine monitor application, and when there are no running input and output tasks in the kernel unloading module, determine that the input and output tasks issued by the virtual machine have been executed.

[0176] In some embodiments of the present invention, the kernel unloading module is provided with a query interface, and the execution completion determination second submodule includes:

[0177] The input / output task running judgment unit is used to determine whether there is an input / output task running in the kernel unloading module according to the query interface through the virtual machine monitor application.

[0178] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0179] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above virtual machine control method when executed by a processor.

[0180] Some embodiments of the present invention further provide an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the above virtual machine control method when executed by the processor.

[0181] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the virtual machine control method as described above is implemented.

[0182] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0183] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0184] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0185] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0186] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0187] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0188] Finally, 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 terminal 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 terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.

[0189] The virtual machine control method and device, electronic device, and storage medium provided above are introduced in detail. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A virtual machine control method, characterized in that: The method comprises: Responding to the switch instruction of the input / output task acceleration function through the virtual machine monitor application, controlling the virtual machine to suspend operation, and determining whether the issued input / output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction; In the case that the issued input / output task has been executed, the virtual machine monitor application determines the input / output task receiving end according to the switch instruction and establishes a data connection between the virtual machine and the input / output task receiving end; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module; When the data connection has been established, the virtual machine is controlled to resume operation through the virtual machine monitor application.

2. The method according to claim 1, characterized in that: The step of determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction by the virtual machine monitor application comprises: Determining, by the virtual machine monitor application, the kernel unloading module as the input / output task receiving end when the switch instruction is the opening instruction; A first data connection between the block device simulation module and the virtual machine is disconnected through the virtual machine monitor application, and a second data connection between the virtual machine and the kernel unloading module is established.

3. The method according to claim 1, characterized in that The step of determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end according to the switch instruction by the virtual machine monitor application comprises: Determining, by the virtual machine monitor application, the block device simulation module as the input / output task receiving end when the switch instruction is the closing instruction; The second data connection between the virtual machine and the kernel unloading module is disconnected through the virtual machine monitor application, and the first data connection between the block device simulation module and the virtual machine is established.

4. The method according to claim 2, characterized in that: The first data connection is a virtual queue configured to communicate between the virtual machine and the block device simulation module, and disconnecting the first data connection between the block device simulation module and the virtual machine, and establishing a second data connection between the virtual machine and the kernel unloading module, includes: The virtual queue is subjected to a first switching process by the virtual machine monitor application, and the second data connection is established according to the virtual queue after the first switching process is completed.

5. The method according to claim 2, characterized in that: After disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes: The interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the block device simulation module are subjected to a second switching process by the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the kernel unload module.

6. The method according to claim 3, characterized in that The second data connection is a virtual queue configured to communicate between the virtual machine and the kernel unloading module, and disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing a first data connection between the block device simulation module and the virtual machine includes: The virtual queue is subjected to a third switching process by the virtual machine monitor application, and the first data connection is established according to the virtual queue after the third switching process is completed.

7. The method according to claim 3, characterized in that After disconnecting the second data connection between the virtual machine and the kernel unloading module and establishing the first data connection between the block device simulation module and the virtual machine, the method further includes: A fourth switching process is performed on the interrupt request file descriptor and the event file descriptor configured to communicate between the kernel-based virtual machine and the kernel unload module through the virtual machine monitor application to configure the interrupt request file descriptor and the event file descriptor to communicate between the kernel-based virtual machine and the block device simulation module.

8. The method according to claim 1, characterized in that The method of controlling the virtual machine to suspend operation in response to a switch instruction of the input / output task acceleration function through the virtual machine monitor application and determining whether the issued input / output task of the virtual machine has been completed includes: The virtual machine monitoring command data is obtained through the virtual machine monitor application, and the switch instruction of the input and output task acceleration function is determined according to the virtual machine monitoring command data.

9. The method according to claim 2, characterized in that: The determining whether the issued input and output tasks of the virtual machine have been completed includes: The virtual machine monitor application program responds to the triggering operation of the interrupt request file descriptor to determine that the issued input and output tasks of the virtual machine have been completed.

10. The method according to claim 9, characterized in that The trigger operation is a trigger operation that is automatically executed after the issued input and output tasks in the underlying file system are completed.

11. The method according to claim 8, characterized in that The block device simulation module is provided with a virtual machine monitor machine protocol command interface, and the obtaining of virtual machine monitor command data includes: The virtual machine monitor command data is obtained through the virtual machine monitor application according to the virtual machine monitor machine protocol command interface.

12. The method according to claim 4, characterized in that The establishing the second data connection according to the virtual queue after completing the first switching process includes: The virtual queue after completing the first switching process is configured as the second data connection through the virtual machine monitor application.

13. The method according to claim 6, characterized in that The establishing the first data connection according to the virtual queue after completing the third switching process includes: The virtual queue after completing the third switching process is configured as the first data connection through the virtual machine monitor application.

14. The method according to claim 2, characterized in that After disconnecting the first data connection between the block device simulation module and the virtual machine and establishing the second data connection between the virtual machine and the kernel unloading module, the method further includes: The input and output task processing function of the kernel unloading module is enabled through the virtual machine monitor application.

15. The method according to claim 3, characterized in that The determining whether the issued input and output tasks of the virtual machine have been completed includes: The virtual machine monitor application determines whether there is any running input / output task in the kernel unloading module, and when there is no running input / output task in the kernel unloading module, determines that the issued input / output task of the virtual machine has been executed.

16. The method according to claim 15, characterized in that The kernel unloading module is provided with a query interface, and determining whether there is an input and output task running in the kernel unloading module through the virtual machine monitor application comprises: The virtual machine monitor application determines whether there is an input / output task running in the kernel unloading module according to the query interface.

17. A virtual machine control device, characterized in that: The device comprises: A switch instruction response module, used to respond to the switch instruction of the input and output task acceleration function through the virtual machine monitor application, control the virtual machine to suspend operation, and determine whether the issued input and output tasks of the virtual machine have been completed; wherein the switch instruction includes any one of an on instruction and a off instruction; a data connection establishing module, used for determining the input / output task receiving end and establishing a data connection between the virtual machine and the input / output task receiving end through the virtual machine monitor application according to the switch instruction when the issued input / output task has been executed; wherein the input / output task receiving end includes a block device simulation module and a kernel unloading module; The virtual machine recovery module is used to control the virtual machine to recover through the virtual machine monitor application when the data connection has been established.

18. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the virtual machine control method according to any one of claims 1 to 16 is implemented.

19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the virtual machine control method according to any one of claims 1 to 16 is implemented.

20. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the virtual machine control method according to any one of claims 1 to 16.