[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 39/46] block stream: close unused files and update -
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 39/46] block stream: close unused files and update ->backing_hd |
Date: |
Thu, 5 Apr 2012 17:52:17 +0200 |
From: Marcelo Tosatti <address@hidden>
Close the now unused images that were part of the previous backing file
chain and adjust ->backing_hd, backing_filename and backing_format
properly.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=801449
Signed-off-by: Marcelo Tosatti <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/stream.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/block/stream.c b/block/stream.c
index 61ff7a2..0efe1ad 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -76,6 +76,39 @@ static int coroutine_fn stream_populate(BlockDriverState *bs,
return bdrv_co_copy_on_readv(bs, sector_num, nb_sectors, &qiov);
}
+static void close_unused_images(BlockDriverState *top, BlockDriverState *base,
+ const char *base_id)
+{
+ BlockDriverState *intermediate;
+ intermediate = top->backing_hd;
+
+ while (intermediate) {
+ BlockDriverState *unused;
+
+ /* reached base */
+ if (intermediate == base) {
+ break;
+ }
+
+ unused = intermediate;
+ intermediate = intermediate->backing_hd;
+ unused->backing_hd = NULL;
+ bdrv_delete(unused);
+ }
+ top->backing_hd = base;
+
+ pstrcpy(top->backing_file, sizeof(top->backing_file), "");
+ pstrcpy(top->backing_format, sizeof(top->backing_format), "");
+ if (base_id) {
+ pstrcpy(top->backing_file, sizeof(top->backing_file), base_id);
+ if (base->drv) {
+ pstrcpy(top->backing_format, sizeof(top->backing_format),
+ base->drv->format_name);
+ }
+ }
+
+}
+
/*
* Given an image chain: [BASE] -> [INTER1] -> [INTER2] -> [TOP]
*
@@ -223,6 +256,7 @@ retry:
base_id = s->backing_file_id;
}
ret = bdrv_change_backing_file(bs, base_id, NULL);
+ close_unused_images(bs, base, base_id);
}
qemu_vfree(buf);
--
1.7.6.5
- [Qemu-devel] [PATCH 12/46] qerror: fix QERR_PROPERTY_VALUE_OUT_OF_RANGE description, (continued)
- [Qemu-devel] [PATCH 12/46] qerror: fix QERR_PROPERTY_VALUE_OUT_OF_RANGE description, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 45/46] qed: honor BDRV_O_INCOMING for incoming live migration, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 44/46] migration: clear BDRV_O_INCOMING flags on end of incoming live migration, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 34/46] sheepdog: fix send req helpers, Kevin Wolf, 2012/04/05
- [Qemu-devel] [PATCH 31/46] qed: track dirty flag status, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 40/46] block: Add new BDRV_O_INCOMING flag to notice incoming live migration, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 46/46] qed: remove incoming live migration blocker, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 16/46] vdi: move end-of-I/O handling at the end, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 30/46] qemu-img: add dirty flag status, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 41/46] block: add a function to clear incoming live migration flags, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 39/46] block stream: close unused files and update ->backing_hd,
Kevin Wolf <=
- [Qemu-devel] [PATCH 26/46] block: set job->speed in block_set_speed, Kevin Wolf, 2012/04/06
- [Qemu-devel] [PATCH 35/46] qemu-iotests: qcow2.py, Kevin Wolf, 2012/04/06
- Re: [Qemu-devel] [PULL 00/46] Block patches, Anthony Liguori, 2012/04/10