115d9c3ceSAlex Bennée.. _vhost_user:
215d9c3ceSAlex Bennée
315d9c3ceSAlex Bennéevhost-user back ends
415d9c3ceSAlex Bennée--------------------
515d9c3ceSAlex Bennée
615d9c3ceSAlex Bennéevhost-user back ends are way to service the request of VirtIO devices
715d9c3ceSAlex Bennéeoutside of QEMU itself. To do this there are a number of things
815d9c3ceSAlex Bennéerequired.
915d9c3ceSAlex Bennée
1015d9c3ceSAlex Bennéevhost-user device
1115d9c3ceSAlex Bennée===================
1215d9c3ceSAlex Bennée
1315d9c3ceSAlex BennéeThese are simple stub devices that ensure the VirtIO device is visible
1415d9c3ceSAlex Bennéeto the guest. The code is mostly boilerplate although each device has
1515d9c3ceSAlex Bennéea ``chardev`` option which specifies the ID of the ``--chardev``
1615d9c3ceSAlex Bennéedevice that connects via a socket to the vhost-user *daemon*.
1715d9c3ceSAlex Bennée
1815d9c3ceSAlex Bennéevhost-user daemon
1915d9c3ceSAlex Bennée=================
2015d9c3ceSAlex Bennée
2115d9c3ceSAlex BennéeThis is a separate process that is connected to by QEMU via a socket
2215d9c3ceSAlex Bennéefollowing the :ref:`vhost_user_proto`. There are a number of daemons
2315d9c3ceSAlex Bennéethat can be built when enabled by the project although any daemon that
2415d9c3ceSAlex Bennéemeets the specification for a given device can be used.
2515d9c3ceSAlex Bennée
2615d9c3ceSAlex BennéeShared memory object
2715d9c3ceSAlex Bennée====================
2815d9c3ceSAlex Bennée
2915d9c3ceSAlex BennéeIn order for the daemon to access the VirtIO queues to process the
3015d9c3ceSAlex Bennéerequests it needs access to the guest's address space. This is
3115d9c3ceSAlex Bennéeachieved via the ``memory-backend-file`` or ``memory-backend-memfd``
3215d9c3ceSAlex Bennéeobjects. A reference to a file-descriptor which can access this object
3315d9c3ceSAlex Bennéewill be passed via the socket as part of the protocol negotiation.
3415d9c3ceSAlex Bennée
3515d9c3ceSAlex BennéeCurrently the shared memory object needs to match the size of the main
3615d9c3ceSAlex Bennéesystem memory as defined by the ``-m`` argument.
3715d9c3ceSAlex Bennée
3815d9c3ceSAlex BennéeExample
3915d9c3ceSAlex Bennée=======
4015d9c3ceSAlex Bennée
41*9c36407aSMilan ZamazalFirst start your daemon.
4215d9c3ceSAlex Bennée
4315d9c3ceSAlex Bennée.. parsed-literal::
4415d9c3ceSAlex Bennée
4515d9c3ceSAlex Bennée  $ virtio-foo --socket-path=/var/run/foo.sock $OTHER_ARGS
4615d9c3ceSAlex Bennée
47*9c36407aSMilan ZamazalThen you start your QEMU instance specifying the device, chardev and
4815d9c3ceSAlex Bennéememory objects.
4915d9c3ceSAlex Bennée
5015d9c3ceSAlex Bennée.. parsed-literal::
5115d9c3ceSAlex Bennée
5215d9c3ceSAlex Bennée  $ |qemu_system| \\
5315d9c3ceSAlex Bennée      -m 4096 \\
5415d9c3ceSAlex Bennée      -chardev socket,id=ba1,path=/var/run/foo.sock \\
5515d9c3ceSAlex Bennée      -device vhost-user-foo,chardev=ba1,$OTHER_ARGS \\
5615d9c3ceSAlex Bennée      -object memory-backend-memfd,id=mem,size=4G,share=on \\
5715d9c3ceSAlex Bennée      -numa node,memdev=mem \\
5815d9c3ceSAlex Bennée        ...
5915d9c3ceSAlex Bennée
60