[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 15/37] hmp: Add read-only-mode option to change comma
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 15/37] hmp: Add read-only-mode option to change command |
Date: |
Thu, 5 Nov 2015 19:17:43 +0100 |
From: Max Reitz <address@hidden>
Expose the new read-only-mode option of 'blockdev-change-medium' for the
'change' HMP command.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hmp-commands.hx | 20 +++++++++++++++++---
hmp.c | 22 +++++++++++++++++++++-
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3a4ae39..814ea86 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -194,8 +194,8 @@ ETEXI
{
.name = "change",
- .args_type = "device:B,target:F,arg:s?",
- .params = "device filename [format]",
+ .args_type = "device:B,target:F,arg:s?,read-only-mode:s?",
+ .params = "device filename [format [read-only-mode]]",
.help = "change a removable medium, optional format",
.mhandler.cmd = hmp_change,
},
@@ -206,7 +206,7 @@ STEXI
Change the configuration of a device.
@table @option
address@hidden change @var{diskdevice} @var{filename} address@hidden
address@hidden change @var{diskdevice} @var{filename} address@hidden
address@hidden
Change the medium for a removable disk device to point to @var{filename}. eg
@example
@@ -215,6 +215,20 @@ Change the medium for a removable disk device to point to
@var{filename}. eg
@var{format} is optional.
address@hidden may be used to change the read-only status of the device.
+It accepts the following values:
+
address@hidden @var
address@hidden retain
+Retains the current status; this is the default.
+
address@hidden read-only
+Makes the device read-only.
+
address@hidden read-write
+Makes the device writable.
address@hidden table
+
@item change vnc @var{display},@var{options}
Change the configuration of the VNC server. The valid syntax for @var{display}
and @var{options} are described at @ref{sec_invocation}. eg
diff --git a/hmp.c b/hmp.c
index efa07a2..8166fd2 100644
--- a/hmp.c
+++ b/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"
@@ -1336,9 +1337,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) {
@@ -1348,7 +1356,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);
--
1.8.3.1
- [Qemu-block] [PULL 01/37] block: Don't call blk_bs() twice in bdrv_lookup_bs(), (continued)
- [Qemu-block] [PULL 01/37] block: Don't call blk_bs() twice in bdrv_lookup_bs(), Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 05/37] blockdev: Add blockdev-open-tray, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 04/37] block: Add functions for inheriting a BBRS, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 06/37] blockdev: Add blockdev-close-tray, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 07/37] blockdev: Add blockdev-remove-medium, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 08/37] blockdev: Add blockdev-insert-medium, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 10/37] blockdev: Implement change with basic operations, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 11/37] block: Inquire tray state before tray-moved events, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 12/37] qmp: Introduce blockdev-change-medium, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 14/37] blockdev: read-only-mode for blockdev-change-medium, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 15/37] hmp: Add read-only-mode option to change command,
Kevin Wolf <=
- [Qemu-block] [PULL 17/37] block: check for existing device IDs in external_snapshot_prepare(), Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 09/37] blockdev: Implement eject with basic operations, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 13/37] hmp: Use blockdev-change-medium for change command, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 20/37] block: add a 'blockdev-snapshot' QMP command, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 16/37] iotests: Add test for change-related QMP commands, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 21/37] block: add tests for the 'blockdev-snapshot' command, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 18/37] block: rename BlockdevSnapshot to BlockdevSnapshotSync, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 19/37] block: support passing 'backing': '' to 'blockdev-add', Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 22/37] commit: reopen overlay_bs before base, Kevin Wolf, 2015/11/05
- [Qemu-block] [PULL 23/37] qemu-iotests: Test the reopening of overlay_bs in 'block-commit', Kevin Wolf, 2015/11/05