43 lines
1.4 KiB
Diff
43 lines
1.4 KiB
Diff
From 81e295744d016824a5c756bfc954c63f5a249b5f Mon Sep 17 00:00:00 2001
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
Date: Tue, 23 Feb 2016 15:48:41 +0100
|
|
Subject: [PATCH 32/49] vma: better driver guessing for bdrv_open
|
|
|
|
Only use 'raw' when the file actually ends with .raw and
|
|
no protocol has been specified. With protocol pass the
|
|
BDRV_O_PROTOCOL flag to tell bdrv_fill_options() to take it
|
|
into account.
|
|
---
|
|
vma.c | 15 ++++++++++++++-
|
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/vma.c b/vma.c
|
|
index c7c05385f6..4903568fb4 100644
|
|
--- a/vma.c
|
|
+++ b/vma.c
|
|
@@ -294,7 +294,20 @@ static int extract_content(int argc, char **argv)
|
|
}
|
|
|
|
BlockDriverState *bs = bdrv_new();
|
|
- if (errp || bdrv_open(&bs, devfn, NULL, NULL, flags, &errp)) {
|
|
+
|
|
+ size_t devlen = strlen(devfn);
|
|
+ bool protocol = path_has_protocol(devfn);
|
|
+ QDict *options = NULL;
|
|
+ if (devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0 && !protocol) {
|
|
+ /* 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)) {
|
|
g_error("can't open file %s - %s", devfn,
|
|
error_get_pretty(errp));
|
|
}
|
|
--
|
|
2.11.0
|
|
|