summaryrefslogtreecommitdiff
path: root/hmp.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2015-10-26 21:39:16 +0100
committerKevin Wolf <kwolf@redhat.com>2015-11-11 16:22:47 +0100
commit1068674927a08cb9f535946abe2f91529b13160c (patch)
tree9499a3f55eb469b6321e0fe84689f03bb9d7552b /hmp.c
parent24fb4133001e1f54a526f0927837f30c1507169a (diff)
downloadqemu-1068674927a08cb9f535946abe2f91529b13160c.tar.gz
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: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hmp.c')
-rw-r--r--hmp.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/hmp.c b/hmp.c
index e1f854aefe..e5ad944811 100644
--- a/hmp.c
+++ b/hmp.c
@@ -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);
}