[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V12 15/18] hmp: add function hmp_info_snapshots()
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V12 15/18] hmp: add function hmp_info_snapshots() |
Date: |
Sat, 13 Apr 2013 16:56:44 +0800 |
This function will simply call qmp interface qmp_query_snapshots()
added in last commit and then dump information in monitor console.
To get snapshot info, Now qemu and qemu-img both call block layer
function bdrv_query_snapshot_info_list() in their calling path, and
then they just translate the qmp object got to strings in stdout or
monitor console.
Signed-off-by: Wenchao Xia <address@hidden>
---
hmp.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
hmp.h | 1 +
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/hmp.c b/hmp.c
index dbe9b90..cef5eee 100644
--- a/hmp.c
+++ b/hmp.c
@@ -22,6 +22,7 @@
#include "qemu/sockets.h"
#include "monitor/monitor.h"
#include "ui/console.h"
+#include "block/qapi.h"
static void hmp_handle_error(Monitor *mon, Error **errp)
{
@@ -653,6 +654,49 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
qapi_free_TPMInfoList(info_list);
}
+/* assume list is valid */
+static void monitor_dump_snapshotinfolist(Monitor *mon, SnapshotInfoList *list)
+{
+ SnapshotInfoList *elem;
+
+ bdrv_snapshot_dump(NULL);
+ monitor_printf(mon, "\n");
+
+ for (elem = list; elem; elem = elem->next) {
+ QEMUSnapshotInfo sn = {
+ .vm_state_size = elem->value->vm_state_size,
+ .date_sec = elem->value->date_sec,
+ .date_nsec = elem->value->date_nsec,
+ .vm_clock_nsec = elem->value->vm_clock_sec * 1000000000ULL +
+ elem->value->vm_clock_nsec,
+ };
+ pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id);
+ pstrcpy(sn.name, sizeof(sn.name), elem->value->name);
+ bdrv_snapshot_dump(&sn);
+ monitor_printf(mon, "\n");
+ }
+}
+
+void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+ SnapshotInfoList *list;
+
+ list = qmp_query_snapshots(&err);
+ if (error_is_set(&err)) {
+ hmp_handle_error(mon, &err);
+ return;
+ }
+
+ if (list == NULL) {
+ monitor_printf(mon, "There is no suitable snapshot available\n");
+ return;
+ }
+
+ monitor_dump_snapshotinfolist(mon, list);
+ qapi_free_SnapshotInfoList(list);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index 80e8b41..1172c47 100644
--- a/hmp.h
+++ b/hmp.h
@@ -37,6 +37,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
void hmp_info_pci(Monitor *mon, const QDict *qdict);
void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
void hmp_quit(Monitor *mon, const QDict *qdict);
void hmp_stop(Monitor *mon, const QDict *qdict);
void hmp_system_reset(Monitor *mon, const QDict *qdict);
--
1.7.1
- Re: [Qemu-devel] [PATCH V12 02/18] block: distinguish id and name in bdrv_find_snapshot(), (continued)
- [Qemu-devel] [PATCH V12 01/18] block: move bdrv_snapshot_find() to block/snapshot.c, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 10/18] qmp: add interface query-snapshots, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 11/18] qmp: add recursive member in ImageInfo, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 06/18] block: add check for VM snapshot in bdrv_query_snapshot_info_list(), Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 13/18] block: move bdrv_snapshot_dump() and dump_human_image_info() to block/qapi.c, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 15/18] hmp: add function hmp_info_snapshots(),
Wenchao Xia <=
- [Qemu-devel] [PATCH V12 17/18] hmp: show ImageInfo in 'info block', Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 14/18] block: dump to monitor for bdrv_snapshot_dump() and bdrv_image_info_dump(), Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 12/18] qmp: add ImageInfo in BlockDeviceInfo used by query-block, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 16/18] hmp: switch snapshot info function to qmp based one, Wenchao Xia, 2013/04/13
- [Qemu-devel] [PATCH V12 18/18] hmp: add parameters device and -v for info block, Wenchao Xia, 2013/04/13
- Re: [Qemu-devel] [PATCH V12 00/18] qmp/hmp interfaces for internal snapshot info, Wenchao Xia, 2013/04/21