pve-qemu-qoup/debian/patches/pve/0031-vma-add-cache-option-to-device-map.patch
Wolfgang Bumiller e220dcddbc merge: vma & rbd changes
vma: remove forced NO_FLUSH option
rbd: fix cache mode behavior
vma: add cache option to device map

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-04-05 11:04:11 +02:00

104 lines
3.7 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] vma: add cache option to device map
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
vma.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/vma.c b/vma.c
index 71be120cfc..e0271060af 100644
--- a/vma.c
+++ b/vma.c
@@ -20,6 +20,7 @@
#include "qemu/main-loop.h"
#include "qemu/cutils.h"
#include "qapi/qmp/qstring.h"
+#include "qapi/qmp/qbool.h"
#include "sysemu/block-backend.h"
static void help(void)
@@ -135,6 +136,7 @@ typedef struct RestoreMap {
char *format;
uint64_t throttling_bps;
char *throttling_group;
+ char *cache;
bool write_zero;
} RestoreMap;
@@ -242,6 +244,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 +259,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 +297,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 +327,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 +341,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 +363,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 +378,19 @@ static int extract_content(int argc, char **argv)
options = qdict_new();
qdict_put(options, "driver", qstring_from_str("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