]> xenbits.xensource.com Git - libvirt.git/commitdiff
Allow empty bridges in interface xml.
authorLaine Stump <laine@laine.org>
Sat, 2 Jan 2010 01:40:24 +0000 (20:40 -0500)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 19 Jan 2010 20:13:03 +0000 (21:13 +0100)
src/conf/interface_conf.c

index ca8220852a5eaf37022fb6e9611c6f2ac429cd01..d7821e7defc779f143f8508ae16444c07c74dc09 100644 (file)
@@ -557,28 +557,30 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def,
 
     bridge = ctxt->node;
     nbItf = virXPathNodeSet(conn, "./interface", ctxt, &interfaces);
-    if (nbItf <= 0) {
+    if (nbItf < 0) {
         virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
-                                "%s", _("bridge has no interfaces"));
+                                "%s", _("bridge interfaces"));
         ret = -1;
         goto error;
     }
-    if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) {
-        virReportOOMError(conn);
-        ret = -1;
-        goto error;
-    }
-    def->data.bridge.nbItf = nbItf;
-
-    for (i = 0; i < nbItf;i++) {
-        ctxt->node = interfaces[i];
-        itf = virInterfaceDefParseBareInterface(conn, ctxt, 0);
-        if (itf == NULL) {
+    if (nbItf > 0) {
+        if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) {
+            virReportOOMError(conn);
             ret = -1;
-            def->data.bridge.nbItf = i;
             goto error;
         }
-        def->data.bridge.itf[i] = itf;
+        def->data.bridge.nbItf = nbItf;
+
+        for (i = 0; i < nbItf;i++) {
+            ctxt->node = interfaces[i];
+            itf = virInterfaceDefParseBareInterface(conn, ctxt, 0);
+            if (itf == NULL) {
+                ret = -1;
+                def->data.bridge.nbItf = i;
+                goto error;
+            }
+            def->data.bridge.itf[i] = itf;
+        }
     }
 
 error: