[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/48] qemu-io: Call blk_set_enable_write_cache() exp
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 27/48] qemu-io: Call blk_set_enable_write_cache() explicitly |
Date: |
Tue, 29 Mar 2016 17:08:27 +0200 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
qemu-io.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/qemu-io.c b/qemu-io.c
index 1bd1158..21492d0 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -50,7 +50,7 @@ static const cmdinfo_t close_cmd = {
.oneline = "close the current open file",
};
-static int openfile(char *name, int flags, QDict *opts)
+static int openfile(char *name, int flags, bool writethrough, QDict *opts)
{
Error *local_err = NULL;
BlockDriverState *bs;
@@ -82,6 +82,7 @@ static int openfile(char *name, int flags, QDict *opts)
}
}
+ blk_set_enable_write_cache(qemuio_blk, !writethrough);
return 0;
@@ -136,6 +137,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
{
int flags = 0;
int readonly = 0;
+ bool writethrough = true;
int c;
QemuOpts *qopts;
QDict *opts;
@@ -146,7 +148,8 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
flags |= BDRV_O_SNAPSHOT;
break;
case 'n':
- flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
+ flags |= BDRV_O_NOCACHE;
+ writethrough = false;
break;
case 'r':
readonly = 1;
@@ -184,9 +187,9 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
qemu_opts_reset(&empty_opts);
if (optind == argc - 1) {
- return openfile(argv[optind], flags, opts);
+ return openfile(argv[optind], flags, writethrough, opts);
} else if (optind == argc) {
- return openfile(NULL, flags, opts);
+ return openfile(NULL, flags, writethrough, opts);
} else {
QDECREF(opts);
return qemuio_command_usage(&open_cmd);
@@ -427,6 +430,7 @@ int main(int argc, char **argv)
int c;
int opt_index = 0;
int flags = BDRV_O_UNMAP;
+ bool writethrough = true;
Error *local_error = NULL;
QDict *opts = NULL;
const char *format = NULL;
@@ -448,7 +452,8 @@ int main(int argc, char **argv)
flags |= BDRV_O_SNAPSHOT;
break;
case 'n':
- flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
+ flags |= BDRV_O_NOCACHE;
+ writethrough = false;
break;
case 'd':
if (bdrv_parse_discard_flags(optarg, &flags) < 0) {
@@ -472,7 +477,7 @@ int main(int argc, char **argv)
flags |= BDRV_O_NATIVE_AIO;
break;
case 't':
- if (bdrv_parse_cache_flags(optarg, &flags) < 0) {
+ if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
error_report("Invalid cache option: %s", optarg);
exit(1);
}
@@ -554,13 +559,13 @@ int main(int argc, char **argv)
exit(1);
}
opts = qemu_opts_to_qdict(qopts, NULL);
- openfile(NULL, flags, opts);
+ openfile(NULL, flags, writethrough, opts);
} else {
if (format) {
opts = qdict_new();
qdict_put(opts, "driver", qstring_from_str(format));
}
- openfile(argv[optind], flags, opts);
+ openfile(argv[optind], flags, writethrough, opts);
}
}
command_loop();
--
1.8.3.1
- [Qemu-devel] [PULL 17/48] tests: add output filter to python I/O tests helper, (continued)
- [Qemu-devel] [PULL 17/48] tests: add output filter to python I/O tests helper, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 18/48] block: add generic full disk encryption driver, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 23/48] replay: fix error message, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 19/48] block: move encryption deprecation warning into qcow code, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 21/48] block: add flush callback, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 25/48] block: Add bdrv_parse_cache_mode(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 22/48] replay: bh scheduling fix, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 26/48] qemu-nbd: Call blk_set_enable_write_cache() explicitly, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 28/48] qemu-img: Expand all BDRV_O_FLAGS uses, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 29/48] qemu-img: Call blk_set_enable_write_cache() explicitly, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 27/48] qemu-io: Call blk_set_enable_write_cache() explicitly,
Kevin Wolf <=
- [Qemu-devel] [PULL 24/48] replay: introduce block devices record/replay, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 30/48] xen_disk: Call blk_set_enable_write_cache() explicitly, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 33/48] block: Handle flush error in bdrv_pwrite_sync(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 31/48] block: blockdev_init(): Call blk_set_enable_write_cache() explicitly, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 34/48] block: Move enable_write_cache to BB level, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 37/48] iscsi: Support BDRV_REQ_FUA, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 32/48] block: Always set writeback mode in blk_new_open(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 39/48] raw: Support BDRV_REQ_FUA, Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 36/48] block: Introduce bdrv_co_writev_flags(), Kevin Wolf, 2016/03/29
- [Qemu-devel] [PULL 35/48] block/qapi: Use blk_enable_write_cache(), Kevin Wolf, 2016/03/29