]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0032-vma-better-driver-guessing-for-bdrv_open.patch
fix backup jobs
[pve-qemu-kvm.git] / debian / patches / pve / 0032-vma-better-driver-guessing-for-bdrv_open.patch
CommitLineData
e9ee6d7c 1From 34252ba5e295a4c1be59dc8e722a23d9c35e7d68 Mon Sep 17 00:00:00 2001
2c75dbed
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Tue, 23 Feb 2016 15:48:41 +0100
9c3bec39 4Subject: [PATCH 32/47] vma: better driver guessing for bdrv_open
2c75dbed
WB
5
6Only use 'raw' when the file actually ends with .raw and
7no protocol has been specified. With protocol pass the
8BDRV_O_PROTOCOL flag to tell bdrv_fill_options() to take it
9into account.
10---
68a30562
WB
11 vma.c | 15 ++++++++++++++-
12 1 file changed, 14 insertions(+), 1 deletion(-)
2c75dbed
WB
13
14diff --git a/vma.c b/vma.c
1a91ab45 15index c7c0538..4903568 100644
2c75dbed
WB
16--- a/vma.c
17+++ b/vma.c
1a91ab45 18@@ -294,7 +294,20 @@ static int extract_content(int argc, char **argv)
68a30562 19 }
2c75dbed
WB
20
21 BlockDriverState *bs = bdrv_new();
68a30562
WB
22- if (errp || bdrv_open(&bs, devfn, NULL, NULL, flags, &errp)) {
23+
2c75dbed
WB
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+ }
68a30562
WB
35+
36+ if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) {
2c75dbed 37 g_error("can't open file %s - %s", devfn,
68a30562
WB
38 error_get_pretty(errp));
39 }
2c75dbed
WB
40--
412.1.4
42