Method and apparatus for data interaction between virtual machine and host machine

By waking up idle data exchangers in advance and injecting interrupts during data interaction between the virtual machine and the host machine, the problems of network latency and low communication efficiency are solved, resulting in more efficient data transmission and improved business performance.

CN115469971BActive Publication Date: 2026-03-17JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing data interaction technologies between virtual machines and host machines suffer from high network latency, long communication times, and low efficiency, which affect the performance of virtual machine services.

Method used

By obtaining the last interrupt injection time, it is determined whether the time interval has reached the set threshold. If it has, the first interrupt is injected to wake up the data interaction party in advance, and the second interrupt is injected after writing the data packet for data processing. If the threshold has not been reached, the data is directly written to the data queue and the second interrupt is injected.

Benefits of technology

It reduces network latency for data interaction between the virtual machine and the host machine, lowers communication time, improves communication efficiency, and enhances the business performance of the virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115469971B_ABST
    Figure CN115469971B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for data interaction between a virtual machine and a host computer, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: in response to a data interaction instruction of a data interaction party, obtaining a last interruption injection time; in the case that a time interval between the last interruption injection time and a current time reaches a set threshold, injecting a first interruption to the data interaction party, the first interruption being used for waking up the data interaction party; writing a data packet into a data queue of a virtual device, and injecting a second interruption to the data interaction party, the second interruption being used for notifying the data interaction party to perform data processing. The embodiment reduces network time delay of data interaction between the virtual machine and the host computer, reduces communication time consumption, improves communication efficiency, and improves service performance of the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for data interaction between a virtual machine and a host machine. Background Technology

[0002] In host-based network virtualization scenarios, Virtio (virtual I / O, a specification and implementation for communication between virtual machines and the host machine in a virtual environment) technology is generally used for front-end and back-end communication. The front-end refers to the virtual network interface driver (VIT) in the virtual machine, and the back-end is the virtual network interface device (VIT) in the host machine. The front-end and back-end use a shared-memory virtio ring queue for data exchange: one end sequentially writes data packets to the ring queue, then notifies the other end of a data packet to be processed by injecting an interrupt. The other end is then asynchronously awakened and prepared to receive packets, reading them from the ring queue in a first-in, first-out (FIFO) manner.

[0003] In the process of realizing this invention, the inventors discovered at least the following problems in the prior art:

[0004] Existing technologies for data interaction between virtual machines and host machines suffer from significant network latency, resulting in long communication times and low efficiency, which negatively impacts the performance of virtual machine services. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a method and apparatus for data interaction between a virtual machine and a host machine, which can reduce network latency for data interaction between the virtual machine and the host machine, reduce communication time, improve communication efficiency, and enhance the service performance of the virtual machine.

[0006] To achieve the above objectives, according to one aspect of the present invention, a method for data interaction between a virtual machine and a host machine is provided, comprising:

[0007] In response to data interaction instructions from the data interaction party, obtain the last interruption injection time;

[0008] If the time interval between the last interrupt injection time and the current time reaches a set threshold, a first interrupt is injected into the data interaction party, and the first interrupt is used to wake up the data interaction party.

[0009] The data packet is written into the data queue of the virtual device, and a second interrupt is injected into the data interaction party. The second interrupt is used to notify the data interaction party to perform data processing.

[0010] Optionally, the method further includes: if the time interval between the last interrupt injection time and the current time does not reach a set threshold, directly writing the data packet into the data queue of the virtual device and injecting the second interrupt into the data interaction party.

[0011] Optionally, after injecting the second interrupt into the data interaction party, the method further includes: recording the injection time of the second interrupt and updating the previous interrupt injection time using the injection time of the second interrupt.

[0012] Optionally, the injection time of the second interrupt is the time when the second interrupt injection begins or the time when the second interrupt injection ends.

[0013] According to another aspect of the present invention, an apparatus for data interaction between a virtual machine and a host machine is provided, comprising:

[0014] The interrupt information acquisition module is used to obtain the last interrupt injection time in response to data interaction instructions from the data interaction party.

[0015] The first interrupt injection module is used to inject a first interrupt into the data interaction party when the time interval between the last interrupt injection time and the current time reaches a set threshold. The first interrupt is used to wake up the data interaction party.

[0016] The second interrupt injection module is used to write data packets into the data queue of the virtual device and inject a second interrupt into the data interaction party. The second interrupt is used to notify the data interaction party to perform data processing.

