usb-storage: Add rerror/werror properties
The error handling policy was traditionally set with -drive, but with -blockdev it is no longer possible to set frontend options. scsi-disk (and other block devices) have long supported qdev properties to configure the error handling policy, so let's add these options to usb-storage as well and just forward them to the internal scsi-disk instance. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
0ab1c41d1c
commit
b8efb36b9e
|
@ -226,6 +226,8 @@ static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)
|
||||||
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, int bootindex,
|
||||||
bool share_rw,
|
bool share_rw,
|
||||||
|
BlockdevOnError rerror,
|
||||||
|
BlockdevOnError werror,
|
||||||
const char *serial, Error **errp)
|
const char *serial, Error **errp)
|
||||||
{
|
{
|
||||||
const char *driver;
|
const char *driver;
|
||||||
|
@ -262,6 +264,10 @@ SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
|
||||||
object_unparent(OBJECT(dev));
|
object_unparent(OBJECT(dev));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qdev_prop_set_enum(dev, "rerror", rerror);
|
||||||
|
qdev_prop_set_enum(dev, "werror", werror);
|
||||||
|
|
||||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_propagate(errp, err);
|
error_propagate(errp, err);
|
||||||
|
@ -285,7 +291,10 @@ 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, NULL, &error_fatal);
|
unit, false, -1, false,
|
||||||
|
BLOCKDEV_ON_ERROR_AUTO,
|
||||||
|
BLOCKDEV_ON_ERROR_AUTO,
|
||||||
|
NULL, &error_fatal);
|
||||||
}
|
}
|
||||||
loc_pop(&loc);
|
loc_pop(&loc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,6 +625,7 @@ static void usb_msd_storage_realize(USBDevice *dev, Error **errp)
|
||||||
&usb_msd_scsi_info_storage, NULL);
|
&usb_msd_scsi_info_storage, NULL);
|
||||||
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.bootindex, s->conf.share_rw,
|
||||||
|
s->conf.rerror, s->conf.werror,
|
||||||
dev->serial,
|
dev->serial,
|
||||||
errp);
|
errp);
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
@ -671,6 +672,7 @@ static const VMStateDescription vmstate_usb_msd = {
|
||||||
|
|
||||||
static Property msd_properties[] = {
|
static Property msd_properties[] = {
|
||||||
DEFINE_BLOCK_PROPERTIES(MSDState, conf),
|
DEFINE_BLOCK_PROPERTIES(MSDState, conf),
|
||||||
|
DEFINE_BLOCK_ERROR_PROPERTIES(MSDState, conf),
|
||||||
DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
|
DEFINE_PROP_BIT("removable", MSDState, removable, 0, false),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -154,6 +154,8 @@ 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, int bootindex,
|
||||||
bool share_rw,
|
bool share_rw,
|
||||||
|
BlockdevOnError rerror,
|
||||||
|
BlockdevOnError werror,
|
||||||
const char *serial, Error **errp);
|
const char *serial, Error **errp);
|
||||||
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
|
||||||
void scsi_legacy_handle_cmdline(void);
|
void scsi_legacy_handle_cmdline(void);
|
||||||
|
|
Loading…
Reference in a new issue