From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL v2 15/40] hmp: Add read-only-mode option to change command
Date: Tue, 10 Nov 2015 15:09:15 +0100 [thread overview]
Message-ID: <1447164580-31094-16-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1447164580-31094-1-git-send-email-kwolf@redhat.com>
From: Max Reitz <mreitz@redhat.com>
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>
---
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
-@item change @var{diskdevice} @var{filename} [@var{format}]
+@item change @var{diskdevice} @var{filename} [@var{format} [@var{read-only-mode}]]
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.
+@var{read-only-mode} may be used to change the read-only status of the device.
+It accepts the following values:
+
+@table @var
+@item retain
+Retains the current status; this is the default.
+
+@item read-only
+Makes the device read-only.
+
+@item read-write
+Makes the device writable.
+@end 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
next prev parent reply other threads:[~2015-11-10 14:10 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 14:09 [Qemu-devel] [PULL v2 00/40] Block layer patches Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 01/40] block: Don't call blk_bs() twice in bdrv_lookup_bs() Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 02/40] block: Add blk_remove_bs() Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 03/40] block: Make bdrv_states public Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 04/40] block: Add functions for inheriting a BBRS Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 05/40] blockdev: Add blockdev-open-tray Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 06/40] blockdev: Add blockdev-close-tray Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 07/40] blockdev: Add blockdev-remove-medium Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 08/40] blockdev: Add blockdev-insert-medium Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 09/40] blockdev: Implement eject with basic operations Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 10/40] blockdev: Implement change " Kevin Wolf
2016-01-07 18:06 ` Peter Maydell
2016-01-07 19:37 ` Max Reitz
2016-01-07 19:56 ` Peter Maydell
2016-01-07 20:14 ` Max Reitz
2016-01-07 21:42 ` Peter Maydell
2016-01-07 21:57 ` Max Reitz
2016-01-07 22:19 ` Peter Maydell
2016-01-07 22:43 ` Max Reitz
2016-01-08 10:36 ` Peter Maydell
2016-01-11 18:23 ` Markus Armbruster
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 11/40] block: Inquire tray state before tray-moved events Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 12/40] qmp: Introduce blockdev-change-medium Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 13/40] hmp: Use blockdev-change-medium for change command Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 14/40] blockdev: read-only-mode for blockdev-change-medium Kevin Wolf
2015-11-10 14:09 ` Kevin Wolf [this message]
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 16/40] iotests: Add test for change-related QMP commands Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 17/40] block: check for existing device IDs in external_snapshot_prepare() Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 18/40] block: rename BlockdevSnapshot to BlockdevSnapshotSync Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 19/40] block: support passing 'backing': '' to 'blockdev-add' Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 20/40] block: add a 'blockdev-snapshot' QMP command Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 21/40] block: add tests for the 'blockdev-snapshot' command Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 22/40] commit: reopen overlay_bs before base Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 23/40] qemu-iotests: Test the reopening of overlay_bs in 'block-commit' Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 24/40] qcow2: avoid misaligned 64bit bswap Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 25/40] qemu-img: add check for zero-length job len Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 26/40] throttle: Check for pending requests in throttle_group_unregister_bs() Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 27/40] throttle: Use bs->throttle_state instead of bs->io_limits_enabled Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 28/40] block: Disallow snapshots if the overlay doesn't support backing files Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 29/40] block: Remove inner quotation marks in iotest 085 Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 30/40] block: test 'blockdev-snapshot' using a file BDS as the overlay Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 31/40] qemu-io: fix cvtnum lval types Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 32/40] qemu-io: Check for trailing chars Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 33/40] qemu-io: Correct error messages Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 34/40] qemu-iotests: fix cleanup of background processes Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 35/40] qemu-iotests: fix -valgrind option for check Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 36/40] mirror: block all operations on the target image during the job Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 37/40] block: Add blk_get_refcnt() Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 38/40] block: Add 'x-blockdev-del' QMP command Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 39/40] iotests: Add tests for the x-blockdev-del command Kevin Wolf
2015-11-10 14:59 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-11-10 15:03 ` Kevin Wolf
2015-11-10 14:09 ` [Qemu-devel] [PULL v2 40/40] qcow2: Fix qcow2_get_cluster_offset() for zero clusters Kevin Wolf
2015-11-10 17:10 ` [Qemu-devel] [PULL v2 00/40] Block layer patches Peter Maydell
2015-11-11 15:35 ` Kevin Wolf
2015-11-11 16:38 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447164580-31094-16-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).