]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: adjust the maxmemlock limit when hotplugging a vDPA device
authorLaine Stump <laine@redhat.com>
Fri, 21 May 2021 18:51:05 +0000 (14:51 -0400)
committerLaine Stump <laine@redhat.com>
Tue, 25 May 2021 14:08:03 +0000 (10:08 -0400)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_hotplug.c

index 6cad1682ed96ffd97d476ec07fcd3813ce76e002..9ff6175dd3dffbe50c9b97d3039b8698e9d24ae0 100644 (file)
@@ -1191,6 +1191,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);
@@ -1369,6 +1370,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;
@@ -1549,6 +1554,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);