[Libvir] [PATCH 5/6] Inactive domain support: pygrub / framebuffer fix
Daniel P. Berrange
berrange at redhat.com
Wed Nov 15 02:27:53 UTC 2006
With the paravirtualized framebuffer, the 'vnc' related options are all
within the (image (linux ...)) bit of the S-Expression. When using the
pygrub bootloader though, there is no (image) block in the SXPR at all.
This patch changes this, so that if a bootloader is used, then we still
generate an (image) block containing only the VNC related bits.
This patch is dependant on a corresponding fix to XenD server - I'm also
attaching this patch here for conveinance. It appears as if the paravirt
framebuffer configuration will change significantly before it is merged
upstream in xen-devel, so I don't anticpate the attached patch being
merged in libvirt CVS. Instead it'll probably live in the Fedora / RHEL
RPM spec files as a patch. I include it here merely for completeness
Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
-------------- next part --------------
Index: src/xml.c
===================================================================
RCS file: /data/cvs/libvirt/src/xml.c,v
retrieving revision 1.48
diff -c -r1.48 xml.c
*** src/xml.c 15 Nov 2006 00:38:13 -0000 1.48
--- src/xml.c 15 Nov 2006 02:34:06 -0000
***************
*** 818,823 ****
--- 818,824 ----
* @buf: a buffer for the result S-Expr
* @ctxt: a path context representing the XML description
* @xendConfigVersion: xend configuration file format
+ * @hasBootLoader: flag indicating whether a bootloader is set
*
* Parse the OS part of the XML description for a paravirtualized domain
* and add it to the S-Expr in buf. This is a temporary interface as the
***************
*** 827,833 ****
* Returns 0 in case of success, -1 in case of error.
*/
static int
! virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion)
{
xmlNodePtr cur, txt;
xmlXPathObjectPtr obj = NULL;
--- 828,834 ----
* Returns 0 in case of success, -1 in case of error.
*/
static int
! virDomainParseXMLOSDescPV(xmlNodePtr node, virBufferPtr buf, xmlXPathContextPtr ctxt, int xendConfigVersion, int hasBootloader)
{
xmlNodePtr cur, txt;
xmlXPathObjectPtr obj = NULL;
***************
*** 875,898 ****
}
cur = cur->next;
}
if ((type != NULL) && (!xmlStrEqual(type, BAD_CAST "linux"))) {
/* VIR_ERR_OS_TYPE */
virXMLError(VIR_ERR_OS_TYPE, (const char *) type, 0);
return (-1);
}
virBufferAdd(buf, "(image (linux ", 14);
! if (kernel == NULL) {
virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
! return (-1);
! } else {
! virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel);
}
- if (initrd != NULL)
- virBufferVSprintf(buf, "(ramdisk '%s')", (const char *) initrd);
- if (root != NULL)
- virBufferVSprintf(buf, "(root '%s')", (const char *) root);
- if (cmdline != NULL)
- virBufferVSprintf(buf, "(args '%s')", (const char *) cmdline);
/* Is a graphics device specified? */
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
--- 876,901 ----
}
cur = cur->next;
}
+
if ((type != NULL) && (!xmlStrEqual(type, BAD_CAST "linux"))) {
/* VIR_ERR_OS_TYPE */
virXMLError(VIR_ERR_OS_TYPE, (const char *) type, 0);
return (-1);
}
virBufferAdd(buf, "(image (linux ", 14);
! if (kernel != NULL) {
! virBufferVSprintf(buf, "(kernel '%s')", (const char *) kernel);
!
! if (initrd != NULL)
! virBufferVSprintf(buf, "(ramdisk '%s')", (const char *) initrd);
! if (root != NULL)
! virBufferVSprintf(buf, "(root '%s')", (const char *) root);
! if (cmdline != NULL)
! virBufferVSprintf(buf, "(args '%s')", (const char *) cmdline);
! } else if (!hasBootloader) {
virXMLError(VIR_ERR_NO_KERNEL, NULL, 0);
! return (-1);
}
/* Is a graphics device specified? */
obj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
***************
*** 1341,1370 ****
obj = xmlXPathEval(BAD_CAST "/domain/os[1]", ctxt);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
! /* Analyze of the os description, based on HVM or PV. */
! tmpobj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
! if ((tmpobj != NULL) &&
! ((tmpobj->type != XPATH_STRING) || (tmpobj->stringval == NULL) ||
! (tmpobj->stringval[0] == 0))) {
! xmlXPathFreeObject(tmpobj);
! virXMLError(VIR_ERR_OS_TYPE, nam, 0);
! goto error;
! }
! if ((tmpobj == NULL) || !xmlStrEqual(tmpobj->stringval, BAD_CAST "hvm")) {
! res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
! } else {
! hvm = 1;
! res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
! }
! xmlXPathFreeObject(tmpobj);
! if (res != 0)
! goto error;
! } else if (bootloader == 0) {
! virXMLError(VIR_ERR_NO_OS, nam, 0);
! goto error;
}
xmlXPathFreeObject(obj);
--- 1344,1388 ----
obj = xmlXPathEval(BAD_CAST "/domain/os[1]", ctxt);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr == 1)) {
! /* Analyze of the os description, based on HVM or PV. */
! tmpobj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
! if ((tmpobj != NULL) &&
! ((tmpobj->type != XPATH_STRING) || (tmpobj->stringval == NULL) ||
! (tmpobj->stringval[0] == 0))) {
! xmlXPathFreeObject(tmpobj);
! virXMLError(VIR_ERR_OS_TYPE, nam, 0);
! goto error;
! }
! if ((tmpobj == NULL) || !xmlStrEqual(tmpobj->stringval, BAD_CAST "hvm")) {
! res = virDomainParseXMLOSDescPV(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion, bootloader);
! } else {
! hvm = 1;
! res = virDomainParseXMLOSDescHVM(obj->nodesetval->nodeTab[0], &buf, ctxt, xendConfigVersion);
! }
! xmlXPathFreeObject(tmpobj);
! if (res != 0)
! goto error;
! } else {
! if (bootloader == 1) {
! /* Is a graphics device specified? */
! tmpobj = xmlXPathEval(BAD_CAST "/domain/devices/graphics[1]", ctxt);
! if ((tmpobj != NULL) && (tmpobj->type == XPATH_NODESET) &&
! (tmpobj->nodesetval != NULL) && (tmpobj->nodesetval->nodeNr > 0)) {
! virBufferAdd(&buf, "(image (linux ", 14);
! res = virDomainParseXMLGraphicsDesc(tmpobj->nodesetval->nodeTab[0], &buf, xendConfigVersion);
! if (res != 0) {
! goto error;
! }
! virBufferAdd(&buf, "))", 2);
! }
! xmlXPathFreeObject(tmpobj);
! } else {
! virXMLError(VIR_ERR_NO_OS, nam, 0);
! goto error;
! }
}
xmlXPathFreeObject(obj);
-------------- next part --------------
1289c1289
< if self.infoIsSet('bootloader') and not self.infoIsSet('image'):
---
> if self.infoIsSet('bootloader') and not self.is_kernel_set():
1773a1774,1785
> def is_kernel_set(self):
> if self.info["image"] is None:
> log.debug("No image set")
> return False
> img = self.info["image"]
> kernel = sxp.child_value(img, "kernel", None)
> if kernel is None:
> log.debug("No kernel set")
> return False
> log.debug("FOund kernel")
> return True
>
More information about the libvir-list
mailing list