Re: [libvirt] [PATCH 5/6] lxc: Create a method to initialize network data outisde.

2019-02-25 Thread John Ferlan


$SUBJ:

lxc: Introduce lxcNetworkParseDataType

[see below for name change]

On 2/18/19 2:09 PM, Julio Faracco wrote:
> This method has the same idea of the method to parse IPv{4,6} data.
> The method lxcNetworkParseDataInit() is responsible to initialize
> network settings outside handler.

Extract out the network "type" processing into it's own method
rather than inline within lxcNetworkParseDataSuffix.

> 
> Signed-off-by: Julio Faracco 
> ---
>  src/lxc/lxc_native.c | 56 +---
>  1 file changed, 32 insertions(+), 24 deletions(-)
> 
> diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
> index 95e08c18f4..25e35e93dd 100644
> --- a/src/lxc/lxc_native.c
> +++ b/src/lxc/lxc_native.c
> @@ -552,6 +552,37 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
>  return -1;
>  }
>  
> +static int
> +lxcNetworkParseDataInit(virConfValuePtr value, lxcNetworkParseData 
> *parseData)

Similar w/r/t blank lines and 2 lines per argument

I think this is better named lxcNetworkParseDataType

Reviewed-by: John Ferlan 

John

[...]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 5/6] lxc: Create a method to initialize network data outisde.

2019-02-18 Thread Julio Faracco
This method has the same idea of the method to parse IPv{4,6} data.
The method lxcNetworkParseDataInit() is responsible to initialize
network settings outside handler.

Signed-off-by: Julio Faracco 
---
 src/lxc/lxc_native.c | 56 +---
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 95e08c18f4..25e35e93dd 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -552,6 +552,37 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data)
 return -1;
 }
 
+static int
+lxcNetworkParseDataInit(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, 
lxcNetworkParseData *parseData)
 {
@@ -591,32 +622,9 @@ lxcNetworkParseDataIPs(const char *name, virConfValuePtr 
value, lxcNetworkParseD
 static int
 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 (lxcNetworkParseDataInit(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;
-- 
2.19.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list