mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Fix virtual networking XML -> XM config file conversion & a mem leak
This commit is contained in:
parent
aa826860bc
commit
bf70fe4883
@ -1,3 +1,10 @@
|
||||
Wed Oct 10 13:13:53 EST 2007 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xm_internal.c: Fix XML -> XM config file conversion to
|
||||
include bridge name for virtual networks
|
||||
* src/xml.c: Fix memory leak handling XML -> SEXPR conversion
|
||||
of virtual network bridge devices
|
||||
|
||||
Mon Oct 8 17:01:53 CEST 2007 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/xend_internal.c: applied patch from Beth Kon to fix
|
||||
|
@ -1635,7 +1635,7 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
|
||||
|
||||
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;
|
||||
@ -1645,6 +1645,7 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
int typ = 0;
|
||||
char *buf = NULL;
|
||||
int buflen = 0;
|
||||
char *bridge = NULL;
|
||||
|
||||
type = xmlGetProp(node, BAD_CAST "type");
|
||||
if (type != NULL) {
|
||||
@ -1652,6 +1653,8 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
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;
|
||||
@ -1662,8 +1665,10 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
|
||||
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");
|
||||
@ -1685,8 +1690,17 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
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)
|
||||
@ -1705,9 +1719,12 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
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) {
|
||||
@ -1723,6 +1740,8 @@ static char *xenXMParseXMLVif(xmlNodePtr node, int hvm) {
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (bridge != NULL)
|
||||
free(bridge);
|
||||
if (mac != NULL)
|
||||
xmlFree(mac);
|
||||
if (source != NULL)
|
||||
@ -2058,7 +2077,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
|
||||
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)))) {
|
||||
|
@ -1023,9 +1023,12 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, xmlNodePtr node, vi
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user