qemu: add support for shmem-{plain, doorbell} role

Role(master or peer) controls how the domain behaves on migration.
For more details about migration with ivshmem, see
https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/system/ivshmem.rst;hb=HEAD

It's a optional attribute in libvirt, and qemu will choose default
role for ivshmem device if the user is not specified.

With device property 'role', the value can be 'master' or 'peer'.
 - 'master' (means 'master=on' in qemu), the guest will copy
   the shared memory on migration to the destination host.
 - 'peer' (means 'master=off' in qemu), the migration is disabled.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Signed-off-by: Yang Hang <yanghang44@huawei.com>
Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Wang Xin
2020-08-03 10:57:47 +02:00
committed by Martin Kletzander
parent 77296c807b
commit 493d2769f2
15 changed files with 114 additions and 19 deletions
@@ -1,4 +1,4 @@
<shmem name='shmem0'>
<shmem name='shmem0' role='peer'>
<model type='ivshmem-plain'/>
<size unit='M'>4</size>
<alias name='shmem0'/>
@@ -1,3 +1,3 @@
<shmem name='shmem0'>
<shmem name='shmem0' role='peer'>
<model type='ivshmem-plain'/>
</shmem>
@@ -45,7 +45,7 @@
<alias name='input1'/>
</input>
<memballoon model='none'/>
<shmem name='shmem0'>
<shmem name='shmem0' role='peer'>
<model type='ivshmem-plain'/>
<size unit='M'>4</size>
<alias name='shmem0'/>
@@ -45,7 +45,7 @@
<alias name='input1'/>
</input>
<memballoon model='none'/>
<shmem name='shmem0'>
<shmem name='shmem0' role='peer'>
<model type='ivshmem-plain'/>
<size unit='M'>4</size>
<alias name='shmem0'/>
@@ -30,10 +30,12 @@ size=4194304,share=yes \
-device ivshmem-plain,id=shmem0,memdev=shmmem-shmem0,bus=pci.0,addr=0x3 \
-object memory-backend-file,id=shmmem-shmem1,mem-path=/dev/shm/shmem1,\
size=134217728,share=yes \
-device ivshmem-plain,id=shmem1,memdev=shmmem-shmem1,bus=pci.0,addr=0x5 \
-device ivshmem-plain,id=shmem1,memdev=shmmem-shmem1,master=off,bus=pci.0,\
addr=0x5 \
-object memory-backend-file,id=shmmem-shmem2,mem-path=/dev/shm/shmem2,\
size=268435456,share=yes \
-device ivshmem-plain,id=shmem2,memdev=shmmem-shmem2,bus=pci.0,addr=0x4 \
-device ivshmem-plain,id=shmem2,memdev=shmmem-shmem2,master=on,bus=pci.0,\
addr=0x4 \
-device ivshmem-doorbell,id=shmem3,chardev=charshmem3,ioeventfd=on,bus=pci.0,\
addr=0x6 \
-chardev socket,id=charshmem3,path=/var/lib/libvirt/shmem-shmem3-sock \
@@ -22,11 +22,11 @@
<shmem name='shmem0'>
<model type='ivshmem-plain'/>
</shmem>
<shmem name='shmem1'>
<shmem name='shmem1' role='peer'>
<model type='ivshmem-plain'/>
<size unit='M'>128</size>
</shmem>
<shmem name='shmem2'>
<shmem name='shmem2' role='master'>
<model type='ivshmem-plain'/>
<size unit='M'>256</size>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
@@ -26,12 +26,12 @@
<size unit='M'>4</size>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</shmem>
<shmem name='shmem1'>
<shmem name='shmem1' role='peer'>
<model type='ivshmem-plain'/>
<size unit='M'>128</size>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</shmem>
<shmem name='shmem2'>
<shmem name='shmem2' role='master'>
<model type='ivshmem-plain'/>
<size unit='M'>256</size>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+2 -1
View File
@@ -1135,7 +1135,8 @@ mymain(void)
DO_TEST("tap-vhost", NONE);
DO_TEST("tap-vhost-incorrect", NONE);
DO_TEST("shmem", NONE);
DO_TEST("shmem-plain-doorbell", NONE);
DO_TEST("shmem-plain-doorbell",
QEMU_CAPS_DEVICE_IVSHMEM_PLAIN, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL);
DO_TEST("smbios", NONE);
DO_TEST("smbios-multiple-type2", NONE);
DO_TEST("smbios-type-fwcfg", NONE);