[0017] Optionally, the device further includes an interrupt injection notification module, used to: directly write the data packet into the data queue of the virtual device and inject the second interrupt into the data interaction party if the time interval between the last interrupt injection time and the current time does not reach a set threshold.

[0018] Optionally, the device further includes an injection time update module, configured to: after injecting a second interrupt into the data interaction party, record the injection time of the second interrupt, and update the previous interrupt injection time using the injection time of the second interrupt.

[0019] Optionally, the injection time of the second interrupt is the time when the second interrupt injection begins or the time when the second interrupt injection ends.

[0020] According to another aspect of the present invention, an electronic device for data interaction between a virtual machine and a host machine is provided, comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for data interaction between a virtual machine and a host machine provided in the embodiments of the present invention.

[0021] According to another aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method for data interaction between a virtual machine and a host machine provided in the embodiments of the present invention.

[0022] One embodiment of the above invention has the following advantages or beneficial effects: by responding to the data interaction command of the data interaction party, obtaining the last interrupt injection time; when the time interval between the last interrupt injection time and the current time reaches a set threshold, injecting a first interrupt into the data interaction party, the first interrupt is used to wake up the data interaction party; writing data packets into the data queue of the virtual device and injecting a second interrupt into the data interaction party, the second interrupt is used to notify the data interaction party to perform data processing, the technical solution reduces the network latency of data interaction between the virtual machine and the host machine by waking up the idle data interaction party in advance, thereby reducing communication time, improving communication efficiency, and enhancing the service performance of the virtual machine.

[0023] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0024] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0025] Figure 1 This is a schematic diagram illustrating the implementation principle of communication between the virtual machine and the host machine;

[0026] Figure 2 This is a schematic diagram illustrating the main steps of a method for data interaction between a virtual machine and a host machine according to an embodiment of the present invention.

[0027] Figure 3 This is a comparative diagram showing the latency required by existing technologies and the latency required by embodiments of the present invention;

[0028] Figure 4 This is a schematic diagram of the main modules of a device for data interaction between a virtual machine and a host machine according to an embodiment of the present invention;

[0029] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0030] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0031] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0032] The acquisition, storage, use, and processing of data in the technical solution of this invention all comply with the relevant provisions of national laws and regulations.

[0033] Figure 1 This is a schematic diagram illustrating the implementation principle of communication between the virtual machine and the host machine. For example... Figure 1 As shown, in a host-based network virtualization scenario, the virtual network interface driver (VIT) in the virtual machine and the virtual network interface device (VIT) on the host machine use a shared-memory VIT ring queue for data exchange. Here, the ring is a first-in, first-out (FIFO) queue.

[0034] Figure 2 This is a schematic diagram illustrating the main steps of a method for data interaction between a virtual machine and a host machine according to an embodiment of the present invention. The method for data interaction between a virtual machine and a host machine according to this embodiment of the present invention can be executed on either the virtual machine or the host machine; accordingly, the other party is the data interaction party. Figure 2 As shown, the method for data interaction between the virtual machine and the host machine in this embodiment of the invention mainly includes the following steps S201 to S203.

[0035] Step S201: In response to the data interaction command from the data interaction party, obtain the last interrupt injection time. Since the process of data interaction between the virtual machine and the host machine is the same when interacting with another party, in this embodiment of the invention, if the party currently sending data is a virtual machine, then the data interaction party is the host machine; if the party currently sending data is the host machine, then the data interaction party is the virtual machine. For ease of description, the party currently sending data is referred to as the current party. If the current party wants to interact with the data interaction party, in response to the data interaction command from the data interaction party, the current party will first obtain the last interrupt injection time when it last interacted with the data interaction party. An interrupt refers to the automatic stopping of the running program and the switching to a program to handle the new situation when certain unexpected situations occur during computer operation, after which the machine returns to the originally suspended program to continue running. In this embodiment of the invention, the interrupt is used to remind or notify the data interaction party.

[0036] Step S202: If the time interval between the last interrupt injection time and the current time reaches a set threshold, a first interrupt is injected into the data interaction party. The first interrupt is used to wake up the data interaction party. In the embodiments of the present invention, the interrupt injection time is recorded after each data interaction with the data interaction party, so that when data interaction with the data interaction party is performed again, it can be determined whether the data interaction party needs to be woken up in advance based on the time interval between the last interrupt injection time and the current time. A process has multiple states during operation; when it transitions from a waiting state to a ready state, it is called being woken up.

