mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 09:55:55 +00:00
scsi: Don't ignore most usb-storage properties
usb-storage is for the most part just a wrapper around an internally created scsi-disk device. It uses DEFINE_BLOCK_PROPERTIES() to offer all of the usual block device properties to the user, but then only forwards a few select properties to the internal device while the rest is silently ignored. This changes scsi_bus_legacy_add_drive() to accept a whole BlockConf instead of some individual values inside of it so that usb-storage can now pass the whole configuration to the internal scsi-disk. This enables the remaining block device properties, e.g. logical/physical_block_size or discard_granularity. Buglink: https://issues.redhat.com/browse/RHEL-22375 Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20240131130607.24117-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b3d9bb9a56
commit
3089637461
|
@ -376,15 +376,13 @@ static void scsi_qdev_unrealize(DeviceState *qdev)
|
||||||
|
|
||||||
/* handle legacy '-drive if=scsi,...' cmd line args */
|
/* handle legacy '-drive if=scsi,...' cmd line args */
|
||||||
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||||
int unit, bool removable, int bootindex,
|
int unit, bool removable, BlockConf *conf,
|
||||||
bool share_rw,
|
|
||||||
BlockdevOnError rerror,
|
|
||||||
BlockdevOnError werror,
|
|
||||||
const char *serial, Error **errp)
|
const char *serial, Error **errp)
|
||||||
{
|
{
|
||||||
const char *driver;
|
const char *driver;
|
||||||
char *name;
|
char *name;
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
|
SCSIDevice *s;
|
||||||
DriveInfo *dinfo;
|
DriveInfo *dinfo;
|
||||||
|
|
||||||
if (blk_is_sg(blk)) {
|
if (blk_is_sg(blk)) {
|
||||||
|
@ -402,11 +400,10 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||||
object_property_add_child(OBJECT(bus), name, OBJECT(dev));
|
object_property_add_child(OBJECT(bus), name, OBJECT(dev));
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
|
s = SCSI_DEVICE(dev);
|
||||||
|
s->conf = *conf;
|
||||||
|
|
||||||
qdev_prop_set_uint32(dev, "scsi-id", unit);
|
qdev_prop_set_uint32(dev, "scsi-id", unit);
|
||||||
if (bootindex >= 0) {
|
|
||||||
object_property_set_int(OBJECT(dev), "bootindex", bootindex,
|
|
||||||
&error_abort);
|
|
||||||
}
|
|
||||||
if (object_property_find(OBJECT(dev), "removable")) {
|
if (object_property_find(OBJECT(dev), "removable")) {
|
||||||
qdev_prop_set_bit(dev, "removable", removable);
|
qdev_prop_set_bit(dev, "removable", removable);
|
||||||
}
|
}
|
||||||
|
@ -417,19 +414,12 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||||
object_unparent(OBJECT(dev));
|
object_unparent(OBJECT(dev));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!object_property_set_bool(OBJECT(dev), "share-rw", share_rw, errp)) {
|
|
||||||
object_unparent(OBJECT(dev));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
qdev_prop_set_enum(dev, "rerror", rerror);
|
|
||||||
qdev_prop_set_enum(dev, "werror", werror);
|
|
||||||
|
|
||||||
if (!qdev_realize_and_unref(dev, &bus->qbus, errp)) {
|
if (!qdev_realize_and_unref(dev, &bus->qbus, errp)) {
|
||||||
object_unparent(OBJECT(dev));
|
object_unparent(OBJECT(dev));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return SCSI_DEVICE(dev);
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
|
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
|
||||||
|
@ -437,6 +427,12 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
|
||||||
Location loc;
|
Location loc;
|
||||||
DriveInfo *dinfo;
|
DriveInfo *dinfo;
|
||||||
int unit;
|
int unit;
|
||||||
|
BlockConf conf = {
|
||||||
|
.bootindex = -1,
|
||||||
|
.share_rw = false,
|
||||||
|
.rerror = BLOCKDEV_ON_ERROR_AUTO,
|
||||||
|
.werror = BLOCKDEV_ON_ERROR_AUTO,
|
||||||
|
};
|
||||||
|
|
||||||
loc_push_none(&loc);
|
loc_push_none(&loc);
|
||||||
for (unit = 0; unit <= bus->info->max_target; unit++) {
|
for (unit = 0; unit <= bus->info->max_target; unit++) {
|
||||||
|
@ -446,10 +442,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
|
||||||
}
|
}
|
||||||
qemu_opts_loc_restore(dinfo->opts);
|
qemu_opts_loc_restore(dinfo->opts);
|
||||||
scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
|
scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
|
||||||
unit, false, -1, false,
|
unit, false, &conf, NULL, &error_fatal);
|
||||||
BLOCKDEV_ON_ERROR_AUTO,
|
|
||||||
BLOCKDEV_ON_ERROR_AUTO,
|
|
||||||
NULL, &error_fatal);
|
|
||||||
}
|
}
|
||||||
loc_pop(&loc);
|
loc_pop(&loc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,10 +67,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
|
||||||
scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(dev),
|
scsi_bus_init(&s->bus, sizeof(s->bus), DEVICE(dev),
|
||||||
&usb_msd_scsi_info_storage);
|
&usb_msd_scsi_info_storage);
|
||||||
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
|
scsi_dev = scsi_bus_legacy_add_drive(&s->bus, blk, 0, !!s->removable,
|
||||||
s->conf.bootindex, s->conf.share_rw,
|
&s->conf, dev->serial, errp);
|
||||||
s->conf.rerror, s->conf.werror,
|
|
||||||
dev->serial,
|
|
||||||
errp);
|
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
if (!scsi_dev) {
|
if (!scsi_dev) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -199,10 +199,7 @@ static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
|
||||||
}
|
}
|
||||||
|
|
||||||
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||||
int unit, bool removable, int bootindex,
|
int unit, bool removable, BlockConf *conf,
|
||||||
bool share_rw,
|
|
||||||
BlockdevOnError rerror,
|
|
||||||
BlockdevOnError werror,
|
|
||||||
const char *serial, Error **errp);
|
const char *serial, Error **errp);
|
||||||
void scsi_bus_set_ua(SCSIBus *bus, SCSISense sense);
|
void scsi_bus_set_ua(SCSIBus *bus, SCSISense sense);
|
||||||
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
||||||
|
|
Loading…
Reference in a new issue