#include "virconf.h"
#include "virerror.h"
+#include "virlog.h"
#include "domain_conf.h"
#include "viralloc.h"
#include "virstring.h"
#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.
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;
if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
return -1;
- if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
- return -1;
-
- if (xenConfigGetString(conf, "root", &root, NULL) < 0)
+ if (xenParseCmdline(conf, &def->os.cmdline) < 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)
if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0)
return -1;
- if (xenConfigGetString(conf, "extra", &extra, NULL) < 0)
- return -1;
-
- if (xenConfigGetString(conf, "root", &root, NULL) < 0)
+ if (xenParseCmdline(conf, &def->os.cmdline) < 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;
return -1;
if (def->os.cmdline &&
- xenConfigSetString(conf, "extra", def->os.cmdline) < 0)
+ xenConfigSetString(conf, "cmdline", def->os.cmdline) < 0)
return -1;
#endif
return -1;
if (def->os.cmdline &&
- xenConfigSetString(conf, "extra", def->os.cmdline) < 0)
+ xenConfigSetString(conf, "cmdline", def->os.cmdline) < 0)
return -1;
} /* !hvm */
--- /dev/null
+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" ]
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenfv'>hvm</type>
+ <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+ <kernel>/tmp/vmlinuz</kernel>
+ <initrd>/tmp/initrd</initrd>
+ <cmdline>ignore_loglvl</cmdline>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='variable' adjustment='0' basis='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy' type='raw'/>
+ <source dev='/dev/HostVG/XenGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ <model type='e1000'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ </devices>
+</domain>
--- /dev/null
+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" ]
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenfv'>hvm</type>
+ <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+ <kernel>/tmp/vmlinuz</kernel>
+ <initrd>/tmp/initrd</initrd>
+ <cmdline>ignore_loglvl</cmdline>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='variable' adjustment='0' basis='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='phy' type='raw'/>
+ <source dev='/dev/HostVG/XenGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ <model type='e1000'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ </devices>
+</domain>
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" ]
--- /dev/null
+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" ]
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenpv'>linux</type>
+ <kernel>/tmp/vmlinuz</kernel>
+ <initrd>/tmp/initrd</initrd>
+ <cmdline>root=/dev/xvda1 console=hvc0</cmdline>
+ </os>
+ <clock offset='utc' adjustment='reset'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/dev/HostVG/XenGuest2'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <console type='pty'>
+ <target type='xen' port='0'/>
+ </console>
+ </devices>
+</domain>
--- /dev/null
+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" ]
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenpv'>linux</type>
+ <kernel>/tmp/vmlinuz</kernel>
+ <initrd>/tmp/initrd</initrd>
+ <cmdline>root=/dev/xvda1 console=hvc0</cmdline>
+ </os>
+ <clock offset='utc' adjustment='reset'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/dev/HostVG/XenGuest2'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <console type='pty'>
+ <target type='xen' port='0'/>
+ </console>
+ </devices>
+</domain>
--- /dev/null
+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" ]
--- /dev/null
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenpv'>linux</type>
+ <kernel>/tmp/vmlinuz</kernel>
+ <initrd>/tmp/initrd</initrd>
+ <cmdline>root=/dev/xvda1 console=hvc0</cmdline>
+ </os>
+ <clock offset='utc' adjustment='reset'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='/dev/HostVG/XenGuest2'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ </interface>
+ <console type='pty'>
+ <target type='xen' port='0'/>
+ </console>
+ </devices>
+</domain>
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);