]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* src/xend_internal.c src/xm_internal.c src/xml.c: add support
authorDaniel Veillard <veillard@redhat.com>
Thu, 7 Jun 2007 13:50:18 +0000 (13:50 +0000)
committerDaniel Veillard <veillard@redhat.com>
Thu, 7 Jun 2007 13:50:18 +0000 (13:50 +0000)
  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

ChangeLog
src/xend_internal.c
src/xm_internal.c
src/xml.c
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr [new file with mode: 0644]
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml [new file with mode: 0644]
tests/sexpr2xmltest.c
tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr [new file with mode: 0644]
tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml [new file with mode: 0644]
tests/xml2sexprtest.c

index c5ea03bc18042da976d174ec742b8bc9ad9639a4..7544099dd29d9c9820b72881bdb2e5dc8ea936ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 44a4b1070027394dcbca12ab587c8d65b75911fd..218d9fea293064017651f8d92d6e5cf3c89fca3b 100644 (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")) {
index b1580b2f97553a72260061cc6397a1f53a07447a..495a957bc79e754bf9a88493f66edf525039237b 100644 (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;
index 50800ed1ef6c8c923207036bdaa24f4740e7f20b..dc58b19a68dee17f35ac870e9166f41fe3e7bf5c 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -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;
         }
diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.sexpr
new file mode 100644 (file)
index 0000000..51b511c
--- /dev/null
@@ -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'))))
\ No newline at end of file
diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml b/tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml
new file mode 100644 (file)
index 0000000..221832d
--- /dev/null
@@ -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>
index 2c567aaf8baa576d1befbad45748c9bb4753a9e1..1f0af7c93fd226532026a4208cc95a0622f6811a 100644 (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;
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr b/tests/xml2sexprdata/xml2sexpr-pv-bootloader.sexpr
new file mode 100644 (file)
index 0000000..a3bc30d
--- /dev/null
@@ -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'))))
\ No newline at end of file
diff --git a/tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml b/tests/xml2sexprdata/xml2sexpr-pv-bootloader.xml
new file mode 100644 (file)
index 0000000..6bf7e26
--- /dev/null
@@ -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>
+
index 069d65f063b538195330be1709cd6fe1bbd38dba..7cc93a02410ad94c61f97782525089721858866a 100644 (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;