Skip to content

Commit 0d074bf

Browse files
committed
scsi: deprecate scsi-disk
It's an old compatibility shim that just delegates to scsi-cd or scsi-hd. Just like ide-drive, we don't need this. Acked-by: Peter Krempa <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 2f34ebf commit 0d074bf

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

hw/scsi/scsi-bus.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,18 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
254254
char *name;
255255
DeviceState *dev;
256256
Error *err = NULL;
257+
DriveInfo *dinfo;
257258

258-
driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk";
259+
if (blk_is_sg(blk)) {
260+
driver = "scsi-generic";
261+
} else {
262+
dinfo = blk_legacy_dinfo(blk);
263+
if (dinfo && dinfo->media_cd) {
264+
driver = "scsi-cd";
265+
} else {
266+
driver = "scsi-hd";
267+
}
268+
}
259269
dev = qdev_create(&bus->qbus, driver);
260270
name = g_strdup_printf("legacy[%d]", unit);
261271
object_property_add_child(OBJECT(bus), name, OBJECT(dev), NULL);

hw/scsi/scsi-disk.c

+3
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,9 @@ static void scsi_disk_realize(SCSIDevice *dev, Error **errp)
24812481
DriveInfo *dinfo;
24822482
Error *local_err = NULL;
24832483

2484+
warn_report("'scsi-disk' is deprecated, "
2485+
"please use 'scsi-hd' or 'scsi-cd' instead");
2486+
24842487
if (!dev->conf.blk) {
24852488
scsi_realize(dev, &local_err);
24862489
assert(local_err);

qemu-deprecated.texi

+5
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ their usecases.
259259
The 'ide-drive' device is deprecated. Users should use 'ide-hd' or
260260
'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed.
261261

262+
@subsection scsi-disk (since 4.2)
263+
264+
The 'scsi-disk' device is deprecated. Users should use 'scsi-hd' or
265+
'scsi-cd' as appropriate to get a SCSI hard disk or CD-ROM as needed.
266+
262267
@section System emulator machines
263268

264269
@subsection pc-0.12, pc-0.13, pc-0.14 and pc-0.15 (since 4.0)

tests/qemu-iotests/051.pc.out

+4-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ QEMU X.Y.Z monitor - type 'help' for more information
167167

168168
Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-disk,drive=disk
169169
QEMU X.Y.Z monitor - type 'help' for more information
170-
(qemu) QEMU_PROG: -device scsi-disk,drive=disk: Device needs media, but drive is empty
170+
(qemu) QEMU_PROG: -device scsi-disk,drive=disk: warning: 'scsi-disk' is deprecated, please use 'scsi-hd' or 'scsi-cd' instead
171+
QEMU_PROG: -device scsi-disk,drive=disk: Device needs media, but drive is empty
171172

172173
Testing: -drive if=none,id=disk -device lsi53c895a -device scsi-hd,drive=disk
173174
QEMU X.Y.Z monitor - type 'help' for more information
@@ -238,7 +239,8 @@ QEMU X.Y.Z monitor - type 'help' for more information
238239

239240
Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-disk,drive=disk
240241
QEMU X.Y.Z monitor - type 'help' for more information
241-
(qemu) quit
242+
(qemu) QEMU_PROG: -device scsi-disk,drive=disk: warning: 'scsi-disk' is deprecated, please use 'scsi-hd' or 'scsi-cd' instead
243+
quit
242244

243245
Testing: -drive file=TEST_DIR/t.qcow2,if=none,id=disk,readonly=on -device lsi53c895a -device scsi-hd,drive=disk
244246
QEMU X.Y.Z monitor - type 'help' for more information

0 commit comments

Comments
 (0)