]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Introduce lxcNetworkParseDataType
authorJulio Faracco <jcfaracco@gmail.com>
Mon, 18 Feb 2019 19:09:09 +0000 (16:09 -0300)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 25 Feb 2019 15:41:39 +0000 (10:41 -0500)
Extract out the network "type" processing into it's own method
rather than inline within lxcNetworkParseDataSuffix.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/lxc/lxc_native.c

index 6c0421a06ae3b33f000a6757a49078204275b9a3..5df05b6b5576a5154d9819b72accfc57d4c4990b 100644 (file)
@@ -553,6 +553,39 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
 }
 
 
+static int
+lxcNetworkParseDataType(virConfValuePtr value,
+                        lxcNetworkParseData *parseData)
+{
+    virDomainDefPtr def = parseData->def;
+    size_t networks = parseData->networks;
+    bool privnet = parseData->privnet;
+    int status;
+
+    /* Store the previous NIC */
+    status = lxcAddNetworkDefinition(parseData);
+
+    if (status < 0)
+        return -1;
+    else if (status > 0)
+        networks++;
+    else if (parseData->type != NULL && STREQ(parseData->type, "none"))
+        privnet = false;
+
+    /* clean NIC to store a new one */
+    memset(parseData, 0, sizeof(*parseData));
+
+    parseData->def = def;
+    parseData->networks = networks;
+    parseData->privnet = privnet;
+
+    /* Keep the new value */
+    parseData->type = value->str;
+
+    return 0;
+}
+
+
 static int
 lxcNetworkParseDataIPs(const char *name,
                        virConfValuePtr value,
@@ -597,32 +630,9 @@ lxcNetworkParseDataSuffix(const char *name,
                           virConfValuePtr value,
                           lxcNetworkParseData *parseData)
 {
-    int status;
-
     if (STREQ(name, "type")) {
-        virDomainDefPtr def = parseData->def;
-        size_t networks = parseData->networks;
-        bool privnet = parseData->privnet;
-
-        /* Store the previous NIC */
-        status = lxcAddNetworkDefinition(parseData);
-
-        if (status < 0)
+        if (lxcNetworkParseDataType(value, parseData) < 0)
             return -1;
-        else if (status > 0)
-            networks++;
-        else if (parseData->type != NULL && STREQ(parseData->type, "none"))
-            privnet = false;
-
-        /* clean NIC to store a new one */
-        memset(parseData, 0, sizeof(*parseData));
-
-        parseData->def = def;
-        parseData->networks = networks;
-        parseData->privnet = privnet;
-
-        /* Keep the new value */
-        parseData->type = value->str;
     }
     else if (STREQ(name, "link"))
         parseData->link = value->str;