From patchwork Thu Jun 17 12:58:37 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: 56042 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 DCADC1007D2 for ; Thu, 17 Jun 2010 23:03:11 +1000 (EST) Received: from localhost ([127.0.0.1]:47763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPEkO-0004Lr-5L for incoming@patchwork.ozlabs.org; Thu, 17 Jun 2010 09:03:08 -0400 Received: from [140.186.70.92] (port=47533 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPEhL-0003ji-3k for qemu-devel@nongnu.org; Thu, 17 Jun 2010 09:00:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OPEhJ-0006fN-Kj for qemu-devel@nongnu.org; Thu, 17 Jun 2010 08:59:58 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:52969) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OPEhJ-0006ez-HC for qemu-devel@nongnu.org; Thu, 17 Jun 2010 08:59:57 -0400 Received: by gwaa20 with SMTP id a20so3312366gwa.4 for ; Thu, 17 Jun 2010 05:59:56 -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=tLkJ7q7durIRGdv2MvaQU8g+OupKYo8cwK8RhrXL5oY=; b=tZzUCmhvat6mjh0EkQ2Ob//mqQcdGtUyouR0h4FmgHx/e978XhPsf900EllB4S4zd2 0IQ9ntG0owIP8HR7e0QZUCYhT3RLXtgdo0eqSR3oPivXXRpbN29oQ0Wa2FhpN8EJDErV BF2qeSn21Fl4H6tPdlk4cxisfalydRg6/t0F0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=eJUN8O6/lkml/ir111ePiYsS1mMQ2RAsPD7HkDyyihmAn8jxisLZf073c7oSJa/i6f ImEDBN92vlrFf24lMnC5ue8djxPurqg2QQlUJu1PdPdf9Ohr98Ne9p5ZZNNyP55CrXQu aGvQXKo9SptM0CLY4B92tYKfgLy4HJjqSPp1s= Received: by 10.150.235.14 with SMTP id i14mr11719029ybh.373.1276779596549; Thu, 17 Jun 2010 05:59:56 -0700 (PDT) Received: from localhost.localdomain ([189.61.230.202]) by mx.google.com with ESMTPS id p37sm54318579ybk.14.2010.06.17.05.59.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 17 Jun 2010 05:59:55 -0700 (PDT) From: Miguel Di Ciurcio Filho To: qemu-devel@nongnu.org Date: Thu, 17 Jun 2010 09:58:37 -0300 Message-Id: <1276779517-2974-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, armbru@redhat.com, lcapitulino@redhat.com, clalance@redhat.com, Miguel Di Ciurcio Filho Subject: [Qemu-devel] [PATCH v2] 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 (VM state image): 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 changelog --------- v1 -> v2 - Added support to identify the device elected to save the VM's state. Signed-off-by: Miguel Di Ciurcio Filho --- savevm.c | 57 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 32 insertions(+), 25 deletions(-) diff --git a/savevm.c b/savevm.c index 20354a8..5bc5fcd 100644 --- a/savevm.c +++ b/savevm.c @@ -1858,37 +1858,44 @@ void do_delvm(Monitor *mon, const QDict *qdict) void do_info_snapshots(Monitor *mon) { - BlockDriverState *bs, *bs1; - QEMUSnapshotInfo *sn_tab, *sn; + BlockDriverState *bs, *bs_vm_state; + QEMUSnapshotInfo *sn_tab; int nb_sns, i; char buf[256]; - bs = get_bs_snapshots(); - if (!bs) { + bs_vm_state = get_bs_snapshots(); + if (!bs_vm_state) { 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", + bdrv_get_device_name(bs)); + + if (bs == bs_vm_state) { + monitor_printf(mon, " (VM state image):\n"); + } else { + monitor_printf(mon, ":\n"); + } + + 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); }