]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0045-vma-add-format-option-to-device-mapping.patch
bump version to 2.6.2-2
[pve-qemu-kvm.git] / debian / patches / pve / 0045-vma-add-format-option-to-device-mapping.patch
CommitLineData
6fb04df7 1From 52002e4bb7572662d937de2c20b2110309095f29 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
6fb04df7 4Subject: [PATCH 45/55] 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
18index 1c4103f..46ae14b 100644
19--- a/vma.c
20+++ b/vma.c
21@@ -137,6 +137,7 @@ static int list_content(int argc, char **argv)
22 typedef struct RestoreMap {
23 char *devname;
24 char *path;
25+ char *format;
26 bool write_zero;
27 } RestoreMap;
28
29@@ -224,13 +225,24 @@ static int extract_content(int argc, char **argv)
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);
56@@ -246,6 +258,7 @@ static int extract_content(int argc, char **argv)
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);
64@@ -270,6 +283,7 @@ static int extract_content(int argc, char **argv)
65 g_free(statefn);
66 } else if (di) {
67 char *devfn = NULL;
68+ const char *format = NULL;
69 int flags = BDRV_O_RDWR|BDRV_O_CACHE_WB;
70 bool write_zero = true;
71
72@@ -280,6 +294,7 @@ static int extract_content(int argc, char **argv)
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",
80@@ -302,15 +317,20 @@ static int extract_content(int argc, char **argv)
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