]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Jan 2024 17:43:21 +0000 (18:43 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Jan 2024 15:41:12 +0000 (16:41 +0100)
After v9.1.0-rc1~116 we track whether it's us who created a
macvtap or not. But when updating a vNIC its definition might be
replaced with a new one (though, ifname is not allowed to
change), e.g. to reflect new QoS, link state, etc.

Now, the fact whether we created macvtap for given vNIC is stored
in net->privateData->created. And replacing definition is done by
simply freeing the old definition and making the pointer point to
the new one. But this does not preserve the 'created' flag, which
in turn means when a domain is shutting off, the macvtap is not
removed (see loop inside of qemuProcessStop()).

Copy this flag into new definition and leave a note in
_qemuDomainNetworkPrivate struct.

Fixes: 61d1b9e6592660121aeda66bf7adbcd39de06aa8
Resolves: https://issues.redhat.com/browse/RHEL-22714
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.h
src/qemu/qemu_hotplug.c

index b4512cc80e250d72a898fdfd1b149fdf1df52772..6ba3f10e8d64687a3d39748b6ca473fd1c394dc1 100644 (file)
@@ -420,6 +420,8 @@ typedef struct _qemuDomainNetworkPrivate qemuDomainNetworkPrivate;
 struct _qemuDomainNetworkPrivate {
     virObject parent;
 
+    /* Don't forget to possibly copy these members in qemuDomainChangeNet(). */
+
     /* True if the device was created by us. Otherwise we should
      * avoid removing it. Currently only used for
      * VIR_DOMAIN_NET_TYPE_DIRECT. */
index 0e45bd53e129b8e7082f7ee5106d661089fcfdd5..31b00e05cad05ba8adcf98f6f5c68d32fdb024e5 100644 (file)
@@ -4166,6 +4166,11 @@ qemuDomainChangeNet(virQEMUDriver *driver,
             else
                 VIR_WARN("Unable to release network device '%s'", NULLSTR(olddev->ifname));
         }
+
+        /* Carry over fact whether we created the device or not. */
+        QEMU_DOMAIN_NETWORK_PRIVATE(newdev)->created =
+            QEMU_DOMAIN_NETWORK_PRIVATE(olddev)->created;
+
         virDomainNetDefFree(olddev);
         /* move newdev into the nets list, and NULL it out from the
          * virDomainDeviceDef that we were given so that the caller