]> xenbits.xensource.com Git - libvirt.git/commitdiff
Tue Feb 14 16:21:18 IST 2007 Mark McLoughlin <markmc@redhat.com>
authorMark McLoughlin <markmc@redhat.com>
Wed, 14 Feb 2007 16:22:02 +0000 (16:22 +0000)
committerMark McLoughlin <markmc@redhat.com>
Wed, 14 Feb 2007 16:22:02 +0000 (16:22 +0000)
        * src/xml.c: with <interface type="network"> connect the
        Xen guest to the appropriate bridge.

ChangeLog
src/xml.c

index cb9228bac4911fbf278c62a9eb5464f8454cf93f..730556b8871eb48c81af37bdff6bb49081ba6384 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 14 16:21:18 IST 2007 Mark McLoughlin <markmc@redhat.com>
+
+       * src/xml.c: with <interface type="network"> connect the
+       Xen guest to the appropriate bridge.
+       
 Tue Feb 14 16:17:51 IST 2007 Mark McLoughlin <markmc@redhat.com>
 
        * include/libvirt/libvirt.h.in, src/libvirt.c: add
index f6e7552cd7be35ae2a0dac8b14ec51bae9f44b9c..50c939286cfa2dd95b47cd22c3e76ed4f3676be2 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -842,6 +842,7 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
     xmlChar *script = NULL;
     xmlChar *ip = NULL;
     int typ = 0;
+    int ret = -1;
 
     type = xmlGetProp(node, BAD_CAST "type");
     if (type != NULL) {
@@ -849,6 +850,8 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
             typ = 0;
         else if (xmlStrEqual(type, BAD_CAST "ethernet"))
             typ = 1;
+        else if (xmlStrEqual(type, BAD_CAST "network"))
+            typ = 2;
         xmlFree(type);
     }
     cur = node->children;
@@ -858,8 +861,10 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
                 (xmlStrEqual(cur->name, BAD_CAST "source"))) {
                 if (typ == 0)
                     source = xmlGetProp(cur, BAD_CAST "bridge");
-                else
+                else if (typ == 1)
                     source = xmlGetProp(cur, BAD_CAST "dev");
+                else
+                    source = xmlGetProp(cur, BAD_CAST "network");
             } else if ((mac == NULL) &&
                        (xmlStrEqual(cur->name, BAD_CAST "mac"))) {
                 mac = xmlGetProp(cur, BAD_CAST "address");
@@ -884,8 +889,18 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
     if (source != NULL) {
         if (typ == 0)
             virBufferVSprintf(buf, "(bridge '%s')", (const char *) source);
-        else                    /* TODO does that work like that ? */
+        else if (typ == 1)      /* TODO does that work like that ? */
             virBufferVSprintf(buf, "(dev '%s')", (const char *) source);
+        else {
+            virNetworkPtr network = virNetworkLookupByName(conn, (const char *) source);
+            char *bridge;
+            if (!network || !(bridge = virNetworkGetBridgeName(network))) {
+                virXMLError(conn, VIR_ERR_NO_SOURCE, (const char *) source, 0);
+                goto error;
+            }
+            virBufferVSprintf(buf, "(bridge '%s')", bridge);
+            free(bridge);
+        }
     }
     if (script != NULL)
         virBufferVSprintf(buf, "(script '%s')", script);
@@ -895,6 +910,8 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
         virBufferAdd(buf, "(type ioemu)", 12);
 
     virBufferAdd(buf, ")", 1);
+    ret = 0;
+ error:
     if (mac != NULL)
         xmlFree(mac);
     if (source != NULL)
@@ -903,7 +920,7 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
         xmlFree(script);
     if (ip != NULL)
         xmlFree(ip);
-    return (0);
+    return (ret);
 }
 
 /**