[go: up one dir, main page]

CN106598696B - Method and device for data interaction between virtual machines - Google Patents

Method and device for data interaction between virtual machines Download PDF

Info

Publication number
CN106598696B
CN106598696B CN201610983811.7A CN201610983811A CN106598696B CN 106598696 B CN106598696 B CN 106598696B CN 201610983811 A CN201610983811 A CN 201610983811A CN 106598696 B CN106598696 B CN 106598696B
Authority
CN
China
Prior art keywords
data
virtual machine
target memory
sent
offset information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610983811.7A
Other languages
Chinese (zh)
Other versions
CN106598696A (en
Inventor
雷红海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Huawei Digital Technologies Co Ltd
Original Assignee
Beijing Huawei Digital Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Huawei Digital Technologies Co Ltd filed Critical Beijing Huawei Digital Technologies Co Ltd
Priority to CN201610983811.7A priority Critical patent/CN106598696B/en
Publication of CN106598696A publication Critical patent/CN106598696A/en
Application granted granted Critical
Publication of CN106598696B publication Critical patent/CN106598696B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention relates to the field of computers, in particular to a method and a device for data interaction between virtual machines, which aim to solve the problem of processing bottleneck possibly occurring in data transmission between the virtual machines, and the method comprises the following steps: when the first virtual machine determines that the application in the first virtual machine needs to send data to the application in the second virtual machine, determining the initial address and the data length of the data to be sent; the first virtual machine determines the identification of the target memory chip according to the identification of the second virtual machine; and the first virtual machine determines the initial copying position of the data to be sent according to the write offset information in the target memory chip, copies the data to be sent to the target memory chip according to the initial address and the data length of the data to be sent, and updates the write offset information. Therefore, the method does not depend on the existing network protocol, and the service processing between the virtual machines is accelerated.

Description

一种虚拟机之间数据交互的方法及装置A method and device for data interaction between virtual machines

技术领域technical field

本发明涉及计算机领域,尤其涉及一种虚拟机之间数据交互的方法及装置。The present invention relates to the field of computers, and in particular, to a method and device for data interaction between virtual machines.

背景技术Background technique

现有虚拟机技术大量应用在集群业务,在集群业务中各个虚拟机(virtualmachine,VM)之间会存在大量的数据交互。目前通用的做法,是基于虚拟机作为一个独立单元,虚拟机之间通过标准传输通道进行数据传输,具有标准化、易用性且兼容性好等优点。但在虚拟机之间单次业务量交互较大且虚拟机之间需要多次交互处理的场景中,如果通过标准传输通道进行数据传输,则可能出现由于到达处理瓶颈导致的应用受限或者无法应用。Existing virtual machine technologies are widely used in cluster services, and there will be a large amount of data interaction between virtual machines (virtual machines, VMs) in cluster services. The current common practice is based on the virtual machine as an independent unit, and data transmission between virtual machines is carried out through a standard transmission channel, which has the advantages of standardization, ease of use, and good compatibility. However, in a scenario where a single traffic interaction between virtual machines is large and multiple interactive processing is required between virtual machines, if data transmission is performed through a standard transmission channel, the application may be limited or unable to reach the processing bottleneck. application.

现有技术中提出了以下两种加速处理虚拟机间业务的方法:The following two methods for accelerating the processing of inter-VM services are proposed in the prior art:

方法1:高性能网络I/O框架(the fast packet I/O framework,netmap)是通过内存映射将网络缓存(buffer)映射到每个虚拟机对应的用户空间去,使虚拟机可直接操作buffer。具体的,在没有内存映射时,上层应用的数据从用户态到内核态,再到网卡驱动的缓存需要有几次拷贝。通过内存映射后,数据拷贝层次减小。数据拷贝次数减小,加速虚拟机间业务处理,提高TCP/IP协议栈的性能。netmap是基于网卡驱动转发进行加速处理的通用做法。Method 1: The high-performance network I/O framework (the fast packet I/O framework, netmap) maps the network cache (buffer) to the user space corresponding to each virtual machine through memory mapping, so that the virtual machine can directly operate the buffer . Specifically, when there is no memory mapping, the data of the upper-layer application needs to be copied several times from the user state to the kernel state, and then to the cache of the network card driver. After memory mapping, the data copy level is reduced. The number of data copies is reduced, the service processing between virtual machines is accelerated, and the performance of the TCP/IP protocol stack is improved. Netmap is a general practice for accelerated processing based on network card driver forwarding.

方法2:通过单根I/O虚拟化(Single-root I/O virtualization,SR-IOV)加速网络传输,其中,SR-IOV是根据外围部件互连专业组(Peripheral Component InterconnectSpecial Interest Group,PCI-SIG)定义的一种用于实现标准用语创建和管理本地共享的设备。它与netmap一样,也是基于网卡加速实现网络报文传输。Method 2: Accelerate network transmission through Single-root I/O virtualization (SR-IOV), wherein SR-IOV is based on the Peripheral Component Interconnect Special Interest Group (PCI-IOV) SIG) for implementing standard terminology to create and manage a device for local shares. Like netmap, it is also based on network card acceleration to realize network packet transmission.

发明内容SUMMARY OF THE INVENTION

本发明实施例的目的是提供一种虚拟机之间数据交互的方法及装置,以解决虚拟机之间进行数据传输时,可能出现的由于到达处理瓶颈而导致的应用受限或者无法应用的问题。The purpose of the embodiments of the present invention is to provide a method and apparatus for data interaction between virtual machines, so as to solve the problem that the application is limited or cannot be applied due to reaching a processing bottleneck when data transmission between virtual machines may occur. .

本发明实施例的目的是通过以下技术方案实现的:The purpose of the embodiment of the present invention is achieved through the following technical solutions:

第一方面,一种虚拟机之间数据交互的方法,包括:第一虚拟机确定第一虚拟机中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,第一虚拟机与第二虚拟机属于同一个宿主机;本发明实施例主要应用于同一宿主机内各个虚拟机进行之间进行通信的场景。进一步地,第一虚拟机根据第二虚拟机的标识确定目标内存片的标识,目标内存片是指宿主机为第一虚拟机分配的用于存储第一虚拟机发往第二虚拟机的数据的内存片,其中,宿主机为每个虚拟机都分配了对应宿主机内每个其他虚拟机的唯一内存片。第一虚拟机根据目标内存片中的写偏移信息确定待发送数据的初始拷贝位置,并根据待发送数据的起始地址和数据长度将待发送数据拷贝至目标内存片,更新写偏移信息;其中,写偏移信息用于指示目标内存片中已存储数据的写偏移,即指示了上次拷贝数据后的结束位置。因此,相比于现有技术中,基于网卡实现网络报文传输,采用本发明实施例提供的方法只需拷贝一次数据,不依赖于现有的网络协议,通过宿主机中的共享内存实现虚拟机之间的交互,加快虚拟机之间的业务处理,从而满足对虚拟机之间交互性能要求较高的场景要求。In a first aspect, a method for data interaction between virtual machines includes: when a first virtual machine determines that an application in the first virtual machine needs to send data to an application in a second virtual machine, determining a start address of the data to be sent and data length, the first virtual machine and the second virtual machine belong to the same host; the embodiment of the present invention is mainly applied to the scenario of communication between virtual machines in the same host. Further, the first virtual machine determines the identifier of the target memory slice according to the identifier of the second virtual machine, and the target memory slice refers to the data allocated by the host machine for the first virtual machine to store the data sent by the first virtual machine to the second virtual machine. A memory slice, wherein the host allocates a unique memory slice corresponding to each other virtual machine in the host for each virtual machine. The first virtual machine determines the initial copy position of the data to be sent according to the write offset information in the target memory slice, and copies the data to be sent to the target memory slice according to the start address and data length of the data to be sent, and updates the write offset information ; wherein, the write offset information is used to indicate the write offset of the data stored in the target memory slice, that is, the end position after the last copy of the data. Therefore, compared with the prior art, which implements network packet transmission based on network cards, the method provided by the embodiment of the present invention only needs to copy data once, and does not depend on the existing network protocol, and realizes virtualized virtualisation through the shared memory in the host machine. The interaction between virtual machines can be accelerated to speed up the business processing between virtual machines, so as to meet the requirements of scenarios that require high interaction performance between virtual machines.

