]>
Commit | Line | Data |
---|---|---|
076b4026 | 1 | From 7ebfbb540393217a1304b7d128f463e80c74702f Mon Sep 17 00:00:00 2001 |
95259824 WB |
2 | From: Thomas Lamprecht <t.lamprecht@proxmox.com> |
3 | Date: Fri, 1 Jul 2016 15:47:29 +0200 | |
45169293 | 4 | Subject: [PATCH 37/49] vma: use BlockBackend on extract |
95259824 WB |
5 | |
6 | As we else rely on bdrv_close_all() do clean up, which was rewritten | |
7 | in ca9bd24cf1d53775169ba9adc17e265554d1afed and fails on "dangling" | |
8 | BDS pointers, such a pointer exists with *bs. | |
9 | Use the BlockBackend to get our BDS and just unref the BlockBackend | |
10 | when done, it handles the rest for us. | |
11 | ||
12 | The other two calls to bdrv_close_all() happen in verify_content() | |
13 | and dump_config(), both do not have a BDS so no need to change here. | |
14 | --- | |
15 | vma.c | 13 ++++++++++--- | |
16 | 1 file changed, 10 insertions(+), 3 deletions(-) | |
17 | ||
18 | diff --git a/vma.c b/vma.c | |
45169293 | 19 | index f71e5a5933..ad51090651 100644 |
95259824 WB |
20 | --- a/vma.c |
21 | +++ b/vma.c | |
a544966d | 22 | @@ -20,6 +20,7 @@ |
95259824 | 23 | #include "qemu/main-loop.h" |
a544966d | 24 | #include "qapi/qmp/qstring.h" |
95259824 WB |
25 | #include "sysemu/char.h" /* qstring_from_str */ |
26 | +#include "sysemu/block-backend.h" | |
27 | ||
28 | static void help(void) | |
29 | { | |
a544966d | 30 | @@ -264,6 +265,8 @@ static int extract_content(int argc, char **argv) |
95259824 WB |
31 | int vmstate_fd = -1; |
32 | guint8 vmstate_stream = 0; | |
33 | ||
34 | + BlockBackend *blk = NULL; | |
35 | + | |
36 | for (i = 1; i < 255; i++) { | |
37 | VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i); | |
38 | if (di && (strcmp(di->devname, "vmstate") == 0)) { | |
a544966d | 39 | @@ -308,8 +311,6 @@ static int extract_content(int argc, char **argv) |
95259824 WB |
40 | write_zero = false; |
41 | } | |
42 | ||
43 | - BlockDriverState *bs = bdrv_new(); | |
44 | - | |
45 | size_t devlen = strlen(devfn); | |
46 | QDict *options = NULL; | |
47 | if (format) { | |
a544966d | 48 | @@ -327,10 +328,14 @@ static int extract_content(int argc, char **argv) |
95259824 WB |
49 | qdict_put(options, "driver", qstring_from_str("raw")); |
50 | } | |
51 | ||
52 | - if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) { | |
53 | + | |
54 | + if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) { | |
55 | g_error("can't open file %s - %s", devfn, | |
56 | error_get_pretty(errp)); | |
57 | } | |
58 | + | |
59 | + BlockDriverState *bs = blk_bs(blk); | |
60 | + | |
61 | if (vma_reader_register_bs(vmar, i, bs, write_zero, &errp) < 0) { | |
62 | g_error("%s", error_get_pretty(errp)); | |
63 | } | |
a544966d | 64 | @@ -363,6 +368,8 @@ static int extract_content(int argc, char **argv) |
95259824 WB |
65 | |
66 | vma_reader_destroy(vmar); | |
67 | ||
68 | + blk_unref(blk); | |
69 | + | |
70 | bdrv_close_all(); | |
71 | ||
72 | return ret; | |
73 | -- | |
45169293 | 74 | 2.11.0 |
95259824 | 75 |