]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0034-vma-add-format-option-to-device-mapping.patch
fix backup jobs
[pve-qemu-kvm.git] / debian / patches / pve / 0034-vma-add-format-option-to-device-mapping.patch
CommitLineData
e9ee6d7c 1From 75cc381c5a486241e47900eab6b0e99de7f45665 Mon Sep 17 00:00:00 2001
62109fac
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Tue, 12 Apr 2016 13:49:44 +0200
9c3bec39 4Subject: [PATCH 34/47] vma: add format option to device mapping
62109fac
WB
5
6The BDRV_O_PROTOCOL option breaks non-raw protocol devices,
7so we instead now allow the format to be explicitly
8specified from the outside.
9
10In other words we now too deprecate the automatic guessing
11of raw formats, just like qemu already does, and have to
12silence the warnings by passing the drive mapping.
13---
14 vma.c | 34 +++++++++++++++++++++++++++-------
15 1 file changed, 27 insertions(+), 7 deletions(-)
16
17diff --git a/vma.c b/vma.c
1a91ab45 18index 4903568..f71e5a5 100644
62109fac
WB
19--- a/vma.c
20+++ b/vma.c
1a91ab45 21@@ -131,6 +131,7 @@ static int list_content(int argc, char **argv)
62109fac
WB
22 typedef struct RestoreMap {
23 char *devname;
24 char *path;
25+ char *format;
26 bool write_zero;
27 } RestoreMap;
28
1a91ab45 29@@ -218,13 +219,24 @@ static int extract_content(int argc, char **argv)
62109fac
WB
30 }
31 }
32
33+ char *format = NULL;
34+ if (strncmp(line, "format=", sizeof("format=")-1) == 0) {
35+ format = line + sizeof("format=")-1;
36+ char *colon = strchr(format, ':');
37+ if (!colon) {
38+ g_error("read map failed - found only a format ('%s')", inbuf);
39+ }
40+ format = g_strndup(format, colon - format);
41+ line = colon+1;
42+ }
43+
44 const char *path;
45 bool write_zero;
46 if (line[0] == '0' && line[1] == ':') {
47- path = inbuf + 2;
48+ path = line + 2;
49 write_zero = false;
50 } else if (line[0] == '1' && line[1] == ':') {
51- path = inbuf + 2;
52+ path = line + 2;
53 write_zero = true;
54 } else {
55 g_error("read map failed - parse error ('%s')", inbuf);
1a91ab45 56@@ -240,6 +252,7 @@ static int extract_content(int argc, char **argv)
62109fac
WB
57 RestoreMap *map = g_new0(RestoreMap, 1);
58 map->devname = g_strdup(devname);
59 map->path = g_strdup(path);
60+ map->format = format;
61 map->write_zero = write_zero;
62
63 g_hash_table_insert(devmap, map->devname, map);
1a91ab45 64@@ -264,6 +277,7 @@ static int extract_content(int argc, char **argv)
62109fac
WB
65 g_free(statefn);
66 } else if (di) {
67 char *devfn = NULL;
68+ const char *format = NULL;
68a30562 69 int flags = BDRV_O_RDWR;
62109fac
WB
70 bool write_zero = true;
71
1a91ab45 72@@ -274,6 +288,7 @@ static int extract_content(int argc, char **argv)
62109fac
WB
73 g_error("no device name mapping for %s", di->devname);
74 }
75 devfn = map->path;
76+ format = map->format;
77 write_zero = map->write_zero;
78 } else {
79 devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
1a91ab45 80@@ -296,15 +311,20 @@ static int extract_content(int argc, char **argv)
62109fac
WB
81 BlockDriverState *bs = bdrv_new();
82
83 size_t devlen = strlen(devfn);
84- bool protocol = path_has_protocol(devfn);
85 QDict *options = NULL;
86- if (devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0 && !protocol) {
87+ if (format) {
88+ /* explicit format from commandline */
89+ options = qdict_new();
90+ qdict_put(options, "driver", qstring_from_str(format));
91+ } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
92+ strncmp(devfn, "/dev/", 5) == 0)
93+ {
94+ /* This part is now deprecated for PVE as well (just as qemu
95+ * deprecated not specifying an explicit raw format, too.
96+ */
97 /* explicit raw format */
98 options = qdict_new();
99 qdict_put(options, "driver", qstring_from_str("raw"));
100- } else if (protocol) {
101- /* tell bdrv_open to honor the protocol */
102- flags |= BDRV_O_PROTOCOL;
103 }
104
105 if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) {
106--
1072.1.4
108