render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
127bba
From 0f6a07209863beec18fb907b293531bd6c61f5d5 Mon Sep 17 00:00:00 2001
127bba
Message-Id: <0f6a07209863beec18fb907b293531bd6c61f5d5@dist-git>
127bba
From: Martin Kletzander <mkletzan@redhat.com>
127bba
Date: Fri, 4 Nov 2016 10:29:52 +0100
127bba
Subject: [PATCH] qemu: Save various defaults for shmem
127bba
127bba
We're keeping some things at default and that's not something we want to
127bba
do intentionally.  Let's save some sensible defaults upfront in order to
127bba
avoid having problems later.  The details for the defaults (of the newer
127bba
implementation) can be found in qemu's commit 5400c02b90bb:
127bba
127bba
  http://git.qemu.org/?p=qemu.git;a=commit;h=5400c02b90bb
127bba
127bba
Since we are merely saving the defaults it will not change the guest ABI
127bba
and thanks to the fact that we're doing it in the PostParse callback it
127bba
will not break the ABI stability checks.
127bba
127bba
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
127bba
(cherry picked from commit acf0ec024a220364c4a6a94996c82875c6d1ba13)
127bba
127bba
https://bugzilla.redhat.com/show_bug.cgi?id=1392031
127bba
127bba
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
127bba
---
127bba
 src/qemu/qemu_domain.c                             | 54 ++++++++++++++++++++++
127bba
 tests/qemuxml2argvdata/qemuxml2argv-shmem.args     |  2 +-
127bba
 .../qemuxml2xmlout-shmem-plain-doorbell.xml        |  5 +-
127bba
 tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml  |  1 +
127bba
 4 files changed, 60 insertions(+), 2 deletions(-)
127bba
127bba
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
127bba
index 4f99c14..3d2650f 100644
127bba
--- a/src/qemu/qemu_domain.c
127bba
+++ b/src/qemu/qemu_domain.c
127bba
@@ -2544,6 +2544,56 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr,
127bba
 
127bba
 
127bba
 static int
127bba
+qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm)
127bba
+{
127bba
+    /* This was the default since the introduction of this device. */
127bba
+    if (shm->model != VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL && !shm->size)
127bba
+        shm->size = 4 << 20;
127bba
+
127bba
+    /* Nothing more to check/change for IVSHMEM */
127bba
+    if (shm->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM)
127bba
+        return 0;
127bba
+
127bba
+    if (!shm->server.enabled) {
127bba
+        if (shm->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL) {
127bba
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
127bba
+                           _("shmem model '%s' is supported "
127bba
+                             "only with server option enabled"),
127bba
+                           virDomainShmemModelTypeToString(shm->model));
127bba
+            return -1;
127bba
+        }
127bba
+
127bba
+        if (shm->msi.enabled) {
127bba
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
127bba
+                           _("shmem model '%s' doesn't support "
127bba
+                             "msi"),
127bba
+                           virDomainShmemModelTypeToString(shm->model));
127bba
+        }
127bba
+    } else {
127bba
+        if (shm->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN) {
127bba
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
127bba
+                           _("shmem model '%s' is supported "
127bba
+                             "only with server option disabled"),
127bba
+                           virDomainShmemModelTypeToString(shm->model));
127bba
+            return -1;
127bba
+        }
127bba
+
127bba
+        if (shm->size) {
127bba
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
127bba
+                           _("shmem model '%s' does not support size setting"),
127bba
+                           virDomainShmemModelTypeToString(shm->model));
127bba
+            return -1;
127bba
+        }
127bba
+        shm->msi.enabled = true;
127bba
+        if (!shm->msi.ioeventfd)
127bba
+            shm->msi.ioeventfd = VIR_TRISTATE_SWITCH_ON;
127bba
+    }
127bba
+
127bba
+    return 0;
127bba
+}
127bba
+
127bba
+
127bba
+static int
127bba
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
127bba
                              const virDomainDef *def,
127bba
                              virCapsPtr caps ATTRIBUTE_UNUSED,
127bba
@@ -2708,6 +2758,10 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
127bba
         }
127bba
     }
127bba
 
127bba
+    if (dev->type == VIR_DOMAIN_DEVICE_SHMEM &&
127bba
+        qemuDomainShmemDefPostParse(dev->data.shmem) < 0)
127bba
+        goto cleanup;
127bba
+
127bba
     ret = 0;
127bba
 
127bba
  cleanup:
127bba
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args
127bba
index 99fac11..bdf660a 100644
127bba
--- a/tests/qemuxml2argvdata/qemuxml2argv-shmem.args
127bba
+++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem.args
127bba
@@ -17,7 +17,7 @@ QEMU_AUDIO_DRV=none \
127bba
 -no-acpi \
127bba
 -boot c \
127bba
 -usb \
127bba
--device ivshmem,id=shmem0,shm=shmem0,bus=pci.0,addr=0x3 \
127bba
+-device ivshmem,id=shmem0,size=4m,shm=shmem0,bus=pci.0,addr=0x3 \
127bba
 -device ivshmem,id=shmem1,size=128m,shm=shmem1,bus=pci.0,addr=0x5 \
127bba
 -device ivshmem,id=shmem2,size=256m,shm=shmem2,bus=pci.0,addr=0x4 \
127bba
 -device ivshmem,id=shmem3,size=512m,chardev=charshmem3,bus=pci.0,addr=0x6 \
127bba
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
index ab9c69b..7872e1c 100644
127bba
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml
127bba
@@ -23,6 +23,7 @@
127bba
     <memballoon model='none'/>
127bba
     <shmem name='shmem0'>
127bba
       <model type='ivshmem-plain'/>
127bba
+      <size unit='M'>4</size>
127bba
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
127bba
     </shmem>
127bba
     <shmem name='shmem1'>
127bba
@@ -38,11 +39,13 @@
127bba
     <shmem name='shmem3'>
127bba
       <model type='ivshmem-doorbell'/>
127bba
       <server/>
127bba
+      <msi ioeventfd='on'/>
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
+      <msi ioeventfd='on'/>
127bba
       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
127bba
     </shmem>
127bba
     <shmem name='shmem5'>
127bba
@@ -54,7 +57,7 @@
127bba
     <shmem name='shmem6'>
127bba
       <model type='ivshmem-doorbell'/>
127bba
       <server path='/tmp/shmem6-sock'/>
127bba
-      <msi vectors='16'/>
127bba
+      <msi vectors='16' ioeventfd='on'/>
127bba
       <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
127bba
     </shmem>
127bba
     <shmem name='shmem7'>
127bba
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml
127bba
index 5602913..04b463a 100644
127bba
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml
127bba
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml
127bba
@@ -23,6 +23,7 @@
127bba
     <memballoon model='none'/>
127bba
     <shmem name='shmem0'>
127bba
       <model type='ivshmem'/>
127bba
+      <size unit='M'>4</size>
127bba
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
127bba
     </shmem>
127bba
     <shmem name='shmem1'>
127bba
-- 
127bba
2.10.2
127bba