blockdev: Store -drive option media in DriveInfo
DriveInfo is closely tied to -drive, and like -drive, it mixes
information about host and guest part of the block device. Unlike
DriveInfo, BlockDriverState should be about the host part only.
One of the remaining guest bits there is the "type hint". -drive
option media sets it, and qdevs "ide-drive", "scsi-disk" and non-qdev
IF_XEN devices check it to pick HD vs. CD.
Communicate -drive option media via new DriveInfo member media_cd
instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 8df8518..397b9d6 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1295,12 +1295,13 @@
static int scsi_disk_initfn(SCSIDevice *dev)
{
SCSIDriveKind kind;
+ DriveInfo *dinfo;
if (!dev->conf.bs) {
kind = SCSI_HD; /* will die in scsi_initfn() */
} else {
- kind = bdrv_get_type_hint(dev->conf.bs) == BDRV_TYPE_CDROM
- ? SCSI_CD : SCSI_HD;
+ dinfo = drive_get_by_blockdev(dev->conf.bs);
+ kind = dinfo->media_cd ? SCSI_CD : SCSI_HD;
}
return scsi_initfn(dev, kind);