From patchwork Wed Jun 16 01:53:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Di Ciurcio Filho X-Patchwork-Id: 55831 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 E1B6DB7D7F for ; Wed, 16 Jun 2010 11:56:33 +1000 (EST) Received: from localhost ([127.0.0.1]:60783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOhri-0007RE-53 for incoming@patchwork.ozlabs.org; Tue, 15 Jun 2010 21:56:30 -0400 Received: from [140.186.70.92] (port=40987 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOhq8-0006Fi-Rb for qemu-devel@nongnu.org; Tue, 15 Jun 2010 21:54:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOhq7-0001XN-DL for qemu-devel@nongnu.org; Tue, 15 Jun 2010 21:54:52 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:52562) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOhq7-0001XE-Av for qemu-devel@nongnu.org; Tue, 15 Jun 2010 21:54:51 -0400 Received: by gxk7 with SMTP id 7so1272233gxk.4 for ; Tue, 15 Jun 2010 18:54:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=x0Gl1tJxcTdLv7lpxf5VorzlBF5IhywqIDzGpfEylD8=; b=w/OZsgmL5V9xjHNnF+aV75Fyly2kURRpTzj5NnRC1yc+MmgF6RoSCR+8KoCB+ApvKa pW/P8IYm/X9ziNE012hup9OFY6j10YFA6EGjZ2UZE3t0Fi2IJZzM+2RYUvISIOn/FMiR DfyU8trUz4cGhnKkVBr8Lry9Gj/mMeNTjDIfI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=POUsUjJh1RNXwQIi++g7Vr11c3ORw9taQ1iDmw49V3SA1Dysifsx3x/mcEBoPYrwGa se+LmUeCR2IrJyRga+q2HNsqN/Bzkgz8BwCNvVy/SXyPjSyaEQl48CYyMj6Bn3eP/fyr 5JIqGSO+c0Muz2/AbFEEG5h7mfpiu8XeLn7uU= Received: by 10.151.33.11 with SMTP id l11mr9412799ybj.177.1276653290640; Tue, 15 Jun 2010 18:54:50 -0700 (PDT) Received: from localhost.localdomain ([189.61.230.202]) by mx.google.com with ESMTPS id f2sm43359478ybi.17.2010.06.15.18.54.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 15 Jun 2010 18:54:50 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Tue, 15 Jun 2010 22:53:34 -0300 Message-Id: <1276653214-15427-1-git-send-email-miguel.filho@gmail.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: kwolf@redhat.com, Miguel Di Ciurcio Filho , armbru@redhat.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] monitor: Really show snapshot information about all devices 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 The 'info snapshots' monitor command does not show snapshot information from all available block devices. Usage example: $ qemu -hda disk1.qcow2 -hdb disk2.qcow2 (qemu) info snapshots Snapshot devices: ide0-hd0 Snapshot list (from ide0-hd0): ID TAG VM SIZE DATE VM CLOCK 1 1.5M 2010-05-26 21:51:02 00:00:03.263 2 1.5M 2010-05-26 21:51:09 00:00:08.844 3 1.5M 2010-05-26 21:51:24 00:00:23.274 4 1.5M 2010-05-26 21:53:17 00:00:03.595 In the above case, disk2.qcow2 has snapshot information, but it is not being shown. Only the first device is always shown. This patch updates the do_info_snapshots() function do correctly show snapshot information about all available block devices. New output: (qemu) info snapshots Snapshot list from ide0-hd0: ID TAG VM SIZE DATE VM CLOCK 1 1.5M 2010-05-26 21:51:02 00:00:03.263 2 1.5M 2010-05-26 21:51:09 00:00:08.844 3 1.5M 2010-05-26 21:51:24 00:00:23.274 4 1.5M 2010-05-26 21:53:17 00:00:03.595 Snapshot list from ide0-hd1: ID TAG VM SIZE DATE VM CLOCK 1 0 2010-05-26 21:51:02 00:00:03.263 2 0 2010-05-26 21:51:09 00:00:08.844 3 0 2010-05-26 21:51:24 00:00:23.274 4 0 2010-05-26 21:53:17 00:00:03.595 Signed-off-by: Miguel Di Ciurcio Filho --- savevm.c | 46 +++++++++++++++++++++++----------------------- 1 files changed, 23 insertions(+), 23 deletions(-) diff --git a/savevm.c b/savevm.c index 20354a8..0eacb9f 100644 --- a/savevm.c +++ b/savevm.c @@ -1858,8 +1858,8 @@ void do_delvm(Monitor *mon, const QDict *qdict) void do_info_snapshots(Monitor *mon) { - BlockDriverState *bs, *bs1; - QEMUSnapshotInfo *sn_tab, *sn; + BlockDriverState *bs; + QEMUSnapshotInfo *sn_tab; int nb_sns, i; char buf[256]; @@ -1868,27 +1868,27 @@ void do_info_snapshots(Monitor *mon) monitor_printf(mon, "No available block device supports snapshots\n"); return; } - monitor_printf(mon, "Snapshot devices:"); - bs1 = NULL; - while ((bs1 = bdrv_next(bs1))) { - if (bdrv_can_snapshot(bs1)) { - if (bs == bs1) - monitor_printf(mon, " %s", bdrv_get_device_name(bs1)); - } - } - monitor_printf(mon, "\n"); - nb_sns = bdrv_snapshot_list(bs, &sn_tab); - if (nb_sns < 0) { - monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns); - return; - } - monitor_printf(mon, "Snapshot list (from %s):\n", - bdrv_get_device_name(bs)); - monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL)); - for(i = 0; i < nb_sns; i++) { - sn = &sn_tab[i]; - monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn)); + bs = NULL; + while ((bs = bdrv_next(bs))) { + if (bdrv_can_snapshot(bs)) { + monitor_printf(mon, "Snapshot list from %s:\n", + bdrv_get_device_name(bs)); + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL)); + + nb_sns = bdrv_snapshot_list(bs, &sn_tab); + if (nb_sns < 0) { + monitor_printf(mon, "bdrv_snapshot_list: error %d\n", nb_sns); + continue; + } + + for (i = 0; i < nb_sns; i++) { + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), + &sn_tab[i])); + } + + qemu_free(sn_tab); + monitor_printf(mon, "\n"); + } } - qemu_free(sn_tab); }