Blame SOURCES/libvirt-qemu-be-sure-we-re-using-the-updated-value-of-backend-during-hotplug.patch

c401cc
From 63a614ff181a9a4248b6cc0b6f20454f1bc8ccba Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <63a614ff181a9a4248b6cc0b6f20454f1bc8ccba.1391615407.git.jdenemar@redhat.com>
c401cc
From: Laine Stump <laine@laine.org>
c401cc
Date: Wed, 5 Feb 2014 03:01:51 -0700
c401cc
Subject: [PATCH] qemu: be sure we're using the updated value of backend during
c401cc
 hotplug
c401cc
c401cc
  https://bugzilla.redhat.com/show_bug.cgi?id=1056360
c401cc
c401cc
commit f094aaac changed qemuPrepareHostdevPCIDevices() such that it
c401cc
may modify the "backend" (vfio vs. legacy kvm) setting in the
c401cc
virHostdevDef. However, qemuDomainAttachHostPciDevice() (used by
c401cc
hotplug) copies the backend setting into a local *before* calling
c401cc
qemuPrepareHostdevPCIDevices(), and then later makes a decision based
c401cc
on that pre-change value.
c401cc
c401cc
The result is that, if the backend had been set to "default" (i.e. not
c401cc
specified in the config) and was later updated to "VFIO" by
c401cc
qemuPrepareHostdevPCIDevices(), the qemu process' MaxMemLock is not
c401cc
increased (as is required for VFIO device assignment).
c401cc
c401cc
This patch delays making the local copy of backend until after its
c401cc
potential modification.
c401cc
c401cc
(cherry picked from commit 0d0a7bf45a67139ae591e69a7b5994e14a7709b8)
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 src/qemu/qemu_hotplug.c | 7 +++++--
c401cc
 1 file changed, 5 insertions(+), 2 deletions(-)
c401cc
c401cc
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
c401cc
index 0f2be8a..d9ce951 100644
c401cc
--- a/src/qemu/qemu_hotplug.c
c401cc
+++ b/src/qemu/qemu_hotplug.c
c401cc
@@ -1,7 +1,7 @@
c401cc
 /*
c401cc
  * qemu_hotplug.h: QEMU device hotplug management
c401cc
  *
c401cc
- * Copyright (C) 2006-2013 Red Hat, Inc.
c401cc
+ * Copyright (C) 2006-2014 Red Hat, Inc.
c401cc
  * Copyright (C) 2006 Daniel P. Berrange
c401cc
  *
c401cc
  * This library is free software; you can redistribute it and/or
c401cc
@@ -1014,7 +1014,7 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
c401cc
     bool releaseaddr = false;
c401cc
     bool teardowncgroup = false;
c401cc
     bool teardownlabel = false;
c401cc
-    int backend = hostdev->source.subsys.u.pci.backend;
c401cc
+    int backend;
c401cc
     unsigned long long memKB;
c401cc
 
c401cc
     if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs+1) < 0)
c401cc
@@ -1024,6 +1024,9 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
c401cc
                                      &hostdev, 1, priv->qemuCaps) < 0)
c401cc
         return -1;
c401cc
 
c401cc
+    /* this could have been changed by qemuPrepareHostdevPCIDevices */
c401cc
+    backend = hostdev->source.subsys.u.pci.backend;
c401cc
+
c401cc
     switch ((virDomainHostdevSubsysPciBackendType) backend) {
c401cc
     case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
c401cc
         if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_VFIO_PCI)) {
c401cc
-- 
c401cc
1.8.5.3
c401cc