在一种可能的实现方式中,所述目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息;所述业务负载区用于存储所述第一虚拟机发往所述第二虚拟机的数据;所述第一虚拟机根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述内存片,包括:所述第一虚拟机确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,确定在超出预设时长前所述业务负载区的剩余内存空间大小大于所述数据的数据长度时,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述业务负载区。此时,第一虚拟机等待剩余内存空间大小大于待拷贝数据的数据长度,以免出现丢包的情况。In a possible implementation manner, the target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the target memory slice, the size of the remaining space in the service load area, and the the write offset information; the service load area is used to store the data sent by the first virtual machine to the second virtual machine; the first virtual machine is based on the starting address and data length of the data to be sent Copying the to-be-sent data to the memory slice includes: when the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, determining that the size of the remaining memory space before exceeding the preset duration is determined. When the size of the remaining memory space in the service load area is greater than the data length of the data, the data to be sent is copied to the service load area according to the start address and data length of the data to be sent. At this time, the first virtual machine waits for the size of the remaining memory space to be greater than the data length of the data to be copied, so as to avoid the situation of packet loss.

在一种可能的实现方式中,还包括:所述第一虚拟机确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,所述第一虚拟机将所述待发送数据拷贝至所述业务负载区失败。此时,第一虚拟机不等待剩余空间变化,当剩余内存空间大小小于等于所述数据的数据长度时,直接丢弃数据,以免后续数据堆积,加快数据处理速度。In a possible implementation manner, the method further includes: when the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, the first virtual machine sends the data to be sent. Failed to copy data to the service load area. At this time, the first virtual machine does not wait for the remaining space to change, and when the size of the remaining memory space is less than or equal to the data length of the data, the data is directly discarded to avoid subsequent data accumulation and speed up data processing.

此外,在循环缓存管理系统中,当写偏移达到业务负载区的尾部时,即业务负载区的剩余空间大小为0,可以根据读偏移覆盖业务负载区中的内容,以实现循环缓存的利用。In addition, in the circular cache management system, when the write offset reaches the end of the service load area, that is, the remaining space in the service load area is 0, the content in the service load area can be overwritten according to the read offset to realize the circular cache. use.

第二方面、一种虚拟机之间数据交互的方法,包括:第一虚拟机检测所述第一虚拟机对应的目标内存片集合,每个目标内存片用于存储发往所述第一虚拟机的数据;所述第一虚拟机检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息读取所述第一目标内存片中的数据,并更新所述读偏移信息;其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移。因此,虚拟机可以检测到哪些虚拟机向自身发送数据,并及时根据对应内存片的读偏移信息和写偏移信息读取内存片中的数据,加快虚拟机之间的业务处理,从而满足对虚拟机之间交互性能要求较高的场景要求。A second aspect provides a method for data interaction between virtual machines, comprising: a first virtual machine detects a set of target memory slices corresponding to the first virtual machine, and each target memory slice is used for storing data sent to the first virtual machine. When the first virtual machine detects that the write offset information in the first target memory slice is updated, the first virtual machine reads all the data according to the write offset information and the read offset information in the first target memory slice. data in the first target memory slice, and update the read offset information; wherein, the write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information The shift information is used to indicate the read offset of the read data in the first target memory slice. Therefore, the virtual machine can detect which virtual machines send data to itself, and read the data in the memory slice according to the read offset information and write offset information of the corresponding memory slice in time, so as to speed up the business processing between the virtual machines, so as to meet the Scenarios that require high interaction performance between virtual machines.

此外,第一虚拟机根据第一目标内存片中的读偏移信息,获知已读取数据的读偏移,从该读取位置开始读取数据,最多可读取至写偏移信息所指示的已存储数据的写偏移,或者,第一虚拟机配置每次读取数据的预设数据读取长度,当写偏移与读偏移的差值大于等于预设数据读取长度时,读取预设数据读取长度的数据。当写偏移与读偏移的差值小于预设数据读取长度时,可以下次再执行读取。当第一虚拟机读取第一目标内存片中的数据时,需要更新读偏移信息。In addition, the first virtual machine learns the read offset of the read data according to the read offset information in the first target memory slice, starts to read the data from the read position, and can read the data up to the amount indicated by the write offset information. The write offset of the stored data, or the first virtual machine configures a preset data read length for each read data, when the difference between the write offset and the read offset is greater than or equal to the preset data read length, Read the data of the preset data read length. When the difference between the write offset and the read offset is less than the preset data read length, the read can be performed next time. When the first virtual machine reads data in the first target memory slice, the read offset information needs to be updated.

在一种可能的实现方式中,所述第一目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述第一目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息和所述读偏移信息;所述业务负载区用于存储所述第二虚拟机发往所述第一虚拟机的数据。In a possible implementation manner, the first target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the first target memory slice and the remainder of the service load area. space size, the write offset information and the read offset information; the service load area is used to store the data sent by the second virtual machine to the first virtual machine.

第三方面、一种虚拟机之间数据交互的方法,包括:宿主机分配内存空间作为待创建虚拟机的共享内存;所述宿主机创建N个虚拟机,N≥2,N为正整数;所述宿主机将所述共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片;其中,为第i个虚拟机分配的(N-1)个内存片与除所述第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数。因此,宿主机可以根据创建的虚拟机数目N为每个虚拟机分配(N-1)个内存片,以实现加快虚拟机之间的业务处理,从而满足对虚拟机之间交互性能要求较高的场景要求。A third aspect, a method for data interaction between virtual machines, comprising: a host machine allocating memory space as the shared memory of the virtual machine to be created; the host machine creating N virtual machines, N≥2, and N is a positive integer; The host machine divides the shared memory into N*(N-1) memory slices, and allocates (N-1) memory slices for each virtual machine; -1) The memory slices are in one-to-one correspondence with other (N-1) virtual machines except the i-th virtual machine, i≥1, and i is a positive integer. Therefore, the host can allocate (N-1) memory slices to each virtual machine according to the number N of virtual machines created, so as to speed up the business processing between the virtual machines, so as to meet the higher requirements on the interaction performance between the virtual machines. scene requirements.

具体的,eshare模块可以为多种逻辑处理单元的集合,提供记录(N-1)个内存片分别对应的内存地址映射、标准读写接口、读写互斥管理、读写接口封装等功能。Specifically, the eshare module can be a collection of multiple logical processing units, providing functions such as recording the memory address mapping corresponding to (N-1) memory slices, standard read and write interfaces, read and write mutual exclusion management, and read and write interface encapsulation.

在一种可能的实现方式中,所述宿主机为每个虚拟机分配(N-1)个内存片,包括:针对为第i个虚拟机分配的每个内存片,所述宿主机执行:将当前内存片对应的宿主机物理地址转换为所述当前内存片对应的宿主机虚拟地址;将所述当前内存片对应的宿主机虚拟地址转换为所述当前内存片对应的客户机物理地址;将所述当前内存片对应的客户机物理地址转换为所述当前内存片对应的客户机虚拟地址。因此,能够实现将宿主机中的共享内存映射到虚拟机的内存空间。In a possible implementation manner, the host machine allocates (N-1) memory slices to each virtual machine, including: for each memory slice allocated to the ith virtual machine, the host machine executes: Converting the host machine physical address corresponding to the current memory slice to the host machine virtual address corresponding to the current memory slice; converting the host machine virtual address corresponding to the current memory slice to the client machine physical address corresponding to the current memory slice; Convert the client physical address corresponding to the current memory slice to the client virtual address corresponding to the current memory slice. Therefore, the shared memory in the host can be mapped to the memory space of the virtual machine.

第四方面、一种虚拟机之间数据交互的装置,包括:确定单元,用于确定所述装置中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述装置与所述第二虚拟机属于同一个宿主机;分析单元,用于根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述装置分配的用于存储所述装置发往所述第二虚拟机的数据的内存片;处理单元,用于根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述目标内存片,更新所述写偏移信息;其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移。A fourth aspect, an apparatus for data interaction between virtual machines, comprising: a determination unit configured to determine a start address of data to be sent when an application in the apparatus needs to send data to an application in a second virtual machine and data length, the device and the second virtual machine belong to the same host; the analysis unit is used to determine the identifier of the target memory slice according to the identifier of the second virtual machine, and the target memory slice refers to the a memory slice allocated by the host to the device for storing data sent by the device to the second virtual machine; a processing unit, configured to determine the to-be-sent data according to write offset information in the target memory slice The initial copy position of the data, and the data to be sent is copied to the target memory slice according to the starting address and data length of the data to be sent, and the write offset information is updated; wherein, the write offset information It is used to indicate the write offset of the stored data in the target memory slice.

在一种可能的实现方式中,所述目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息;所述业务负载区用于存储所述装置发往所述第二虚拟机的数据;根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述内存片时,所述处理单元,具体用于:确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,确定在超出预设时长前所述业务负载区的剩余内存空间大小大于所述数据的数据长度时,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述业务负载区。In a possible implementation manner, the target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the target memory slice, the size of the remaining space in the service load area, and the the write offset information; the service load area is used to store the data sent by the device to the second virtual machine; according to the start address and data length of the data to be sent, the data to be sent is copied to the When the memory chip is used, the processing unit is specifically configured to: when it is determined that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, determine the remaining memory in the service load area before the preset time length is exceeded When the space size is greater than the data length of the data, the data to be sent is copied to the service load area according to the start address and data length of the data to be sent.

