[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBa
From: |
Wen Congyang |
Subject: |
[Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBackend |
Date: |
Thu, 12 Feb 2015 11:07:13 +0800 |
Signed-off-by: Wen Congyang <address@hidden>
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
block.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 2335af1..a7a8932 100644
--- a/block.c
+++ b/block.c
@@ -1218,6 +1218,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*options, Error **errp)
{
char *backing_filename = g_malloc0(PATH_MAX);
int ret = 0;
+ BlockBackend *backing_blk;
BlockDriverState *backing_hd;
Error *local_err = NULL;
@@ -1255,7 +1256,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*options, Error **errp)
goto free_exit;
}
- backing_hd = bdrv_new();
+ backing_blk = blk_hide_new_with_bs();
+ backing_hd = blk_bs(backing_blk);
if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) {
qdict_put(options, "driver", qstring_from_str(bs->backing_format));
@@ -1266,7 +1268,8 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict
*options, Error **errp)
*backing_filename ? backing_filename : NULL, NULL, options,
bdrv_backing_flags(bs->open_flags), NULL, &local_err);
if (ret < 0) {
- bdrv_unref(backing_hd);
+ blk_unref(backing_blk);
+ backing_blk = NULL;
backing_hd = NULL;
bs->open_flags |= BDRV_O_NO_BACKING;
error_setg(errp, "Could not open backing file: %s",
@@ -1870,9 +1873,9 @@ void bdrv_close(BlockDriverState *bs)
if (bs->drv) {
if (bs->backing_hd) {
- BlockDriverState *backing_hd = bs->backing_hd;
+ BlockBackend *backing_blk = bs->backing_hd->blk;
bdrv_set_backing_hd(bs, NULL);
- bdrv_unref(backing_hd);
+ blk_unref(backing_blk);
}
bs->drv->bdrv_close(bs);
g_free(bs->opaque);
--
2.1.0
- [Qemu-devel] [RFC PATCH 03/14] quorum: ignore 0-length child, (continued)
[Qemu-devel] [RFC PATCH 09/14] block: give backing image its own BlockBackend,
Wen Congyang <=
[Qemu-devel] [RFC PATCH 07/14] NBD client: implement block driver interfaces for block replication, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 10/14] allow the backing image access the origin BlockDriverState, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 11/14] allow writing to the backing file, Wen Congyang, 2015/02/11
[Qemu-devel] [RFC PATCH 13/14] COW: move cow interfaces to a seperate file, Wen Congyang, 2015/02/11