[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/25] monitor: make 'info snapshots' show only full
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 09/25] monitor: make 'info snapshots' show only fully available snapshots |
Date: |
Wed, 8 Sep 2010 15:29:26 +0200 |
From: Miguel Di Ciurcio Filho <address@hidden>
The output generated by 'info snapshots' shows only snapshots that exist on the
block device that saves the VM state. This output can cause an user to
erroneously try to load an snapshot that is not available on all block devices.
$ qemu-img snapshot -l xxtest.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 1.5M 2010-07-26 16:51:52 00:00:08.599
2 1.5M 2010-07-26 16:51:53 00:00:09.719
3 1.5M 2010-07-26 17:26:49 00:00:13.245
4 1.5M 2010-07-26 19:01:00 00:00:46.763
$ qemu-img snapshot -l xxtest2.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
3 0 2010-07-26 17:26:49 00:00:13.245
4 0 2010-07-26 19:01:00 00:00:46.763
Current output:
$ qemu -hda xxtest.qcow2 -hdb xxtest2.qcow2 -monitor stdio -vnc :0
QEMU 0.12.4 monitor - type 'help' for more information
(qemu) info snapshots
Snapshot devices: ide0-hd0
Snapshot list (from ide0-hd0):
ID TAG VM SIZE DATE VM CLOCK
1 1.5M 2010-07-26 16:51:52 00:00:08.599
2 1.5M 2010-07-26 16:51:53 00:00:09.719
3 1.5M 2010-07-26 17:26:49 00:00:13.245
4 1.5M 2010-07-26 19:01:00 00:00:46.763
Snapshots 1 and 2 do not exist on xxtest2.qcow, but they are displayed anyway.
This patch sumarizes the output to only show fully available snapshots.
New output:
(qemu) info snapshots
ID TAG VM SIZE DATE VM CLOCK
3 1.5M 2010-07-26 17:26:49 00:00:13.245
4 1.5M 2010-07-26 19:01:00 00:00:46.763
Signed-off-by: Miguel Di Ciurcio Filho <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
savevm.c | 59 +++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/savevm.c b/savevm.c
index 99e4949..d286592 100644
--- a/savevm.c
+++ b/savevm.c
@@ -2039,8 +2039,10 @@ void do_delvm(Monitor *mon, const QDict *qdict)
void do_info_snapshots(Monitor *mon)
{
BlockDriverState *bs, *bs1;
- QEMUSnapshotInfo *sn_tab, *sn;
- int nb_sns, i;
+ QEMUSnapshotInfo *sn_tab, *sn, s, *sn_info = &s;
+ int nb_sns, i, ret, available;
+ int total;
+ int *available_snapshots;
char buf[256];
bs = bdrv_snapshots();
@@ -2048,27 +2050,52 @@ 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++) {
+
+ if (nb_sns == 0) {
+ monitor_printf(mon, "There is no snapshot available.\n");
+ return;
+ }
+
+ available_snapshots = qemu_mallocz(sizeof(int) * nb_sns);
+ total = 0;
+ for (i = 0; i < nb_sns; i++) {
sn = &sn_tab[i];
- monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn));
+ available = 1;
+ bs1 = NULL;
+
+ while ((bs1 = bdrv_next(bs1))) {
+ if (bdrv_can_snapshot(bs1) && bs1 != bs) {
+ ret = bdrv_snapshot_find(bs1, sn_info, sn->id_str);
+ if (ret < 0) {
+ available = 0;
+ break;
+ }
+ }
+ }
+
+ if (available) {
+ available_snapshots[total] = i;
+ total++;
+ }
}
+
+ if (total > 0) {
+ monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf),
NULL));
+ for (i = 0; i < total; i++) {
+ sn = &sn_tab[available_snapshots[i]];
+ monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf),
sn));
+ }
+ } else {
+ monitor_printf(mon, "There is no suitable snapshot available\n");
+ }
+
qemu_free(sn_tab);
+ qemu_free(available_snapshots);
+
}
--
1.7.2.2
- [Qemu-devel] [PATCH 05/25] qemu-img rebase: Open new backing file read-only, (continued)
- [Qemu-devel] [PATCH 05/25] qemu-img rebase: Open new backing file read-only, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 24/25] block: Fix BDRV_O_CACHE_MASK, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 20/25] Improve ATA IDENTIFY word 64 contents., Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 23/25] qemu-img convert: Use cache=unsafe for output image, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 21/25] scsi-disk: add some optional scsi commands, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 07/25] nbd: Introduce NBD named exports., Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 19/25] raw-posix: Don't use file name for host_cdrom detection on Linux, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 03/25] block: Fix image re-open in bdrv_commit, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 11/25] scsi-disk: fix the mode data length field returned by the MODE SENSE command, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 12/25] scsi-disk: fix the mode data header returned by the MODE SENSE(10) command, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 09/25] monitor: make 'info snapshots' show only fully available snapshots,
Kevin Wolf <=
- [Qemu-devel] [PATCH 16/25] scsi-disk: fix the check of the DBD bit in the MODE SENSE command, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 08/25] posix-aio-compat: Fix async_conmtext for ioctl, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 13/25] scsi-disk: respect the page control (PC) field in the MODE SENSE command, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 01/25] virtio: Factor virtqueue_map_sg out, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 04/25] sheepdog: remove unnecessary includes, Kevin Wolf, 2010/09/08
- [Qemu-devel] [PATCH 10/25] savevm: Generate a name when run without one, Kevin Wolf, 2010/09/08
- Re: [Qemu-devel] [PULL v2 00/25] Block patches, Anthony Liguori, 2010/09/08