76 lines
2.3 KiB
Diff
76 lines
2.3 KiB
Diff
From 0d4b69786584eec1386183b259c22f7cae6df69d Mon Sep 17 00:00:00 2001
|
|
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
Date: Fri, 1 Jul 2016 15:47:29 +0200
|
|
Subject: [PATCH 37/47] vma: use BlockBackend on extract
|
|
|
|
As we else rely on bdrv_close_all() do clean up, which was rewritten
|
|
in ca9bd24cf1d53775169ba9adc17e265554d1afed and fails on "dangling"
|
|
BDS pointers, such a pointer exists with *bs.
|
|
Use the BlockBackend to get our BDS and just unref the BlockBackend
|
|
when done, it handles the rest for us.
|
|
|
|
The other two calls to bdrv_close_all() happen in verify_content()
|
|
and dump_config(), both do not have a BDS so no need to change here.
|
|
---
|
|
vma.c | 13 ++++++++++---
|
|
1 file changed, 10 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/vma.c b/vma.c
|
|
index c8ad6c0..a2ddd32 100644
|
|
--- a/vma.c
|
|
+++ b/vma.c
|
|
@@ -19,6 +19,7 @@
|
|
#include "qemu/error-report.h"
|
|
#include "qemu/main-loop.h"
|
|
#include "sysemu/char.h" /* qstring_from_str */
|
|
+#include "sysemu/block-backend.h"
|
|
|
|
static void help(void)
|
|
{
|
|
@@ -263,6 +264,8 @@ static int extract_content(int argc, char **argv)
|
|
int vmstate_fd = -1;
|
|
guint8 vmstate_stream = 0;
|
|
|
|
+ BlockBackend *blk = NULL;
|
|
+
|
|
for (i = 1; i < 255; i++) {
|
|
VmaDeviceInfo *di = vma_reader_get_device_info(vmar, i);
|
|
if (di && (strcmp(di->devname, "vmstate") == 0)) {
|
|
@@ -307,8 +310,6 @@ static int extract_content(int argc, char **argv)
|
|
write_zero = false;
|
|
}
|
|
|
|
- BlockDriverState *bs = bdrv_new();
|
|
-
|
|
size_t devlen = strlen(devfn);
|
|
QDict *options = NULL;
|
|
if (format) {
|
|
@@ -326,10 +327,14 @@ static int extract_content(int argc, char **argv)
|
|
qdict_put(options, "driver", qstring_from_str("raw"));
|
|
}
|
|
|
|
- if (errp || bdrv_open(&bs, devfn, NULL, options, flags, &errp)) {
|
|
+
|
|
+ if (errp || !(blk = blk_new_open(devfn, NULL, options, flags, &errp))) {
|
|
g_error("can't open file %s - %s", devfn,
|
|
error_get_pretty(errp));
|
|
}
|
|
+
|
|
+ BlockDriverState *bs = blk_bs(blk);
|
|
+
|
|
if (vma_reader_register_bs(vmar, i, bs, write_zero, &errp) < 0) {
|
|
g_error("%s", error_get_pretty(errp));
|
|
}
|
|
@@ -362,6 +367,8 @@ static int extract_content(int argc, char **argv)
|
|
|
|
vma_reader_destroy(vmar);
|
|
|
|
+ blk_unref(blk);
|
|
+
|
|
bdrv_close_all();
|
|
|
|
return ret;
|
|
--
|
|
2.1.4
|
|
|