[libvirt] [PATCH 2/7] conf: make virDomainNetGetActualVlan arg/return val const

Laine Stump laine at redhat.com
Wed Oct 23 01:24:15 UTC 2019


This is needed if we want to call the function when the
virDomainNetDef* we have is a const.

Since virDomainNetGetActualVlan returns a pointer to memory that is
within the virDomainNetDefPtr arg, the returned pointer must also be
made const. This leads to a cascade of other virNetDevVlanPtr's that
must be changed to "const virNetDevVlan *".

Signed-off-by: Laine Stump <laine at redhat.com>
---
 src/conf/domain_conf.c          | 6 +++---
 src/conf/domain_conf.h          | 2 +-
 src/libxl/libxl_conf.c          | 2 +-
 src/libxl/xen_common.c          | 2 +-
 src/util/virhostdev.c           | 2 +-
 src/util/virnetdev.c            | 4 ++--
 src/util/virnetdev.h            | 2 +-
 src/util/virnetdevmacvlan.c     | 4 ++--
 src/util/virnetdevmacvlan.h     | 2 +-
 src/util/virnetdevopenvswitch.c | 6 +++---
 src/util/virnetdevopenvswitch.h | 4 ++--
 src/util/virnetdevtap.c         | 6 +++---
 src/util/virnetdevtap.h         | 6 +++---
 tests/bhyvexml2argvmock.c       | 2 +-
 14 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 80e19a15df..c0122dfd07 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29710,10 +29710,10 @@ virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
     return iface->bandwidth;
 }
 
