From: Eric Farman Date: Tue, 3 Sep 2019 20:09:47 +0000 (+0200) Subject: qemu: Reset the maximum locked memory on hotplug fail X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=94714594c5a868ba9739a7d5bd1d7d7771f730b3;p=libvirt.git qemu: Reset the maximum locked memory on hotplug fail 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 Reviewed-by: Daniel Henrique Barboza Reviewed-by: Pavel Hrdina --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 20f3bfa2ff..a63f1c7af4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -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);