pve-qemu/debian/patches/pve/0027-PVE-vma-add-cache-opti...

96 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
Date: Thu, 22 Mar 2018 15:32:04 +0100
Subject: [PATCH] PVE: vma: add cache option to device map
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
vma.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/vma.c b/vma.c
index f9f5c308fe..476b7bee00 100644
--- a/vma.c
+++ b/vma.c
@@ -135,6 +135,7 @@ typedef struct RestoreMap {
char *format;
uint64_t throttling_bps;
char *throttling_group;
+ char *cache;
bool write_zero;
} RestoreMap;
@@ -242,6 +243,7 @@ static int extract_content(int argc, char **argv)
char *format = NULL;
char *bps = NULL;
char *group = NULL;
+ char *cache = NULL;
if (!line || line[0] == '\0' || !strcmp(line, "done\n")) {
break;
}
@@ -256,7 +258,8 @@ static int extract_content(int argc, char **argv)
while (1) {
if (!try_parse_option(&line, "format", &format, inbuf) &&
!try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
- !try_parse_option(&line, "throttling.group", &group, inbuf))
+ !try_parse_option(&line, "throttling.group", &group, inbuf) &&
+ !try_parse_option(&line, "cache", &cache, inbuf))
{
break;
}
@@ -293,6 +296,7 @@ static int extract_content(int argc, char **argv)
map->format = format;
map->throttling_bps = bps_value;
map->throttling_group = group;
+ map->cache = cache;
map->write_zero = write_zero;
g_hash_table_insert(devmap, map->devname, map);
@@ -322,6 +326,7 @@ static int extract_content(int argc, char **argv)
const char *format = NULL;
uint64_t throttling_bps = 0;
const char *throttling_group = NULL;
+ const char *cache = NULL;
int flags = BDRV_O_RDWR | BDRV_O_NO_FLUSH;
bool write_zero = true;
@@ -335,6 +340,7 @@ static int extract_content(int argc, char **argv)
format = map->format;
throttling_bps = map->throttling_bps;
throttling_group = map->throttling_group;
+ cache = map->cache;
write_zero = map->write_zero;
} else {
devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
@@ -356,6 +362,7 @@ static int extract_content(int argc, char **argv)
size_t devlen = strlen(devfn);
QDict *options = NULL;
+ bool writethrough;
if (format) {
/* explicit format from commandline */
options = qdict_new();
@@ -370,12 +377,19 @@ static int extract_content(int argc, char **argv)
options = qdict_new();
qdict_put_str(options, "driver", "raw");
}
+ if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
+ g_error("invalid cache option: %s\n", cache);
+ }
if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
g_error("can't open file %s - %s", devfn,
error_get_pretty(errp));
}
+ if (cache) {
+ blk_set_enable_write_cache(blk, !writethrough);
+ }
+
if (throttling_group) {
blk_io_limits_enable(blk, throttling_group);
}
--
2.11.0