-virNetDevVlanPtr
-virDomainNetGetActualVlan(virDomainNetDefPtr iface)
+const virNetDevVlan *
+virDomainNetGetActualVlan(const virDomainNetDef *iface)
 {
-    virNetDevVlanPtr vlan = &iface->vlan;
+    const virNetDevVlan *vlan = &iface->vlan;
 
     /* if there is an ActualNetDef, *always* return
      * its vlan rather than the NetDef's vlan.
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a481389925..9ca3a5bf06 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3213,7 +3213,7 @@ virNetDevVPortProfilePtr
 virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
 virNetDevBandwidthPtr
 virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
-virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface);
+const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *iface);
 bool virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface);
 const char *virDomainNetGetModelString(const virDomainNetDef *net);
 int virDomainNetSetModelString(virDomainNetDefPtr et,
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 3f08f0f710..89122826fc 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1218,7 +1218,7 @@ libxlMakeNic(virDomainDefPtr def,
     virConnectPtr conn = NULL;
     virNetDevBandwidthPtr actual_bw;
     virNetDevVPortProfilePtr port_profile;
-    virNetDevVlanPtr virt_vlan;
+    const virNetDevVlan *virt_vlan;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     size_t i;
     const char *script = NULL;
diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index cc9039a0cf..6e77921333 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -1681,7 +1681,7 @@ xenFormatNet(virConnectPtr conn,
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
     {
         virNetDevVPortProfilePtr port_profile = virDomainNetGetActualVirtPortProfile(net);
-        virNetDevVlanPtr virt_vlan = virDomainNetGetActualVlan(net);
+        const virNetDevVlan *virt_vlan = virDomainNetGetActualVlan(net);
         const char *script = net->script;
         size_t i;
 
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 010eb551a9..223a78bd34 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -501,7 +501,7 @@ virHostdevSetNetConfig(virDomainHostdevDefPtr hostdev,
                        const unsigned char *uuid)
 {
     g_autofree char *linkdev = NULL;
-    virNetDevVlanPtr vlan;
+    const virNetDevVlan *vlan;
     virNetDevVPortProfilePtr virtPort;
     int vf = -1;
     bool port_profile_associate = true;
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 5391f0030b..7adc69905d 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -2178,7 +2178,7 @@ virNetDevReadNetConfig(const char *linkdev, int vf,
 int
 virNetDevSetNetConfig(const char *linkdev, int vf,
                       const virMacAddr *adminMAC,
-                      virNetDevVlanPtr vlan,
+                      const virNetDevVlan *vlan,
                       const virMacAddr *MAC,
                       bool setVlan)
 {
@@ -2401,7 +2401,7 @@ int
 virNetDevSetNetConfig(const char *linkdev G_GNUC_UNUSED,
                       int vf G_GNUC_UNUSED,
                       const virMacAddr *adminMAC G_GNUC_UNUSED,
-                      virNetDevVlanPtr vlan G_GNUC_UNUSED,
+                      const virNetDevVlan *vlan G_GNUC_UNUSED,
                       const virMacAddr *MAC G_GNUC_UNUSED,
                       bool setVlan G_GNUC_UNUSED)
 {
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index b5a5214bcb..24b41498ed 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -253,7 +253,7 @@ virNetDevReadNetConfig(const char *linkdev, int vf,
 int
 virNetDevSetNetConfig(const char *linkdev, int vf,
                       const virMacAddr *adminMAC,
-                      virNetDevVlanPtr vlan,
+                      const virNetDevVlan *vlan,
                       const virMacAddr *MAC,
                       bool setVLan)
     ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 2ccd83d1bb..c530cb75ed 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -895,7 +895,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
                                        const virMacAddr *macaddress,
                                        const char *linkdev,
                                        virNetDevMacVLanMode mode,
-                                       virNetDevVlanPtr vlan,
+                                       const virNetDevVlan *vlan,
                                        const unsigned char *vmuuid,
                                        virNetDevVPortProfilePtr virtPortProfile,
                                        char **ifnameResult,
@@ -1224,7 +1224,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname G_GNUC_UNUSED,
                                            const virMacAddr *macaddress G_GNUC_UNUSED,
                                            const char *linkdev G_GNUC_UNUSED,
                                            virNetDevMacVLanMode mode G_GNUC_UNUSED,
-                                           virNetDevVlanPtr vlan G_GNUC_UNUSED,
+                                           const virNetDevVlan *vlan G_GNUC_UNUSED,
                                            const unsigned char *vmuuid G_GNUC_UNUSED,
                                            virNetDevVPortProfilePtr virtPortProfile G_GNUC_UNUSED,
                                            char **res_ifname G_GNUC_UNUSED,
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
index 30038a45b5..f455ec3384 100644
--- a/src/util/virnetdevmacvlan.h
+++ b/src/util/virnetdevmacvlan.h
@@ -76,7 +76,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
                                            const virMacAddr *macaddress,
                                            const char *linkdev,
                                            virNetDevMacVLanMode mode,
-                                           virNetDevVlanPtr vlan,
+                                           const virNetDevVlan *vlan,
                                            const unsigned char *vmuuid,
                                            virNetDevVPortProfilePtr virtPortProfile,
                                            char **res_ifname,
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 1d2bbf9dd7..9aa2c5ad84 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -68,7 +68,7 @@ virNetDevOpenvswitchAddTimeout(virCommandPtr cmd)
  * Returns 0 in case of success or -1 in case of failure.
  */
 static int
-virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr virtVlan)
+virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, const virNetDevVlan *virtVlan)
 {
     int ret = -1;
     size_t i = 0;
@@ -136,7 +136,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
                                 const virMacAddr *macaddr,
                                 const unsigned char *vmuuid,
                                 virNetDevVPortProfilePtr ovsport,
-                                virNetDevVlanPtr virtVlan)
+                                const virNetDevVlan *virtVlan)
 {
     char macaddrstr[VIR_MAC_STRING_BUFLEN];
     char ifuuidstr[VIR_UUID_STRING_BUFLEN];
@@ -547,7 +547,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
  * Returns 0 in case of success or -1 in case of failure.
  */
 int virNetDevOpenvswitchUpdateVlan(const char *ifname,
-                                   virNetDevVlanPtr virtVlan)
+                                   const virNetDevVlan *virtVlan)
 {
     g_autoptr(virCommand) cmd = NULL;
 
diff --git a/src/util/virnetdevopenvswitch.h b/src/util/virnetdevopenvswitch.h
index 2e15384b5f..dddb21a5a2 100644
--- a/src/util/virnetdevopenvswitch.h
+++ b/src/util/virnetdevopenvswitch.h
@@ -33,7 +33,7 @@ int virNetDevOpenvswitchAddPort(const char *brname,
                                 const virMacAddr *macaddr,
                                 const unsigned char *vmuuid,
                                 virNetDevVPortProfilePtr ovsport,
-                                virNetDevVlanPtr virtVlan)
+                                const virNetDevVlan *virtVlan)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
     G_GNUC_WARN_UNUSED_RESULT;
 
