]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: make virDomainNetNotifyActualDevice() callable for all interface types
authorLaine Stump <laine@redhat.com>
Tue, 20 Oct 2020 16:35:09 +0000 (12:35 -0400)
committerLaine Stump <laine@redhat.com>
Fri, 8 Jan 2021 16:34:21 +0000 (11:34 -0500)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>Reviewed-by: Michal Privoznik <mprivozn@redhat.com>#Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h

index 472ce79e679ab23b8bf106c4905b766c1c2ff908..40ca20be334b49fd7102e3605e50a00dcc9c53c6 100644 (file)
@@ -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) {
         return;
     }
 
@@ -30946,7 +30947,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
          * (final arg to virNetDevTapReattachBridge())
          */
         ignore_value(virNetDevTapReattachBridge(iface->ifname,
-                                                iface->data.network.actual->data.bridge.brname,
+                                                virDomainNetGetActualBridgeName(iface),
                                                 &iface->mac, dom->uuid,
                                                 virDomainNetGetActualVirtPortProfile(iface),
                                                 virDomainNetGetActualVlan(iface),
index 59bf8a12b3e607e8f285d34d98fbeb1aa810de79..ec43bbe186680215808d45385686621e4f71118e 100644 (file)
@@ -3875,7 +3875,7 @@ void
 virDomainNetNotifyActualDevice(virConnectPtr conn,
                                virDomainDefPtr dom,
                                virDomainNetDefPtr iface)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 
 int
 virDomainNetReleaseActualDevice(virConnectPtr conn,