From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kd9Eo-0001M4-LI for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kd9Em-0001J2-FE for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:57 -0400 Received: from [199.232.76.173] (port=35803 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kd9El-0001IY-CF for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:55 -0400 Received: from e31.co.us.ibm.com ([32.97.110.149]:39265) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kd9El-0001tx-Gb for qemu-devel@nongnu.org; Tue, 09 Sep 2008 15:50:55 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e31.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m89JoqVS022429 for ; Tue, 9 Sep 2008 15:50:52 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m89JopLU220734 for ; Tue, 9 Sep 2008 13:50:51 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m89Joptv007650 for ; Tue, 9 Sep 2008 13:50:51 -0600 From: Anthony Liguori Date: Tue, 9 Sep 2008 14:49:55 -0500 Message-Id: <1220989802-13706-4-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> References: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 3/10] Add bdrv_flush_all() Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Chris Wright , Uri Lublin , Anthony Liguori , kvm@vger.kernel.org This patch adds a bdrv_flush_all() function. It's necessary to ensure that all IO operations have been flushed to disk before completely a live migration. N.B. we don't actually use this now. We really should flush the block drivers using an live savevm callback to avoid unnecessary guest down time. Signed-off-by: Anthony Liguori diff --git a/block.c b/block.c index 544176f..921d382 100644 --- a/block.c +++ b/block.c @@ -884,6 +884,21 @@ void bdrv_flush(BlockDriverState *bs) bdrv_flush(bs->backing_hd); } +void bdrv_iterate_writeable(void (*it)(BlockDriverState *bs)) +{ + BlockDriverState *bs; + + for (bs = bdrv_first; bs != NULL; bs = bs->next) + if (bs->drv && !bdrv_is_read_only(bs) && + (!bdrv_is_removable(bs) || bdrv_is_inserted(bs))) + it(bs); +} + +void bdrv_flush_all(void) +{ + bdrv_iterate_writeable(bdrv_flush); +} + /* * Returns true iff the specified sector is present in the disk image. Drivers * not implementing the functionality are assumed to not support backing files, diff --git a/block.h b/block.h index fa741b5..8586dc1 100644 --- a/block.h +++ b/block.h @@ -112,6 +112,8 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num, int nb_sectors, #define BIOS_ATA_TRANSLATION_LARGE 3 #define BIOS_ATA_TRANSLATION_RECHS 4 +void bdrv_flush_all(void); + void bdrv_set_geometry_hint(BlockDriverState *bs, int cyls, int heads, int secs); void bdrv_set_type_hint(BlockDriverState *bs, int type);