1324b2298SPaolo BonziniInter-VM Shared Memory device 2324b2298SPaolo Bonzini----------------------------- 3324b2298SPaolo Bonzini 4324b2298SPaolo BonziniOn Linux hosts, a shared memory device is available. The basic syntax 5324b2298SPaolo Bonziniis: 6324b2298SPaolo Bonzini 7324b2298SPaolo Bonzini.. parsed-literal:: 8324b2298SPaolo Bonzini 9324b2298SPaolo Bonzini |qemu_system_x86| -device ivshmem-plain,memdev=hostmem 10324b2298SPaolo Bonzini 11324b2298SPaolo Bonziniwhere hostmem names a host memory backend. For a POSIX shared memory 12324b2298SPaolo Bonzinibackend, use something like 13324b2298SPaolo Bonzini 14324b2298SPaolo Bonzini:: 15324b2298SPaolo Bonzini 16324b2298SPaolo Bonzini -object memory-backend-file,size=1M,share,mem-path=/dev/shm/ivshmem,id=hostmem 17324b2298SPaolo Bonzini 18324b2298SPaolo BonziniIf desired, interrupts can be sent between guest VMs accessing the same 19324b2298SPaolo Bonzinishared memory region. Interrupt support requires using a shared memory 20324b2298SPaolo Bonziniserver and using a chardev socket to connect to it. The code for the 21324b2298SPaolo Bonzinishared memory server is qemu.git/contrib/ivshmem-server. An example 22324b2298SPaolo Bonzinisyntax when using the shared memory server is: 23324b2298SPaolo Bonzini 24324b2298SPaolo Bonzini.. parsed-literal:: 25324b2298SPaolo Bonzini 26324b2298SPaolo Bonzini # First start the ivshmem server once and for all 27324b2298SPaolo Bonzini ivshmem-server -p pidfile -S path -m shm-name -l shm-size -n vectors 28324b2298SPaolo Bonzini 29324b2298SPaolo Bonzini # Then start your qemu instances with matching arguments 30324b2298SPaolo Bonzini |qemu_system_x86| -device ivshmem-doorbell,vectors=vectors,chardev=id 31324b2298SPaolo Bonzini -chardev socket,path=path,id=id 32324b2298SPaolo Bonzini 33324b2298SPaolo BonziniWhen using the server, the guest will be assigned a VM ID (>=0) that 34324b2298SPaolo Bonziniallows guests using the same server to communicate via interrupts. 35324b2298SPaolo BonziniGuests can read their VM ID from a device register (see 36*bb1cff6eSPeter Maydell:doc:`../../specs/ivshmem-spec`). 37324b2298SPaolo Bonzini 38324b2298SPaolo BonziniMigration with ivshmem 39324b2298SPaolo Bonzini~~~~~~~~~~~~~~~~~~~~~~ 40324b2298SPaolo Bonzini 41324b2298SPaolo BonziniWith device property ``master=on``, the guest will copy the shared 42324b2298SPaolo Bonzinimemory on migration to the destination host. With ``master=off``, the 43324b2298SPaolo Bonziniguest will not be able to migrate with the device attached. In the 44324b2298SPaolo Bonzinilatter case, the device should be detached and then reattached after 45324b2298SPaolo Bonzinimigration using the PCI hotplug support. 46324b2298SPaolo Bonzini 47324b2298SPaolo BonziniAt most one of the devices sharing the same memory can be master. The 48324b2298SPaolo Bonzinimaster must complete migration before you plug back the other devices. 49324b2298SPaolo Bonzini 50324b2298SPaolo Bonziniivshmem and hugepages 51324b2298SPaolo Bonzini~~~~~~~~~~~~~~~~~~~~~ 52324b2298SPaolo Bonzini 53324b2298SPaolo BonziniInstead of specifying the <shm size> using POSIX shm, you may specify a 54324b2298SPaolo Bonzinimemory backend that has hugepage support: 55324b2298SPaolo Bonzini 56324b2298SPaolo Bonzini.. parsed-literal:: 57324b2298SPaolo Bonzini 58324b2298SPaolo Bonzini |qemu_system_x86| -object memory-backend-file,size=1G,mem-path=/dev/hugepages/my-shmem-file,share,id=mb1 59324b2298SPaolo Bonzini -device ivshmem-plain,memdev=mb1 60324b2298SPaolo Bonzini 61324b2298SPaolo Bonziniivshmem-server also supports hugepages mount points with the ``-m`` 62324b2298SPaolo Bonzinimemory path argument. 63