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