diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 026cbcc100..be194e3535 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -27,6 +27,7 @@
#include "virconf.h"
#include "virerror.h"
+#include "virlog.h"
#include "domain_conf.h"
#include "viralloc.h"
#include "virstring.h"
@@ -35,6 +36,8 @@
#define VIR_FROM_THIS VIR_FROM_XENXL
+VIR_LOG_INIT("xen.xen_xl");
+
/*
* Xen provides a libxl utility library, with several useful functions,
* specifically xlu_disk_parse for parsing xl disk config strings.
@@ -58,11 +61,46 @@ extern int xlu_disk_parse(XLU_Config *cfg,
libxl_device_disk *disk);
#endif
+static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
+{
+ char *cmdline = NULL;
+ const char *root, *extra, *buf;
+
+ if (xenConfigGetString(conf, "cmdline", &buf, NULL) < 0)
+ return -1;
+
+ if (xenConfigGetString(conf, "root", &root, NULL) < 0)
+ return -1;
+
+ if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
+ return -1;
+
+ if (buf) {
+ if (VIR_STRDUP(cmdline, buf) < 0)
+ return -1;
+ if (root || extra)
+ VIR_WARN("ignoring root= and extra= in favour of cmdline=");
+ } else {
+ if (root && extra) {
+ if (virAsprintf(&cmdline, "root=%s %s", root, extra) < 0)
+ return -1;
+ } else if (root) {
+ if (virAsprintf(&cmdline, "root=%s", root) < 0)
+ return -1;
+ } else if (extra) {
+ if (VIR_STRDUP(cmdline, extra) < 0)
+ return -1;
+ }
+ }
+
+ *r_cmdline = cmdline;
+ return 0;
+}
+
static int
xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
{
size_t i;
- const char *extra, *root;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
const char *boot;
@@ -84,19 +122,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
return -1;
- if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
+ if (xenParseCmdline(conf, &def->os.cmdline) < 0)
return -1;
-
- if (xenConfigGetString(conf, "root", &root, NULL) < 0)
- return -1;
-
- if (root) {
- if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0)
- return -1;
- } else {
- if (VIR_STRDUP(def->os.cmdline, extra) < 0)
- return -1;
- }
#endif
if (xenConfigGetString(conf, "boot", &boot, "c") < 0)
@@ -132,19 +159,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
return -1;
- if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
+ if (xenParseCmdline(conf, &def->os.cmdline) < 0)
return -1;
-
- if (xenConfigGetString(conf, "root", &root, NULL) < 0)
- return -1;
-
- if (root) {
- if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0)
- return -1;
- } else {
- if (VIR_STRDUP(def->os.cmdline, extra) < 0)
- return -1;
- }
}
return 0;
@@ -503,7 +519,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
return -1;
if (def->os.cmdline &&
- xenConfigSetString(conf, "extra", def->os.cmdline) < 0)
+ xenConfigSetString(conf, "cmdline", def->os.cmdline) < 0)
return -1;
#endif
@@ -554,7 +570,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
return -1;
if (def->os.cmdline &&
- xenConfigSetString(conf, "extra", def->os.cmdline) < 0)
+ xenConfigSetString(conf, "cmdline", def->os.cmdline) < 0)
return -1;
} /* !hvm */
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.cfg b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.cfg
new file mode 100644
index 0000000000..83ab975e66
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.cfg
@@ -0,0 +1,31 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+hap = 0
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vncpasswd = "123poi"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "ignore_loglvl"
+extra = "SHOULD BE IGNORED"
+boot = "d"
+disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml
new file mode 100644
index 0000000000..f750e02074
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml
@@ -0,0 +1,51 @@
+
+ XenGuest2
+ c7a5fdb2-cdaf-9455-926a-d65c16db1809
+ 592896
+ 403456
+ 1
+
+ hvm
+ /usr/lib/xen/boot/hvmloader
+ /tmp/vmlinuz
+ /tmp/initrd
+ ignore_loglvl
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ restart
+
+ /usr/lib/xen/bin/qemu-system-i386
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.cfg b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.cfg
new file mode 100644
index 0000000000..f452af62d8
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.cfg
@@ -0,0 +1,30 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+hap = 0
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vncpasswd = "123poi"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+extra = "ignore_loglvl"
+boot = "d"
+disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml
new file mode 100644
index 0000000000..f750e02074
--- /dev/null
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml
@@ -0,0 +1,51 @@
+
+ XenGuest2
+ c7a5fdb2-cdaf-9455-926a-d65c16db1809
+ 592896
+ 403456
+ 1
+
+ hvm
+ /usr/lib/xen/boot/hvmloader
+ /tmp/vmlinuz
+ /tmp/initrd
+ ignore_loglvl
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ restart
+
+ /usr/lib/xen/bin/qemu-system-i386
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
index f452af62d8..32b08e1a87 100644
--- a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
+++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.cfg
@@ -25,6 +25,6 @@ serial = "none"
builder = "hvm"
kernel = "/tmp/vmlinuz"
ramdisk = "/tmp/initrd"
-extra = "ignore_loglvl"
+cmdline = "ignore_loglvl"
boot = "d"
disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
diff --git a/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.cfg b/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.cfg
new file mode 100644
index 0000000000..c5b25af825
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.cfg
@@ -0,0 +1,13 @@
+localtime = 0
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge" ]
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
+extra = "SHOULD BE IGNORED"
+root = "SHOULD BE IGNORED"
+disk = [ "/dev/HostVG/XenGuest2,raw,xvda,w" ]
diff --git a/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.xml b/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.xml
new file mode 100644
index 0000000000..f4ab9e6366
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline-bogus-extra-root.xml
@@ -0,0 +1,32 @@
+
+ XenGuest2
+ c7a5fdb2-cdaf-9455-926a-d65c16db1809
+ 592896
+ 403456
+ 1
+
+ linux
+ /tmp/vmlinuz
+ /tmp/initrd
+ root=/dev/xvda1 console=hvc0
+
+
+ destroy
+ restart
+ restart
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xlconfigdata/test-paravirt-cmdline-extra-root.cfg b/tests/xlconfigdata/test-paravirt-cmdline-extra-root.cfg
new file mode 100644
index 0000000000..d0c503bbab
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline-extra-root.cfg
@@ -0,0 +1,15 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge" ]
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+root = "/dev/xvda1"
+extra = "console=hvc0"
+disk = [ "/dev/HostVG/XenGuest2,raw,xvda,w,backendtype=qdisk" ]
diff --git a/tests/xlconfigdata/test-paravirt-cmdline-extra-root.xml b/tests/xlconfigdata/test-paravirt-cmdline-extra-root.xml
new file mode 100644
index 0000000000..f4ab9e6366
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline-extra-root.xml
@@ -0,0 +1,32 @@
+
+ XenGuest2
+ c7a5fdb2-cdaf-9455-926a-d65c16db1809
+ 592896
+ 403456
+ 1
+
+ linux
+ /tmp/vmlinuz
+ /tmp/initrd
+ root=/dev/xvda1 console=hvc0
+
+
+ destroy
+ restart
+ restart
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xlconfigdata/test-paravirt-cmdline.cfg b/tests/xlconfigdata/test-paravirt-cmdline.cfg
new file mode 100644
index 0000000000..c512a055e3
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline.cfg
@@ -0,0 +1,14 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge" ]
+kernel = "/tmp/vmlinuz"
+ramdisk = "/tmp/initrd"
+cmdline = "root=/dev/xvda1 console=hvc0"
+disk = [ "/dev/HostVG/XenGuest2,raw,xvda,w,backendtype=qdisk" ]
diff --git a/tests/xlconfigdata/test-paravirt-cmdline.xml b/tests/xlconfigdata/test-paravirt-cmdline.xml
new file mode 100644
index 0000000000..f4ab9e6366
--- /dev/null
+++ b/tests/xlconfigdata/test-paravirt-cmdline.xml
@@ -0,0 +1,32 @@
+
+ XenGuest2
+ c7a5fdb2-cdaf-9455-926a-d65c16db1809
+ 592896
+ 403456
+ 1
+
+ linux
+ /tmp/vmlinuz
+ /tmp/initrd
+ root=/dev/xvda1 console=hvc0
+
+
+ destroy
+ restart
+ restart
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index e99700909c..bad69ca6eb 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -180,29 +180,45 @@ mymain(void)
if (!(xmlopt = libxlCreateXMLConf()))
return EXIT_FAILURE;
-#define DO_TEST(name) \
+#define DO_TEST_PARSE(name) \
do { \
struct testInfo info0 = { name, 0 }; \
- struct testInfo info1 = { name, 1 }; \
- if (virtTestRun("Xen XM-2-XML Parse " name, \
+ if (virtTestRun("Xen XL-2-XML Parse " name, \
testCompareHelper, &info0) < 0) \
ret = -1; \
- if (virtTestRun("Xen XM-2-XML Format " name, \
+ } while (0)
+
+#define DO_TEST_FORMAT(name) \
+ do { \
+ struct testInfo info1 = { name, 1 }; \
+ if (virtTestRun("Xen XL-2-XML Format " name, \
testCompareHelper, &info1) < 0) \
ret = -1; \
} while (0)
+#define DO_TEST(name) \
+ do { \
+ DO_TEST_PARSE(name); \
+ DO_TEST_FORMAT(name); \
+ } while (0)
+
DO_TEST("paravirt-maxvcpus");
DO_TEST("new-disk");
DO_TEST("spice");
DO_TEST("spice-features");
DO_TEST("vif-rate");
+ DO_TEST("paravirt-cmdline");
+ DO_TEST_FORMAT("paravirt-cmdline-extra-root");
+ DO_TEST_FORMAT("paravirt-cmdline-bogus-extra-root");
+
#ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
DO_TEST("fullvirt-multiusb");
#endif
#ifdef LIBXL_HAVE_BUILDINFO_KERNEL
DO_TEST("fullvirt-direct-kernel-boot");
+ DO_TEST_FORMAT("fullvirt-direct-kernel-boot-extra");
+ DO_TEST_FORMAT("fullvirt-direct-kernel-boot-bogus-extra");
#endif
virObjectUnref(caps);