File 94714594-qemu-Reset-the-maximum-locked-memory-on-hotplug-fail.patch of Package libvirt.19372

commit 94714594c5a868ba9739a7d5bd1d7d7771f730b3
Author: Eric Farman <farman@linux.ibm.com>
Date:   Tue Sep 3 22:09:47 2019 +0200

    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 <farman@linux.ibm.com>
    Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    Reviewed-by: Pavel Hrdina <phrdina@redhat.com>

Index: libvirt-5.1.0/src/qemu/qemu_hotplug.c
===================================================================
--- libvirt-5.1.0.orig/src/qemu/qemu_hotplug.c
+++ libvirt-5.1.0/src/qemu/qemu_hotplug.c
@@ -1686,6 +1686,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDri
     bool teardowncgroup = false;
     bool teardownlabel = false;
     bool teardowndevice = false;
+    bool teardownmemlock = false;
     int backend;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     unsigned int flags = 0;
@@ -1727,6 +1728,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDri
 
     if (qemuDomainAdjustMaxMemLockHostdev(vm, hostdev) < 0)
         goto error;
+    teardownmemlock = true;
 
     if (qemuDomainNamespaceSetupHostdev(vm, hostdev) < 0)
         goto error;
@@ -1807,6 +1809,8 @@ qemuDomainAttachHostPCIDevice(virQEMUDri
     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, NULL);
openSUSE Build Service is sponsored by