提交 10686749 编写于 作者: M Max Reitz 提交者: Kevin Wolf

hmp: Use blockdev-change-medium for change command

Use separate code paths for the two overloaded functions of the 'change'
HMP command, and invoke the 'blockdev-change-medium' QMP command if used
on a block device (by calling qmp_blockdev_change_medium()).
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 24fb4133
......@@ -1345,22 +1345,25 @@ void hmp_change(Monitor *mon, const QDict *qdict)
const char *arg = qdict_get_try_str(qdict, "arg");
Error *err = NULL;
if (strcmp(device, "vnc") == 0 &&
(strcmp(target, "passwd") == 0 ||
strcmp(target, "password") == 0)) {
if (!arg) {
monitor_read_password(mon, hmp_change_read_arg, NULL);
if (strcmp(device, "vnc") == 0) {
if (strcmp(target, "passwd") == 0 ||
strcmp(target, "password") == 0) {
if (!arg) {
monitor_read_password(mon, hmp_change_read_arg, NULL);
return;
}
}
qmp_change("vnc", target, !!arg, arg, &err);
} else {
qmp_blockdev_change_medium(device, target, !!arg, arg, &err);
if (err &&
error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) {
error_free(err);
monitor_read_block_device_key(mon, device, NULL, NULL);
return;
}
}
qmp_change(device, target, !!arg, arg, &err);
if (err &&
error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) {
error_free(err);
monitor_read_block_device_key(mon, device, NULL, NULL);
return;
}
hmp_handle_error(mon, &err);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册