+++ /dev/null
-From a61194439318c95dfcb7df973ac961c12937dbcd Mon Sep 17 00:00:00 2001
-From: Wolfgang Bumiller <w.bumiller@proxmox.com>
-Date: Tue, 12 Apr 2016 13:49:44 +0200
-Subject: [PATCH 34/48] vma: add format option to device mapping
-
-The BDRV_O_PROTOCOL option breaks non-raw protocol devices,
-so we instead now allow the format to be explicitly
-specified from the outside.
-
-In other words we now too deprecate the automatic guessing
-of raw formats, just like qemu already does, and have to
-silence the warnings by passing the drive mapping.
----
- vma.c | 34 +++++++++++++++++++++++++++-------
- 1 file changed, 27 insertions(+), 7 deletions(-)
-
-diff --git a/vma.c b/vma.c
-index 4903568..f71e5a5 100644
---- a/vma.c
-+++ b/vma.c
-@@ -131,6 +131,7 @@ static int list_content(int argc, char **argv)
- typedef struct RestoreMap {
- char *devname;
- char *path;
-+ char *format;
- bool write_zero;
- } RestoreMap;
-
-@@ -218,13 +219,24 @@ static int extract_content(int argc, char **argv)
- }
- }
-
-+ char *format = NULL;
-+ if (strncmp(line, "format=", sizeof("format=")-1) == 0) {
-+ format = line + sizeof("format=")-1;
-+ char *colon = strchr(format, ':');
-+ if (!colon) {
-+ g_error("read map failed - found only a format ('%s')", inbuf);
-+ }
-+ format = g_strndup(format, colon - format);
-+ line = colon+1;
-+ }
-+
- const char *path;
- bool write_zero;
- if (line[0] == '0' && line[1] == ':') {
-- path = inbuf + 2;
-+ path = line + 2;
- write_zero = false;
- } else if (line[0] == '1' && line[1] == ':') {
-- path = inbuf + 2;
-+ path = line + 2;
- write_zero = true;
- } else {
- g_error("read map failed - parse error ('%s')", inbuf);
-@@ -240,6 +252,7 @@ static int extract_content(int argc, char **argv)
- RestoreMap *map = g_new0(RestoreMap, 1);
- map->devname = g_strdup(devname);
- map->path = g_strdup(path);
-+ map->format = format;
- map->write_zero = write_zero;
-
- g_hash_table_insert(devmap, map->devname, map);
-@@ -264,6 +277,7 @@ static int extract_content(int argc, char **argv)
- g_free(statefn);
- } else if (di) {
- char *devfn = NULL;
-+ const char *format = NULL;
- int flags = BDRV_O_RDWR;
- bool write_zero = true;
-
-@@ -274,6 +288,7 @@ static int extract_content(int argc, char **argv)
- g_error("no device name mapping for %s", di->devname);
- }
- devfn = map->path;
-+ format = map->format;
- write_zero = map->write_zero;
- } else {
- devfn = g_strdup_printf("%s/tmp-disk-%s.raw",
-@@ -296,15 +311,20 @@ static int extract_content(int argc, char **argv)
- BlockDriverState *bs = bdrv_new();
-
- size_t devlen = strlen(devfn);
-- bool protocol = path_has_protocol(devfn);
- QDict *options = NULL;
-- if (devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0 && !protocol) {
-+ if (format) {
-+ /* explicit format from commandline */
-+ options = qdict_new();
-+ qdict_put(options, "driver", qstring_from_str(format));
-+ } else if ((devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0) ||
-+ strncmp(devfn, "/dev/", 5) == 0)
-+ {
-+ /* This part is now deprecated for PVE as well (just as qemu
-+ * deprecated not specifying an explicit raw format, too.
-+ */
- /* explicit raw format */
- options = qdict_new();
- qdict_put(options, "driver", qstring_from_str("raw"));
-- } else if (protocol) {
-- /* tell bdrv_open to honor the protocol */
-- flags |= BDRV_O_PROTOCOL;
- }
-
- if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) {
---
-2.1.4
-