[libvirt PATCH 4/4] qemu: adjust the maxmemlock limit when hotplugging a vDPA device

Laine Stump laine at redhat.com
Fri May 21 19:11:20 UTC 2021


and re-adjust if the hotplug fails.

This fixes a bug found during testing of
https://bugzilla.redhat.com/1939776, which was supposed to be resolved
by commit 98e22ff749, but failed to account for the case of device
hotplug.

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/qemu/qemu_hotplug.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dff31666f7..794c80444f 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1184,6 +1184,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
     int ret = -1;
     bool releaseaddr = false;
     bool iface_connected = false;
+    bool adjustmemlock = false;
     virDomainNetType actualType;
     const virNetDevBandwidth *actualBandwidth;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
@@ -1362,6 +1363,10 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
         break;
 
     case VIR_DOMAIN_NET_TYPE_VDPA:
+        if (qemuDomainAdjustMaxMemLock(vm, false) < 0)
+            goto cleanup;
+        adjustmemlock = true;
+
         if ((vdpafd = qemuInterfaceVDPAConnect(net)) < 0)
             goto cleanup;
         break;
@@ -1542,6 +1547,13 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver,
          */
         virDomainNetRemoveByObj(vm->def, net);
 
+        /* if we adjusted the memlock limit (for a vDPA device) then
+         * we need to re-adjust since we won't be using the device
+         * after all
+         */
+        if (adjustmemlock)
+            qemuDomainAdjustMaxMemLock(vm, false);
+
         if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
             if (conn)
                 virDomainNetReleaseActualDevice(conn, vm->def, net);
-- 
2.31.1




More information about the libvir-list mailing list