在一种可能的实现方式中,所述处理单元,还用于:确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,将所述待发送数据拷贝至所述业务负载区失败。In a possible implementation manner, the processing unit is further configured to: when it is determined that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, copy the data to be sent to the service Load zone failed.

第五方面、一种虚拟机之间数据交互的装置,包括:检测单元,用于检测所述装置对应的目标内存片集合,每个目标内存片用于存储发往所述装置的数据;处理单元,用于检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息读取所述第一目标内存片中的数据,并更新所述读偏移信息;其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移。A fifth aspect, an apparatus for data interaction between virtual machines, comprising: a detection unit for detecting a set of target memory slices corresponding to the apparatus, each target memory slice being used to store data sent to the apparatus; processing The unit is configured to read the first target memory slice according to the write offset information and the read offset information in the first target memory slice when it is detected that the write offset information in the first target memory slice is updated and update the read offset information; wherein, the write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information is used to indicate the The read offset of the read data in the first target memory slice is described.

在一种可能的实现方式中,所述第一目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述第一目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息和所述读偏移信息;所述业务负载区用于存储所述第二虚拟机发往所述装置的数据。In a possible implementation manner, the first target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the first target memory slice and the remainder of the service load area. space size, the write offset information and the read offset information; the service load area is used to store the data sent by the second virtual machine to the device.

第六方面、一种虚拟机之间数据交互的装置,包括:分配单元,用于分配内存空间作为待创建虚拟机的共享内存;创建单元,用于创建N个虚拟机,N≥2,N为正整数;处理单元,用于将所述共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片;其中,为第i个虚拟机分配的(N-1)个内存片与除所述第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数。A sixth aspect, an apparatus for data interaction between virtual machines, comprising: an allocation unit for allocating memory space as the shared memory of the virtual machine to be created; a creation unit for creating N virtual machines, N≥2, N is a positive integer; the processing unit is used to divide the shared memory into N*(N-1) memory slices, and allocate (N-1) memory slices to each virtual machine; wherein, is the ith virtual The (N-1) memory slices allocated by the machine are in one-to-one correspondence with other (N-1) virtual machines except the i-th virtual machine, i≥1, and i is a positive integer.

在一种可能的实现方式中,为每个虚拟机分配(N-1)个内存片时,所述处理单元,具体用于:针对为第i个虚拟机分配的每个内存片,执行:将当前内存片对应的宿主机物理地址转换为所述当前内存片对应的宿主机虚拟地址;将所述当前内存片对应的宿主机虚拟地址转换为所述当前内存片对应的客户机物理地址;将所述当前内存片对应的客户机物理地址转换为所述当前内存片对应的客户机虚拟地址。In a possible implementation manner, when (N-1) memory slices are allocated to each virtual machine, the processing unit is specifically configured to: for each memory slice allocated to the ith virtual machine, execute: Converting the host machine physical address corresponding to the current memory slice to the host machine virtual address corresponding to the current memory slice; converting the host machine virtual address corresponding to the current memory slice to the client machine physical address corresponding to the current memory slice; Convert the client physical address corresponding to the current memory slice to the client virtual address corresponding to the current memory slice.

第七方面,一种虚拟机之间数据交互的设备,包括:通信接口1001和处理器1002;所述处理器,用于:确定所述装置中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述装置与所述第二虚拟机属于同一个宿主机;根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述装置分配的用于存储所述装置发往所述第二虚拟机的数据的内存片;根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据通过所述通信接口拷贝至所述目标内存片,更新所述写偏移信息;其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移。In a seventh aspect, a device for data interaction between virtual machines, comprising: a communication interface 1001 and a processor 1002; the processor is configured to: determine that an application in the apparatus needs to send data to an application in a second virtual machine When data, determine the starting address and data length of the data to be sent, the device and the second virtual machine belong to the same host; determine the identifier of the target memory slice according to the identifier of the second virtual machine, the target A memory slice refers to a memory slice allocated by the host to the device for storing data sent by the device to the second virtual machine; the memory slice to be determined is determined according to the write offset information in the target memory slice. Send the initial copy position of the data, and copy the data to be sent to the target memory slice through the communication interface according to the starting address and data length of the data to be sent, and update the write offset information; wherein, The write offset information is used to indicate the write offset of the data stored in the target memory slice.

第八方面,一种虚拟机之间数据交互的设备,包括:通信接口和处理器;所述处理器,用于:检测所述装置对应的目标内存片集合,每个目标内存片用于存储发往所述装置的数据;检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息通过所述通信接口读取所述第一目标内存片中的数据,并更新所述读偏移信息;其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移。In an eighth aspect, a device for data interaction between virtual machines, comprising: a communication interface and a processor; the processor is configured to: detect a set of target memory slices corresponding to the device, and each target memory slice is used to store data sent to the device; when the update of the write offset information in the first target memory slice is detected, pass the communication interface according to the write offset information and the read offset information in the first target memory slice Read the data in the first target memory slice, and update the read offset information; wherein the write offset information is used to indicate the write offset of the data stored in the first target memory slice, so The read offset information is used to indicate the read offset of the read data in the first target memory chip.

第九方面,一种虚拟机之间数据交互的设备,例如宿主机,包括:通信接口、处理器、存储器;所述处理器,用于:分配所述存储器中的内存空间作为待创建虚拟机的共享内存;用于创建N个虚拟机,N≥2,N为正整数;将所述共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片;其中,为第i个虚拟机分配的(N-1)个内存片与除所述第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数;所述通信接口,用于与所述宿主机中的各个虚拟机进行通信。In a ninth aspect, a device for data interaction between virtual machines, such as a host machine, includes: a communication interface, a processor, and a memory; the processor is configured to: allocate memory space in the memory as a virtual machine to be created The shared memory is used to create N virtual machines, N≥2, N is a positive integer; the shared memory is divided into N*(N-1) memory slices, and (N-1) is allocated to each virtual machine ) memory slices; wherein, the (N-1) memory slices allocated for the i-th virtual machine correspond one-to-one with other (N-1) virtual machines except the i-th virtual machine, and i≥1 , i is a positive integer; the communication interface is used to communicate with each virtual machine in the host.

附图说明Description of drawings

图1为本发明实施例中基于KVM+qemu+guest os的框架示意图;1 is a schematic diagram of a framework based on KVM+qemu+guest os in an embodiment of the present invention;

图2为本发明实施例中宿主机侧虚拟机之间数据交互的方法概述流程图;2 is an overview flowchart of a method for data interaction between virtual machines on the host side in an embodiment of the present invention;

图3为本发明实施例中内存片的结构示意图;3 is a schematic structural diagram of a memory chip in an embodiment of the present invention;

图4为本发明实施例中虚拟机之间数据交互的方法概述流程图之一;4 is one of the overview flowcharts of the method for data interaction between virtual machines in an embodiment of the present invention;

图5为本发明实施例中虚拟机之间数据交互的方法概述流程图之二;5 is the second overview flow chart of the method for data interaction between virtual machines in an embodiment of the present invention;

图6为本发明实施例中虚拟机之间的具体交互过程示意图;6 is a schematic diagram of a specific interaction process between virtual machines in an embodiment of the present invention;

图7为本发明实施例中虚拟机之间数据交互的装置结构示意图之一;FIG. 7 is a schematic structural diagram of an apparatus for data interaction between virtual machines in an embodiment of the present invention;

图8为本发明实施例中虚拟机之间数据交互的装置结构示意图之二;8 is a second schematic structural diagram of an apparatus for data interaction between virtual machines in an embodiment of the present invention;

图9为本发明实施例中虚拟机之间数据交互的装置结构示意图之三;9 is a third schematic structural diagram of an apparatus for data interaction between virtual machines in an embodiment of the present invention;

图10为本发明实施例中虚拟机之间数据交互的设备结构示意图之一;10 is one of the schematic diagrams of device structures for data interaction between virtual machines in an embodiment of the present invention;

图11为本发明实施例中虚拟机之间数据交互的装置结构示意图之二;11 is a second schematic structural diagram of an apparatus for data interaction between virtual machines in an embodiment of the present invention;

