xref: /openbmc/qemu/docs/system/devices/ivshmem.rst (revision 30b6852c)
1.. _pcsys_005fivshmem:
2
3Inter-VM Shared Memory device
4-----------------------------
5
6On Linux hosts, a shared memory device is available. The basic syntax
7is:
8
9.. parsed-literal::
10
11   |qemu_system_x86| -device ivshmem-plain,memdev=hostmem
12
13where hostmem names a host memory backend. For a POSIX shared memory
14backend, use something like
15
16::
17
18   -object memory-backend-file,size=1M,share,mem-path=/dev/shm/ivshmem,id=hostmem
19
20If desired, interrupts can be sent between guest VMs accessing the same
21shared memory region. Interrupt support requires using a shared memory
22server and using a chardev socket to connect to it. The code for the
23shared memory server is qemu.git/contrib/ivshmem-server. An example
24syntax when using the shared memory server is:
25
26.. parsed-literal::
27
28   # First start the ivshmem server once and for all
29   ivshmem-server -p pidfile -S path -m shm-name -l shm-size -n vectors
30
31   # Then start your qemu instances with matching arguments
32   |qemu_system_x86| -device ivshmem-doorbell,vectors=vectors,chardev=id
33                    -chardev socket,path=path,id=id
34
35When using the server, the guest will be assigned a VM ID (>=0) that
36allows guests using the same server to communicate via interrupts.
37Guests can read their VM ID from a device register (see
38ivshmem-spec.txt).
39
40Migration with ivshmem
41~~~~~~~~~~~~~~~~~~~~~~
42
43With device property ``master=on``, the guest will copy the shared
44memory on migration to the destination host. With ``master=off``, the
45guest will not be able to migrate with the device attached. In the
46latter case, the device should be detached and then reattached after
47migration using the PCI hotplug support.
48
49At most one of the devices sharing the same memory can be master. The
50master must complete migration before you plug back the other devices.
51
52ivshmem and hugepages
53~~~~~~~~~~~~~~~~~~~~~
54
55Instead of specifying the <shm size> using POSIX shm, you may specify a
56memory backend that has hugepage support:
57
58.. parsed-literal::
59
60   |qemu_system_x86| -object memory-backend-file,size=1G,mem-path=/dev/hugepages/my-shmem-file,share,id=mb1
61                    -device ivshmem-plain,memdev=mb1
62
63ivshmem-server also supports hugepages mount points with the ``-m``
64memory path argument.
65