127bba
From 1a9572f07ac3c181166e3c67b179716d5830134c Mon Sep 17 00:00:00 2001
127bba
Message-Id: <1a9572f07ac3c181166e3c67b179716d5830134c@dist-git>
127bba
From: Martin Kletzander <mkletzan@redhat.com>
127bba
Date: Fri, 4 Nov 2016 10:29:50 +0100
127bba
Subject: [PATCH] conf, qemu: Add newer shmem models
127bba
127bba
The old ivshmem is deprecated in QEMU, so let's use the better
127bba
ivshmem-{plain,doorbell} variants instead.
127bba
127bba
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
127bba
(cherry picked from commit 3c06aa7b30e91920698368ceb87c49aab06e37fe)
127bba
127bba
 Conflicts:
127bba
	tests/qemuxml2xmltest.c -- DO_TEST rewrite
127bba
127bba
https://bugzilla.redhat.com/show_bug.cgi?id=1392031
127bba
127bba
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
127bba
---
127bba
 docs/formatdomain.html.in                          | 10 +++-
127bba
 docs/schemas/domaincommon.rng                      |  2 +
127bba
 src/conf/domain_conf.c                             |  4 +-
127bba
 src/conf/domain_conf.h                             |  2 +
127bba
 src/qemu/qemu_command.c                            |  7 +++
127bba
 .../qemuxml2argv-shmem-plain-doorbell.xml          | 58 +++++++++++++++++++
127bba
 .../qemuxml2xmlout-shmem-plain-doorbell.xml        | 67 ++++++++++++++++++++++
127bba
 tests/qemuxml2xmltest.c                            |  1 +
127bba
 8 files changed, 147 insertions(+), 4 deletions(-)
127bba
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml
127bba
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
127bba
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
127bba
index a39d730..e9b7bad 100644
127bba
--- a/docs/formatdomain.html.in
127bba
+++ b/docs/formatdomain.html.in
127bba
@@ -6686,10 +6686,11 @@ qemu-kvm -net nic,model=? /dev/null
127bba
   ...
127bba
   <devices>
127bba
     <shmem name='my_shmem0'>
127bba
+      <model type='ivshmem-plain'/>
127bba
       <size unit='M'>4</size>
127bba
     </shmem>
127bba
     <shmem name='shmem_server'>
127bba
-      <model type='ivshmem'/>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
       <size unit='M'>2</size>
127bba
       <server path='/tmp/socket-shmem'/>
127bba
       <msi vectors='32' ioeventfd='on'/>
127bba
@@ -6708,8 +6709,11 @@ qemu-kvm -net nic,model=? /dev/null
127bba
     
127bba
       Attribute type of the optional element model
127bba
       specifies the model of the underlying device providing the
127bba
-      shmem device.  Currently the only supported model is
127bba
-      ivshmem.
127bba
+      shmem device.  The models currently supported are
127bba
+      ivshmem (supports both server and server-less shmem, but is
127bba
+      deprecated by newer QEMU in favour of the -plain and -doorbell variants),
127bba
+      ivshmem-plain (only for server-less shmem) and
127bba
+      ivshmem-doorbell (only for shmem with the server).
127bba
     
127bba
     
size
127bba
     
127bba
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
127bba
index 7d16536..6acc107 100644
127bba
--- a/docs/schemas/domaincommon.rng
127bba
+++ b/docs/schemas/domaincommon.rng
127bba
@@ -3557,6 +3557,8 @@
127bba
             <attribute name="type">
127bba
               <choice>
127bba
                 <value>ivshmem</value>
127bba
+                <value>ivshmem-plain</value>
127bba
+                <value>ivshmem-doorbell</value>
127bba
               </choice>
127bba
             </attribute>
127bba
           </element>
127bba
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
127bba
index 25b1c63..514e50d 100644
127bba
--- a/src/conf/domain_conf.c
127bba
+++ b/src/conf/domain_conf.c
127bba
@@ -841,7 +841,9 @@ VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST,
127bba
               "", "dimm")
127bba
 
127bba
 VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST,
127bba
-              "ivshmem")
127bba
+              "ivshmem",
127bba
+              "ivshmem-plain",
127bba
+              "ivshmem-doorbell")
127bba
 
127bba
 static virClassPtr virDomainObjClass;
127bba
 static virClassPtr virDomainXMLOptionClass;
127bba
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
127bba
index db74d1d..b8944cb 100644
127bba
--- a/src/conf/domain_conf.h
127bba
+++ b/src/conf/domain_conf.h
127bba
@@ -1551,6 +1551,8 @@ struct _virDomainNVRAMDef {
127bba
 
127bba
 typedef enum {
127bba
     VIR_DOMAIN_SHMEM_MODEL_IVSHMEM,
127bba
+    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN,
127bba
+    VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL,
127bba
 
127bba
     VIR_DOMAIN_SHMEM_MODEL_LAST
127bba
 } virDomainShmemModel;
127bba
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
127bba
index c5d29b4..e145c9f 100644
127bba
--- a/src/qemu/qemu_command.c
127bba
+++ b/src/qemu/qemu_command.c
127bba
@@ -8564,6 +8564,13 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
127bba
         devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps);
