]>
Commit | Line | Data |
---|---|---|
f185a969 | 1 | From 81e295744d016824a5c756bfc954c63f5a249b5f Mon Sep 17 00:00:00 2001 |
95259824 WB |
2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> |
3 | Date: Tue, 23 Feb 2016 15:48:41 +0100 | |
45169293 | 4 | Subject: [PATCH 32/49] vma: better driver guessing for bdrv_open |
95259824 WB |
5 | |
6 | Only use 'raw' when the file actually ends with .raw and | |
7 | no protocol has been specified. With protocol pass the | |
8 | BDRV_O_PROTOCOL flag to tell bdrv_fill_options() to take it | |
9 | into account. | |
10 | --- | |
11 | vma.c | 15 ++++++++++++++- | |
12 | 1 file changed, 14 insertions(+), 1 deletion(-) | |
13 | ||
14 | diff --git a/vma.c b/vma.c | |
45169293 | 15 | index c7c05385f6..4903568fb4 100644 |
95259824 WB |
16 | --- a/vma.c |
17 | +++ b/vma.c | |
a544966d | 18 | @@ -294,7 +294,20 @@ static int extract_content(int argc, char **argv) |
95259824 WB |
19 | } |
20 | ||
21 | BlockDriverState *bs = bdrv_new(); | |
22 | - if (errp || bdrv_open(&bs, devfn, NULL, NULL, flags, &errp)) { | |
23 | + | |
24 | + size_t devlen = strlen(devfn); | |
25 | + bool protocol = path_has_protocol(devfn); | |
26 | + QDict *options = NULL; | |
27 | + if (devlen > 4 && strcmp(devfn+devlen-4, ".raw") == 0 && !protocol) { | |
28 | + /* explicit raw format */ | |
29 | + options = qdict_new(); | |
30 | + qdict_put(options, "driver", qstring_from_str("raw")); | |
31 | + } else if (protocol) { | |
32 | + /* tell bdrv_open to honor the protocol */ | |
33 | + flags |= BDRV_O_PROTOCOL; | |
34 | + } | |
35 | + | |
36 | + if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) { | |
37 | g_error("can't open file %s - %s", devfn, | |
38 | error_get_pretty(errp)); | |
39 | } | |
40 | -- | |
45169293 | 41 | 2.11.0 |
95259824 | 42 |