* src/xend_internal.c src/xm_internal.c src/xml.c: add support

for arguments to bootloader, patch from Hugh Brock
* tests/sexpr2xmltest.c tests/xml2sexprtest.c
  tests/sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr
  tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml
  tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr
  tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml: add specific
  regression tests
Daniel
This commit is contained in:
Daniel Veillard 2007-06-07 13:50:18 +00:00
parent 2a10972010
commit a80faa4bf0
10 changed files with 97 additions and 8 deletions

View File

@ -1,3 +1,14 @@
Thu Jun 7 15:48:30 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/xend_internal.c src/xm_internal.c src/xml.c: add support
for arguments to bootloader, patch from Hugh Brock
* tests/sexpr2xmltest.c tests/xml2sexprtest.c
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml
tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr
tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml: add specific
regression tests
Thu Jun 7 15:02:44 CEST 2007 Daniel Veillard <veillard@redhat.com>
* src/libvirt.c: do not die if the daemon is not running on a Xen

View File

@ -1414,6 +1414,13 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
bootloader = 1;
virBufferVSprintf(&buf, " <bootloader>%s</bootloader>\n", tmp);
}
tmp = sexpr_node(root, "domain/bootloader_args");
if (tmp != NULL && bootloader) {
/*
* Only insert bootloader_args if there is also a bootloader param
*/
virBufferVSprintf(&buf, " <bootloader_args>%s</bootloader_args>\n", tmp);
}
if (domid != 0) {
if (sexpr_lookup(root, "domain/image")) {

View File

@ -643,6 +643,8 @@ char *xenXMDomainFormatXML(virConnectPtr conn, virConfPtr conf) {
if (xenXMConfigGetString(conf, "bootloader", &str) == 0)
virBufferVSprintf(buf, " <bootloader>%s</bootloader>\n", str);
if (xenXMConfigGetString(conf, "bootargs", &str) == 0)
virBufferVSprintf(buf, " <bootloader_args>%s</bootloader_args>\n", str);
if (xenXMConfigGetString(conf, "kernel", &str) == 0) {
virBufferAdd(buf, " <os>\n", -1);
virBufferAdd(buf, " <type>linux</type>\n", -1);
@ -1833,6 +1835,9 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if (xenXMConfigSetStringFromXPath(conn, conf, ctxt, "bootloader", "string(/domain/bootloader)", 1,
"cannot set the bootloader parameter") < 0)
goto error;
if (xenXMConfigSetStringFromXPath(conn, conf, ctxt, "bootargs", "string(/domain/bootloader_args)", 1,
"cannot set the bootloader_args parameter") < 0)
goto error;
if (xenXMConfigSetStringFromXPath(conn, conf, ctxt, "kernel", "string(/domain/os/kernel)", 1,
"cannot set the kernel parameter") < 0)
goto error;

View File

@ -1270,13 +1270,19 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
if (str != NULL) {
virBufferVSprintf(&buf, "(bootloader '%s')", str);
/*
* if using pygrub, the kernel and initrd strings are not
* if using a bootloader, the kernel and initrd strings are not
* significant and should be discarded
*/
if (strstr(str, "pygrub"))
bootloader = 2;
else
bootloader = 1;
bootloader = 1;
free(str);
}
str = virXPathString("string(/domain/bootloader_args[1])", ctxt);
if (str != NULL && bootloader) {
/*
* ignore the bootloader_args value unless a bootloader was specified
*/
virBufferVSprintf(&buf, "(bootloader_args '%s')", str);
free(str);
}
@ -1298,10 +1304,10 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
free(str);
}
if (bootloader != 2) {
if (!bootloader) {
if ((node = virXPathNode("/domain/os[1]", ctxt)) != NULL) {
/* Analyze of the os description, based on HVM or PV. */
str = virXPathString("string(/domain/os/type[1])", ctxt);
str = virXPathString("string(/domain/os/type[1])", ctxt);
if ((str == NULL) || (strcmp(str, "hvm"))) {
res = virDomainParseXMLOSDescPV(conn, node,
@ -1316,7 +1322,7 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name, int
if (res != 0)
goto error;
} else if (bootloader == 0) {
} else {
virXMLError(conn, VIR_ERR_NO_OS, nam, 0);
goto error;
}

View File

@ -0,0 +1 @@
(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(bootloader '/usr/bin/pypxeboot')(bootloader_args 'mac=AA:00:86:e2:35:72')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))

View File

@ -0,0 +1,18 @@
<domain type='xen' id='6'>
<name>pvtest</name>
<uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
<bootloader>/usr/bin/pypxeboot</bootloader>
<bootloader_args>mac=AA:00:86:e2:35:72</bootloader_args>
<memory>430080</memory>
<vcpu>2</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='file'/>
<source file='/root/some.img'/>
<target dev='xvda'/>
</disk>
</devices>
</domain>

View File

@ -81,6 +81,12 @@ static int testCompareFVversion2(void *data ATTRIBUTE_UNUSED) {
2);
}
static int testComparePVBootloader(void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-pv-bootloader.xml",
"sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr",
2);
}
static int testCompareDiskFile(void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("sexpr2xmldata/sexpr2xml-disk-file.xml",
"sexpr2xmldata/sexpr2xml-disk-file.sexpr",
@ -167,6 +173,10 @@ main(int argc, char **argv)
1, testCompareFVversion2, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML PV config bootloader",
1, testComparePVBootloader, NULL) != 0)
ret = -1;
if (virtTestRun("SEXPR-2-XML Disk File config",
1, testCompareDiskFile, NULL) != 0)
ret = -1;

View File

@ -0,0 +1 @@
(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(bootloader '/usr/bin/pypxeboot')(bootloader_args 'mac=AA:00:86:e2:35:72')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))

View File

@ -0,0 +1,19 @@
<domain type='xen' id='15'>
<name>pvtest</name>
<uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
<bootloader>/usr/bin/pypxeboot</bootloader>
<bootloader_args>mac=AA:00:86:e2:35:72</bootloader_args>
<memory>430080</memory>
<vcpu>2</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<source file='/root/some.img'/>
<target dev='xvda'/>
</disk>
<console tty='/dev/pts/4'/>
</devices>
</domain>

View File

@ -103,6 +103,13 @@ static int testComparePVNewVFB(void *data ATTRIBUTE_UNUSED) {
3);
}
static int testComparePVBootloader(void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-pv-bootloader.xml",
"xml2sexprdata/xml2sexpr-pv-bootloader.sexpr",
"pvtest",
1);
}
static int testCompareDiskFile(void *data ATTRIBUTE_UNUSED) {
return testCompareFiles("xml2sexprdata/xml2sexpr-disk-file.xml",
"xml2sexprdata/xml2sexpr-disk-file.sexpr",
@ -221,6 +228,10 @@ main(int argc, char **argv)
1, testComparePVNewVFB, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR PV config with bootloader",
1, testComparePVBootloader, NULL) != 0)
ret = -1;
if (virtTestRun("XML-2-SEXPR Disk File",
1, testCompareDiskFile, NULL) != 0)
ret = -1;