[libvirt] [PATCH 2/3] qemu: Reset the maximum locked memory on hotplug fail

Eric Farman farman at linux.ibm.com
Tue Sep 3 20:09:47 UTC 2019


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 at linux.ibm.com>
---
 src/qemu/qemu_hotplug.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 24e75e49be..979e97b608 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1469,6 +1469,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;
@@ -1510,6 +1511,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
 
     if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
         goto error;
+    teardownmemlock = true;
 
     if (qemuDomainNamespaceSetupHostdev(vm, hostdev) < 0)
         goto error;
@@ -1577,6 +1579,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);
-- 
2.17.1




More information about the libvir-list mailing list