# US 2019/0377593 A1 · Communication method, apparatus and system for virtual machine and host machine

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2019/0377593 A1
- Document ID: US20190377593A1
- Status: Published application
- Kind: A1
- Application number: 16/351,272
- Filed: 2019-03-12
- Published: 2019-12-12
- Earliest claimed: 2018-06-12
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science and Technology Co., Ltd.
- Inventors: Xun NI; Yongji XIE; Yu ZHANG
- Web page: https://patentgrep.com/patent/US20190377593A1

## CPC

- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 9/544: {Buffers; Shared memory; Pipes}
- G06F 9/546: {Message passing systems or structures, e.g. queues}
- G06F 2009/45579: {I/O management, e.g. providing access to device drivers or storage}
- G06F 2009/45583: {Memory management, e.g. access or allocation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the present disclosure disclose a communication method, apparatus and system for a virtual machine and a host machine. An embodiment of the communication method for a virtual machine and a host machine includes: polling a first command completion identifier queue set in a shared memory; comparing, in response to detecting an update of the first command completion identifier queue, the first command completion identifier queue with a second command completion identifier queue stored in the virtual machine to determine an identifier of a currently completed command; and updating the second command completion identifier queue based on the identifier of the currently completed command.

## Claims

### Claim 1

A communication method for a virtual machine and a host machine, the method comprising:
polling a first command completion identifier queue set in a shared memory;
comparing, in response to detecting an update of the first command completion identifier queue, the first command completion identifier queue with a second command completion identifier queue stored in the virtual machine to determine an identifier of a currently completed command; and
updating the second command completion identifier queue based on the identifier of the currently completed command.

### Claim 2 (depends on 1)

The method according to claim 1, the method further comprising:
sending an I/O port read and write request to a to-be-executed command queue, and updating a to-be-executed command identifier queue corresponding to the to-be-executed command queue, causing the host machine polling the to-be-executed command identifier queue to obtain a current to-be-executed command, and to update the first command completion identifier queue after the current to-be-executed command is executed.

### Claim 3 (depends on 1)

The method according to claim 1, the method further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.

### Claim 4 (depends on 2)

The method according to claim 2, the method further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.

### Claim 5

A communication system for a virtual machine and a host machine, the system comprising: a host machine and at least one virtual machine deployed on the host machine, wherein:
for the at least one virtual machine, the virtual machine is configured to:
poll a first command completion identifier queue set in a shared memory;
compare, in response to detecting an update of the first command completion identifier queue, the first command completion identifier queue with a second command completion identifier queue stored in the virtual machine to determine an identifier of a currently completed command; and
update the second command completion identifier queue based on the identifier of the currently completed command.

### Claim 6 (depends on 5)

The system according to claim 5, wherein the at least one virtual machine is further configured to:
send an I/O port read and write request to a to-be-executed command queue, and update a to-be-executed command identifier queue corresponding to the to-be-executed command queue.

### Claim 7 (depends on 6)

The system according to claim 6, wherein the host machine is configured to:
poll the to-be-executed command identifier queue in the shared memory;
determine, in response to detecting an update of the to-be-executed command identifier queue, from the to-be-executed command queue the I/O port read and write request as a current to-be-executed command;
send the current to-be-executed command to a hardware device to cause the hardware device to execute the current to-be-executed command; and
add, in response to receiving a command execution completion message returned by the hardware device, returned data of the current to-be-executed command to a command completion queue, and update the first command completion identifier queue.

### Claim 8 (depends on 7)

The system according to claim 7, wherein the at least one virtual machine is further configured to:
obtain returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoke a function to process the returned data.

### Claim 9

A communication apparatus for a virtual machine and a host machine, the apparatus comprising:
at least one processor; and
a memory storing instructions, wherein the instructions when executed by the at least one processor, cause the at least one processor to perform operations, the operations comprising:
polling a first command completion identifier queue set in a shared memory;
comparing, in response to detecting an update of the first command completion identifier queue, the first command completion identifier queue with a second command completion identifier queue stored in the virtual machine to determine an identifier of a currently completed command; and
updating the second command completion identifier queue based on the identifier of the currently completed command.

### Claim 10 (depends on 9)

The apparatus according to claim 9, the operations further comprising:
sending an I/O port read and write request to a to-be-executed command queue, and updating a to-be-executed command identifier queue corresponding to the to-be-executed command queue, causing the host machine polling the to-be-executed command identifier queue to obtain a current to-be-executed command, and to update the first command completion identifier queue after the current to-be-executed command is executed.

### Claim 11 (depends on 9)

The apparatus according to claim 9, the operations further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.

### Claim 12 (depends on 10)

The apparatus according to claim 10, the operations further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.

### Claim 13

A non-transitory computer readable storage medium, storing a computer program thereon, the computer program, when executed by a processor of a host machine that has at least one virtual machine deployed thereon, causes the processor to perform actions, the actions including:
polling a first command completion identifier queue set in a shared memory;
comparing, in response to detecting an update of the first command completion identifier queue, the first command completion identifier queue with a second command completion identifier queue stored in the virtual machine to determine an identifier of a currently completed command; and
updating the second command completion identifier queue based on the identifier of the currently completed command.

### Claim 14 (depends on 13)

The non-transitory computer readable storage medium according to claim 13, the actions further comprising:
sending an I/O port read and write request to a to-be-executed command queue, and updating a to-be-executed command identifier queue corresponding to the to-be-executed command queue, causing the host machine polling the to-be-executed command identifier queue to obtain a current to-be-executed command, and to update the first command completion identifier queue after the current to-be-executed command is executed.

### Claim 15 (depends on 13)

The non-transitory computer readable storage medium according to claim 13, the actions further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.

### Claim 16 (depends on 14)

The non-transitory computer readable storage medium according to claim 14, the actions further comprising:
obtaining returned data corresponding to the currently completed command from a command queue based on the identifier of the currently completed command; and
invoking a function to process the returned data.
