[libvirt Patch v2 1/4] conf: make virDomainNetNotifyActualDevice() callable for all interface types

Laine Stump laine at redhat.com
Fri Jan 8 15:38:46 UTC 2021

The bridge reattach functionality in this function should be called
for interface types other than just type='network', so make it
callable for any type - it just becomes a NOP for types where no
action is needed.

In the case of <interface type='network'> we need to create a port in
the network driver, and for both type='network and type='bridge' we
need to reattach the bridge device (note that
virDomainNetGetActualBridgeName() gets the bridge name from the
appropriate (and different!) location for either type of interface).

All other interfaces currently require no action.

modifying callers of this function to actually call it for all
interface types is in the next patch. For now the behavior should be
identical pre and post-patch.

(NB: the conn argument can now legitimately be NULL, so we need to
change the ATTRIBUTE_NONNULL() directive for the function's
declaration - I noticed when making this change that argument 3 (the
NetDefPtr) could never be NULL, so I added ATTRIBUTE_NONNULL(3) while
removing ATTRIBUTE_NONNULL(1) (conn)).

Signed-off-by: Laine Stump <laine at redhat.com>
 src/conf/domain_conf.c | 7 ++++---
 src/conf/domain_conf.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 472ce79e67..40ca20be33 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30933,8 +30933,9 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
     virDomainNetType actualType = virDomainNetGetActualType(iface);
-    if (virDomainNetCreatePort(conn, dom, iface,
-                               VIR_NETWORK_PORT_CREATE_RECLAIM) < 0) {
+    if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && conn
+        && virDomainNetCreatePort(conn, dom, iface,
+                                  VIR_NETWORK_PORT_CREATE_RECLAIM) < 0) {
@@ -30946,7 +30947,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
          * (final arg to virNetDevTapReattachBridge())
-                                                iface->data.network.actual->data.bridge.brname,
+                                                virDomainNetGetActualBridgeName(iface),
                                                 &iface->mac, dom->uuid,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 59bf8a12b3..ec43bbe186 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3875,7 +3875,7 @@ void
 virDomainNetNotifyActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
                                virDomainNetDefPtr iface)
 virDomainNetReleaseActualDevice(virConnectPtr conn,

More information about the libvir-list mailing list