diff -rup libvirt-0.2.3.orig/src/xm_internal.c libvirt-0.2.3.new/src/xm_internal.c --- libvirt-0.2.3.orig/src/xm_internal.c 2007-07-24 14:32:41.000000000 -0400 +++ libvirt-0.2.3.new/src/xm_internal.c 2007-08-09 12:46:58.000000000 -0400 @@ -1624,7 +1623,7 @@ static int xenXMParseXMLDisk(xmlNodePtr return (ret); } -static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) { +static char *xenXMParseXMLVif(virConnectPtr conn, xmlNodePtr node, int hvm) { xmlNodePtr cur; xmlChar *type = NULL; xmlChar *source = NULL; @@ -1634,6 +1633,7 @@ static char *xenXMParseXMLVif(xmlNodePtr int typ = 0; char *buf = NULL; int buflen = 0; + char *bridge = NULL; type = xmlGetProp(node, BAD_CAST "type"); if (type != NULL) { @@ -1641,6 +1641,8 @@ static char *xenXMParseXMLVif(xmlNodePtr 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; @@ -1651,8 +1653,10 @@ static char *xenXMParseXMLVif(xmlNodePtr 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"); @@ -1674,8 +1678,17 @@ static char *xenXMParseXMLVif(xmlNodePtr if (source) { if (typ == 0) { buflen += 8 + strlen((const char *)source); - } else { + } else if (typ == 1) { buflen += 5 + strlen((const char *)source); + } else { + virNetworkPtr network = virNetworkLookupByName(conn, (const char *) source); + if (!network || !(bridge = virNetworkGetBridgeName(network))) { + if (network) + virNetworkFree(network); + goto cleanup; + } + virNetworkFree(network); + buflen += 8 + strlen(bridge); } } if (hvm) @@ -1694,9 +1707,12 @@ static char *xenXMParseXMLVif(xmlNodePtr if (typ == 0) { strcat(buf, ",bridge="); strcat(buf, (const char*)source); - } else { - strcat(buf, ",mac="); + } else if (typ == 1) { + strcat(buf, ",dev="); strcat(buf, (const char*)source); + } else { + strcat(buf, ",bridge="); + strcat(buf, bridge); } } if (hvm) { @@ -1712,6 +1728,8 @@ static char *xenXMParseXMLVif(xmlNodePtr } cleanup: + if (bridge != NULL) + free(bridge); if (mac != NULL) xmlFree(mac); if (source != NULL) @@ -2033,7 +2058,7 @@ virConfPtr xenXMParseXMLToConfig(virConn vifs->list = NULL; for (i = 0; i < obj->nodesetval->nodeNr; i++) { virConfValuePtr thisVif; - char *vif = xenXMParseXMLVif(obj->nodesetval->nodeTab[i], hvm); + char *vif = xenXMParseXMLVif(conn, obj->nodesetval->nodeTab[i], hvm); if (!vif) goto error; if (!(thisVif = malloc(sizeof(virConfValue)))) { diff -rup libvirt-0.2.3.orig/src/xml.c libvirt-0.2.3.new/src/xml.c --- libvirt-0.2.3.orig/src/xml.c 2007-08-09 11:23:40.000000000 -0400 +++ libvirt-0.2.3.new/src/xml.c 2007-08-09 12:44:55.000000000 -0400 @@ -1119,9 +1119,12 @@ virDomainParseXMLIfDesc(virConnectPtr co virNetworkPtr network = virNetworkLookupByName(conn, (const char *) source); char *bridge; if (!network || !(bridge = virNetworkGetBridgeName(network))) { + if (network) + virNetworkFree(network); virXMLError(conn, VIR_ERR_NO_SOURCE, (const char *) source, 0); goto error; } + virNetworkFree(network); virBufferVSprintf(buf, "(bridge '%s')", bridge); free(bridge); }