|
|
9ae3a8 |
From d106c599acad51da2d0eff0d3f87cff867d52f18 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Sep 2013 14:28:22 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 31/38] blockdev: Split up 'cache' option
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1378736903-18489-32-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54218
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 31/32] blockdev: Split up 'cache' option
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The old 'cache' option really encodes three different boolean flags into
|
|
|
9ae3a8 |
a cache mode name, without providing all combinations. Make them three
|
|
|
9ae3a8 |
separate options instead and translate the old option to the new ones
|
|
|
9ae3a8 |
for drive_init().
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The specific boolean options take precedence if the old cache option is
|
|
|
9ae3a8 |
specified as well, so the following options are equivalent:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-drive file=x,cache=none,cache.no-flush=true
|
|
|
9ae3a8 |
-drive file=x,cache.writeback=true,cache.direct=true,cache.no-flush=true
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 29c4e2b50d95f4a15c3dd62b39f3402f05a34907)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
|
|
|
9ae3a8 |
1 file changed, 47 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
|
|
|
9ae3a8 |
1 files changed, 47 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 5d4f2f8..8ffed03 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -452,12 +452,15 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bdrv_flags |= BDRV_O_CACHE_WB;
|
|
|
9ae3a8 |
- if ((buf = qemu_opt_get(opts, "cache")) != NULL) {
|
|
|
9ae3a8 |
- if (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) {
|
|
|
9ae3a8 |
- error_report("invalid cache option");
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ bdrv_flags = 0;
|
|
|
9ae3a8 |
+ if (qemu_opt_get_bool(opts, "cache.writeback", true)) {
|
|
|
9ae3a8 |
+ bdrv_flags |= BDRV_O_CACHE_WB;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (qemu_opt_get_bool(opts, "cache.direct", false)) {
|
|
|
9ae3a8 |
+ bdrv_flags |= BDRV_O_NOCACHE;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (qemu_opt_get_bool(opts, "cache.no-flush", true)) {
|
|
|
9ae3a8 |
+ bdrv_flags |= BDRV_O_NO_FLUSH;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#ifdef CONFIG_LINUX_AIO
|
|
|
9ae3a8 |
@@ -740,6 +743,8 @@ static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ const char *value;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* Change legacy command line options into QMP ones */
|
|
|
9ae3a8 |
qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
|
|
|
9ae3a8 |
qemu_opt_rename(all_opts, "iops_rd", "throttling.iops-read");
|
|
|
9ae3a8 |
@@ -751,6 +756,31 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu_opt_rename(all_opts, "readonly", "read-only");
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ value = qemu_opt_get(all_opts, "cache");
|
|
|
9ae3a8 |
+ if (value) {
|
|
|
9ae3a8 |
+ int flags = 0;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ if (bdrv_parse_cache_flags(value, &flags) != 0) {
|
|
|
9ae3a8 |
+ error_report("invalid cache option");
|
|
|
9ae3a8 |
+ return NULL;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Specific options take precedence */
|
|
|
9ae3a8 |
+ if (!qemu_opt_get(all_opts, "cache.writeback")) {
|
|
|
9ae3a8 |
+ qemu_opt_set_bool(all_opts, "cache.writeback",
|
|
|
9ae3a8 |
+ !!(flags & BDRV_O_CACHE_WB));
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!qemu_opt_get(all_opts, "cache.direct")) {
|
|
|
9ae3a8 |
+ qemu_opt_set_bool(all_opts, "cache.direct",
|
|
|
9ae3a8 |
+ !!(flags & BDRV_O_NOCACHE));
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!qemu_opt_get(all_opts, "cache.no-flush")) {
|
|
|
9ae3a8 |
+ qemu_opt_set_bool(all_opts, "cache.no-flush",
|
|
|
9ae3a8 |
+ !!(flags & BDRV_O_NO_FLUSH));
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ qemu_opt_unset(all_opts, "cache");
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
return blockdev_init(all_opts, block_default_type);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1674,10 +1704,17 @@ QemuOptsList qemu_common_drive_opts = {
|
|
|
9ae3a8 |
.type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
.help = "discard operation (ignore/off, unmap/on)",
|
|
|
9ae3a8 |
},{
|
|
|
9ae3a8 |
- .name = "cache",
|
|
|
9ae3a8 |
- .type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
- .help = "host cache usage (none, writeback, writethrough, "
|
|
|
9ae3a8 |
- "directsync, unsafe)",
|
|
|
9ae3a8 |
+ .name = "cache.writeback",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
+ .help = "enables writeback mode for any caches",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "cache.direct",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
+ .help = "enables use of O_DIRECT (bypass the host page cache)",
|
|
|
9ae3a8 |
+ },{
|
|
|
9ae3a8 |
+ .name = "cache.no-flush",
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
+ .help = "ignore any flush requests for the device",
|
|
|
9ae3a8 |
},{
|
|
|
9ae3a8 |
.name = "aio",
|
|
|
9ae3a8 |
.type = QEMU_OPT_STRING,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|