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