图12为本发明实施例中虚拟机之间数据交互的装置结构示意图之三。FIG. 12 is a third schematic structural diagram of an apparatus for data interaction between virtual machines according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,并不是全部的实施例。依赖对于本身就在宿主机内构建的虚拟机,如果可以不用走网络协议栈处理,可以节省这部分的性能损失。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Dependency For the virtual machine built in the host itself, if it can be processed without going through the network protocol stack, this part of the performance loss can be saved.

Linux内核虚拟化技术目前有开放源代码虚拟机监视器(XEN)和基于内核的虚拟机(Kernel-based Virtual Machine,KVM)两个主流,基于KVM+qemu+guest os大致的框架如图1所示。一般地,在该系统最下面一层是硬件,比如各种设备(device),有cpu和mem(内存条)等。在它上面一层是操作系统(OS:operate system),其中,KVM为OS内核(kernel)的一个模块,提供虚拟机管理。快速模拟器(qemu)是一个面向完整个人计算机(personalcomputer,PC)系统的开源仿真器软件,上层各个隔离的guest os(每个guest os实际上就是一个进程)都可以通过qemu来模拟。本发明实施例的实现主要针对上述KVM+qemu+guestos(Linux系统)虚拟机系统。Linux kernel virtualization technology currently has two mainstreams: Open Source Virtual Machine Monitor (XEN) and Kernel-based Virtual Machine (KVM). The general framework based on KVM+qemu+guest os is shown in Figure 1. Show. Generally, the bottom layer of the system is hardware, such as various devices, such as cpu and mem (memory stick). The layer above it is an operating system (OS: operate system), in which KVM is a module of the OS kernel (kernel) that provides virtual machine management. Quick Emulator (qemu) is an open source emulator software for a complete personal computer (PC) system. Each isolated guest os in the upper layer (each guest os is actually a process) can be simulated by qemu. The implementation of the embodiments of the present invention is mainly aimed at the above-mentioned KVM+qemu+guestos (Linux system) virtual machine system.

下面结合附图对本发明优选的实施例进行详细说明。The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

参阅图2所示,本发明实施例提供一种虚拟机之间数据交互的方法,该方法包括:Referring to FIG. 2 , an embodiment of the present invention provides a method for data interaction between virtual machines, and the method includes:

步骤200:宿主机分配内存空间作为待创建虚拟机的共享内存。Step 200: The host allocates memory space as the shared memory of the virtual machine to be created.

步骤210:宿主机创建N个虚拟机,N≥2,N为正整数。Step 210: The host creates N virtual machines, where N≥2, and N is a positive integer.

步骤220:宿主机将共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片。Step 220: The host divides the shared memory into N*(N-1) memory slices, and allocates (N-1) memory slices to each virtual machine.

其中,为第i个虚拟机分配的(N-1)个内存片与除第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数。Among them, the (N-1) memory slices allocated for the ith virtual machine are in one-to-one correspondence with other (N-1) virtual machines except the ith virtual machine, i≥1, and i is a positive integer.

具体的,宿主机(Host)分配内存空间,作为待创建虚拟机的共享内存。假设Host通过qemu创建了N个虚拟机,则将该共享内存分为N*(N-1)个内存片。其中,每个虚拟机对应(N-1)个内存片,用于分别存储该虚拟机发往其他(N-1)个虚拟机的数据。Specifically, the host (Host) allocates memory space as the shared memory of the virtual machine to be created. Assuming that Host creates N virtual machines through qemu, the shared memory is divided into N*(N-1) memory slices. Wherein, each virtual machine corresponds to (N-1) memory slices, which are used to respectively store data sent by the virtual machine to other (N-1) virtual machines.

每个内存片的结构如图3所述,包括管理控制区和业务负载区。其中,前面一小段为管理控制区,占用较少的内存空间,用于存储内存片的标识、业务负载区的剩余内存空间大小、读偏移信息和写偏移信息。后面一大段为业务负载区,用于存放节点间的交互数据。The structure of each memory slice is described in Figure 3, including the management control area and the service load area. Among them, the first section is the management control area, which occupies less memory space and is used to store the identification of the memory slice, the remaining memory space size of the service load area, read offset information and write offset information. The latter part is the service load area, which is used to store the interactive data between nodes.

可选地,在Host通过qemu创建虚拟机时,由qemu为创建的虚拟机分配共享内存中的(N-1)个内存片,即完成将Host中的共享内存映射到虚拟机的内存空间。Optionally, when the Host creates a virtual machine through qemu, qemu allocates (N-1) memory slices in the shared memory for the created virtual machine, that is, the shared memory in the Host is mapped to the memory space of the virtual machine.

具体的,在为第i个虚拟机分配每个内存片时,Host执行:Specifically, when allocating each memory slice to the ith virtual machine, the Host executes:

将当前内存片对应的宿主机物理地址转换为当前内存片对应的宿主机虚拟地址,将当前内存片对应的宿主机虚拟地址转换为当前内存片对应的客户机物理地址,将当前内存片对应的客户机物理地址转换为当前内存片对应的客户机虚拟地址。Convert the host physical address corresponding to the current memory slice to the host virtual address corresponding to the current memory slice, convert the host virtual address corresponding to the current memory slice to the client physical address corresponding to the current memory slice, and convert the current memory slice corresponding to the guest physical address. The guest physical address is converted to the guest virtual address corresponding to the current memory slice.

此外,还需确定每个内存片的内存片标识,例如,为第i个虚拟机分配的内存片标识为ij,则该内存片的业务负载区用于存放第i个虚拟机发往第j个虚拟机的数据。内存片标识为ji,该内存片的业务负载区则用于存放第j个虚拟机发往第i个虚拟机的数据,表示为第j个虚拟机指定的内存片。这里确定内存片标识的方法只是举例说明,不做具体限定。In addition, the memory slice identifier of each memory slice needs to be determined. For example, if the memory slice identifier allocated to the i-th virtual machine is ij, the service load area of the memory slice is used to store the i-th virtual machine and send it to the j-th virtual machine. data of a virtual machine. The memory slice is identified as ji, and the service load area of the memory slice is used to store the data sent by the jth virtual machine to the ith virtual machine, which is represented as the memory slice designated by the jth virtual machine. The method for determining the memory slice identifier here is just an example, and no specific limitation is made.

在上述宿主机完成内存片的分配后,下面结合附图介绍虚拟机之间交互数据的具体过程。After the host machine completes the allocation of memory slices, the following describes the specific process of exchanging data between virtual machines with reference to the accompanying drawings.

参阅图4所示,本发明实施例提供一种虚拟机之间数据交互的方法,在发送侧,该方法包括:Referring to FIG. 4 , an embodiment of the present invention provides a method for data interaction between virtual machines. On the sending side, the method includes:

步骤400:第一虚拟机确定第一虚拟机中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,第一虚拟机与第二虚拟机属于同一个宿主机。Step 400: When the first virtual machine determines that the application in the first virtual machine needs to send data to the application in the second virtual machine, it determines the start address and data length of the data to be sent, and the first virtual machine and the second virtual machine belong to the same host.

应理解的是,本发明实施例提供的方法优化了属于同一宿主机的虚拟机之间的交互过程,针对不同宿主机中的虚拟机之间的交互仍采用现有技术中的方法。It should be understood that the method provided by the embodiment of the present invention optimizes the interaction process between virtual machines belonging to the same host, and the method in the prior art is still used for the interaction between virtual machines in different hosts.

步骤410:第一虚拟机根据第二虚拟机的标识确定目标内存片的标识,目标内存片是指宿主机为第一虚拟机分配的用于存储第一虚拟机发往第二虚拟机的数据的内存片。Step 410: The first virtual machine determines the identifier of the target memory slice according to the identifier of the second virtual machine, and the target memory slice refers to the memory allocated by the host machine for the first virtual machine to store the data sent by the first virtual machine to the second virtual machine. memory chips.

由上述宿主机为虚拟机分配内存片的过程可知,当宿主机中的虚拟机总数为N时,每个虚拟机对应(N-1)个内存片,用于分别存储该虚拟机发往其他(N-1)个虚拟机的数据。因此,当第一虚拟机中的应用确定要向第二虚拟机中的应用发送数据时,可以根据第二虚拟机的标识从当前分配的内存片确定目标内存片,即用于存储发往第二虚拟机的数据的内存片。例如,可以在虚拟机内保存一个虚拟机标识与内存片的对应关系索引表,以确定每个虚拟机对应的目标内存片。From the above process of allocating memory slices for virtual machines by the host, when the total number of virtual machines in the host is N, each virtual machine corresponds to (N-1) memory slices, which are used to store the virtual machine and send it to other Data for (N-1) virtual machines. Therefore, when the application in the first virtual machine determines to send data to the application in the second virtual machine, the target memory slice can be determined from the currently allocated memory slice according to the identifier of the second virtual machine, that is, the target memory slice is used to store data sent to the second virtual machine. Two memory slices for virtual machine data. For example, an index table of the correspondence between the virtual machine identifier and the memory slice may be stored in the virtual machine, so as to determine the target memory slice corresponding to each virtual machine.

