[libvirt] [PATCH v4 1/2] xen_common: Split per-Vif logic from xenParseVif()

Ján Tomko jtomko at redhat.com
Thu Jun 14 15:23:24 UTC 2018


On Thu, Jun 14, 2018 at 06:59:52AM +0200, Fabiano Fidêncio wrote:
>xenParseVif() does a lot of stuff and, in order to make things cleaner,
>let's split it in two new functions:
>- xenParseVif(): it's a new function that keeps the old name. It's
>responsible for the whole per-Vif logic from the old xenParseVif();
>- xenParseVifList(): it's basically the old xenParsePCI(), but now it
>just iterates over the list of Vifs, calling xenParsePCI() per each Vif.
>
>This patch is basically preparing the ground for the future when
>typesafe virConf acessors will be used.
>
>Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
>---
> src/xenconfig/xen_common.c | 358 +++++++++++++++++++++++----------------------
> 1 file changed, 187 insertions(+), 171 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>
With the following diff squashed in, to minimize changes:

Jano

diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 02765c540b..4a94127da1 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -984,25 +984,21 @@ xenParseVif(char *entry, const char *vif_typename)
         virStringListFree(ip_list);
     }
 
-    if (script && script[0]) {
-        if (VIR_STRDUP(net->script, script) < 0)
-            goto cleanup;
-    }
+    if (script && script[0] &&
+        VIR_STRDUP(net->script, script) < 0)
+        goto cleanup;
 
-    if (model[0]) {
-        if (VIR_STRDUP(net->model, model) < 0)
-            goto cleanup;
-    }
+    if (model[0] &&
+        VIR_STRDUP(net->model, model) < 0)
+        goto cleanup;
 
-    if (!model[0] && type[0] && STREQ(type, vif_typename)) {
-        if (VIR_STRDUP(net->model, "netfront") < 0)
-            goto cleanup;
-    }
+    if (!model[0] && type[0] && STREQ(type, vif_typename) &&
+        VIR_STRDUP(net->model, "netfront") < 0)
+        goto cleanup;
 
-    if (vifname[0]) {
-        if (VIR_STRDUP(net->ifname, vifname) < 0)
-            goto cleanup;
-    }
+    if (vifname[0] &&
+        VIR_STRDUP(net->ifname, vifname) < 0)
+        goto cleanup;
 
     if (rate[0]) {
         virNetDevBandwidthPtr bandwidth;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180614/f3e38fba/attachment-0001.sig>


More information about the libvir-list mailing list