[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V9 14/14] hmp: add command info images
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V9 14/14] hmp: add command info images |
Date: |
Mon, 11 Mar 2013 19:23:16 +0800 |
This command will show block image's information, including
internal snapshots.
Signed-off-by: Wenchao Xia <address@hidden>
---
hmp.c | 38 ++++++++++++++++++++++++++++++++++++++
hmp.h | 1 +
monitor.c | 7 +++++++
3 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/hmp.c b/hmp.c
index 34f0691..05d9b3b 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)
{
@@ -649,6 +650,43 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict)
qapi_free_SnapshotInfoList(list);
}
+#define IMAGE_INFO_BUF_SIZE (2048)
+static void mon_dump_device_image_info_list(Monitor *mon,
+ DeviceImageInfoList *list)
+{
+ char *buf = g_malloc0(IMAGE_INFO_BUF_SIZE);
+ DeviceImageInfoList *p = list;
+ DeviceImageInfo *dii;
+ while (p) {
+ dii = p->value;
+ monitor_printf(mon, "Device : %s\n", dii->device);
+ if (dii->has_image) {
+ bdrv_image_info_dump(buf, IMAGE_INFO_BUF_SIZE, dii->image);
+ monitor_printf(mon, "%s", buf);
+ }
+ monitor_printf(mon, "\n");
+
+ p = p->next;
+ }
+ g_free(buf);
+}
+
+void hmp_info_images(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_try_str(qdict, "device");
+ int backing = qdict_get_try_bool(qdict, "backing", 0);
+ Error *err = NULL;
+ DeviceImageInfoList *list = NULL;
+
+ list = qmp_query_images(!!device, device, true, backing, &err);
+ if (!error_is_set(&err) && list) {
+ mon_dump_device_image_info_list(mon, list);
+ }
+
+ hmp_handle_error(mon, &err);
+ qapi_free_DeviceImageInfoList(list);
+}
+
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
diff --git a/hmp.h b/hmp.h
index 0b0ae13..9d9ada3 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_snapshots(Monitor *mon, const QDict *qdict);
+void hmp_info_images(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);
diff --git a/monitor.c b/monitor.c
index 5112375..b470963 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2597,6 +2597,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.cmd = hmp_info_snapshots,
},
{
+ .name = "images",
+ .args_type = "backing:-b,device:B?",
+ .params = "[-b] [device]",
+ .help = "show the image info",
+ .mhandler.cmd = hmp_info_images,
+ },
+ {
.name = "status",
.args_type = "",
.params = "",
--
1.7.1
- [Qemu-devel] [PATCH V9 02/14] block: distinguish id and name in bdrv_find_snapshot(), (continued)
- [Qemu-devel] [PATCH V9 02/14] block: distinguish id and name in bdrv_find_snapshot(), Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 09/14] qmp: add interface query-images, Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 07/14] block: add image info query function bdrv_query_image_info(), Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 10/14] hmp: add function hmp_info_snapshots(), Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 08/14] qmp: add interface query-snapshots, Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 11/14] hmp: switch snapshot info function to qmp based one, Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 12/14] block: move dump_human_image_info() to block/qapi.c, Wenchao Xia, 2013/03/11
- [Qemu-devel] [PATCH V9 14/14] hmp: add command info images,
Wenchao Xia <=
- [Qemu-devel] [PATCH V9 13/14] block: dump to buffer for bdrv_image_info_dump(), Wenchao Xia, 2013/03/11
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Stefan Hajnoczi, 2013/03/12
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Eric Blake, 2013/03/12
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Wenchao Xia, 2013/03/12
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Stefan Hajnoczi, 2013/03/13
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Eric Blake, 2013/03/13
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Kevin Wolf, 2013/03/13
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Stefan Hajnoczi, 2013/03/13
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Wenchao Xia, 2013/03/15
- Re: [Qemu-devel] [PATCH V9 00/14] qmp/hmp interfaces for internal snapshot info, Kevin Wolf, 2013/03/15