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.
---
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 26 +++++++++++++++-
tests/qemuhelptest.c | 3 +-
.../qemuxml2argv-disk-ide-drive-split.args | 8 +++++
.../qemuxml2argv-disk-ide-drive-split.xml | 32 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
7 files changed, 74 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c4b04ae..1f999a7 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -156,6 +156,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"scsi-disk.channel",
"scsi-block",
"scsi-cd",
+
+ "ide-cd", /* 90 */
);
struct qemu_feature_flags {
@@ -1450,6 +1452,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;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 5ebffdc..e664f29 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -124,6 +124,7 @@ enum qemuCapsFlags {
QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */
QEMU_CAPS_SCSI_BLOCK = 88, /* -device scsi-block */
QEMU_CAPS_SCSI_CD = 89, /* -device scsi-cd */
+ QEMU_CAPS_IDE_CD = 90, /* -device ide-cd */
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 afe5db8..9a02a80 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1971,6 +1971,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");
}
@@ -2194,7 +2197,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);
@@ -2285,12 +2297,22 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("bus must be 0 for ide controller"));
goto error;
}
+
if (disk->info.addr.drive.target != 0) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("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);
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index a01c389..d23b35a 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -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;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
new file mode 100644
index 0000000..e24490d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
@@ -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
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
new file mode 100644
index 0000000..b965677
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
@@ -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>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 97e2bac..b503ddc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -753,6 +753,9 @@ mymain(void)
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);
VIR_FREE(map);
--
1.7.1