]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Reset the maximum locked memory on hotplug fail
authorEric Farman <farman@linux.ibm.com>
Tue, 3 Sep 2019 20:09:47 +0000 (22:09 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Sep 2019 14:39:52 +0000 (16:39 +0200)
If attaching a PCI hostdev fails, there are several things that
need to be un-done as part of the cleanup.  One thing that is
not done is re-calculating/re-setting the maximum amount of locked
memory for the domain, since we may have changed that.

Let's fix that, just to ensure everything is back the way it was.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_hotplug.c

index 20f3bfa2ff88f4be9786303904ed40458e61f22a..a63f1c7af45ca7828b2106c5580e3dfa438957c2 100644 (file)
@@ -1582,6 +1582,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
     bool teardowncgroup = false;
     bool teardownlabel = false;
     bool teardowndevice = false;
+    bool teardownmemlock = false;
     int backend;
     VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
     unsigned int flags = 0;
@@ -1623,6 +1624,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
 
     if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
         goto error;
+    teardownmemlock = true;
 
     if (qemuDomainNamespaceSetupHostdev(vm, hostdev) < 0)
         goto error;
@@ -1690,6 +1692,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
     if (teardowndevice &&
         qemuDomainNamespaceTeardownHostdev(vm, hostdev) < 0)
         VIR_WARN("Unable to remove host device from /dev");
+    if (teardownmemlock && qemuDomainAdjustMaxMemLock(vm) < 0)
+        VIR_WARN("Unable to reset maximum locked memory on hotplug fail");
 
     if (releaseaddr)
         qemuDomainReleaseDeviceAddress(vm, info);