]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0023-PVE-vma-add-cache-option-to-device-map.patch
update sources for v4.0.1
[pve-qemu.git] / debian / patches / pve / 0023-PVE-vma-add-cache-option-to-device-map.patch
CommitLineData
e220dcdd
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Thu, 22 Mar 2018 15:32:04 +0100
53e83913 4Subject: [PATCH] PVE: vma: add cache option to device map
e220dcdd
WB
5
6Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
b855dce7 7Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
e220dcdd 8---
53e83913
WB
9 vma.c | 16 +++++++++++++++-
10 1 file changed, 15 insertions(+), 1 deletion(-)
e220dcdd
WB
11
12diff --git a/vma.c b/vma.c
53e83913 13index f9f5c308fe..476b7bee00 100644
e220dcdd
WB
14--- a/vma.c
15+++ b/vma.c
53e83913 16@@ -135,6 +135,7 @@ typedef struct RestoreMap {
e220dcdd
WB
17 char *format;
18 uint64_t throttling_bps;
19 char *throttling_group;
20+ char *cache;
21 bool write_zero;
22 } RestoreMap;
23
53e83913 24@@ -242,6 +243,7 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
25 char *format = NULL;
26 char *bps = NULL;
27 char *group = NULL;
28+ char *cache = NULL;
29 if (!line || line[0] == '\0' || !strcmp(line, "done\n")) {
30 break;
31 }
53e83913 32@@ -256,7 +258,8 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
33 while (1) {
34 if (!try_parse_option(&line, "format", &format, inbuf) &&
35 !try_parse_option(&line, "throttling.bps", &bps, inbuf) &&
36- !try_parse_option(&line, "throttling.group", &group, inbuf))
37+ !try_parse_option(&line, "throttling.group", &group, inbuf) &&
38+ !try_parse_option(&line, "cache", &cache, inbuf))
39 {
40 break;
41 }
53e83913 42@@ -293,6 +296,7 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
43 map->format = format;
44 map->throttling_bps = bps_value;
45 map->throttling_group = group;
46+ map->cache = cache;
47 map->write_zero = write_zero;
48
49 g_hash_table_insert(devmap, map->devname, map);
53e83913 50@@ -322,6 +326,7 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
51 const char *format = NULL;
52 uint64_t throttling_bps = 0;
53 const char *throttling_group = NULL;
54+ const char *cache = NULL;
55 int flags = BDRV_O_RDWR | BDRV_O_NO_FLUSH;
56 bool write_zero = true;
57
53e83913 58@@ -335,6 +340,7 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
59 format = map->format;
60 throttling_bps = map->throttling_bps;
61 throttling_group = map->throttling_group;
62+ cache = map->cache;
63 write_zero = map->write_zero;
64 } else {
65 devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
53e83913 66@@ -356,6 +362,7 @@ static int extract_content(int argc, char **argv)
e220dcdd
WB
67
68 size_t devlen = strlen(devfn);
69 QDict *options = NULL;
70+ bool writethrough;
71 if (format) {
72 /* explicit format from commandline */
73 options = qdict_new();
53e83913 74@@ -370,12 +377,19 @@ static int extract_content(int argc, char **argv)
e220dcdd 75 options = qdict_new();
53e83913 76 qdict_put_str(options, "driver", "raw");
e220dcdd
WB
77 }
78+ if (cache && bdrv_parse_cache_mode(cache, &flags, &writethrough)) {
79+ g_error("invalid cache option: %s\n", cache);
80+ }
81
82 if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
83 g_error("can't open file %s - %s", devfn,
84 error_get_pretty(errp));
85 }
86
87+ if (cache) {
88+ blk_set_enable_write_cache(blk, !writethrough);
89+ }
90+
91 if (throttling_group) {
92 blk_io_limits_enable(blk, throttling_group);
93 }