步骤420:第一虚拟机根据目标内存片中的写偏移信息确定待发送数据的初始拷贝位置,并根据待发送数据的起始地址和数据长度将待发送数据拷贝至目标内存片,更新写偏移信息。Step 420: The first virtual machine determines the initial copy position of the data to be sent according to the write offset information in the target memory slice, and copies the data to be sent to the target memory slice according to the start address and data length of the data to be sent, and updates the write offset information.

其中,写偏移信息用于指示目标内存片中已存储数据的写偏移。The write offset information is used to indicate the write offset of the data stored in the target memory slice.

应理解的是,在循环缓存管理系统中,写偏移信息用于指示内存片中已存储数据的写偏移,用以在下次写入数据时,确定初始写入位置。因此,第一虚拟机根据写偏移信息可以获知本次写入数据的初始写入位置,即待发送数据的初始拷贝位置,然后根据待发送数据的起始位置和数据长度,将待发送数据拷贝至目标内存片中。由此可知,相比于现有技术中,基于网卡实现网络报文传输,采用本发明实施例提供的方法只需拷贝一次数据,不依赖于现有的网络协议,通过宿主机中的共享内存实现虚拟机之间的交互,加快虚拟机之间的业务处理,从而满足对虚拟机之间交互性能要求较高的场景。It should be understood that, in the circular cache management system, the write offset information is used to indicate the write offset of the data stored in the memory slice, so as to determine the initial write position when data is written next time. Therefore, the first virtual machine can know the initial write position of the data to be written this time, that is, the initial copy position of the data to be sent, according to the write offset information, and then according to the start position and data length of the data to be sent, the data to be sent Copy to the target memory slice. It can be seen from this that, compared with the prior art, which implements network message transmission based on network cards, the method provided by the embodiment of the present invention only needs to copy data once, does not depend on the existing network protocol, and uses the shared memory in the host machine. Realize the interaction between virtual machines and speed up the business processing between virtual machines, so as to meet the scenarios that require high interaction performance between virtual machines.

针对上述目标内存片(其他内存片的结构类似),内存片包括管理控制区和业务负载区,管理控制区用于存储目标内存片的标识、业务负载区的剩余空间大小,写偏移信息;业务负载区用于存储第一虚拟机发往第二虚拟机的数据;For the above-mentioned target memory slice (the structures of other memory slices are similar), the memory slice includes a management control area and a service load area, and the management control area is used to store the identifier of the target memory slice, the remaining space size of the service load area, and write offset information; The service load area is used to store data sent by the first virtual machine to the second virtual machine;

可选地,第一虚拟机根据待发送数据的起始地址和数据长度将待发送数据拷贝至内存片时,可能出现以下几种情形,包括:Optionally, when the first virtual machine copies the data to be sent to the memory slice according to the start address and data length of the data to be sent, the following situations may occur, including:

第一种情形:第一虚拟机确定业务负载区的剩余内存空间大小小于等于数据的数据长度时,确定在超出预设时长前业务负载区的剩余内存空间大小大于数据的数据长度时,根据待发送数据的起始地址和数据长度将待发送数据拷贝至业务负载区。Scenario 1: When the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, it determines that the size of the remaining memory space in the service load area is greater than the data length of the data before the preset time period exceeds the data length. The starting address and data length of the data to be sent are copied to the service load area.

第二种情形:第一虚拟机确定业务负载区的剩余内存空间大小小于等于数据的数据长度时,第一虚拟机将待发送数据拷贝至业务负载区失败。此时,在间隔预设时长后,可以重试将待发送数据拷贝至业务负载区。The second situation: when the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, the first virtual machine fails to copy the data to be sent to the service load area. In this case, after a preset time interval, it is possible to retry to copy the data to be sent to the service load area.

第一虚拟机可以调用发送接口完成上述拷贝待发送数据,当发送接口为阻塞型接口时,对应第一种情形;当发送接口为非阻塞型接口时,对应第二种情形。The first virtual machine may call the sending interface to complete the above-mentioned copying of the data to be sent. When the sending interface is a blocking interface, it corresponds to the first situation; when the sending interface is a non-blocking interface, it corresponds to the second situation.

应理解的是,在循环缓存管理系统中,当写偏移达到业务负载区的尾部时,即业务负载区的剩余空间大小为0,可以根据读偏移覆盖业务负载区中的内容,以实现循环缓存的利用。It should be understood that in the circular cache management system, when the write offset reaches the end of the service load area, that is, the remaining space in the service load area is 0, the content in the service load area can be overwritten according to the read offset to achieve Use of circular cache.

参阅图5所示,本发明实施例提供一种虚拟机之间数据交互的方法,在接收侧,该方法包括:Referring to FIG. 5, an embodiment of the present invention provides a method for data interaction between virtual machines. On the receiving side, the method includes:

步骤500:第一虚拟机检测第一虚拟机对应的目标内存片集合,每个目标内存片用于存储发往第一虚拟机的数据。Step 500: The first virtual machine detects a set of target memory slices corresponding to the first virtual machine, and each target memory slice is used to store data sent to the first virtual machine.

这里的第一虚拟机对应的目标内存片集合是指用于存储其他虚拟机发往第一虚拟机的数据的内存片的集合。例如,当宿主机中包括N个虚拟机时,第一虚拟机对应的目标内存片集合包括(N-1)个内存片。这(N-1)个内存片与除第一虚拟机外的其他(N-1)个虚拟机一一对应。The target memory slice set corresponding to the first virtual machine here refers to a set of memory slices used to store data sent by other virtual machines to the first virtual machine. For example, when the host machine includes N virtual machines, the target memory slice set corresponding to the first virtual machine includes (N-1) memory slices. The (N-1) memory slices are in one-to-one correspondence with other (N-1) virtual machines except the first virtual machine.

步骤510:第一虚拟机检测到第一目标内存片中的写偏移信息更新时,根据写偏移信息和第一目标内存片中的读偏移信息读取第一目标内存片中的数据,并更新读偏移信息。Step 510: When the first virtual machine detects that the write offset information in the first target memory slice is updated, it reads the data in the first target memory slice according to the write offset information and the read offset information in the first target memory slice , and update the read offset information.

其中,写偏移信息用于指示第一目标内存片中已存储数据的写偏移,读偏移信息用于指示第一目标内存片中已读取数据的读偏移。The write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information is used to indicate the read offset of the read data in the first target memory slice.

具体的,第一虚拟机可以检测到第一目标内存片中的写偏移信息更新时,表明第一目标内存片对应的虚拟机向第一虚拟机发送数据,使该第一目标内存片的写偏移信息更新。Specifically, when the first virtual machine detects that the write offset information in the first target memory slice is updated, it indicates that the virtual machine corresponding to the first target memory slice sends data to the first virtual machine, so that the Write offset information update.

具体的,第一虚拟机根据第一目标内存片中的读偏移信息,获知已读取数据的读偏移,从该读取位置开始读取数据,最多可读取至写偏移信息所指示的已存储数据的写偏移,或者,第一虚拟机配置每次读取数据的预设数据读取长度,当写偏移与读偏移的差值大于等于预设数据读取长度时,读取预设数据读取长度的数据。当写偏移与读偏移的差值小于预设数据读取长度时,可以下次再执行读取。当第一虚拟机读取第一目标内存片中的数据时,需要更新读偏移信息。Specifically, the first virtual machine learns the read offset of the read data according to the read offset information in the first target memory slice, starts to read the data from the read position, and can read up to the write offset information. The indicated write offset of the stored data, or the first virtual machine configures the preset data read length for each read data, when the difference between the write offset and the read offset is greater than or equal to the preset data read length , read the data of the preset data read length. When the difference between the write offset and the read offset is less than the preset data read length, the read can be performed next time. When the first virtual machine reads data in the first target memory slice, the read offset information needs to be updated.

下面以图6为例,具体说明虚拟机之间的交互过程,其中,eshare模块用于执行虚拟机之间的交互过程。每个虚拟机可以通过共享内存(eshare)模块实现向Host内的其他宿主机发送数据,和读取其他Host内虚拟机向自身发送的数据。具体的,eshare模块可以为多种逻辑处理单元的集合,提供记录(N-1)个内存片分别对应的内存地址映射、标准读写接口、读写互斥管理、读写接口封装等功能。The following takes FIG. 6 as an example to specifically describe the interaction process between virtual machines, wherein the eshare module is used to execute the interaction process between virtual machines. Each virtual machine can send data to other hosts in the host through the shared memory (eshare) module, and read the data sent by the virtual machines in other hosts to itself. Specifically, the eshare module can be a collection of multiple logical processing units, providing functions such as recording the memory address mapping corresponding to (N-1) memory slices, standard read and write interfaces, read and write mutual exclusion management, and read and write interface encapsulation.

