The "dtb" option sets the filename for the device tree.
If without this option support, "-dtb file" will be converted into
<qemu:commandline> in domain XML file.
For example, '-dtb /media/ram/test.dtb' will be converted into
<qemu:commandline>
<qemu:arg value='-dtb'/>
<qemu:arg value='/media/ram/test.dtb'/>
</qemu:commandline>
This is not very friendly.
This patchset add special <dtb> tag like <kernel> and <initrd>
which is easier for user to write domain XML file.
<os>
<type arch='ppc' machine='ppce500v2'>hvm</type>
<kernel>/media/ram/uImage</kernel>
<initrd>/media/ram/ramdisk</initrd>
<dtb>/media/ram/test.dtb</dtb>
<cmdline>root=/dev/ram rw console=ttyS0,115200</cmdline>
</os>
---
src/qemu/qemu_capabilities.c | 8 ++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 6 ++++
tests/qemuhelptest.c | 30 +++++++++++++------
tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args | 1 +
tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml | 28 ++++++++++++++++++
tests/qemuxml2argvtest.c | 2 +
tests/testutilsqemu.c | 33 ++++++++++++++++++++++
8 files changed, 97 insertions(+), 12 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 79cfdb3..636608a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -210,7 +210,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"rng-random", /* 130 */
"rng-egd",
- "virtio-ccw"
+ "virtio-ccw",
+ "dtb",
);
struct _virQEMUCaps {
@@ -1173,8 +1174,10 @@ virQEMUCapsComputeCmdFlags(const char *help,
if (version >= 12000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_PCI_ROMBAR);
- if (version >= 11000)
+ if (version >= 11000) {
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_HOST);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
+ }
if (version >= 1002000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
@@ -2299,6 +2302,7 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NETDEV_BRIDGE);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_SECCOMP_SANDBOX);
virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_DTB);
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 5c5dc5a..9f88593 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -172,6 +172,7 @@ enum virQEMUCapsFlags {
virtio rng */
QEMU_CAPS_OBJECT_RNG_EGD = 131, /* EGD protocol daemon for rng */
QEMU_CAPS_VIRTIO_CCW = 132, /* -device virtio-*-ccw */
+ QEMU_CAPS_DTB = 133, /* -dtb file */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e7f2325..a95d41c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5984,6 +5984,8 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArgList(cmd, "-initrd", def->os.initrd, NULL);
if (def->os.cmdline)
virCommandAddArgList(cmd, "-append", def->os.cmdline, NULL);
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DTB) && def->os.dtb)
+ virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL);
} else {
virCommandAddArgList(cmd, "-bootloader", def->os.bootloader, NULL);
}
@@ -9161,6 +9163,10 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
WANT_VALUE();
if (!(def->os.cmdline = strdup(val)))
goto no_memory;
+ } else if (STREQ(arg, "-dtb")) {
+ WANT_VALUE();
+ if (!(def->os.dtb = strdup(val)))
+ goto no_memory;
} else if (STREQ(arg, "-boot")) {
const char *token = NULL;
WANT_VALUE();
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 720a188..460c5fd 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -339,7 +339,8 @@ mymain(void)
QEMU_CAPS_NO_ACPI,
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_CPU_HOST,
- QEMU_CAPS_VNC);
+ QEMU_CAPS_VNC,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-0.12.1.2-rhel60", 12001, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -397,7 +398,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-0.12.3", 12003, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -440,7 +442,8 @@ mymain(void)
QEMU_CAPS_NO_ACPI,
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_CPU_HOST,
- QEMU_CAPS_VNC);
+ QEMU_CAPS_VNC,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-0.13.0", 13000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -506,7 +509,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-0.12.1.2-rhel61", 12001, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -571,7 +575,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-0.12.1.2-rhel62-beta", 12001, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -643,7 +648,8 @@ mymain(void)
QEMU_CAPS_VNC,
QEMU_CAPS_DEVICE_QXL,
QEMU_CAPS_DEVICE_VGA,
- QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ QEMU_CAPS_DEVICE_CIRRUS_VGA,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-1.0", 1000000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -723,7 +729,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-1.1.0", 1001000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -811,7 +818,8 @@ mymain(void)
QEMU_CAPS_DEVICE_CIRRUS_VGA,
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-1.2.0", 1002000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -910,7 +918,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -1014,7 +1023,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VMWARE_SVGA,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_DEVICE_USB_SERIAL,
- QEMU_CAPS_DEVICE_USB_NET);
+ QEMU_CAPS_DEVICE_USB_NET,
+ QEMU_CAPS_DTB);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
new file mode 100644
index 0000000..a66ac51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-ppc -S -M
ppce500v2 -m 256 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi
-boot c -kernel /media/ram/uImage -initrd /media/ram/ramdisk -append 'root=/dev/ram rw
console=ttyS0,115200' -dtb /media/ram/test.dtb -usb -net none -serial pty -parallel
none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml
b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml
new file mode 100644
index 0000000..3674621
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-ppc-dtb.xml
@@ -0,0 +1,28 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>49545eb3-75e1-2d0a-acdd-f0294406c99e</uuid>
+ <memory unit='KiB'>262144</memory>
+ <currentMemory unit='KiB'>262144</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc' machine='ppce500v2'>hvm</type>
+ <kernel>/media/ram/uImage</kernel>
+ <initrd>/media/ram/ramdisk</initrd>
+ <cmdline>root=/dev/ram rw console=ttyS0,115200</cmdline>
+ <dtb>/media/ram/test.dtb</dtb>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc</emulator>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a9a5557..8f6a50d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -901,6 +901,8 @@ mymain(void)
DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_EGD);
+ DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
+
virObjectUnref(driver.config);
virObjectUnref(driver.caps);
virObjectUnref(driver.xmlconf);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 4e13db9..db15ee6 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -92,6 +92,36 @@ error:
return -1;
}
+static int testQemuAddPPCGuest(virCapsPtr caps)
+{
+ static const char *machine[] = { "g3beige",
+ "mac99",
+ "prep",
+ "ppce500v2" };
+ virCapsGuestMachinePtr *machines = NULL;
+ virCapsGuestPtr guest;
+
+ machines = virCapabilitiesAllocMachines(machine, 1);
+ if (!machines)
+ goto error;
+
+ guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC,
+ "/usr/bin/qemu-system-ppc", NULL,
+ 1, machines);
+ if (!guest)
+ goto error;
+
+ if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL))
+ goto error;
+
+ return 0;
+
+error:
+ /* No way to free a guest? */
+ virCapabilitiesFreeMachines(machines, 1);
+ return -1;
+}
+
static int testQemuAddS390Guest(virCapsPtr caps)
{
static const char *s390_machines[] = { "s390-virtio",
@@ -242,6 +272,9 @@ virCapsPtr testQemuCapsInit(void) {
if (testQemuAddPPC64Guest(caps))
goto cleanup;
+ if (testQemuAddPPCGuest(caps))
+ goto cleanup;
+
if (testQemuAddS390Guest(caps))
goto cleanup;
--
1.6.4