[0037] Specifically, if the time interval between the last interrupt injection and the current time reaches a set threshold, it indicates that the data interaction between the current party and the data interaction party is not frequent, and the data interaction party is in a relatively idle state. Therefore, the data interaction party can be woken up in advance to enable data processing as soon as possible, reduce network latency between the virtual machine and the host machine, and improve communication efficiency. This threshold can be flexibly set according to business needs, for example, it can be set to 50μs.

[0038] Step S203: Write the data packet into the data queue of the virtual device and inject a second interrupt into the data interaction party. The second interrupt is used to notify the data interaction party to process the data. After injecting the first interrupt into the data interaction party, the front party writes the data packet to be transmitted into the virtio ring, and after writing is completed, injects the second interrupt into the data interaction party again to notify the data interaction party to process the data. In one embodiment of the present invention, the first interrupt and the second interrupt can be different interrupts, implemented through different interfaces to express different semantic functions. For example, the first interrupt is used to remind the data interaction party that there is a data packet to process, and the second interrupt is used to remind the data interaction party that the data packet has been sent and should be processed. Correspondingly, in another embodiment, the first interrupt and the second interrupt can also be the same interrupt, implemented through the same interface, expressing the same semantic function, that is, both are used to remind the data interaction party that there is a data packet to process. In specific implementation, it can be flexibly set according to business needs.

[0039] According to another embodiment of the present invention, the method for data interaction between the virtual machine and the host machine may further include: if the time interval between the last interrupt injection time and the current time does not reach a set threshold, directly writing the data packet into the data queue of the virtual device and injecting a second interrupt into the data interaction party. If the time interval between the last interrupt injection time and the current time does not reach the set threshold, it indicates that the data interaction between the current party and the data interaction party is relatively frequent, and the data interaction party is in a relatively busy state. In this case, there is no need to wake up the data interaction party in advance; the data can be directly written into the data queue and then the interrupt can be injected.

[0040] According to an embodiment of the present invention, after injecting a second interrupt into the data interaction party, the method further includes: recording the injection time of the second interrupt and updating the previous interrupt injection time using the injection time of the second interrupt. After each data interaction between the current end and the data interaction party, the injection time of the second interrupt needs to be recorded to update the previous interrupt injection time, so that the interval between two data interactions can be determined during the next data interaction. Since the embodiments of the present invention send the second interrupt again after prematurely waking up the data interaction party, this will increase the execution time of the current end. By determining the interval between two data interactions, premature waking up can be performed only on idle data interaction parties, thereby minimizing the performance impact on the current end.

[0041] According to an embodiment of the present invention, the injection time of the second interrupt is either the start time of the second interrupt injection or the end time of the second interrupt injection. In specific implementation, the time can be flexibly selected as needed.