首先,Host通过qemu创建VM_0时,为它分配(N-1)个内存片。First, when Host creates VM_0 through qemu, it allocates (N-1) memory slices to it.

针对这(N-1)个内存片将每个内存片对应的宿主机物理地址转换为对应的宿主机虚拟地址,进一步将宿主机虚拟地址转换为客户机物理地址,最后将客户机物理地址转换为客户机虚拟地址。For the (N-1) memory slices, the host physical address corresponding to each memory slice is converted into the corresponding host virtual address, the host virtual address is further converted into the guest physical address, and finally the guest physical address is converted is the virtual address of the guest.

当VM_0中的app0需要向VM_N中的appN发送数据时,确定待发送数据的起始地址和数据长度。VM_0根据VM_N的标识确定目标内存片的标识,该目标内存片为Host为VM_0分配的用于存储VM_0发往VM_N的数据。When app0 in VM_0 needs to send data to appN in VM_N, the start address and data length of the data to be sent are determined. VM_0 determines the identifier of the target memory slice according to the identifier of VM_N, where the target memory slice is allocated by the Host for VM_0 to store the data sent by VM_0 to VM_N.

进一步地,VM_0根据该目标内存片中的写偏移信息,确定待发送数据的初始拷贝位置,并根据待发送数据的起始地址和数据长度将待发送数据从该初始拷贝位置开始,将待发送数据拷贝至目标内存片的业务负载区。在数据拷贝完成后,更新写偏移信息。Further, VM_0 determines the initial copy position of the data to be sent according to the write offset information in the target memory slice, and starts the data to be sent from the initial copy position according to the start address and data length of the data to be sent, and stores the data to be sent from the initial copy position. Send data copy to the service load area of the target memory slice. After the data copy is completed, the write offset information is updated.

VM_N检测到用于存储VM_0发往VM_N的数据的内存片中的写偏移信息更新时,根据写偏移信息和该内存片中的读偏移信息读取第一目标内存片中的数据,并更新读偏移信息。When VM_N detects that the write offset information in the memory slice used to store the data sent by VM_0 to VM_N is updated, it reads the data in the first target memory slice according to the write offset information and the read offset information in the memory slice, And update the read offset information.

参阅图7所示,本发明实施例提供一种虚拟机之间数据交互的装置,包括:Referring to FIG. 7 , an embodiment of the present invention provides an apparatus for data interaction between virtual machines, including:

确定单元70,用于确定所述装置中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述装置与所述第二虚拟机属于同一个宿主机;The determining unit 70 is configured to determine the start address and data length of the data to be sent when the application in the device needs to send data to the application in the second virtual machine, the device and the second virtual machine belong to the same a host;

分析单元71,用于根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述装置分配的用于存储所述装置发往所述第二虚拟机的数据的内存片;The analysis unit 71 is configured to determine the identifier of the target memory slice according to the identifier of the second virtual machine, where the target memory slice refers to the memory allocated by the host for the device to store the device and send it to the first virtual machine. Two memory slices of virtual machine data;

处理单元72,用于根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述目标内存片,更新所述写偏移信息;The processing unit 72 is configured to determine the initial copy position of the data to be sent according to the write offset information in the target memory chip, and copy the data to be sent according to the start address and data length of the data to be sent To the target memory slice, update the write offset information;

其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移。The write offset information is used to indicate the write offset of the data stored in the target memory slice.

在一种可能的实现方式中,所述目标内存片包括管理控制区和业务负载区;In a possible implementation manner, the target memory slice includes a management control area and a service load area;

所述管理控制区用于存储所述目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息;所述业务负载区用于存储所述装置发往所述第二虚拟机的数据;The management control area is used to store the identifier of the target memory slice, the remaining space size of the service load area, and the write offset information; the service load area is used to store the data sent by the device to the second virtual machine data;

根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述内存片时,所述处理单元72,具体用于:When copying the data to be sent to the memory chip according to the start address and data length of the data to be sent, the processing unit 72 is specifically configured to:

确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,确定在超出预设时长前所述业务负载区的剩余内存空间大小大于所述数据的数据长度时,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述业务负载区。When it is determined that the size of the remaining memory space of the service load area is less than or equal to the data length of the data, when it is determined that the size of the remaining memory space of the service load area is greater than the data length of the data before exceeding the preset time length, according to the The starting address and data length of the data to be sent are copied to the service load area.

在一种可能的实现方式中,所述处理单元72,还用于:In a possible implementation manner, the processing unit 72 is further configured to:

确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,将所述待发送数据拷贝至所述业务负载区失败。When it is determined that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, it fails to copy the data to be sent to the service load area.

参阅图8所示,本发明实施例提供一种虚拟机之间数据交互的装置,包括:Referring to FIG. 8, an embodiment of the present invention provides an apparatus for data interaction between virtual machines, including:

检测单元80,用于检测所述装置对应的目标内存片集合,每个目标内存片用于存储发往所述装置的数据;A detection unit 80, configured to detect a set of target memory chips corresponding to the device, and each target memory chip is used to store data sent to the device;

处理单元81,用于检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息读取所述第一目标内存片中的数据,并更新所述读偏移信息;The processing unit 81 is configured to read the first target memory according to the write offset information and the read offset information in the first target memory slice when detecting that the write offset information in the first target memory slice is updated data in the memory slice, and update the read offset information;

其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移。The write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information is used to indicate the read offset of the read data in the first target memory slice offset.

在一种可能的实现方式中,所述第一目标内存片包括管理控制区和业务负载区;In a possible implementation manner, the first target memory slice includes a management control area and a service load area;

所述管理控制区用于存储所述第一目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息和所述读偏移信息;The management control area is used to store the identifier of the first target memory slice, the remaining space size of the service load area, the write offset information and the read offset information;

所述业务负载区用于存储所述第二虚拟机发往所述装置的数据。The service load area is used for storing data sent by the second virtual machine to the device.

参阅图9所示,本发明实施例提供一种虚拟机之间数据交互的装置,包括:Referring to FIG. 9, an embodiment of the present invention provides an apparatus for data interaction between virtual machines, including:

分配单元90,用于分配内存空间作为待创建虚拟机的共享内存;an allocation unit 90 for allocating memory space as the shared memory of the virtual machine to be created;

创建单元91,用于创建N个虚拟机,N≥2,N为正整数;A creation unit 91 is used to create N virtual machines, where N≥2, and N is a positive integer;

处理单元92,用于将所述共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片;a processing unit 92, configured to divide the shared memory into N*(N-1) memory slices, and allocate (N-1) memory slices to each virtual machine;

其中,为第i个虚拟机分配的(N-1)个内存片与除所述第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数。Among them, the (N-1) memory slices allocated for the i-th virtual machine are in one-to-one correspondence with other (N-1) virtual machines except the i-th virtual machine, i≥1, and i is a positive integer .

在一种可能的实现方式中,为每个虚拟机分配(N-1)个内存片时,所述处理单元92,具体用于:In a possible implementation manner, when (N-1) memory slices are allocated to each virtual machine, the processing unit 92 is specifically used for:

针对为第i个虚拟机分配的每个内存片,执行:For each memory slice allocated for the ith virtual machine, execute:

将当前内存片对应的宿主机物理地址转换为所述当前内存片对应的宿主机虚拟地址;Converting the physical address of the host machine corresponding to the current memory slice into the virtual address of the host machine corresponding to the current memory slice;

将所述当前内存片对应的宿主机虚拟地址转换为所述当前内存片对应的客户机物理地址;converting the virtual address of the host machine corresponding to the current memory slice to the physical address of the client computer corresponding to the current memory slice;

将所述当前内存片对应的客户机物理地址转换为所述当前内存片对应的客户机虚拟地址。Convert the client physical address corresponding to the current memory slice to the client virtual address corresponding to the current memory slice.

参阅图10所示,本发明实施例提供一种虚拟机之间数据交互的设备,包括:通信接口1001和处理器1002;Referring to FIG. 10, an embodiment of the present invention provides a device for data interaction between virtual machines, including: a communication interface 1001 and a processor 1002;

所述处理器,用于:the processor for:

