xref: /qemu/docs/system/devices/vhost-user.rst (revision 15d9c3cef108f34874200785bf9970bf77dc378b)
1*15d9c3ceSAlex Bennée.. _vhost_user:
2*15d9c3ceSAlex Bennée
3*15d9c3ceSAlex Bennéevhost-user back ends
4*15d9c3ceSAlex Bennée--------------------
5*15d9c3ceSAlex Bennée
6*15d9c3ceSAlex Bennéevhost-user back ends are way to service the request of VirtIO devices
7*15d9c3ceSAlex Bennéeoutside of QEMU itself. To do this there are a number of things
8*15d9c3ceSAlex Bennéerequired.
9*15d9c3ceSAlex Bennée
10*15d9c3ceSAlex Bennéevhost-user device
11*15d9c3ceSAlex Bennée===================
12*15d9c3ceSAlex Bennée
13*15d9c3ceSAlex BennéeThese are simple stub devices that ensure the VirtIO device is visible
14*15d9c3ceSAlex Bennéeto the guest. The code is mostly boilerplate although each device has
15*15d9c3ceSAlex Bennéea ``chardev`` option which specifies the ID of the ``--chardev``
16*15d9c3ceSAlex Bennéedevice that connects via a socket to the vhost-user *daemon*.
17*15d9c3ceSAlex Bennée
18*15d9c3ceSAlex Bennéevhost-user daemon
19*15d9c3ceSAlex Bennée=================
20*15d9c3ceSAlex Bennée
21*15d9c3ceSAlex BennéeThis is a separate process that is connected to by QEMU via a socket
22*15d9c3ceSAlex Bennéefollowing the :ref:`vhost_user_proto`. There are a number of daemons
23*15d9c3ceSAlex Bennéethat can be built when enabled by the project although any daemon that
24*15d9c3ceSAlex Bennéemeets the specification for a given device can be used.
25*15d9c3ceSAlex Bennée
26*15d9c3ceSAlex BennéeShared memory object
27*15d9c3ceSAlex Bennée====================
28*15d9c3ceSAlex Bennée
29*15d9c3ceSAlex BennéeIn order for the daemon to access the VirtIO queues to process the
30*15d9c3ceSAlex Bennéerequests it needs access to the guest's address space. This is
31*15d9c3ceSAlex Bennéeachieved via the ``memory-backend-file`` or ``memory-backend-memfd``
32*15d9c3ceSAlex Bennéeobjects. A reference to a file-descriptor which can access this object
33*15d9c3ceSAlex Bennéewill be passed via the socket as part of the protocol negotiation.
34*15d9c3ceSAlex Bennée
35*15d9c3ceSAlex BennéeCurrently the shared memory object needs to match the size of the main
36*15d9c3ceSAlex Bennéesystem memory as defined by the ``-m`` argument.
37*15d9c3ceSAlex Bennée
38*15d9c3ceSAlex BennéeExample
39*15d9c3ceSAlex Bennée=======
40*15d9c3ceSAlex Bennée
41*15d9c3ceSAlex BennéeFirst start you daemon.
42*15d9c3ceSAlex Bennée
43*15d9c3ceSAlex Bennée.. parsed-literal::
44*15d9c3ceSAlex Bennée
45*15d9c3ceSAlex Bennée  $ virtio-foo --socket-path=/var/run/foo.sock $OTHER_ARGS
46*15d9c3ceSAlex Bennée
47*15d9c3ceSAlex BennéeThe you start your QEMU instance specifying the device, chardev and
48*15d9c3ceSAlex Bennéememory objects.
49*15d9c3ceSAlex Bennée
50*15d9c3ceSAlex Bennée.. parsed-literal::
51*15d9c3ceSAlex Bennée
52*15d9c3ceSAlex Bennée  $ |qemu_system| \\
53*15d9c3ceSAlex Bennée      -m 4096 \\
54*15d9c3ceSAlex Bennée      -chardev socket,id=ba1,path=/var/run/foo.sock \\
55*15d9c3ceSAlex Bennée      -device vhost-user-foo,chardev=ba1,$OTHER_ARGS \\
56*15d9c3ceSAlex Bennée      -object memory-backend-memfd,id=mem,size=4G,share=on \\
57*15d9c3ceSAlex Bennée      -numa node,memdev=mem \\
58*15d9c3ceSAlex Bennée        ...
59*15d9c3ceSAlex Bennée
60