From 0d0a7bf45a67139ae591e69a7b5994e14a7709b8 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Tue, 4 Feb 2014 13:12:47 +0200 Subject: [PATCH] qemu: be sure we're using the updated value of backend during hotplug 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' MacMemLock is not increased (as is required for VFIO device assignment). This patch delays making the local copy of backend until after its potential modification. --- 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 4315df2a5c..4a885d22ef 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 @@ -1152,7 +1152,7 @@ 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) @@ -1162,6 +1162,9 @@ 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)) { -- GitLab