From patchwork Wed May 12 10:46:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 98988 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4CAdZgP025110 for ; Wed, 12 May 2010 10:39:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753285Ab0ELKjM (ORCPT ); Wed, 12 May 2010 06:39:12 -0400 Received: from sh.osrg.net ([192.16.179.4]:43730 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706Ab0ELKjJ (ORCPT ); Wed, 12 May 2010 06:39:09 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o4CAcIZM012963; Wed, 12 May 2010 19:38:19 +0900 Received: from localhost (dfs1401.osrg.net [10.68.14.1]) by fs.osrg.net (Postfix) with ESMTP id EE0801B8001; Wed, 12 May 2010 19:38:18 +0900 (JST) From: MORITA Kazutaka To: aliguori@us.ibm.com, avi@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, sheepdog@lists.wpkg.org, fujita.tomonori@lab.ntt.co.jp Subject: [RFC PATCH 1/2] close all the block drivers before the qemu process exits Date: Wed, 12 May 2010 19:46:52 +0900 Message-Id: <1273661213-19611-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1273661213-19611-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> References: <1273661213-19611-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 75 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 10:39:35 +0000 (UTC) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Wed, 12 May 2010 19:38:20 +0900 (JST) X-Virus-Scanned: clamav-milter 0.96 at sh X-Virus-Status: Clean Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/block.c b/block.c index 7326bfe..a606820 100644 --- a/block.c +++ b/block.c @@ -526,6 +526,17 @@ void bdrv_close(BlockDriverState *bs) } } +void bdrv_close_all(void) +{ + BlockDriverState *bs, *n; + + for (bs = bdrv_first, n = bs->next; bs; bs = n, n = bs ? bs->next : NULL) { + if (bs && bs->drv && bs->drv->bdrv_close) { + bs->drv->bdrv_close(bs); + } + } +} + void bdrv_delete(BlockDriverState *bs) { BlockDriverState **pbs; diff --git a/block.h b/block.h index fa51ddf..1a1293a 100644 --- a/block.h +++ b/block.h @@ -123,6 +123,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_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum); diff --git a/monitor.c b/monitor.c index 17e59f5..44bfe83 100644 --- a/monitor.c +++ b/monitor.c @@ -845,6 +845,7 @@ static void do_info_cpu_stats(Monitor *mon) */ static void do_quit(Monitor *mon, const QDict *qdict, QObject **ret_data) { + bdrv_close_all(); exit(0); } diff --git a/vl.c b/vl.c index 77677e8..65160ed 100644 --- a/vl.c +++ b/vl.c @@ -4205,6 +4205,7 @@ static void main_loop(void) vm_stop(r); } } + bdrv_close_all(); pause_all_vcpus(); }