aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/usb/dev-storage.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
index f47c8561ef..f50bcb83e2 100644
--- a/hw/usb/dev-storage.c
+++ b/hw/usb/dev-storage.c
@@ -610,6 +610,23 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
return;
}
+ bdrv_add_key(blk_bs(blk), NULL, &err);
+ if (err) {
+ if (monitor_cur_is_qmp()) {
+ error_propagate(errp, err);
+ return;
+ }
+ error_free(err);
+ err = NULL;
+ if (cur_mon) {
+ monitor_read_bdrv_key_start(cur_mon, blk_bs(blk),
+ usb_msd_password_cb, s);
+ s->dev.auto_attach = 0;
+ } else {
+ autostart = 0;
+ }
+ }
+
blkconf_serial(&s->conf, &dev->serial);
blkconf_blocksizes(&s->conf);
@@ -638,25 +655,6 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
}
usb_msd_handle_reset(dev);
s->scsi_dev = scsi_dev;
-
- if (bdrv_key_required(blk_bs(blk))) {
- if (cur_mon) {
- bdrv_add_key(blk_bs(blk), NULL, &err);
- if (!err) {
- usb_msd_password_cb(s, 0);
- } else if (monitor_cur_is_qmp()) {
- qerror_report_err(err);
- error_free(err);
- } else {
- error_free(err);
- monitor_read_bdrv_key_start(cur_mon, blk_bs(blk),
- usb_msd_password_cb, s);
- }
- s->dev.auto_attach = 0;
- } else {
- autostart = 0;
- }
- }
}
static void usb_msd_realize_bot(USBDevice *dev, Error **errp)