[0042] Figure 3 This is a comparative diagram showing the latency required by existing technologies and the latency required by embodiments of the present invention. For example... Figure 3 As shown, taking data transmission from a backend located on the host machine to a frontend located on a virtual machine as an example, the general process of the backend sending data packets to the frontend in the prior art is as follows ( Figure 3 As shown in (a) in the diagram: (1) The backend writes (1-N) data packets to the virtio ring, which takes time T1; (2) The backend injects an interrupt into the frontend, which takes time T2, to notify the frontend that there are data packets that need to be processed; (3) The frontend is asynchronously woken up and prepares to receive data packets, which takes time T3. Therefore, the network latency required for one data interaction in the prior art is (T1+T2+T3).

[0043] According to an embodiment of the present invention, when the time interval between the last interruption injection time and the current time reaches a set threshold, the general process of the backend sending data packets to the frontend is as follows: Figure 3 As shown in (b) in step (1), before writing data to the data queue virtio ring, the backend injects the first interrupt in advance, which takes time T2, to wake up the frontend in advance; (2) the backend writes (1-N) data packets to the virtio ring, which takes time T1; (3) the backend injects the second interrupt, which takes time T2, to notify the frontend that there are data packets that need to be processed, and records the time of the second interrupt injection; (4) the frontend is asynchronously woken up and prepares to receive data packets, which takes time T3. Since the backend injects an extra interrupt in advance in step (1), the frontend receives data packets in advance in step (4). Therefore, the network latency required for one data interaction is (T2+T3).

[0044] In comparison, the network latency required for a single data interaction in this embodiment of the invention is less than that required for a single data interaction in the prior art. Furthermore, if the time interval between the last interrupt injection time and the current time does not reach a set threshold, the network latency required for a single data interaction is the same as that in the prior art. Therefore, overall, the technical solution of this embodiment of the invention can reduce the network latency for data interaction between the virtual machine and the host machine, reduce communication time, improve communication efficiency, and enhance the service performance of the virtual machine.

[0045] According to the technical solution of this invention, although injecting an additional interrupt in advance will increase the backend execution time, by comparing the time interval between the last interrupt injection time and the current time with a set threshold, the situation of injecting interrupts in advance can be limited, thus reducing the impact and achieving the goal of reducing network latency when interacting with idle virtual machines. Tests show that the average latency can be reduced by approximately 10%.

[0046] Figure 4 This is a schematic diagram of the main modules of a device for data interaction between a virtual machine and a host machine according to an embodiment of the present invention. Figure 4 As shown, the device 400 for data interaction between the virtual machine and the host machine in this embodiment of the invention mainly includes an interrupt information acquisition module 401, a first interrupt injection module 402, and a second interrupt injection module 403.

[0047] Interrupt information acquisition module 401 is used to acquire the last interrupt injection time in response to data interaction instructions from the data interaction party;

[0048] The first interrupt injection module 402 is used to inject a first interrupt into the data interaction party when the time interval between the last interrupt injection time and the current time reaches a set threshold. The first interrupt is used to wake up the data interaction party.

[0049] The second interrupt injection module 403 is used to write data packets into the data queue of the virtual device and inject a second interrupt into the data interaction party. The second interrupt is used to notify the data interaction party to perform data processing.

[0050] According to an embodiment of the present invention, the device 400 for data interaction between the virtual machine and the host machine may further include an interrupt injection notification module (not shown in the figure), which is used to: directly write the data packet into the data queue of the virtual device and inject the second interrupt into the data interaction party when the time interval between the last interrupt injection time and the current time does not reach a set threshold.

[0051] According to another embodiment of the present invention, the apparatus 400 for data interaction between the virtual machine and the host machine may further include an injection time update module (not shown in the figure), which is used to: after injecting a second interrupt into the data interaction party, record the injection time of the second interrupt, and update the previous interrupt injection time using the injection time of the second interrupt.

[0052] According to another embodiment of the present invention, the injection time of the second interrupt is the time when the second interrupt injection begins or the time when the second interrupt injection ends.

[0053] According to the technical solution of the present invention, by responding to the data interaction instruction with the data interaction party, obtaining the last interrupt injection time; when the time interval between the last interrupt injection time and the current time reaches a set threshold, injecting a first interrupt into the data interaction party, the first interrupt is used to wake up the data interaction party; writing data packets into the data queue of the virtual device and injecting a second interrupt into the data interaction party, the second interrupt is used to notify the data interaction party to perform data processing, the technical solution reduces the network latency of data interaction between the virtual machine and the host machine, reduces communication time, improves communication efficiency, and enhances the service performance of the virtual machine by waking up the idle data interaction party in advance.

[0054] Figure 5 An exemplary system architecture 500 is shown, which can be applied to a method or apparatus for data interaction between a virtual machine and a host machine according to embodiments of the present invention.

[0055] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0056] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications, such as data processing applications and data interaction applications, can be installed on terminal devices 501, 502, and 503 (for example only).

[0057] Terminal devices 501, 502, and 503 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0058] Server 505 can be a server providing various services, such as a backend management server supporting websites browsed by users using terminal devices 501, 502, and 503 (for example only). The backend management server can retrieve the last interrupt injection time from received data interaction instructions or requests; if the time interval between the last interrupt injection time and the current time reaches a set threshold, it injects a first interrupt into the data interaction party, which is used to wake up the data interaction party; it writes data packets into the data queue of the virtual device and injects a second interrupt into the data interaction party, which is used to notify the data interaction party to perform data processing and other processing, and feeds back the processing result (e.g., data interaction result – for example only) to the terminal device.

[0059] It should be noted that the method for data interaction between the virtual machine and the host machine provided in this embodiment of the invention is generally executed by the server 505, and correspondingly, the device for data interaction between the virtual machine and the host machine is generally set in the server 505.

[0060] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0061] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing terminal devices or servers of the present invention. Figure 6 The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0062] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0063] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0064] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.

