qemu: Split ide-drive into ide-cd and ide-hd

A "ide-drive" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.

Upstream qemu splitted "ide-drive" into "ide-hd" and "ide-cd"
since commit 1f56e32, and ",media=cdrom" is not required for
ide-cd anymore. "ide-drive" is still supported for backwards
compatibility, but no doubt we should go foward.
This commit is contained in:
Osier Yang 2012-04-17 17:16:52 +08:00
parent 02e8d0cfdf
commit a4cda054e7
7 changed files with 72 additions and 3 deletions

View File

@ -160,6 +160,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"block-job-sync", /* 90 */
"block-job-async",
"scsi-cd",
"ide-cd",
);
struct qemu_feature_flags {
@ -1454,6 +1455,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_SCSI_BLOCK);
if (strstr(str, "scsi-cd"))
qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
if (strstr(str, "ide-cd"))
qemuCapsSet(flags, QEMU_CAPS_IDE_CD);
return 0;
}

View File

@ -127,6 +127,7 @@ enum qemuCapsFlags {
QEMU_CAPS_BLOCKJOB_SYNC = 90, /* RHEL 6.2 block_job_cancel */
QEMU_CAPS_BLOCKJOB_ASYNC = 91, /* qemu 1.1 block-job-cancel */
QEMU_CAPS_SCSI_CD = 92, /* -device scsi-cd */
QEMU_CAPS_IDE_CD = 93, /* -device ide-cd */
QEMU_CAPS_LAST, /* this must always be the last item */
};

View File

@ -1982,6 +1982,9 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
if ((disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
virBufferAddLit(&opt, ",media=cdrom");
} else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD))
virBufferAddLit(&opt, ",media=cdrom");
} else {
virBufferAddLit(&opt, ",media=cdrom");
}
@ -2205,7 +2208,16 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("target must be 0 for ide controller"));
goto error;
}
virBufferAddLit(&opt, "ide-drive");
if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
virBufferAddLit(&opt, "ide-cd");
else
virBufferAddLit(&opt, "ide-hd");
} else {
virBufferAddLit(&opt, "ide-drive");
}
virBufferAsprintf(&opt, ",bus=ide.%d,unit=%d",
disk->info.addr.drive.bus,
disk->info.addr.drive.unit);
@ -2301,7 +2313,16 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("target must be 0 for ide controller"));
goto error;
}
virBufferAddLit(&opt, "ide-drive");
if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
virBufferAddLit(&opt, "ide-cd");
else
virBufferAddLit(&opt, "ide-hd");
} else {
virBufferAddLit(&opt, "ide-drive");
}
virBufferAsprintf(&opt, ",bus=ahci%d.%d",
disk->info.addr.drive.controller,
disk->info.addr.drive.unit);

View File

@ -676,7 +676,8 @@ mymain(void)
QEMU_CAPS_CPU_HOST,
QEMU_CAPS_FSDEV_WRITEOUT,
QEMU_CAPS_SCSI_BLOCK,
QEMU_CAPS_SCSI_CD);
QEMU_CAPS_SCSI_CD,
QEMU_CAPS_IDE_CD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -0,0 +1,8 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1 \
-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
-drive file=/tmp/idedisk.img,if=none,id=drive-ide0-0-2 \
-device ide-hd,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4

View File

@ -0,0 +1,32 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</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='cdrom'>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk'>
<source file='/tmp/idedisk.img'/>
<target dev='hdc' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='ide' index='1'/>
<memballoon model='virtio'/>
</devices>
</domain>

View File

@ -758,6 +758,9 @@ mymain(void)
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("pseries-vio-address-clash", true, QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-ide-drive-split", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_IDE_CD);
VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);