确定所述装置中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述装置与所述第二虚拟机属于同一个宿主机;根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述装置分配的用于存储所述装置发往所述第二虚拟机的数据的内存片;根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据通过所述通信接口拷贝至所述目标内存片,更新所述写偏移信息;其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移。When determining that the application in the device needs to send data to the application in the second virtual machine, determine the start address and data length of the data to be sent, the device and the second virtual machine belong to the same host; The identifier of the second virtual machine determines the identifier of the target memory slice, and the target memory slice refers to the memory slice allocated by the host for the device to store the data sent by the device to the second virtual machine ; Determine the initial copy position of the data to be sent according to the write offset information in the target memory chip, and copy the data to be sent through the communication interface according to the start address and data length of the data to be sent to the target memory slice, and update the write offset information; wherein, the write offset information is used to indicate the write offset of the data stored in the target memory slice.

参阅图11所示,本发明实施例提供一种虚拟机之间数据交互的设备,包括:通信接口1101和处理器1102;Referring to FIG. 11, an embodiment of the present invention provides a device for data interaction between virtual machines, including: a communication interface 1101 and a processor 1102;

所述处理器1101,用于:The processor 1101 is used for:

检测所述装置对应的目标内存片集合,每个目标内存片用于存储发往所述装置的数据;检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息通过所述通信接口读取所述第一目标内存片中的数据,并更新所述读偏移信息;其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移。Detecting a set of target memory slices corresponding to the device, each target memory slice is used to store data sent to the device; when it is detected that the write offset information in the first target memory slice is updated, according to the write offset information and the read offset information in the first target memory slice through the communication interface to read the data in the first target memory slice, and update the read offset information; wherein, the write offset information uses In order to indicate the write offset of the data stored in the first target memory slice, the read offset information is used to indicate the read offset of the read data in the first target memory slice.

参阅图12所示,本发明实施例提供一种虚拟机之间数据交互的设备,例如宿主机,包括:通信接口1201、处理器1202、存储器1203;Referring to FIG. 12, an embodiment of the present invention provides a device for data interaction between virtual machines, such as a host, including: a communication interface 1201, a processor 1202, and a memory 1203;

所述处理器1202,用于:The processor 1202 is used for:

分配所述存储器1203中的内存空间作为待创建虚拟机的共享内存;用于创建N个虚拟机,N≥2,N为正整数;将所述共享内存分为N*(N-1)个内存片,并为每个虚拟机分配(N-1)个内存片;其中,为第i个虚拟机分配的(N-1)个内存片与除所述第i个虚拟机以外的其他(N-1)个虚拟机一一对应,i≥1,i为正整数;Allocate the memory space in the storage 1203 as the shared memory of the virtual machine to be created; for creating N virtual machines, N≥2, N is a positive integer; the shared memory is divided into N*(N-1) memory slices, and allocate (N-1) memory slices for each virtual machine; among them, the (N-1) memory slices allocated for the i-th virtual machine are different from other (N-1) memory slices except the i-th virtual machine ( N-1) virtual machines are in one-to-one correspondence, i≥1, i is a positive integer;

所述通信接口1201,用于与所述宿主机中的各个虚拟机进行通信。The communication interface 1201 is used to communicate with each virtual machine in the host.

综上所述,本发明实施例提供一种虚拟机之间数据交互的方法及装置,以解决虚拟机之间进行数据传输可能出现的处理瓶颈问题,该方法包括:第一虚拟机确定第一虚拟机中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度;第一虚拟机根据第二虚拟机的标识确定目标内存片的标识;第一虚拟机根据目标内存片中的写偏移信息确定待发送数据的初始拷贝位置,并根据待发送数据的起始地址和数据长度将待发送数据拷贝至目标内存片,更新写偏移信息。因此,相比于现有技术中,基于网卡实现网络报文传输,采用本发明实施例提供的方法只需拷贝一次数据,不依赖于现有的网络协议,通过宿主机中的共享内存实现虚拟机之间的交互,加快虚拟机之间的业务处理,从而满足对虚拟机之间交互性能要求较高的场景要求。To sum up, the embodiments of the present invention provide a method and apparatus for data interaction between virtual machines, so as to solve the processing bottleneck problem that may occur in data transmission between virtual machines. The method includes: the first virtual machine determines the first When the application in the virtual machine needs to send data to the application in the second virtual machine, it determines the starting address and data length of the data to be sent; the first virtual machine determines the identifier of the target memory slice according to the identifier of the second virtual machine; The virtual machine determines the initial copy position of the data to be sent according to the write offset information in the target memory slice, and copies the data to be sent to the target memory slice according to the start address and data length of the data to be sent, and updates the write offset information. Therefore, compared with the prior art, which implements network packet transmission based on network cards, the method provided by the embodiment of the present invention only needs to copy data once, and does not depend on the existing network protocol, and realizes virtualized virtualisation through the shared memory in the host machine. The interaction between virtual machines can be accelerated to speed up the business processing between virtual machines, so as to meet the requirements of scenarios that require high interaction performance between virtual machines.

本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。Although preferred embodiments of the present invention have been described, additional changes and modifications to these embodiments may occur to those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiment and all changes and modifications that fall within the scope of the present invention.

显然,本领域的技术人员可以对本发明实施例进行各种改动和变型而不脱离本发明实施例的精神和范围。这样,倘若本发明实施例的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present invention without departing from the spirit and scope of the embodiments of the present invention. Thus, provided that these modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (8)