[0065] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0066] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0067] The units or modules described in the embodiments of the present invention can be implemented in software or hardware. The described units or modules can also be located in a processor; for example, a processor can be described as including an interrupt information acquisition module, a first interrupt injection module, and a second interrupt injection module. The names of these units or modules do not necessarily limit the specific unit or module itself; for example, the interrupt information acquisition module can also be described as "a module for acquiring the last interrupt injection time in response to a data interaction instruction from a data interaction party."

[0068] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs that, when executed by the device, cause the device to: in response to a data interaction instruction from a data interaction party, acquire the last interrupt injection time; if the time interval between the last interrupt injection time and the current time reaches a set threshold, inject a first interrupt into the data interaction party, the first interrupt being used to wake up the data interaction party; write a data packet into the data queue of a virtual device, and inject a second interrupt into the data interaction party, the second interrupt being used to notify the data interaction party to perform data processing.

[0069] According to the technical solution of the present invention, by responding to the data interaction instruction with the data interaction party, obtaining the last interrupt injection time; when the time interval between the last interrupt injection time and the current time reaches a set threshold, injecting a first interrupt into the data interaction party, the first interrupt is used to wake up the data interaction party; writing data packets into the data queue of the virtual device and injecting a second interrupt into the data interaction party, the second interrupt is used to notify the data interaction party to perform data processing, the technical solution reduces the network latency of data interaction between the virtual machine and the host machine, reduces communication time, improves communication efficiency, and enhances the service performance of the virtual machine by waking up the idle data interaction party in advance.

[0070] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method for data interaction between a virtual machine and a host machine, characterized in that, The method comprises: in response to a data interaction instruction of a data interaction party, obtaining a last interrupt injection time, the last interrupt injection time being a time when a second interrupt is injected last time by the data interaction; in a case where a time interval between the last interrupt injection time and a current time reaches a set threshold, injecting a first interrupt to the data interaction party, the first interrupt being used to wake up the data interaction party; writing a data packet into a data queue of a virtual device, and injecting a second interrupt to the data interaction party, the second interrupt being used to inform the data interaction party to process data, the data queue of the virtual device being a virtual data queue of a shared memory used by a virtual machine and a host.

2. The method of claim 1, wherein, The method further comprises: in a case where the time interval between the last interrupt injection time and the current time does not reach the set threshold, directly writing the data packet into the data queue of the virtual device, and injecting the second interrupt to the data interaction party.

3. The method according to claim 1 or 2, characterized in that, After injecting the second interrupt to the data interaction party, the method further comprises: recording an injection time of the second interrupt, and updating the last interrupt injection time by using the injection time of the second interrupt.

4. The method of claim 3, wherein, The injection time of the second interrupt is a time when the second interrupt starts to be injected or a time when the injection of the second interrupt ends.

5. An apparatus for data interaction between a virtual machine and a host machine, the apparatus comprising: The apparatus comprises: an interrupt information obtaining module, configured to obtain a last interrupt injection time in response to a data interaction instruction of a data interaction party, the last interrupt injection time being a time when a second interrupt is injected last time by the data interaction; a first interrupt injecting module, configured to inject a first interrupt to the data interaction party in a case where a time interval between the last interrupt injection time and a current time reaches a set threshold, the first interrupt being used to wake up the data interaction party; a second interrupt injecting module, configured to write a data packet into a data queue of a virtual device, and inject a second interrupt to the data interaction party, the second interrupt being used to inform the data interaction party to process data, the data queue of the virtual device being a virtual data queue of a shared memory used by a virtual machine and a host.

6. The apparatus of claim 5, wherein, The apparatus further comprises an interrupt injection informing module, configured to: in a case where the time interval between the last interrupt injection time and the current time does not reach the set threshold, directly write the data packet into the data queue of the virtual device, and inject the second interrupt to the data interaction party.

7. The apparatus of claim 5 or 6, wherein, The apparatus further comprises an injection time updating module, configured to: after injecting the second interrupt to the data interaction party, record an injection time of the second interrupt, and update the last interrupt injection time by using the injection time of the second interrupt.

8. The apparatus of claim 7, wherein, The injection time of the second interrupt is a time when the second interrupt starts to be injected or a time when the injection of the second interrupt ends.

9. An electronic device, comprising: The apparatus comprises: one or more processors; a storage apparatus configured to store one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-4.

10. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Communication method and device used for virtual machine and host and system

    CN108845863A

  • Communication method and device between virtual machines, physical host and medium

    CN112905304A