From patchwork Mon May 17 10:19:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [RFC, v3, 1/3] close all the block drivers before the qemu process exits Date: Mon, 17 May 2010 00:19:47 -0000 From: MORITA Kazutaka X-Patchwork-Id: 52773 Message-Id: <1274091589-19991-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> To: avi@redhat.com, aliguori@us.ibm.com, kwolf@redhat.com, hch@lst.de Cc: fujita.tomonori@lab.ntt.co.jp, sheepdog@lists.wpkg.org, qemu-devel@nongnu.org, kvm@vger.kernel.org This patch calls the close handler of the block driver before the qemu process exits. This is necessary because the sheepdog block driver releases the lock of VM images in the close handler. Signed-off-by: MORITA Kazutaka --- block.c | 9 +++++++++ block.h | 1 + vl.c | 1 + 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index bfe46e3..f3bf3f2 100644 --- a/block.c +++ b/block.c @@ -636,6 +636,15 @@ void bdrv_close(BlockDriverState *bs) } } +void bdrv_close_all(void) +{ + BlockDriverState *bs; + + QTAILQ_FOREACH(bs, &bdrv_states, list) { + bdrv_close(bs); + } +} + void bdrv_delete(BlockDriverState *bs) { /* remove from list, if necessary */ diff --git a/block.h b/block.h index 278259c..531e802 100644 --- a/block.h +++ b/block.h @@ -121,6 +121,7 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, /* Ensure contents are flushed to disk. */ void bdrv_flush(BlockDriverState *bs); void bdrv_flush_all(void); +void bdrv_close_all(void); int bdrv_has_zero_init(BlockDriverState *bs); int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, diff --git a/vl.c b/vl.c index 85bcc84..5ce7807 100644 --- a/vl.c +++ b/vl.c @@ -2007,6 +2007,7 @@ static void main_loop(void) exit(0); } } + bdrv_close_all(); pause_all_vcpus(); }