提交 2c37f479 编写于 作者: D Daniel P. Berrange

Support paravirt disk configuration for xenner guests

上级 60495940
Thu May 15 11:57:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
Support paravirt disk configuration for xenner guests
* src/qemu_conf.c, src/qemu_conf.h: Add support for 'xen' disk
bus and 'xvd' disk device names for Xenner
* src/util.c: Support parsing 'xvd' disk names
* tests/qemuxml2argv-disk-xenvbd.{args,xml}: Test case data
files for xvd disks.
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add
test case for xvd disk / xen bus type
Thu May 15 09:12:08 CEST 2008 Jim Meyering <meyering@redhat.com>
Avoid using STREQLEN with a literal; use STRPREFIX instead
......
......@@ -667,7 +667,8 @@ static int qemudParseDiskXML(virConnectPtr conn,
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 @@ static int qemudParseDiskXML(virConnectPtr conn,
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 @@ static const char *qemudBusIdToName(int busId, int qemuIF) {
const char *busnames[] = { "ide",
(qemuIF ? "floppy" : "fdc"),
"scsi",
"virtio" };
"virtio",
"xen"};
verify_true(ARRAY_CARDINALITY(busnames) == QEMUD_DISK_BUS_LAST);
return busnames[busId];
......
......@@ -61,6 +61,7 @@ enum qemud_vm_disk_bus {
QEMUD_DISK_BUS_FDC,
QEMUD_DISK_BUS_SCSI,
QEMUD_DISK_BUS_VIRTIO,
QEMUD_DISK_BUS_XEN,
QEMUD_DISK_BUS_LAST
};
......
......@@ -778,25 +778,19 @@ virParseMacAddr(const char* str, unsigned char *addr)
int virDiskNameToIndex(const char *name) {
const char *ptr = NULL;
int idx = 0;
static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd"};
unsigned int i;
if (strlen(name) < 3)
return -1;
switch (*name) {
case 'f':
case 'h':
case 'v':
case 's':
for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
if (STRPREFIX(name, drive_prefix[i])) {
ptr = name + strlen(drive_prefix[i]);
break;
default:
return 0;
}
}
if (*(name + 1) != 'd')
if (!ptr)
return -1;
ptr = name+2;
while (*ptr) {
idx = idx * 26;
......
/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
<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>
......@@ -153,6 +153,7 @@ main(int argc, char **argv)
DO_TEST("disk-floppy", 0);
DO_TEST("disk-many", 0);
DO_TEST("disk-virtio", 1);
DO_TEST("disk-xenvbd", 1);
DO_TEST("graphics-vnc", 0);
DO_TEST("graphics-sdl", 0);
DO_TEST("input-usbmouse", 0);
......
......@@ -102,6 +102,7 @@ main(int argc, char **argv)
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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册