]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/pve/0034-vma-add-format-option-to-device-mapping.patch
4275a2ab0a530dbac9f59b632454cb92744c1fc8
[pve-qemu-kvm.git] / debian / patches / pve / 0034-vma-add-format-option-to-device-mapping.patch
1 From 87c344c964eac376a816b081acb6796893ce0992 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Tue, 12 Apr 2016 13:49:44 +0200
4 Subject: [PATCH 34/47] vma: add format option to device mapping
5
6 The BDRV_O_PROTOCOL option breaks non-raw protocol devices,
7 so we instead now allow the format to be explicitly
8 specified from the outside.
9
10 In other words we now too deprecate the automatic guessing
11 of raw formats, just like qemu already does, and have to
12 silence the warnings by passing the drive mapping.
13 ---
14 vma.c | 34 +++++++++++++++++++++++++++-------
15 1 file changed, 27 insertions(+), 7 deletions(-)
16
17 diff --git a/vma.c b/vma.c
18 index 4903568..f71e5a5 100644
19 --- a/vma.c
20 +++ b/vma.c
21 @@ -131,6 +131,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 @@ -218,13 +219,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 @@ -240,6 +252,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 @@ -264,6 +277,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;
70 bool write_zero = true;
71
72 @@ -274,6 +288,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 @@ -296,15 +311,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 --
107 2.1.4
108