]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0023-PVE-vma-add-cache-option-to-device-map.patch
update patches for v4.0.0
[pve-qemu.git] / debian / patches / pve / 0023-PVE-vma-add-cache-option-to-device-map.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Thu, 22 Mar 2018 15:32:04 +0100
4 Subject: [PATCH] PVE: vma: add cache option to device map
5
6 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
7 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 ---
9 vma.c | 16 +++++++++++++++-
10 1 file changed, 15 insertions(+), 1 deletion(-)
11
12 diff --git a/vma.c b/vma.c
13 index f9f5c308fe..476b7bee00 100644
14 --- a/vma.c
15 +++ b/vma.c
16 @@ -135,6 +135,7 @@ typedef struct RestoreMap {
17 char *format;
18 uint64_t throttling_bps;
19 char *throttling_group;
20 + char *cache;
21 bool write_zero;
22 } RestoreMap;
23
24 @@ -242,6 +243,7 @@ static int extract_content(int argc, char **argv)
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 }
32 @@ -256,7 +258,8 @@ static int extract_content(int argc, char **argv)
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 }
42 @@ -293,6 +296,7 @@ static int extract_content(int argc, char **argv)
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);
50 @@ -322,6 +326,7 @@ static int extract_content(int argc, char **argv)
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
58 @@ -335,6 +340,7 @@ static int extract_content(int argc, char **argv)
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",
66 @@ -356,6 +362,7 @@ static int extract_content(int argc, char **argv)
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();
74 @@ -370,12 +377,19 @@ static int extract_content(int argc, char **argv)
75 options = qdict_new();
76 qdict_put_str(options, "driver", "raw");
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 }
94 --
95 2.20.1
96