@@ -65,5 +65,5 @@ int virNetDevOpenvswitchGetVhostuserIfname(const char *path,
     ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT G_GNUC_NO_INLINE;
 
 int virNetDevOpenvswitchUpdateVlan(const char *ifname,
-                                   virNetDevVlanPtr virtVlan)
+                                   const virNetDevVlan *virtVlan)
     ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index fe4f55f8fc..fa1626d6ba 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -503,7 +503,7 @@ virNetDevTapAttachBridge(const char *tapname,
                          const virMacAddr *macaddr,
                          const unsigned char *vmuuid,
                          virNetDevVPortProfilePtr virtPortProfile,
-                         virNetDevVlanPtr virtVlan,
+                         const virNetDevVlan *virtVlan,
                          unsigned int mtu,
                          unsigned int *actualMTU)
 {
@@ -575,7 +575,7 @@ virNetDevTapReattachBridge(const char *tapname,
                            const virMacAddr *macaddr,
                            const unsigned char *vmuuid,
                            virNetDevVPortProfilePtr virtPortProfile,
-                           virNetDevVlanPtr virtVlan,
+                           const virNetDevVlan *virtVlan,
                            unsigned int mtu,
                            unsigned int *actualMTU)
 {
@@ -661,7 +661,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
                                    int *tapfd,
                                    size_t tapfdSize,
                                    virNetDevVPortProfilePtr virtPortProfile,
-                                   virNetDevVlanPtr virtVlan,
+                                   const virNetDevVlan *virtVlan,
                                    virNetDevCoalescePtr coalesce,
                                    unsigned int mtu,
                                    unsigned int *actualMTU,
diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h
index cbc799bdbe..4fc734fd5e 100644
--- a/src/util/virnetdevtap.h
+++ b/src/util/virnetdevtap.h
@@ -64,7 +64,7 @@ virNetDevTapAttachBridge(const char *tapname,
                          const virMacAddr *macaddr,
                          const unsigned char *vmuuid,
                          virNetDevVPortProfilePtr virtPortProfile,
-                         virNetDevVlanPtr virtVlan,
+                         const virNetDevVlan *virtVlan,
                          unsigned int mtu,
                          unsigned int *actualMTU)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
@@ -76,7 +76,7 @@ virNetDevTapReattachBridge(const char *tapname,
                            const virMacAddr *macaddr,
                            const unsigned char *vmuuid,
                            virNetDevVPortProfilePtr virtPortProfile,
-                           virNetDevVlanPtr virtVlan,
+                           const virNetDevVlan *virtVlan,
                            unsigned int mtu,
                            unsigned int *actualMTU)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
@@ -90,7 +90,7 @@ int virNetDevTapCreateInBridgePort(const char *brname,
                                    int *tapfd,
                                    size_t tapfdSize,
                                    virNetDevVPortProfilePtr virtPortProfile,
-                                   virNetDevVlanPtr virtVlan,
+                                   const virNetDevVlan *virtVlan,
                                    virNetDevCoalescePtr coalesce,
                                    unsigned int mtu,
                                    unsigned int *actualMTU,
diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c
index b0d38187f9..ac4ffe8596 100644
--- a/tests/bhyvexml2argvmock.c
+++ b/tests/bhyvexml2argvmock.c
@@ -27,7 +27,7 @@ int virNetDevTapCreateInBridgePort(const char *brname G_GNUC_UNUSED,
                                    int *tapfd G_GNUC_UNUSED,
                                    size_t tapfdSize G_GNUC_UNUSED,
                                    virNetDevVPortProfilePtr virtPortProfile G_GNUC_UNUSED,
-                                   virNetDevVlanPtr virtVlan G_GNUC_UNUSED,
+                                   const virNetDevVlan *virtVlan G_GNUC_UNUSED,
                                    virNetDevCoalescePtr coalesce G_GNUC_UNUSED,
                                    unsigned int mtu G_GNUC_UNUSED,
                                    unsigned int *actualMTU G_GNUC_UNUSED,
-- 
2.21.0




More information about the libvir-list mailing list