From patchwork Wed Jun 2 16:55:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 54398 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 EB98EB7D4C for ; Thu, 3 Jun 2010 03:24:37 +1000 (EST) Received: from localhost ([127.0.0.1]:42013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJrgA-0008Db-2y for incoming@patchwork.ozlabs.org; Wed, 02 Jun 2010 13:24:34 -0400 Received: from [140.186.70.92] (port=40048 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJrEj-0007Rc-Th for qemu-devel@nongnu.org; Wed, 02 Jun 2010 12:56:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJrE4-0005hV-Mw for qemu-devel@nongnu.org; Wed, 02 Jun 2010 12:55:45 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:35285) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJrE4-0005gc-DK for qemu-devel@nongnu.org; Wed, 02 Jun 2010 12:55:32 -0400 Received: from blackfin.pond.sub.org (pD9E39C24.dip.t-dialin.net [217.227.156.36]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 74BE62DD37D for ; Wed, 2 Jun 2010 18:55:30 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 5782D360; Wed, 2 Jun 2010 18:55:29 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 2 Jun 2010 18:55:21 +0200 Message-Id: <1275497729-13120-6-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1275497729-13120-1-git-send-email-armbru@redhat.com> References: <1275497729-13120-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: kwolf@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCH 05/13] block: Decouple savevm 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 We find snapshots by iterating 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. Iterate over all host block devices instead, with bdrv_next(). Signed-off-by: Markus Armbruster --- savevm.c | 32 ++++++++++++++------------------ 1 files changed, 14 insertions(+), 18 deletions(-) diff --git a/savevm.c b/savevm.c index 18852cd..12a8ba5 100644 --- a/savevm.c +++ b/savevm.c @@ -1593,12 +1593,13 @@ static int bdrv_has_snapshot(BlockDriverState *bs) static BlockDriverState *get_bs_snapshots(void) { BlockDriverState *bs; - DriveInfo *dinfo; if (bs_snapshots) return bs_snapshots; - QTAILQ_FOREACH(dinfo, &drives, next) { - bs = dinfo->bdrv; + /* FIXME what if bs_snapshots gets hot-unplugged? */ + + bs = NULL; + while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs)) goto ok; } @@ -1636,12 +1637,11 @@ static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, static int del_existing_snapshots(Monitor *mon, const char *name) { BlockDriverState *bs; - DriveInfo *dinfo; QEMUSnapshotInfo sn1, *snapshot = &sn1; int ret; - QTAILQ_FOREACH(dinfo, &drives, next) { - bs = dinfo->bdrv; + bs = NULL; + while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) && bdrv_snapshot_find(bs, snapshot, name) >= 0) { @@ -1660,7 +1660,6 @@ static int del_existing_snapshots(Monitor *mon, const char *name) void do_savevm(Monitor *mon, const QDict *qdict) { - DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1; int ret; @@ -1730,8 +1729,8 @@ void do_savevm(Monitor *mon, const QDict *qdict) /* create the snapshots */ - QTAILQ_FOREACH(dinfo, &drives, next) { - bs1 = dinfo->bdrv; + bs1 = NULL; + while ((bs1 = bdrv_next(bs1))) { if (bdrv_has_snapshot(bs1)) { /* Write VM state size only to the image that contains the state */ sn->vm_state_size = (bs == bs1 ? vm_state_size : 0); @@ -1750,7 +1749,6 @@ void do_savevm(Monitor *mon, const QDict *qdict) int load_vmstate(const char *name) { - DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo sn; QEMUFile *f; @@ -1765,8 +1763,8 @@ int load_vmstate(const char *name) /* Flush all IO requests so they don't interfere with the new state. */ qemu_aio_flush(); - QTAILQ_FOREACH(dinfo, &drives, next) { - bs1 = dinfo->bdrv; + bs1 = NULL; + while ((bs1 = bdrv_next(bs1))) { if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); if (ret < 0) { @@ -1816,7 +1814,6 @@ int load_vmstate(const char *name) void do_delvm(Monitor *mon, const QDict *qdict) { - DriveInfo *dinfo; BlockDriverState *bs, *bs1; int ret; const char *name = qdict_get_str(qdict, "name"); @@ -1827,8 +1824,8 @@ void do_delvm(Monitor *mon, const QDict *qdict) return; } - QTAILQ_FOREACH(dinfo, &drives, next) { - bs1 = dinfo->bdrv; + bs1 = NULL; + while ((bs1 = bdrv_next(bs1))) { if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_delete(bs1, name); if (ret < 0) { @@ -1846,7 +1843,6 @@ void do_delvm(Monitor *mon, const QDict *qdict) void do_info_snapshots(Monitor *mon) { - DriveInfo *dinfo; BlockDriverState *bs, *bs1; QEMUSnapshotInfo *sn_tab, *sn; int nb_sns, i; @@ -1858,8 +1854,8 @@ void do_info_snapshots(Monitor *mon) return; } monitor_printf(mon, "Snapshot devices:"); - QTAILQ_FOREACH(dinfo, &drives, next) { - bs1 = dinfo->bdrv; + bs1 = NULL; + while ((bs1 = bdrv_next(bs1))) { if (bdrv_has_snapshot(bs1)) { if (bs == bs1) monitor_printf(mon, " %s", bdrv_get_device_name(bs1));