mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
hmp: Add read-only-mode option to change command
Expose the new read-only-mode option of 'blockdev-change-medium' for the 'change' HMP command. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
39ff43d9e1
commit
baead0abef
2 changed files with 38 additions and 4 deletions
22
hmp.c
22
hmp.c
|
@ -27,6 +27,7 @@
|
|||
#include "qapi/opts-visitor.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qapi/string-output-visitor.h"
|
||||
#include "qapi/util.h"
|
||||
#include "qapi-visit.h"
|
||||
#include "ui/console.h"
|
||||
#include "block/qapi.h"
|
||||
|
@ -1343,9 +1344,16 @@ void hmp_change(Monitor *mon, const QDict *qdict)
|
|||
const char *device = qdict_get_str(qdict, "device");
|
||||
const char *target = qdict_get_str(qdict, "target");
|
||||
const char *arg = qdict_get_try_str(qdict, "arg");
|
||||
const char *read_only = qdict_get_try_str(qdict, "read-only-mode");
|
||||
BlockdevChangeReadOnlyMode read_only_mode = 0;
|
||||
Error *err = NULL;
|
||||
|
||||
if (strcmp(device, "vnc") == 0) {
|
||||
if (read_only) {
|
||||
monitor_printf(mon,
|
||||
"Parameter 'read-only-mode' is invalid for VNC\n");
|
||||
return;
|
||||
}
|
||||
if (strcmp(target, "passwd") == 0 ||
|
||||
strcmp(target, "password") == 0) {
|
||||
if (!arg) {
|
||||
|
@ -1355,7 +1363,19 @@ void hmp_change(Monitor *mon, const QDict *qdict)
|
|||
}
|
||||
qmp_change("vnc", target, !!arg, arg, &err);
|
||||
} else {
|
||||
qmp_blockdev_change_medium(device, target, !!arg, arg, false, 0, &err);
|
||||
if (read_only) {
|
||||
read_only_mode =
|
||||
qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup,
|
||||
read_only, BLOCKDEV_CHANGE_READ_ONLY_MODE_MAX,
|
||||
BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
|
||||
if (err) {
|
||||
hmp_handle_error(mon, &err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qmp_blockdev_change_medium(device, target, !!arg, arg,
|
||||
!!read_only, read_only_mode, &err);
|
||||
if (err &&
|
||||
error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) {
|
||||
error_free(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue