mirror of https://github.com/xemu-project/xemu.git
monitor usb: Inline monitor_read_bdrv_key_start()'s first part
monitor_read_bdrv_key_start() does several things: 1. If no key is needed, call completion_cb() and succeed 2. If we're in QMP context, call qerror_report_err() and fail 3. Start reading the key in the monitor. This is two things too many. Inline 1. and 2. into its callers monitor_read_block_device_key() and usb_msd_realize_storage(). Since monitor_read_block_device_key() only ever runs in HMP context, drop 2. there. The next commit will clean up the result in usb_msd_realize_storage(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
988e0f0662
commit
9b14e0efcc
|
@ -641,8 +641,17 @@ static void usb_msd_realize_storage(USBDevice *dev, Error **errp)
|
||||||
|
|
||||||
if (bdrv_key_required(blk_bs(blk))) {
|
if (bdrv_key_required(blk_bs(blk))) {
|
||||||
if (cur_mon) {
|
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),
|
monitor_read_bdrv_key_start(cur_mon, blk_bs(blk),
|
||||||
usb_msd_password_cb, s);
|
usb_msd_password_cb, s);
|
||||||
|
}
|
||||||
s->dev.auto_attach = 0;
|
s->dev.auto_attach = 0;
|
||||||
} else {
|
} else {
|
||||||
autostart = 0;
|
autostart = 0;
|
||||||
|
|
27
monitor.c
27
monitor.c
|
@ -5377,25 +5377,8 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
|
||||||
BlockCompletionFunc *completion_cb,
|
BlockCompletionFunc *completion_cb,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
bdrv_add_key(bs, NULL, &local_err);
|
|
||||||
if (!local_err) {
|
|
||||||
if (completion_cb)
|
|
||||||
completion_cb(opaque, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Need a key for @bs */
|
|
||||||
|
|
||||||
if (monitor_ctrl_mode(mon)) {
|
|
||||||
qerror_report_err(local_err);
|
|
||||||
error_free(local_err);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_free(local_err);
|
|
||||||
monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
|
monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
|
||||||
bdrv_get_encrypted_filename(bs));
|
bdrv_get_encrypted_filename(bs));
|
||||||
|
|
||||||
|
@ -5414,6 +5397,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
|
||||||
BlockCompletionFunc *completion_cb,
|
BlockCompletionFunc *completion_cb,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
|
Error *err = NULL;
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
|
|
||||||
blk = blk_by_name(device);
|
blk = blk_by_name(device);
|
||||||
|
@ -5422,7 +5406,16 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bdrv_add_key(blk_bs(blk), NULL, &err);
|
||||||
|
if (err) {
|
||||||
|
error_free(err);
|
||||||
return monitor_read_bdrv_key_start(mon, blk_bs(blk), completion_cb, opaque);
|
return monitor_read_bdrv_key_start(mon, blk_bs(blk), completion_cb, opaque);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (completion_cb) {
|
||||||
|
completion_cb(opaque, 0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QemuOptsList qemu_mon_opts = {
|
QemuOptsList qemu_mon_opts = {
|
||||||
|
|
Loading…
Reference in New Issue