Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.52
diff -c -b -r1.52 xend_internal.c
*** src/xend_internal.c 9 Aug 2006 15:21:16 -0000 1.52
--- src/xend_internal.c 9 Aug 2006 22:58:48 -0000
***************
*** 791,796 ****
--- 791,808 ----
goto error;
ret = sscanf(r,
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x"
+ "%02x%02x%02x%02x",
+ uuid + 0, uuid + 1, uuid + 2, uuid + 3,
+ uuid + 4, uuid + 5, uuid + 6, uuid + 7,
+ uuid + 8, uuid + 9, uuid + 10, uuid + 11,
+ uuid + 12, uuid + 13, uuid + 14, uuid + 15);
+ if (ret == 16)
+ goto done;
+
+ ret = sscanf(r,
"%02x%02x%02x%02x-"
"%02x%02x-"
"%02x%02x-"
***************
*** 1416,1436 ****
virBufferVSprintf(buf, " %s\n", tmp);
tmp = sexpr_node(node, "domain/image/hvm/boot");
if ((tmp != NULL) && (tmp[0] != 0)) {
- /*
- * FIXME:
- * Figure out how to map the 'a', 'b', 'c' nonsense to a
- * device.
- */
if (tmp[0] == 'a')
! virBufferAdd(buf, " \n", 25 );
else if (tmp[0] == 'c')
/*
* Don't know what to put here. Say the vm has been given 3
* disks - hda, hdb, hdc. How does one identify the boot disk?
*/
! virBufferAdd(buf, " \n", 22 );
else if (strcmp(tmp, "d") == 0)
! virBufferAdd(buf, " \n", 29 );
}
} else {
virBufferVSprintf(buf, " linux\n");
--- 1428,1446 ----
virBufferVSprintf(buf, " %s\n", tmp);
tmp = sexpr_node(node, "domain/image/hvm/boot");
if ((tmp != NULL) && (tmp[0] != 0)) {
if (tmp[0] == 'a')
! /* XXX no way to deal with boot from 2nd floppy */
! virBufferAdd(buf, " \n", 21 );
else if (tmp[0] == 'c')
/*
* Don't know what to put here. Say the vm has been given 3
* disks - hda, hdb, hdc. How does one identify the boot disk?
+ * We're going to assume that first disk is the boot disk since
+ * this is most common practice
*/
! virBufferAdd(buf, " \n", 21 );
else if (strcmp(tmp, "d") == 0)
! virBufferAdd(buf, " \n", 24 );
}
} else {
virBufferVSprintf(buf, " linux\n");
***************
*** 1482,1492 ****
/* ERROR */
return (NULL);
}
! ret = malloc(1000);
if (ret == NULL)
return (NULL);
buf.content = ret;
! buf.size = 1000;
buf.use = 0;
domid = sexpr_int(root, "domain/domid");
--- 1492,1502 ----
/* ERROR */
return (NULL);
}
! ret = malloc(4000);
if (ret == NULL)
return (NULL);
buf.content = ret;
! buf.size = 4000;
buf.use = 0;
domid = sexpr_int(root, "domain/domid");
***************
*** 1625,1630 ****
--- 1635,1662 ----
}
if (hvm) {
+ tmp = sexpr_node(root, "domain/image/hvm/fda");
+ if ((tmp != NULL) && (tmp[0] != 0)) {
+ virBufferAdd(&buf, " \n", 23);
+ virBufferVSprintf(&buf, " \n", tmp);
+ virBufferAdd(&buf, " \n", 26);
+ virBufferAdd(&buf, " \n", 12);
+ }
+ tmp = sexpr_node(root, "domain/image/hvm/fdb");
+ if ((tmp != NULL) && (tmp[0] != 0)) {
+ virBufferAdd(&buf, " \n", 23);
+ virBufferVSprintf(&buf, " \n", tmp);
+ virBufferAdd(&buf, " \n", 26);
+ virBufferAdd(&buf, " \n", 12);
+ }
+ tmp = sexpr_node(root, "domain/image/hvm/cdrom");
+ if ((tmp != NULL) && (tmp[0] != 0)) {
+ virBufferAdd(&buf, " \n", 23);
+ virBufferVSprintf(&buf, " \n", tmp);
+ virBufferAdd(&buf, " \n", 28);
+ virBufferAdd(&buf, " \n", 12);
+ }
+
/* Graphics device */
tmp = sexpr_node(root, "domain/image/hvm/vnc");
if (tmp != NULL) {
***************
*** 1641,1651 ****
if (tmp[0] == '1')
virBufferAdd(&buf, " \n", 27 );
}
-
- /*
- * TODO:
- * Device for cdrom
- */
}
tty = xenStoreDomainGetConsolePath(conn, domid);
--- 1673,1678 ----
Index: src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.30
diff -c -b -r1.30 xml.c
*** src/xml.c 9 Aug 2006 15:21:16 -0000 1.30
--- src/xml.c 9 Aug 2006 22:58:49 -0000
***************
*** 634,655 ****
obj = NULL;
if (boot_dev) {
! /* TODO:
! * Have to figure out the naming used here.
! */
! if (xmlStrEqual(type, BAD_CAST "hda")) {
virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
! } else if (xmlStrEqual(type, BAD_CAST "hdd")) {
virBufferVSprintf(buf, "(boot d)", (const char *) boot_dev);
! } else {
! /* Force hd[b|c] if boot_dev specified but not floppy or cdrom? */
virBufferVSprintf(buf, "(boot c)", (const char *) boot_dev);
}
}
! /* TODO:
! * Is a cdrom disk device specified?
! * Kind of ugly since it is buried in the devices/diskk node.
! */
/* Is a graphics device specified? */
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
--- 634,704 ----
obj = NULL;
if (boot_dev) {
! if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
virBufferVSprintf(buf, "(boot a)", (const char *) boot_dev);
! } else if (xmlStrEqual(boot_dev, BAD_CAST "cdrom")) {
virBufferVSprintf(buf, "(boot d)", (const char *) boot_dev);
! } else if (xmlStrEqual(boot_dev, BAD_CAST "hd")) {
virBufferVSprintf(buf, "(boot c)", (const char *) boot_dev);
+ } else {
+ /* Any other type of boot dev is unsupported right now */
+ virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
}
+
+ /* get the 1st floppy device file */
+ obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@type='file' and target/@dev='fda']/source", ctxt);
+ if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
+ (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
+ cur = obj->nodesetval->nodeTab[0];
+ virBufferVSprintf(buf, "(fda '%s')",
+ (const char *) xmlGetProp(cur, BAD_CAST "file"));
+ cur = NULL;
+ }
+ if (obj) {
+ xmlXPathFreeObject(obj);
+ obj = NULL;
}
!
! /* get the 2nd floppy device file */
! obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@type='file' and target/@dev='fdb']/source", ctxt);
! if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
! (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
! cur = obj->nodesetval->nodeTab[0];
! virBufferVSprintf(buf, "(fdb '%s')",
! (const char *) xmlGetProp(cur, BAD_CAST "file"));
! cur = NULL;
! }
! if (obj) {
! xmlXPathFreeObject(obj);
! obj = NULL;
! }
!
!
! /* get the cdrom device file */
! obj = xmlXPathEval(BAD_CAST "/domain/devices/disk[@type='file' and target/@dev='cdrom']/source", ctxt);
! if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
! (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
! cur = obj->nodesetval->nodeTab[0];
! virBufferVSprintf(buf, "(cdrom '%s')",
! (const char *) xmlGetProp(cur, BAD_CAST "file"));
! cur = NULL;
! }
! if (obj) {
! xmlXPathFreeObject(obj);
! obj = NULL;
! }
! }
!
! obj = xmlXPathEval(BAD_CAST "count(domain/devices/console) > 0", ctxt);
! if ((obj == NULL) || (obj->type != XPATH_BOOLEAN)) {
! virXMLError(VIR_ERR_XML_ERROR, NULL, 0);
! goto error;
! }
! if (obj->boolval) {
! virBufferAdd(buf, "(serial pty)", 12);
! }
! xmlXPathFreeObject(obj);
! obj = NULL;
/* Is a graphics device specified? */
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
***************
*** 795,800 ****
--- 844,850 ----
typ = 1;
xmlFree(type);
}
+
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
***************
*** 828,833 ****
--- 878,896 ----
xmlFree(source);
return (-1);
}
+
+ /* Skip floppy/cdrom disk used as the boot device
+ since that's incorporated into the HVM kernel
+ (image (hvm..)) part of the sexpr, rather than
+ the (devices...) bit. Odd Xend HVM config :-( */
+ if (!strcmp((const char *)target, "fda") ||
+ !strcmp((const char *)target, "fdb") ||
+ !strcmp((const char *)target, "cdrom")) {
+ return 0;
+ }
+
+
+ virBufferAdd(buf, "(device ", 8);
virBufferAdd(buf, "(vbd ", 5);
virBufferVSprintf(buf, "(dev '%s')", (const char *) target);
if (typ == 0)
***************
*** 844,849 ****
--- 907,913 ----
virBufferVSprintf(buf, "(mode 'r')");
virBufferAdd(buf, ")", 1);
+ virBufferAdd(buf, ")", 1);
xmlFree(target);
xmlFree(source);
return (0);
***************
*** 911,916 ****
--- 975,981 ----
}
if (script != NULL)
virBufferVSprintf(buf, "(script '%s')", script);
+ virBufferAdd(buf, "(type ioemu)", 12);
virBufferAdd(buf, ")", 1);
if (mac != NULL)
***************
*** 1089,1100 ****
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
- virBufferAdd(&buf, "(device ", 8);
res = virDomainParseXMLDiskDesc(obj->nodesetval->nodeTab[i], &buf);
if (res != 0) {
goto error;
}
- virBufferAdd(&buf, ")", 1);
}
}
xmlXPathFreeObject(obj);
--- 1154,1163 ----