* src/xm_internal.c: patches from Masayuki Sunou to fix a problem

when an HVM domain is started with a CD-Rom config, this should
  fix #328841
Daniel
This commit is contained in:
Daniel Veillard 2007-11-01 13:33:58 +00:00
parent 390cca8125
commit c33b54df47
2 changed files with 50 additions and 28 deletions

View File

@ -1,3 +1,9 @@
Thu Nov 1 14:32:07 CET 2007 Daniel Veillard <veillard@redhat.com>
* src/xm_internal.c: patches from Masayuki Sunou to fix a problem
when an HVM domain is started with a CD-Rom config, this should
fix #328841
Wed Oct 31 10:36:00 CET 2007 Daniel Veillard <veillard@redhat.com> Wed Oct 31 10:36:00 CET 2007 Daniel Veillard <veillard@redhat.com>
* proxy/libvirt_proxy.c src/proxy_internal.[ch] src/xen_internal.c * proxy/libvirt_proxy.c src/proxy_internal.[ch] src/xen_internal.c

View File

@ -758,10 +758,15 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
/* Extract source driver type */ /* Extract source driver type */
if (!(tmp = strchr(src, ':')) || !tmp[0]) if (!src[0]) {
strcpy(drvName, "phy");
tmp = &src[0];
} else if (!(tmp = strchr(src, ':')) || !tmp[0]) {
goto skipdisk; goto skipdisk;
} else {
strncpy(drvName, src, (tmp-src)); strncpy(drvName, src, (tmp-src));
drvName[tmp-src] = '\0'; drvName[tmp-src] = '\0';
}
/* And the source driver sub-type */ /* And the source driver sub-type */
if (!strncmp(drvName, "tap", 3)) { if (!strncmp(drvName, "tap", 3)) {
@ -771,6 +776,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
memmove(src, src+(tmp1-src)+1, strlen(src)-(tmp1-src)); memmove(src, src+(tmp1-src)+1, strlen(src)-(tmp1-src));
} else { } else {
drvType[0] = '\0'; drvType[0] = '\0';
if (src[0])
memmove(src, src+(tmp-src)+1, strlen(src)-(tmp-src)); memmove(src, src+(tmp-src)+1, strlen(src)-(tmp-src));
} }
@ -798,6 +804,7 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
virBufferVSprintf(buf, " <driver name='%s' type='%s'/>\n", drvName, drvType); virBufferVSprintf(buf, " <driver name='%s' type='%s'/>\n", drvName, drvType);
else else
virBufferVSprintf(buf, " <driver name='%s'/>\n", drvName); virBufferVSprintf(buf, " <driver name='%s'/>\n", drvName);
if (src[0])
virBufferVSprintf(buf, " <source %s='%s'/>\n", block ? "dev" : "file", src); virBufferVSprintf(buf, " <source %s='%s'/>\n", block ? "dev" : "file", src);
virBufferVSprintf(buf, " <target dev='%s'/>\n", dev); virBufferVSprintf(buf, " <target dev='%s'/>\n", dev);
if (!strcmp(head, "r") || if (!strcmp(head, "r") ||
@ -1536,13 +1543,6 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
cur = cur->next; cur = cur->next;
} }
if (source == NULL) {
if (target != NULL)
xmlFree(target);
if (device != NULL)
xmlFree(device);
return (-1);
}
if (target == NULL) { if (target == NULL) {
if (source != NULL) if (source != NULL)
xmlFree(source); xmlFree(source);
@ -1573,6 +1573,14 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
} }
} }
if (source == NULL && !cdrom) {
if (target != NULL)
xmlFree(target);
if (device != NULL)
xmlFree(device);
return (-1);
}
if (drvName) { if (drvName) {
buflen += strlen((const char*)drvName) + 1; buflen += strlen((const char*)drvName) + 1;
if (!strcmp((const char*)drvName, "tap")) { if (!strcmp((const char*)drvName, "tap")) {
@ -1588,7 +1596,10 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
buflen += 4; buflen += 4;
} }
if(source)
buflen += strlen((const char*)source) + 1; buflen += strlen((const char*)source) + 1;
else
buflen += 1;
buflen += strlen((const char*)target) + 1; buflen += strlen((const char*)target) + 1;
if (hvm && xendConfigVersion == 1) /* ioemu: */ if (hvm && xendConfigVersion == 1) /* ioemu: */
buflen += 6; buflen += 6;
@ -1601,6 +1612,7 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
if (!(buf = malloc(buflen))) if (!(buf = malloc(buflen)))
goto cleanup; goto cleanup;
if(source) {
if (drvName) { if (drvName) {
strcpy(buf, (const char*)drvName); strcpy(buf, (const char*)drvName);
if (!strcmp((const char*)drvName, "tap")) { if (!strcmp((const char*)drvName, "tap")) {
@ -1618,6 +1630,9 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
} }
strcat(buf, ":"); strcat(buf, ":");
strcat(buf, (const char*)source); strcat(buf, (const char*)source);
} else {
strcpy(buf, "");
}
strcat(buf, ","); strcat(buf, ",");
if (hvm && xendConfigVersion == 1) if (hvm && xendConfigVersion == 1)
strcat(buf, "ioemu:"); strcat(buf, "ioemu:");
@ -1637,6 +1652,7 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch
xmlFree(drvName); xmlFree(drvName);
xmlFree(device); xmlFree(device);
xmlFree(target); xmlFree(target);
if(source)
xmlFree(source); xmlFree(source);
*disk = buf; *disk = buf;