127bba
         break;
127bba
 
127bba
+    case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN:
127bba
+    case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL:
127bba
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
127bba
+                       _("%s device is not supported with this QEMU binary"),
127bba
+                       virDomainShmemModelTypeToString(shmem->model));
127bba
+        break;
127bba
+
127bba
     case VIR_DOMAIN_SHMEM_MODEL_LAST:
127bba
         break;
127bba
     }
127bba
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml b/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml
127bba
new file mode 100644
127bba
index 0000000..454437c
127bba
--- /dev/null
127bba
+++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml
127bba
@@ -0,0 +1,58 @@
127bba
+<domain type='qemu'>
127bba
+  <name>QEMUGuest1</name>
127bba
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
127bba
+  <memory unit='KiB'>219136</memory>
127bba
+  <currentMemory unit='KiB'>219136</currentMemory>
127bba
+  <vcpu placement='static'>1</vcpu>
127bba
+  <os>
127bba
+    <type arch='i686' machine='pc'>hvm</type>
127bba
+    <boot dev='hd'/>
127bba
+  </os>
127bba
+  <clock offset='utc'/>
127bba
+  <on_poweroff>destroy</on_poweroff>
127bba
+  <on_reboot>restart</on_reboot>
127bba
+  <on_crash>destroy</on_crash>
127bba
+  <devices>
127bba
+    <emulator>/usr/bin/qemu</emulator>
127bba
+    <controller type='usb' index='0'/>
127bba
+    <controller type='pci' index='0' model='pci-root'/>
127bba
+    <input type='mouse' bus='ps2'/>
127bba
+    <input type='keyboard' bus='ps2'/>
127bba
+    <memballoon model='none'/>
127bba
+    <shmem name='shmem0'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem1'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+      <size unit='M'>128</size>
127bba
+    </shmem>
127bba
+    <shmem name='shmem2'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+      <size unit='M'>256</size>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem3'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem4'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem4-sock'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem5'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem5-sock'/>
127bba
+      <msi ioeventfd='off'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem6'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem6-sock'/>
127bba
+      <msi vectors='16'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem7'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem7-sock'/>
127bba
+      <msi vectors='32' ioeventfd='on'/>
127bba
+    </shmem>
127bba
+  </devices>
127bba
+</domain>
127bba
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
new file mode 100644
127bba
index 0000000..ab9c69b
127bba
--- /dev/null
127bba
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
@@ -0,0 +1,67 @@
127bba
+<domain type='qemu'>
127bba
+  <name>QEMUGuest1</name>
127bba
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
127bba
+  <memory unit='KiB'>219136</memory>
127bba
+  <currentMemory unit='KiB'>219136</currentMemory>
127bba
+  <vcpu placement='static'>1</vcpu>
127bba
+  <os>
127bba
+    <type arch='i686' machine='pc'>hvm</type>
127bba
+    <boot dev='hd'/>
127bba
+  </os>
127bba
+  <clock offset='utc'/>
127bba
+  <on_poweroff>destroy</on_poweroff>
127bba
+  <on_reboot>restart</on_reboot>
127bba
+  <on_crash>destroy</on_crash>
127bba
+  <devices>
127bba
+    <emulator>/usr/bin/qemu</emulator>
127bba
+    <controller type='usb' index='0'>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
127bba
+    </controller>
127bba
+    <controller type='pci' index='0' model='pci-root'/>
127bba
+    <input type='mouse' bus='ps2'/>
127bba
+    <input type='keyboard' bus='ps2'/>
127bba
+    <memballoon model='none'/>
127bba
+    <shmem name='shmem0'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem1'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+      <size unit='M'>128</size>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem2'>
127bba
+      <model type='ivshmem-plain'/>
127bba
+      <size unit='M'>256</size>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem3'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem4'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem4-sock'/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem5'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem5-sock'/>
127bba
+      <msi ioeventfd='off'/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem6'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem6-sock'/>
127bba
+      <msi vectors='16'/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
127bba
+    </shmem>
127bba
+    <shmem name='shmem7'>
127bba
+      <model type='ivshmem-doorbell'/>
127bba
+      <server path='/tmp/shmem7-sock'/>
127bba
+      <msi vectors='32' ioeventfd='on'/>
127bba
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
127bba
+    </shmem>
127bba
+  </devices>
127bba
+</domain>
127bba
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
127bba
index 5458361..c6bf7ad 100644
127bba
--- a/tests/qemuxml2xmltest.c
127bba
+++ b/tests/qemuxml2xmltest.c
127bba
@@ -827,6 +827,7 @@ mymain(void)
127bba
     DO_TEST("tap-vhost");
127bba
     DO_TEST("tap-vhost-incorrect");
127bba
     DO_TEST("shmem");
127bba
+    DO_TEST("shmem-plain-doorbell");
127bba
     DO_TEST("smbios");
127bba
     DO_TEST("smbios-multiple-type2");
127bba
 
127bba
-- 
127bba
2.10.2
127bba