qemu_hotplug: Don't lose 'created' flag in qemuDomainChangeNet()

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: 61d1b9e659
Resolves: https://issues.redhat.com/browse/RHEL-22714
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2024-01-24 18:43:21 +01:00
parent b49fb57395
commit ccfc5c1e16
2 changed files with 7 additions and 0 deletions

View File

@ -420,6 +420,8 @@ typedef struct _qemuDomainNetworkPrivate qemuDomainNetworkPrivate;
struct _qemuDomainNetworkPrivate { struct _qemuDomainNetworkPrivate {
virObject parent; virObject parent;
/* Don't forget to possibly copy these members in qemuDomainChangeNet(). */
/* True if the device was created by us. Otherwise we should /* True if the device was created by us. Otherwise we should
* avoid removing it. Currently only used for * avoid removing it. Currently only used for
* VIR_DOMAIN_NET_TYPE_DIRECT. */ * VIR_DOMAIN_NET_TYPE_DIRECT. */

View File

@ -4166,6 +4166,11 @@ qemuDomainChangeNet(virQEMUDriver *driver,
else else
VIR_WARN("Unable to release network device '%s'", NULLSTR(olddev->ifname)); 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); virDomainNetDefFree(olddev);
/* move newdev into the nets list, and NULL it out from the /* move newdev into the nets list, and NULL it out from the
* virDomainDeviceDef that we were given so that the caller * virDomainDeviceDef that we were given so that the caller