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