[PATCH v4 3/4] lxc: remove domain definition from lxc network struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Domain definition is useless now inside network structure. This pointer
was required because new network definition was being added each time
that a new network type appeared. So, this should be processed into
old function `lxcNetworkParseDataType()`. Now, as it was moved to an
array, it can be handle together each interface pointer.

Signed-off-by: Julio Faracco <jcfaracco@xxxxxxxxx>
---
 src/lxc/lxc_native.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 8bbe205659..99539a0205 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -414,7 +414,6 @@ lxcCreateHostdevDef(int mode, int type, const char *data)
 typedef struct _lxcNetworkParseData lxcNetworkParseData;
 typedef lxcNetworkParseData *lxcNetworkParseDataPtr;
 struct _lxcNetworkParseData {
-    virDomainDefPtr def;
     char *type;
     char *link;
     char *mac;
@@ -470,13 +469,16 @@ lxcAddNetworkRouteDefinition(const char *address,
 }
 
 static int
-lxcAddNetworkDefinition(lxcNetworkParseData *data)
+lxcAddNetworkDefinition(virDomainDefPtr def, lxcNetworkParseData *data)
 {
     virDomainNetDefPtr net = NULL;
     virDomainHostdevDefPtr hostdev = NULL;
     bool isPhys, isVlan = false;
     size_t i;
 
+    if (!data)
+        return -1;
+
     if ((data->type == NULL) || STREQ(data->type, "empty") ||
          STREQ(data->type, "") ||  STREQ(data->type, "none"))
         return 0;
@@ -518,9 +520,9 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
                                          &hostdev->source.caps.u.net.ip.nroutes) < 0)
                 goto error;
 
-        if (VIR_EXPAND_N(data->def->hostdevs, data->def->nhostdevs, 1) < 0)
+        if (VIR_EXPAND_N(def->hostdevs, def->nhostdevs, 1) < 0)
             goto error;
-        data->def->hostdevs[data->def->nhostdevs - 1] = hostdev;
+        def->hostdevs[def->nhostdevs - 1] = hostdev;
     } else {
         if (!(net = lxcCreateNetDef(data->type, data->link, data->mac,
                                     data->flag, data->macvlanmode,
@@ -542,9 +544,9 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
                                          &net->guestIP.nroutes) < 0)
                 goto error;
 
-        if (VIR_EXPAND_N(data->def->nets, data->def->nnets, 1) < 0)
+        if (VIR_EXPAND_N(def->nets, def->nnets, 1) < 0)
             goto error;
-        data->def->nets[data->def->nnets - 1] = net;
+        def->nets[def->nnets - 1] = net;
     }
 
     return 1;
@@ -766,9 +768,8 @@ lxcConvertNetworkSettings(virDomainDefPtr def, virConfPtr properties)
 
     for (i = 0; i < networks.ndata; i++) {
         lxcNetworkParseDataPtr data = networks.parseData[i];
-        data->def = def;
 
-        status = lxcAddNetworkDefinition(data);
+        status = lxcAddNetworkDefinition(def, data);
 
         if (status < 0)
             goto error;
-- 
2.20.1






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux