On 05/30/2018 09:43 AM, Erik Skultety wrote:
If QEMU supports vfio-pci.display option, we default to 'off'
as we're
not trying to guess what a user's intentions with the mdev are. Perform
this decision as part of driver-specific post parse callback.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/qemu/qemu_domain.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 27088d4456..b9f152022b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5887,6 +5887,35 @@ qemuDomainVsockDefPostParse(virDomainVsockDefPtr vsock)
}
+static int
+qemuDomainHostdevDefMdevPostParse(virDomainHostdevSubsysMediatedDevPtr mdevsrc,
+ virQEMUCapsPtr qemuCaps)
+{
+ /* QEMU 2.12 added support for vfio-pci display type, we default to
+ * 'display=off' to stay safe from future changes */
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_PCI_DISPLAY) &&
+ mdevsrc->display == VIR_TRISTATE_SWITCH_ABSENT)
+ mdevsrc->display = VIR_TRISTATE_SWITCH_OFF;
This seems to affirm my reading of the QEMU code from my patch 4
comments where display defaulted to auto which called vfio_realize for
every domain...
Still this then writes "off" out to any configuration that had/used
mdev, right? But if it writes "off", then the parameter has a quasi
optional state that we can never change to auto in the future since
we'll find off and won't know it it's off because someone set it off or
if it's off because we set it that way.
So I think there's a way to do what you want - see comments in patch 7...
John
+
+ return 0;
+}
+
+
+static int
+qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr hostdev,
+ virQEMUCapsPtr qemuCaps)
+{
+ virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV
&&
+ qemuDomainHostdevDefMdevPostParse(&subsys->u.mdev, qemuCaps) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
const virDomainDef *def,
@@ -5942,6 +5971,9 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
case VIR_DOMAIN_DEVICE_INPUT:
case VIR_DOMAIN_DEVICE_SOUND:
case VIR_DOMAIN_DEVICE_HOSTDEV:
+ ret = qemuDomainHostdevDefPostParse(dev->data.hostdev, qemuCaps);
+ break;
+
case VIR_DOMAIN_DEVICE_WATCHDOG:
case VIR_DOMAIN_DEVICE_GRAPHICS:
case VIR_DOMAIN_DEVICE_HUB: