]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
interface: don't error out if a bond has no interfaces
authorLubomir Rintel <lkundrak@v3.sk>
Wed, 27 May 2015 17:30:50 +0000 (19:30 +0200)
committerLaine Stump <laine@laine.org>
Wed, 27 May 2015 18:25:45 +0000 (14:25 -0400)
It's not a problem at all and causes virt-manager to break down.

Note: netcf 0.2.8 and earlier generates invalid XML for a bond with no
interfaces anyway, so in that case this error in libvirt is never
reached since we fail earlier.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
src/conf/interface_conf.c

index c2eb94535488d07220d6a28f7e12ab0a550e762c..26e55cc4f8b3cb12cf664d7ccd0701a6d04124a4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * interface_conf.c: interfaces XML handling
  *
- * Copyright (C) 2006-2010, 2013, 2014 Red Hat, Inc.
+ * Copyright (C) 2006-2010, 2013-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -548,39 +548,34 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
     virInterfaceDefPtr itf;
     int nbItf;
     size_t i;
-    int ret = 0;
+    int ret = -1;
 
     nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
-    if (nbItf < 0) {
-        ret = -1;
-        goto error;
-    }
+    if (nbItf < 0)
+        goto cleanup;
 
     if (nbItf == 0) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       "%s", _("bond has no interfaces"));
-        ret = -1;
-        goto error;
+        ret = 0;
+        goto cleanup;
     }
 
-    if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
-        ret = -1;
-        goto error;
-    }
+    if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0)
+        goto cleanup;
+
     def->data.bond.nbItf = nbItf;
 
     for (i = 0; i < nbItf; i++) {
         ctxt->node = interfaces[i];
         itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND);
         if (itf == NULL) {
-            ret = -1;
             def->data.bond.nbItf = i;
-            goto error;
+            goto cleanup;
         }
         def->data.bond.itf[i] = itf;
     }
 
- error:
+    ret = 0;
+ cleanup:
     VIR_FREE(interfaces);
     ctxt->node = bond;
     return ret;