[libvirt] [PATCH] Allow no <source> for bridge interfaces

john.levon at sun.com john.levon at sun.com
Mon Feb 2 15:01:50 UTC 2009


# HG changeset patch
# User john.levon at sun.com
# Date 1233586907 28800
# Node ID 68087e3caf39c74797720bde71a8df524ec036c8
# Parent  aa50ca252e1419f30eb0e16204b48db42d92c785
Allow no <source> for bridge interfaces

Historically, it was allowed to specify a bridge interface without a
specific bridge source, in which case xend would choose one. Keep
compatible with this behaviour.

Signed-off-by: John Levon <john.levon at sun.com>

diff --git a/src/domain_conf.c b/src/domain_conf.c
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -962,13 +962,10 @@ virDomainNetDefParseXML(virConnectPtr co
         break;
 
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
-        if (bridge == NULL) {
-            virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
-    _("No <source> 'dev' attribute specified with <interface type='bridge'/>"));
-            goto error;
-        }
-        def->data.bridge.brname = bridge;
-        bridge = NULL;
+        if (bridge != NULL) {
+            def->data.bridge.brname = bridge;
+            bridge = NULL;
+        }
         if (script != NULL) {
             def->data.bridge.script = script;
             script = NULL;
@@ -2920,8 +2917,9 @@ virDomainNetDefFormat(virConnectPtr conn
         break;
 
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
-        virBufferEscapeString(buf, "      <source bridge='%s'/>\n",
-                              def->data.bridge.brname);
+        if (def->data.bridge.brname)
+            virBufferEscapeString(buf, "      <source bridge='%s'/>\n",
+                                  def->data.bridge.brname);
         if (def->data.bridge.ipaddr)
             virBufferVSprintf(buf, "      <ip address='%s'/>\n",
                               def->data.bridge.ipaddr);
diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -5149,7 +5149,8 @@ xenDaemonFormatSxprNet(virConnectPtr con
 
     switch (def->type) {
     case VIR_DOMAIN_NET_TYPE_BRIDGE:
-        virBufferVSprintf(buf, "(bridge '%s')", def->data.bridge.brname);
+        if (def->data.bridge.brname)
+            virBufferVSprintf(buf, "(bridge '%s')", def->data.bridge.brname);
         if (def->data.bridge.script)
             script = def->data.bridge.script;
 




More information about the libvir-list mailing list