1.一种虚拟机之间数据交互的方法,其特征在于,包括:1. A method for data interaction between virtual machines, comprising: 第一虚拟机确定所述第一虚拟机中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述第一虚拟机与所述第二虚拟机属于同一个宿主机;When the first virtual machine determines that the application in the first virtual machine needs to send data to the application in the second virtual machine, it determines the starting address and data length of the data to be sent, and the first virtual machine and the second virtual machine The virtual machines belong to the same host; 所述第一虚拟机根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述第一虚拟机分配的用于存储所述第一虚拟机发往所述第二虚拟机的数据的内存片;The first virtual machine determines the identifier of the target memory slice according to the identifier of the second virtual machine, and the target memory slice refers to the memory allocated by the host machine for the first virtual machine to store the first virtual machine. a memory slice of data sent by the machine to the second virtual machine; 所述第一虚拟机根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述目标内存片,更新所述写偏移信息;The first virtual machine determines the initial copy position of the data to be sent according to the write offset information in the target memory slice, and copies the data to be sent according to the start address and data length of the data to be sent To the target memory slice, update the write offset information; 其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移;Wherein, the write offset information is used to indicate the write offset of the stored data in the target memory slice; 所述目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息;所述业务负载区用于存储所述第一虚拟机发往所述第二虚拟机的数据。The target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the target memory slice, the size of the remaining space in the service load area, and the write offset information; the service The load area is used for storing data sent by the first virtual machine to the second virtual machine. 2.如权利要求1所述的方法,其特征在于,所述第一虚拟机根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述内存片,包括:2. The method of claim 1, wherein the first virtual machine copies the to-be-sent data to the memory slice according to the start address and data length of the to-be-sent data, comprising: 所述第一虚拟机确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,确定在超出预设时长前所述业务负载区的剩余内存空间大小大于所述数据的数据长度时,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述业务负载区。When the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, it is determined that the size of the remaining memory space in the service load area is larger than the data of the data before exceeding the preset time length When the length is set, the data to be sent is copied to the service load area according to the start address and data length of the data to be sent. 3.如权利要求1所述的方法,其特征在于,还包括:3. The method of claim 1, further comprising: 所述第一虚拟机确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,所述第一虚拟机将所述待发送数据拷贝至所述业务负载区失败。When the first virtual machine determines that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, the first virtual machine fails to copy the data to be sent to the service load area. 4.一种虚拟机之间数据交互的方法,其特征在于,包括:4. A method for data interaction between virtual machines, comprising: 第一虚拟机检测所述第一虚拟机对应的目标内存片集合,每个目标内存片用于存储发往所述第一虚拟机的数据;The first virtual machine detects a set of target memory slices corresponding to the first virtual machine, and each target memory slice is used to store data sent to the first virtual machine; 所述第一虚拟机检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息读取所述第一目标内存片中的数据,并更新所述读偏移信息;When the first virtual machine detects that the write offset information in the first target memory slice is updated, it reads the first target memory according to the write offset information and the read offset information in the first target memory slice data in the memory slice, and update the read offset information; 其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移;The write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information is used to indicate the read offset of the read data in the first target memory slice offset; 所述第一目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述第一目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息和所述读偏移信息;所述业务负载区用于存储第二虚拟机发往所述第一虚拟机的数据。The first target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the first target memory slice, the remaining space size of the service load area, and the write offset information. and the read offset information; the service load area is used to store the data sent by the second virtual machine to the first virtual machine. 5.一种虚拟机之间数据交互的装置,其特征在于,包括:5. A device for data interaction between virtual machines, comprising: 确定单元,用于确定所述装置中的应用需要向第二虚拟机中的应用发送数据时,确定待发送数据的起始地址和数据长度,所述装置与所述第二虚拟机属于同一个宿主机;a determining unit, configured to determine the start address and data length of the data to be sent when the application in the device needs to send data to the application in the second virtual machine, the device and the second virtual machine belong to the same host machine; 分析单元,用于根据所述第二虚拟机的标识确定目标内存片的标识,所述目标内存片是指所述宿主机为所述装置分配的用于存储所述装置发往所述第二虚拟机的数据的内存片;an analysis unit, configured to determine an identifier of a target memory slice according to an identifier of the second virtual machine, where the target memory slice refers to a location allocated by the host for the device to store the device and send it to the second virtual machine. The memory slice of the data of the virtual machine; 处理单元,用于根据所述目标内存片中的写偏移信息确定所述待发送数据的初始拷贝位置,并根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述目标内存片,更新所述写偏移信息;The processing unit is configured to determine the initial copy position of the data to be sent according to the write offset information in the target memory chip, and copy the data to be sent to For the target memory slice, update the write offset information; 其中,所述写偏移信息用于指示所述目标内存片中已存储数据的写偏移;所述目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息;所述业务负载区用于存储所述装置发往所述第二虚拟机的数据。The write offset information is used to indicate the write offset of the stored data in the target memory slice; the target memory slice includes a management control area and a service load area; the management control area is used to store the target memory slice The identifier of the memory slice, the remaining space size of the service load area, and the write offset information; the service load area is used to store the data sent by the device to the second virtual machine. 6.如权利要求5所述的装置,其特征在于,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述内存片时,所述处理单元,具体用于:6. The apparatus according to claim 5, wherein, when the data to be sent is copied to the memory chip according to the start address and data length of the data to be sent, the processing unit is specifically used for : 确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,确定在超出预设时长前所述业务负载区的剩余内存空间大小大于所述数据的数据长度时,根据所述待发送数据的起始地址和数据长度将所述待发送数据拷贝至所述业务负载区。When it is determined that the size of the remaining memory space of the service load area is less than or equal to the data length of the data, when it is determined that the size of the remaining memory space of the service load area is greater than the data length of the data before exceeding the preset time length, according to the The starting address and data length of the data to be sent are copied to the service load area. 7.如权利要求5所述的装置,其特征在于,所述处理单元,还用于:7. The apparatus of claim 5, wherein the processing unit is further configured to: 确定所述业务负载区的剩余内存空间大小小于等于所述数据的数据长度时,将所述待发送数据拷贝至所述业务负载区失败。When it is determined that the size of the remaining memory space in the service load area is less than or equal to the data length of the data, it fails to copy the data to be sent to the service load area. 8.一种虚拟机之间数据交互的装置,其特征在于,包括:8. A device for data interaction between virtual machines, comprising: 检测单元,用于检测所述装置对应的目标内存片集合,每个目标内存片用于存储发往所述装置的数据;a detection unit, configured to detect a set of target memory chips corresponding to the device, and each target memory chip is used to store data sent to the device; 处理单元,用于检测到第一目标内存片中的写偏移信息更新时,根据所述写偏移信息和所述第一目标内存片中的读偏移信息读取所述第一目标内存片中的数据,并更新所述读偏移信息;A processing unit, configured to read the first target memory according to the write offset information and the read offset information in the first target memory slice when detecting that the write offset information in the first target memory slice is updated data in the slice, and update the read offset information; 其中,所述写偏移信息用于指示所述第一目标内存片中已存储数据的写偏移,所述读偏移信息用于指示所述第一目标内存片中已读取数据的读偏移;The write offset information is used to indicate the write offset of the data stored in the first target memory slice, and the read offset information is used to indicate the read offset of the read data in the first target memory slice offset; 所述第一目标内存片包括管理控制区和业务负载区;所述管理控制区用于存储所述第一目标内存片的标识、所述业务负载区的剩余空间大小,所述写偏移信息和所述读偏移信息;所述业务负载区用于存储第二虚拟机发往所述装置的数据。The first target memory slice includes a management control area and a service load area; the management control area is used to store the identifier of the first target memory slice, the remaining space size of the service load area, and the write offset information. and the read offset information; the service load area is used to store the data sent by the second virtual machine to the device.
CN201610983811.7A 2016-11-08 2016-11-08 Method and device for data interaction between virtual machines Active CN106598696B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610983811.7A CN106598696B (en) 2016-11-08 2016-11-08 Method and device for data interaction between virtual machines

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610983811.7A CN106598696B (en) 2016-11-08 2016-11-08 Method and device for data interaction between virtual machines

Publications (2)

Publication Number Publication Date
CN106598696A CN106598696A (en) 2017-04-26
CN106598696B true CN106598696B (en) 2020-07-28

Family

ID=58590704

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610983811.7A Active CN106598696B (en) 2016-11-08 2016-11-08 Method and device for data interaction between virtual machines

Country Status (1)

Country Link
CN (1) CN106598696B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108173810B (en) * 2017-12-07 2020-10-13 新华三信息安全技术有限公司 Method and device for transmitting network data
CN108540448B (en) * 2018-03-05 2021-08-13 上海迪维欧电子设备有限公司 A kind of streaming media data transmission method
CN109213611B (en) * 2018-08-01 2021-07-02 天津字节跳动科技有限公司 Cross-process communication method, device, terminal and storage medium
CN114020421A (en) * 2021-09-26 2022-02-08 北京声智科技有限公司 Data processing method, device and equipment based on circular queue and storage medium
CN114356474B (en) * 2021-12-16 2025-02-18 西安万像电子科技有限公司 Data transmission method, first virtual machine, virtual desktop management server and system
CN114791844A (en) * 2022-04-01 2022-07-26 北京和利时系统工程有限公司 Virtualization system and high-speed communication method between virtual machines

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819564A (en) * 2009-02-26 2010-09-01 国际商业机器公司 Method and device for assisting communication between virtual machines
CN103176854A (en) * 2011-12-26 2013-06-26 腾讯科技(深圳)有限公司 A method, device and system for inter-process communication

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662777A (en) * 2012-04-28 2012-09-12 浪潮电子信息产业股份有限公司 High speed communication method between clients based on kernel-based virtual machine (KVM)
CN106020997B (en) * 2016-05-13 2019-07-16 北京红山世纪科技有限公司 A kind of method and system for data transmission between virtual machines

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819564A (en) * 2009-02-26 2010-09-01 国际商业机器公司 Method and device for assisting communication between virtual machines
CN103176854A (en) * 2011-12-26 2013-06-26 腾讯科技(深圳)有限公司 A method, device and system for inter-process communication

Also Published As

Publication number Publication date
CN106598696A (en) 2017-04-26

Similar Documents

Publication Publication Date Title
CN106598696B (en) Method and device for data interaction between virtual machines
US10768862B2 (en) Extending existing storage devices in virtualized environments
US9898430B2 (en) Tracking virtual machine memory modified by a single root I/O virtualization (SR-IOV) device
US9552233B1 (en) Virtual machine migration using free page hinting
CN107003892B (en) GPU virtualization method, apparatus, system and electronic device, computer program product
KR102047558B1 (en) Virtual disk storage techniques
CN112306624B (en) Information processing method, physical machine and PCIE device
US10303644B2 (en) Providing remote, reliant and high performance PCI express device in cloud computing environments
US8214576B2 (en) Zero copy transport for target based storage virtual appliances
US9854036B2 (en) Method for migrating memory data of virtual machine, and related apparatus and cluster system
KR102321913B1 (en) Non-volatile memory device, and memory system having the same
US10824466B2 (en) Container migration
US20180121352A1 (en) Efficient and secure direct storage device sharing in virtualized environments
US11599379B1 (en) Methods and systems for tracking a virtual memory of a virtual machine
EP3206124A1 (en) Method, apparatus and system for accessing storage device
CN106445628A (en) Virtualization method, apparatus and system
US20100070677A1 (en) System and Method for Reducing Communication Overhead Between Network Interface Controllers and Virtual Machines
CN107491354B (en) Shared memory-based communication method and device between virtual machines
US20160285970A1 (en) Network communication between virtual machine applications via direct memory access
CN103942087A (en) Virtual machine thermal migration method, related device and cluster computing system
US9483290B1 (en) Method and system for virtual machine communication
US9460009B1 (en) Logical unit creation in data storage system
US11036645B2 (en) Secure userspace networking for guests
US11635970B2 (en) Integrated network boot operating system installation leveraging hyperconverged storage
CN111506385A (en) Engine preemption and recovery

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant