some device emulation documentation cleanup
cover some device emulation documentation cleanup
Hi,
This series attempts to improve our documentation by:
- grouping various device emulation documentation in one place
- writing a preamble that explains concepts
- writing a section on vhost-user
Alex Bennée (2):
docs: collect the disparate device emulation docs into one section
docs: add a section on the generalities of vhost-user
docs/interop/vhost-user.rst | 4 +-
docs/system/device-emulation.rst | 79 +++++++++++++++++++++++
docs/system/{ => devices}/ivshmem.rst | 0
docs/system/{ => devices}/net.rst | 0
docs/system/{ => devices}/nvme.rst | 0
docs/system/{ => devices}/usb.rst | 0
docs/system/devices/vhost-user.rst | 57 ++++++++++++++++
docs/system/{ => devices}/virtio-pmem.rst | 0
docs/system/index.rst | 6 +-
9 files changed, 140 insertions(+), 6 deletions(-)
create mode 100644 docs/system/device-emulation.rst
rename docs/system/{ => devices}/ivshmem.rst (100%)
rename docs/system/{ => devices}/net.rst (100%)
rename docs/system/{ => devices}/nvme.rst (100%)
rename docs/system/{ => devices}/usb.rst (100%)
create mode 100644 docs/system/devices/vhost-user.rst
rename docs/system/{ => devices}/virtio-pmem.rst (100%)Signature · 1 line
2.20.1
PATCH 1/2 docs: collect the disparate device emulation docs into one section
While we are at it add a brief preamble that explains some of the common concepts in QEMU's device emulation which will hopefully lead to less confusing about our dizzying command line options.
---
docs/system/device-emulation.rst | 78 +++++++++++++++++++++++
docs/system/{ => devices}/ivshmem.rst | 0
docs/system/{ => devices}/net.rst | 0
docs/system/{ => devices}/nvme.rst | 0
docs/system/{ => devices}/usb.rst | 0
docs/system/{ => devices}/virtio-pmem.rst | 0
docs/system/index.rst | 6 +-
7 files changed, 79 insertions(+), 5 deletions(-)
create mode 100644 docs/system/device-emulation.rst
rename docs/system/{ => devices}/ivshmem.rst (100%)
rename docs/system/{ => devices}/net.rst (100%)
rename docs/system/{ => devices}/nvme.rst (100%)
rename docs/system/{ => devices}/usb.rst (100%)
rename docs/system/{ => devices}/virtio-pmem.rst (100%)docs/system/device-emulation.rst new file +78 -0
@@ -0,0 +1,78 @@ +.. _device-emulation: + +Device Emulation +---------------- + +QEMU supports the emulation of a large number of devices from +peripherals such network cards and USB devices to integrated systems +on a chip (SoCs). Configuration of these is often a source of +confusion so it helps to have an understanding of some of the terms +used to describes devices within QEMU. + +Common Terms +~~~~~~~~~~~~ + +Device Front End +================ + +A device front end is how a device is presented to the guest. The type +of device presented should match the hardware that the guest operating +system is expecting to see. All devices can be specified with the +``--device`` command line option. Running QEMU with the command line +options ``--device help`` will list all devices it is aware of. Using +the command line ``--device foo,help`` will list the additional +configuration options available for that device. + +A front end is often paired with a back end, which describes how the +host's resources are used in the emulation. + +Device Buses +============ + +All devices exist on a BUS. Depending on the machine model you choose +(``-M foo``) a number of buses will have been automatically created. +In most cases the BUS a device is attached to can be inferred, for +example PCI devices are generally automatically allocated to the next +free slot of the PCI bus. However in complicated configurations you +can explicitly specify what bus a device is attached to and its +address. Some devices, for example a PCI SCSI host controller, will +add an additional bus to the system that other devices can be attached +to. + +Device Back End +=============== + +The back end describes how the data from the emulated device will be +processed by QEMU. The configuration of the back end is usually +specific to the class of device being emulated. For example serial +devices will be backed by a ``--chardev`` which can redirect the data +to a file or socket or some other system. Storage devices are handled +by ``--blockdev`` which will specify how blocks are handled, for +example being stored in a qcow2 file or accessing a raw host disk +partition. Back ends can sometimes be stacked to implement features +like snapshots. + +While the choice of back end is generally transparent to the guest +there are cases where features will not be reported to the guest if +the back end is unable to support it. + +Device Pass Through +=================== + +Device pass through is where the device is actually given access to +the underlying hardware. This can be as simple as exposing a single +USB device on the host system to the guest or dedicating a video card +in a PCI slot to the exclusive use of the guest. + + +Emulated Devices +~~~~~~~~~~~~~~~~ + +.. toctree:: + :maxdepth: 1 + + devices/ivshmem.rst + devices/net.rst + devices/nvme.rst + devices/usb.rst + devices/virtio-pmem.rst
docs/system/devices/ivshmem.rst renamed from docs/system/ivshmem.rst +0 -0
docs/system/devices/net.rst renamed from docs/system/net.rst +0 -0
docs/system/devices/nvme.rst renamed from docs/system/nvme.rst +0 -0
docs/system/devices/usb.rst renamed from docs/system/usb.rst +0 -0
docs/system/devices/virtio-pmem.rst renamed from docs/system/virtio-pmem.rst +0 -0
docs/system/index.rst +1 -5
@@ -16,15 +16,12 @@ Contents: quickstart invocation + device-emulation keys mux-chardev monitor images - net virtio-net-failover - usb - nvme - ivshmem linuxboot generic-loader guest-loader
@@ -35,7 +32,6 @@ Contents: gdb managed-startup cpu-hotplug - virtio-pmem pr-manager targets security
Signature · 1 line
2.20.1
PATCH 2/2 docs: add a section on the generalities of vhost-user
In reply to Alex BennéeWhile we do mention some of this stuff in the various daemons and manuals the subtleties of the socket and memory sharing are sometimes missed. This document attempts to give some background on vhost-user daemons in general terms.
--- docs/interop/vhost-user.rst | 4 ++- docs/system/device-emulation.rst | 1 + docs/system/devices/vhost-user.rst | 57 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user.rst
docs/interop/vhost-user.rst +3 -1
@@ -1,3 +1,5 @@ +.. _vhost_user_proto: + =================== Vhost-user Protocol ===================
@@ -6,7 +8,7 @@ Vhost-user Protocol :Licence: This work is licensed under the terms of the GNU GPL, version 2 or later. See the COPYING file in the top-level directory. - + .. contents:: Table of Contents Introduction
docs/system/device-emulation.rst +1 -0
@@ -75,4 +75,5 @@ Emulated Devices devices/net.rst devices/nvme.rst devices/usb.rst + devices/vhost-user.rst devices/virtio-pmem.rst
docs/system/devices/vhost-user.rst new file +57 -0
57 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v1 2/2] docs: add a section on the generalities of vhost-user
Quoted 65 lines · Alex Bennée
While we do mention some of this stuff in the various daemons and manuals the subtleties of the socket and memory sharing are sometimes missed. This document attempts to give some background on vhost-user daemons in general terms.
Signed-off-by Alex Bennée <[email protected]>Cc Stefan Hajnoczi <[email protected]>--- docs/interop/vhost-user.rst | 4 ++- docs/system/device-emulation.rst | 1 + docs/system/devices/vhost-user.rst | 57 ++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user.rstdocs/interop/vhost-user.rst +3
-1@@ -1,3 +1,5 @@ +.. _vhost_user_proto: + =================== Vhost-user Protocol ===================@@ -6,7 +8,7 @@ Vhost-user Protocol :Licence: This work is licensed under the terms of the GNU GPL, version 2 or later. See the COPYING file in the top-level directory. - + .. contents:: Table of Contents Introductiondocs/system/device-emulation.rst +1
-0@@ -75,4 +75,5 @@ Emulated Devices devices/net.rst devices/nvme.rst devices/usb.rst + devices/vhost-user.rst devices/virtio-pmem.rstdocs/system/devices/vhost-user.rst new file +16
-0@@ -0,0 +1,57 @@ +.. _vhost_user: + +vhost-user back ends +-------------------- + +vhost-user back ends are way to service the request of VirtIO devices +outside of QEMU itself. To do this there are a number of things +required. + +vhost-user device +=================== + +These are simple stub devices that ensure the VirtIO device is visible +to the guest. The code is mostly boilerplate although each device has +a ``chardev`` option which specifies the ID of the ``--chardev`` +device that connects via a socket to the vhost-user *daemon*.
docs/system/devices/vhost-user.rst line 26
Quoted 10 lines
docs/system/devices/vhost-user.rst new file +10
-0+ +vhost-user daemon +================= + +This is a separate process that is connected to by QEMU via a socket +following the :ref:`vhost_user_proto`. There are a number of daemons +that can be built when enabled by the project although any daemon that +meets the specification for a given device can be used. The daemon +will open a socket and *listen* for a connection from QEMU at which +point the protocol will start its negotiation.
I suggest dropping this line because it's more complicated and possibly confusing at this point: vhost-user daemons can either listen or they can connect (i.e. QEMU is the one that listens). I think both directions were supported because they were convenient in different situations.
docs/system/devices/vhost-user.rst line 33
Quoted 7 lines
docs/system/devices/vhost-user.rst new file +7
-0+ +Shared memory object +==================== + +In order for the daemon to access the VirtIO queues to process the +requests it needs access to the guest's address space. This is +achieved via the ``memory-backend-file`` object. A reference to a
``memory-backend-file`` or ``memory-backend-memfd`` objects.
(memory-backend-ram doesn't have an fd so it cannot be passed over a UNIX domain socket.)
Quoted 27 lines
docs/system/devices/vhost-user.rst new file +24
-0+file-descriptor which can access this object will be passed via the +socket as part of the protocol negotiation. + +Example +======= + +First start you daemon. + +.. parsed-literal:: + + $ virtio-foo --socket-path=/var/run/foo.sock $OTHER_ARGS + +The you start your QEMU instance specifying the device, chardev and +memory objects. + +.. parsed-literal:: + + $ |qemu_system| \\ + -chardev socket,id=ba1,path=/var/run/foo.sock \\ + -device vhost-user-foo,chardev=ba1,$OTHER_ARGS \\ + -object memory-backend-memfd,id=mem,size=4G,share=on \\ + -numa node,memdev=mem \\ + ... +Signature · 1 line
2.20.1