]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: forbid updating any attributes of an interface <backend> with update-device
authorLaine Stump <laine@redhat.com>
Wed, 15 Feb 2023 20:29:56 +0000 (15:29 -0500)
committerLaine Stump <laine@redhat.com>
Tue, 21 Feb 2023 19:44:54 +0000 (14:44 -0500)
Changing any of the attributes of an <interface>'s <backend> would
require removing and re-adding the interface for the new setting to
take effect, so fail any update-device that changes anything in
<backend>

Resolves: https://bugzilla.redhat.com/2169245
Signed-off-by: Laine Stump <laine@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms
src/qemu/qemu_hotplug.c

index 651f2ad279ff5ae57c766647fb209761e19fe42d..84ffd93b7f9881bb7308b5692e3cff423073bc99 100644 (file)
@@ -19854,6 +19854,20 @@ virDomainFsDefCheckABIStability(virDomainFSDef *src,
 }
 
 
+bool
+virDomainNetBackendIsEqual(virDomainNetBackend *src,
+                           virDomainNetBackend *dst)
+{
+    if (src->type != dst->type ||
+        STRNEQ_NULLABLE(src->tap, dst->tap) ||
+        STRNEQ_NULLABLE(src->vhost, dst->vhost) ||
+        STRNEQ_NULLABLE(src->logFile, dst->logFile)) {
+        return false;
+    }
+    return true;
+}
+
+
 static bool
 virDomainNetDefCheckABIStability(virDomainNetDef *src,
                                  virDomainNetDef *dst)
index 31839c96e5ffe21ebca78f8c8dbfab7f6a335e9c..2a8ad17f44079e1f6d077c6546c3f2a0033aa580 100644 (file)
@@ -3863,6 +3863,8 @@ virDomainNetDef *virDomainNetFindByName(virDomainDef *def, const char *ifname);
 bool virDomainHasNet(virDomainDef *def, virDomainNetDef *net);
 int virDomainNetInsert(virDomainDef *def, virDomainNetDef *net);
 int virDomainNetUpdate(virDomainDef *def, size_t netidx, virDomainNetDef *newnet);
+bool virDomainNetBackendIsEqual(virDomainNetBackend *src,
+                                virDomainNetBackend *dst);
 int virDomainNetDHCPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
 int virDomainNetARPInterfaces(virDomainDef *def, virDomainInterfacePtr **ifaces);
 virDomainNetDef *virDomainNetRemove(virDomainDef *def, size_t i);
index 97c3d86217a9a2443dd96d4fb9ce3e08c17f1425..c6c47dbfac719cfecf97ae05dbd30caeb65b1811 100644 (file)
@@ -528,6 +528,7 @@ virDomainMouseModeTypeToString;
 virDomainNetAllocateActualDevice;
 virDomainNetAppendIPAddress;
 virDomainNetARPInterfaces;
+virDomainNetBackendIsEqual;
 virDomainNetBandwidthUpdate;
 virDomainNetDefActualFromNetworkPort;
 virDomainNetDefActualToNetworkPort;
index c490e2b97a50cb00a698dba5f0dbc4267d095874..b4cddef9f5be78fd278218f279998965705e7483 100644 (file)
@@ -3675,6 +3675,15 @@ qemuDomainChangeNet(virQEMUDriver *driver,
         goto cleanup;
     }
 
+    /* nothing in <backend> can be modified in an existing interface -
+     * the entire device will need to be removed and re-added.
+     */
+    if (!virDomainNetBackendIsEqual(&olddev->backend, &newdev->backend)) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+                       _("cannot modify network device backend settings"));
+        goto cleanup;
+    }
+
     /* allocate new actual device to compare to old - we will need to
      * free it if we fail for any reason
      */