From patchwork Tue Jun 15 14:19:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 55684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 96181B7D48 for ; Wed, 16 Jun 2010 00:49:42 +1000 (EST) Received: from localhost ([127.0.0.1]:52669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOXSM-0005in-UL for incoming@patchwork.ozlabs.org; Tue, 15 Jun 2010 10:49:39 -0400 Received: from [140.186.70.92] (port=37850 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOWzw-000887-P1 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 10:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOWzu-0000Ae-27 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 10:20:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24714) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOWzt-0000AR-Ri for qemu-devel@nongnu.org; Tue, 15 Jun 2010 10:20:14 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5FEKBUi031296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Jun 2010 10:20:12 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5FEJq71025060; Tue, 15 Jun 2010 10:20:10 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 15 Jun 2010 16:19:34 +0200 Message-Id: <1276611581-3757-13-git-send-email-kwolf@redhat.com> In-Reply-To: <1276611581-3757-1-git-send-email-kwolf@redhat.com> References: <1276611581-3757-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/19] block: Decouple block device "commit all" from DriveInfo X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Markus Armbruster do_commit() and mux_proc_byte() iterate over the list of drives defined with drive_init(). This misses host block devices defined by other means. Such means don't exist now, but will be introduced later in this series. Change them to use new bdrv_commit_all(), which iterates over all host block devices. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- block.c | 9 +++++++++ block.h | 1 + blockdev.c | 16 ++++++++-------- qemu-char.c | 7 +------ 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index e701ec0..df2d3a6 100644 --- a/block.c +++ b/block.c @@ -788,6 +788,15 @@ ro_cleanup: return ret; } +void bdrv_commit_all(void) +{ + BlockDriverState *bs; + + QTAILQ_FOREACH(bs, &bdrv_states, list) { + bdrv_commit(bs); + } +} + /* * Return values: * 0 - success diff --git a/block.h b/block.h index d22401f..1f69cbd 100644 --- a/block.h +++ b/block.h @@ -85,6 +85,7 @@ int64_t bdrv_getlength(BlockDriverState *bs); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs); int bdrv_commit(BlockDriverState *bs); +void bdrv_commit_all(void); int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file, const char *backing_fmt); void bdrv_register(BlockDriver *bdrv); diff --git a/blockdev.c b/blockdev.c index b5570f4..d74cd1d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -486,16 +486,16 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi, int *fatal_error) void do_commit(Monitor *mon, const QDict *qdict) { - int all_devices; - DriveInfo *dinfo; const char *device = qdict_get_str(qdict, "device"); + BlockDriverState *bs; - all_devices = !strcmp(device, "all"); - QTAILQ_FOREACH(dinfo, &drives, next) { - if (!all_devices) - if (strcmp(bdrv_get_device_name(dinfo->bdrv), device)) - continue; - bdrv_commit(dinfo->bdrv); + if (!strcmp(device, "all")) { + bdrv_commit_all(); + } else { + bs = bdrv_find(device); + if (bs) { + bdrv_commit(bs); + } } } diff --git a/qemu-char.c b/qemu-char.c index 87628ea..9b69d92 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -351,12 +351,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) break; } case 's': - { - DriveInfo *dinfo; - QTAILQ_FOREACH(dinfo, &drives, next) { - bdrv_commit(dinfo->bdrv); - } - } + bdrv_commit_all(); break; case 'b': qemu_chr_event(chr, CHR_EVENT_BREAK);