With the recent work to support -drive arg, the QEMU driver now supports
many types of bus for disks attached to VMs - ide, scsi, virtio. This patches
adds another type 'xen' for the Xen blkfront driver.
b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args | 1
b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml | 35 +++++++++++++++++
src/qemu_conf.c | 8 ++-
src/qemu_conf.h | 1
src/util.c | 24 ++++-------
tests/qemuxml2xmltest.c | 1
6 files changed, 53 insertions(+), 17 deletions(-)
Dan.
diff -r f6b47c9986b9 src/qemu_conf.c
--- a/src/qemu_conf.c Sat May 10 12:57:20 2008 -0400
+++ b/src/qemu_conf.c Sat May 10 12:57:46 2008 -0400
@@ -667,7 +667,8 @@
if ((!device || STREQ((const char *)device, "disk")) &&
!STRPREFIX((const char *)target, "hd") &&
!STRPREFIX((const char *)target, "sd") &&
- !STRPREFIX((const char *)target, "vd")) {
+ !STRPREFIX((const char *)target, "vd") &&
+ !STRPREFIX((const char *)target, "xvd")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Invalid harddisk device name: %s"), target);
goto error;
@@ -707,6 +708,8 @@
disk->bus = QEMUD_DISK_BUS_SCSI;
else if (STREQ((const char *)bus, "virtio"))
disk->bus = QEMUD_DISK_BUS_VIRTIO;
+ else if (STREQ((const char *)bus, "xen"))
+ disk->bus = QEMUD_DISK_BUS_XEN;
else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Invalid bus type: %s"), bus);
@@ -1435,7 +1438,8 @@
const char *busnames[] = { "ide",
(qemuIF ? "floppy" : "fdc"),
"scsi",
- "virtio" };
+ "virtio",
+ "xen"};
verify_true(ARRAY_CARDINALITY(busnames) == QEMUD_DISK_BUS_LAST);
return busnames[busId];
diff -r f6b47c9986b9 src/qemu_conf.h
--- a/src/qemu_conf.h Sat May 10 12:57:20 2008 -0400
+++ b/src/qemu_conf.h Sat May 10 12:57:46 2008 -0400
@@ -61,6 +61,7 @@
QEMUD_DISK_BUS_FDC,
QEMUD_DISK_BUS_SCSI,
QEMUD_DISK_BUS_VIRTIO,
+ QEMUD_DISK_BUS_XEN,
QEMUD_DISK_BUS_LAST
};
diff -r f6b47c9986b9 src/util.c
--- a/src/util.c Sat May 10 12:57:20 2008 -0400
+++ b/src/util.c Sat May 10 12:57:46 2008 -0400
@@ -779,23 +779,17 @@
const char *ptr = NULL;
int idx = 0;
- if (strlen(name) < 3)
+ if (!STRPREFIX(name, "fd") &&
+ !STRPREFIX(name, "hd") &&
+ !STRPREFIX(name, "vd") &&
+ !STRPREFIX(name, "sd") &&
+ !STRPREFIX(name, "xvd"))
return -1;
- switch (*name) {
- case 'f':
- case 'h':
- case 'v':
- case 's':
- break;
- default:
- return 0;
- }
-
- if (*(name + 1) != 'd')
- return -1;
-
- ptr = name+2;
+ if (STRPREFIX(name, "xvd"))
+ ptr = name+3;
+ else
+ ptr = name+2;
while (*ptr) {
idx = idx * 26;
diff -r f6b47c9986b9 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args Sat May 10 12:57:47 2008 -0400
@@ -0,0 +1,1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive
file=/tmp/data.img,if=xen,index=0 -drive file=/tmp/logs.img,if=xen,index=6 -net none
-serial none -parallel none -usb
\ No newline at end of file
diff -r f6b47c9986b9 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml Sat May 10 12:57:47 2008 -0400
@@ -0,0 +1,35 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/data.img'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/logs.img'/>
+ <target dev='xvdg' bus='xen'/>
+ </disk>
+ </devices>
+</domain>
diff -r f6b47c9986b9 tests/qemuxml2xmltest.c
--- a/tests/qemuxml2xmltest.c Sat May 10 12:57:20 2008 -0400
+++ b/tests/qemuxml2xmltest.c Sat May 10 12:57:47 2008 -0400
@@ -102,6 +102,7 @@
DO_TEST("disk-cdrom");
DO_TEST("disk-floppy");
DO_TEST("disk-many");
+ DO_TEST("disk-xenvbd");
DO_TEST("graphics-vnc");
DO_TEST("graphics-sdl");
DO_TEST("input-usbmouse");
--
|: Red Hat, Engineering, Boston -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|