Virtio-serial API: Difference between revisions
From KVM
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
|- | |- | ||
|Port discovery | |Port discovery | ||
|symlinks from <code> /dev/virtio-port/<portname> </code> to <code> /dev/vportNpn </code> as mentioned in http://www.linux-kvm.org/page/VMchannel_Requirements#Invocation and http://fedoraproject.org/wiki/Features/VirtioSerial#How_To_Test | |symlinks from <code> /dev/virtio-port/<portname> </code> to <code> /dev/vportNpn </code> as mentioned in [http://www.linux-kvm.org/page/VMchannel_Requirements#Invocation Invocation] and [http://fedoraproject.org/wiki/Features/VirtioSerial#How_To_Test How To Test] | ||
| | | | ||
|- | |- | ||
|Opening port | |Opening port | ||
|<code>open(2)</code> | |<code>open(2)</code> | ||
* Returns >= 0 on success. | * Returns >= 0 on success. | ||
* Only one open allowed at a time for a port. | * Only one open allowed at a time for a port. | ||
Line 17: | Line 17: | ||
|- | |- | ||
|Reading | |Reading | ||
|read(2) | |<code>read(2)</code> | ||
* Blocking as well as non-blocking reads available. | * Blocking as well as non-blocking reads available. | ||
* Return 0 if host is not connected. | * Return 0 if host is not connected. | ||
Line 25: | Line 25: | ||
|- | |- | ||
|Writing | |Writing | ||
|<code>write(2)</code> | |<code>write(2)</code> | ||
* Blocking as well as non-blocking. | * Blocking as well as non-blocking. | ||
* If host is not connected, write blocks or returns <code>-EAGAIN</code>. | * If host is not connected, write blocks or returns <code>-EAGAIN</code>. | ||
Line 32: | Line 32: | ||
|- | |- | ||
|Poll | |Poll | ||
|<code>poll()</code> | |<code>poll()</code> | ||
* <code>POLLIN, POLLOUT</code> with usual meaning. | * <code>POLLIN, POLLOUT</code> with usual meaning. | ||
* <code>POLLHUP</code> when host is not connected or when port or device got unplugged | * <code>POLLHUP</code> when host is not connected or when port or device got unplugged |
Revision as of 06:21, 2 September 2010
Guest API
Function | Linux guest | Windows guest |
---|---|---|
Port discovery | symlinks from /dev/virtio-port/<portname> to /dev/vportNpn as mentioned in Invocation and How To Test
|
|
Opening port | open(2)
|
|
Reading | read(2)
|
|
Writing | write(2)
|
|
Poll | poll()
| |
Asynchronous notifications | signal(7)
|
For an example of a C program that uses the virtio-serial Linux guest API, see auto-virtserial-guest.c
Host API
There's an in-qemu host API exposed by the virtio-serial code. The following is true for the in-qemu API for qemu version 0.13 and for the qemu version found in Red Hat Enterprise Linux 6.0, straight from hw/virtio-serial.h:
|
In addition to this, the VirtIOSerialPortInfo struct has a function pointer for a callback to be called when guest writes some data to the port:
|
For an example use of this API, see hw/virtio-console.c