[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 16/18] qemu-io: Allow reopen read-write
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 16/18] qemu-io: Allow reopen read-write |
Date: |
Tue, 8 Aug 2017 15:58:36 +0200 |
This allows qemu-iotests to test the switch between read-only and
read-write mode for block devices.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: John Snow <address@hidden>
---
qemu-io-cmds.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index 3eb42c6728..2811a89099 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1920,6 +1920,7 @@ static void reopen_help(void)
" 'reopen -o lazy-refcounts=on' - activates lazy refcount writeback on a qcow2
image\n"
"\n"
" -r, -- Reopen the image read-only\n"
+" -w, -- Reopen the image read-write\n"
" -c, -- Change the cache mode to the given value\n"
" -o, -- Changes block driver options (cf. 'open' command)\n"
"\n");
@@ -1942,7 +1943,7 @@ static const cmdinfo_t reopen_cmd = {
.argmin = 0,
.argmax = -1,
.cfunc = reopen_f,
- .args = "[-r] [-c cache] [-o options]",
+ .args = "[(-r|-w)] [-c cache] [-o options]",
.oneline = "reopens an image with new options",
.help = reopen_help,
};
@@ -1955,11 +1956,12 @@ static int reopen_f(BlockBackend *blk, int argc, char
**argv)
int c;
int flags = bs->open_flags;
bool writethrough = !blk_enable_write_cache(blk);
+ bool has_rw_option = false;
BlockReopenQueue *brq;
Error *local_err = NULL;
- while ((c = getopt(argc, argv, "c:o:r")) != -1) {
+ while ((c = getopt(argc, argv, "c:o:rw")) != -1) {
switch (c) {
case 'c':
if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
@@ -1974,7 +1976,20 @@ static int reopen_f(BlockBackend *blk, int argc, char
**argv)
}
break;
case 'r':
+ if (has_rw_option) {
+ error_report("Only one -r/-w option may be given");
+ return 0;
+ }
flags &= ~BDRV_O_RDWR;
+ has_rw_option = true;
+ break;
+ case 'w':
+ if (has_rw_option) {
+ error_report("Only one -r/-w option may be given");
+ return 0;
+ }
+ flags |= BDRV_O_RDWR;
+ has_rw_option = true;
break;
default:
qemu_opts_reset(&reopen_opts);
--
2.13.4
- [Qemu-block] [PULL 03/18] block/vhdx: check error return of bdrv_getlength(), (continued)
- [Qemu-block] [PULL 03/18] block/vhdx: check error return of bdrv_getlength(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 04/18] block/vhdx: check for offset overflow to bdrv_truncate(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 08/18] block/null: Remove 'filename' option, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 09/18] vmdk: Fix error handling/reporting of vmdk_check, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 07/18] block: drop bdrv_set_key from BlockDriver, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 10/18] block: respect error code from bdrv_getlength in handle_aiocb_write_zeroes, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 11/18] parallels: respect error code of bdrv_getlength() in allocate_clusters(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 12/18] parallels: drop check that bdrv_truncate() is working, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 13/18] block: Fix order in bdrv_replace_child(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 14/18] block: Allow reopen rw without BDRV_O_ALLOW_RDWR, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 16/18] qemu-io: Allow reopen read-write,
Kevin Wolf <=
- [Qemu-block] [PULL 15/18] block: Set BDRV_O_ALLOW_RDWR during rw reopen, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 18/18] block/nfs: fix mutex assertion in nfs_file_close(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 17/18] qemu-iotests: Test reopen between read-only and read-write, Kevin Wolf, 2017/08/08
- Re: [Qemu-block] [PULL 00/18] Block layer patches for 2.10.0-rc2, Peter Maydell, 2017/08/08