* [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info
@ 2013-06-06 4:27 Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 1/5] block: add snapshot info query function bdrv_query_snapshot_info_list() Wenchao Xia
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:27 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
This series lets qmp interface show delaied info, including internal snapshot
/backing chain on all block device at runtime, which helps management stack and
human user, by retrieving exactly the same info of what qemu sees.
Example:
-> { "execute": "query-block" }
<- {
"return":[
{
"io-status": "ok",
"device":"ide0-hd0",
"locked":false,
"removable":false,
"inserted":{
"ro":false,
"drv":"qcow2",
"encrypted":false,
"file":"disks/test.qcow2",
"backing_file_depth":1,
"bps":1000000,
"bps_rd":0,
"bps_wr":0,
"iops":1000000,
"iops_rd":0,
"iops_wr":0,
"image":{
"filename":"disks/test.qcow2",
"format":"qcow2",
"virtual-size":2048000,
"backing_file":"base.qcow2",
"full-backing-filename":"disks/base.qcow2",
"backing-filename-format:"qcow2",
"snapshots":[
{
"id": "1",
"name": "snapshot1",
"vm-state-size": 0,
"date-sec": 10000200,
"date-nsec": 12,
"vm-clock-sec": 206,
"vm-clock-nsec": 30
}
],
"backing-image":{
"filename":"disks/base.qcow2",
"format":"qcow2",
"virtual-size":2048000
}
}
},
"type":"unknown"
},
{
"io-status": "ok",
"device":"ide1-cd0",
"locked":false,
"removable":true,
"type":"unknown"
},
{
"device":"floppy0",
"locked":false,
"removable":true,
"type":"unknown"
},
{
"device":"sd0",
"locked":false,
"removable":true,
"type":"unknown"
}
]
}
These patches follows the rule that use qmp to retrieve information,
hmp layer just does a translation from qmp object it got. To make code
graceful, snapshot and image info retrieving code in qemu and qemu-img are
merged into block layer, and some function names were adjusted to describe
them better. For the part touched by the series, it works as:
qemu qemu-img
dump_monitor dump_stdout
|--------------|
|
block/qapi.c
This series requires following series applied:
"[PATCH V3 0/4] qapi and snapshot code clean up in block layer",
https://lists.gnu.org/archive/html/qemu-devel/2013-05/msg03539.html
Special thanks for Markus, Stefan, Kevin, Eric reviewing many times.
V15:
Squash "add recursive member in ImageInfo" patch into 3/6.
Address Stefan's comments:
5/5: use bool instead of int for variable "verbose".
Wenchao Xia (5):
1 block: add snapshot info query function bdrv_query_snapshot_info_list()
2 block: add image info query function bdrv_query_image_info()
3 qmp: add ImageInfo in BlockDeviceInfo used by query-block
4 hmp: show ImageInfo in 'info block'
5 hmp: add parameters device and -v for info block
block/qapi.c | 148 ++++++++++++++++++++++++++++++++++++++++++--------
hmp.c | 21 +++++++
include/block/qapi.h | 14 +++--
monitor.c | 7 ++-
qapi-schema.json | 10 +++-
qemu-img.c | 10 +++-
qmp-commands.hx | 69 +++++++++++++++++++++++-
7 files changed, 242 insertions(+), 37 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH V15 1/5] block: add snapshot info query function bdrv_query_snapshot_info_list()
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
@ 2013-06-06 4:27 ` Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 2/5] block: add image info query function bdrv_query_image_info() Wenchao Xia
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:27 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
This patch adds function bdrv_query_snapshot_info_list(), which will
retrieve snapshot info of an image in qmp object format. The implementation
is based on the code moved from qemu-img.c with modification to fit more
for qmp based block layer API.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
block/qapi.c | 55 ++++++++++++++++++++++++++++++++++++++-----------
include/block/qapi.h | 4 ++-
qemu-img.c | 5 +++-
3 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index 794dbf8..1ed56da 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -26,29 +26,56 @@
#include "block/block_int.h"
#include "qmp-commands.h"
-void bdrv_collect_snapshots(BlockDriverState *bs , ImageInfo *info)
+/*
+ * Returns 0 on success, with *p_list either set to describe snapshot
+ * information, or NULL because there are no snapshots. Returns -errno on
+ * error, with *p_list untouched.
+ */
+int bdrv_query_snapshot_info_list(BlockDriverState *bs,
+ SnapshotInfoList **p_list,
+ Error **errp)
{
int i, sn_count;
QEMUSnapshotInfo *sn_tab = NULL;
- SnapshotInfoList *info_list, *cur_item = NULL;
+ SnapshotInfoList *info_list, *cur_item = NULL, *head = NULL;
+ SnapshotInfo *info;
+
sn_count = bdrv_snapshot_list(bs, &sn_tab);
+ if (sn_count < 0) {
+ const char *dev = bdrv_get_device_name(bs);
+ switch (sn_count) {
+ case -ENOMEDIUM:
+ error_setg(errp, "Device '%s' is not inserted", dev);
+ break;
+ case -ENOTSUP:
+ error_setg(errp,
+ "Device '%s' does not support internal snapshots",
+ dev);
+ break;
+ default:
+ error_setg_errno(errp, -sn_count,
+ "Can't list snapshots of device '%s'", dev);
+ break;
+ }
+ return sn_count;
+ }
for (i = 0; i < sn_count; i++) {
- info->has_snapshots = true;
- info_list = g_new0(SnapshotInfoList, 1);
+ info = g_new0(SnapshotInfo, 1);
+ info->id = g_strdup(sn_tab[i].id_str);
+ info->name = g_strdup(sn_tab[i].name);
+ info->vm_state_size = sn_tab[i].vm_state_size;
+ info->date_sec = sn_tab[i].date_sec;
+ info->date_nsec = sn_tab[i].date_nsec;
+ info->vm_clock_sec = sn_tab[i].vm_clock_nsec / 1000000000;
+ info->vm_clock_nsec = sn_tab[i].vm_clock_nsec % 1000000000;
- info_list->value = g_new0(SnapshotInfo, 1);
- info_list->value->id = g_strdup(sn_tab[i].id_str);
- info_list->value->name = g_strdup(sn_tab[i].name);
- info_list->value->vm_state_size = sn_tab[i].vm_state_size;
- info_list->value->date_sec = sn_tab[i].date_sec;
- info_list->value->date_nsec = sn_tab[i].date_nsec;
- info_list->value->vm_clock_sec = sn_tab[i].vm_clock_nsec / 1000000000;
- info_list->value->vm_clock_nsec = sn_tab[i].vm_clock_nsec % 1000000000;
+ info_list = g_new0(SnapshotInfoList, 1);
+ info_list->value = info;
/* XXX: waiting for the qapi to support qemu-queue.h types */
if (!cur_item) {
- info->snapshots = cur_item = info_list;
+ head = cur_item = info_list;
} else {
cur_item->next = info_list;
cur_item = info_list;
@@ -57,6 +84,8 @@ void bdrv_collect_snapshots(BlockDriverState *bs , ImageInfo *info)
}
g_free(sn_tab);
+ *p_list = head;
+ return 0;
}
void bdrv_collect_image_info(BlockDriverState *bs,
diff --git a/include/block/qapi.h b/include/block/qapi.h
index e6e568d..4f223d1 100644
--- a/include/block/qapi.h
+++ b/include/block/qapi.h
@@ -29,7 +29,9 @@
#include "block/block.h"
#include "block/snapshot.h"
-void bdrv_collect_snapshots(BlockDriverState *bs , ImageInfo *info);
+int bdrv_query_snapshot_info_list(BlockDriverState *bs,
+ SnapshotInfoList **p_list,
+ Error **errp);
void bdrv_collect_image_info(BlockDriverState *bs,
ImageInfo *info,
const char *filename);
diff --git a/qemu-img.c b/qemu-img.c
index 82c7977..29929c5 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1665,7 +1665,10 @@ static ImageInfoList *collect_image_info_list(const char *filename,
info = g_new0(ImageInfo, 1);
bdrv_collect_image_info(bs, info, filename);
- bdrv_collect_snapshots(bs, info);
+ bdrv_query_snapshot_info_list(bs, &info->snapshots, NULL);
+ if (info->snapshots) {
+ info->has_snapshots = true;
+ }
elem = g_new0(ImageInfoList, 1);
elem->value = info;
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH V15 2/5] block: add image info query function bdrv_query_image_info()
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 1/5] block: add snapshot info query function bdrv_query_snapshot_info_list() Wenchao Xia
@ 2013-06-06 4:27 ` Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 3/5] qmp: add ImageInfo in BlockDeviceInfo used by query-block Wenchao Xia
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:27 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
This patch adds function bdrv_query_image_info(), which will
retrieve image info in qmp object format. The implementation is
based on the code moved from qemu-img.c, but uses block layer
function to get snapshot info.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
block/qapi.c | 43 +++++++++++++++++++++++++++++++++++++------
include/block/qapi.h | 6 +++---
qemu-img.c | 11 ++++++-----
3 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index 1ed56da..e9d8b74 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -88,18 +88,29 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
return 0;
}
-void bdrv_collect_image_info(BlockDriverState *bs,
- ImageInfo *info,
- const char *filename)
+/**
+ * bdrv_query_image_info:
+ * @bs: block device to examine
+ * @p_info: location to store image information
+ * @errp: location to store error information
+ *
+ * @p_info will be set only on success. On error, store error in @errp.
+ */
+void bdrv_query_image_info(BlockDriverState *bs,
+ ImageInfo **p_info,
+ Error **errp)
{
uint64_t total_sectors;
- char backing_filename[1024];
+ const char *backing_filename;
char backing_filename2[1024];
BlockDriverInfo bdi;
+ int ret;
+ Error *err = NULL;
+ ImageInfo *info = g_new0(ImageInfo, 1);
bdrv_get_geometry(bs, &total_sectors);
- info->filename = g_strdup(filename);
+ info->filename = g_strdup(bs->filename);
info->format = g_strdup(bdrv_get_format_name(bs));
info->virtual_size = total_sectors * 512;
info->actual_size = bdrv_get_allocated_file_size(bs);
@@ -116,7 +127,7 @@ void bdrv_collect_image_info(BlockDriverState *bs,
info->dirty_flag = bdi.is_dirty;
info->has_dirty_flag = true;
}
- bdrv_get_backing_filename(bs, backing_filename, sizeof(backing_filename));
+ backing_filename = bs->backing_file;
if (backing_filename[0] != '\0') {
info->backing_filename = g_strdup(backing_filename);
info->has_backing_filename = true;
@@ -134,6 +145,26 @@ void bdrv_collect_image_info(BlockDriverState *bs,
info->has_backing_filename_format = true;
}
}
+
+ ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err);
+ switch (ret) {
+ case 0:
+ if (info->snapshots) {
+ info->has_snapshots = true;
+ }
+ break;
+ /* recoverable error */
+ case -ENOMEDIUM:
+ case -ENOTSUP:
+ error_free(err);
+ break;
+ default:
+ error_propagate(errp, err);
+ qapi_free_ImageInfo(info);
+ return;
+ }
+
+ *p_info = info;
}
BlockInfo *bdrv_query_info(BlockDriverState *bs)
diff --git a/include/block/qapi.h b/include/block/qapi.h
index 4f223d1..ab1f48f 100644
--- a/include/block/qapi.h
+++ b/include/block/qapi.h
@@ -32,9 +32,9 @@
int bdrv_query_snapshot_info_list(BlockDriverState *bs,
SnapshotInfoList **p_list,
Error **errp);
-void bdrv_collect_image_info(BlockDriverState *bs,
- ImageInfo *info,
- const char *filename);
+void bdrv_query_image_info(BlockDriverState *bs,
+ ImageInfo **p_info,
+ Error **errp);
BlockInfo *bdrv_query_info(BlockDriverState *s);
BlockStats *bdrv_query_stats(const BlockDriverState *bs);
diff --git a/qemu-img.c b/qemu-img.c
index 29929c5..04a3f7c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1642,6 +1642,7 @@ static ImageInfoList *collect_image_info_list(const char *filename,
ImageInfoList *head = NULL;
ImageInfoList **last = &head;
GHashTable *filenames;
+ Error *err = NULL;
filenames = g_hash_table_new_full(g_str_hash, str_equal_func, NULL, NULL);
@@ -1663,11 +1664,11 @@ static ImageInfoList *collect_image_info_list(const char *filename,
goto err;
}
- info = g_new0(ImageInfo, 1);
- bdrv_collect_image_info(bs, info, filename);
- bdrv_query_snapshot_info_list(bs, &info->snapshots, NULL);
- if (info->snapshots) {
- info->has_snapshots = true;
+ bdrv_query_image_info(bs, &info, &err);
+ if (error_is_set(&err)) {
+ error_report("%s", error_get_pretty(err));
+ error_free(err);
+ goto err;
}
elem = g_new0(ImageInfoList, 1);
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH V15 3/5] qmp: add ImageInfo in BlockDeviceInfo used by query-block
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 1/5] block: add snapshot info query function bdrv_query_snapshot_info_list() Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 2/5] block: add image info query function bdrv_query_image_info() Wenchao Xia
@ 2013-06-06 4:27 ` Wenchao Xia
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 4/5] hmp: show ImageInfo in 'info block' Wenchao Xia
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:27 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
Now image info will be retrieved as an embbed json object inside
BlockDeviceInfo, backing chain info and all related internal snapshot
info can be got in the enhanced recursive structure of ImageInfo. New
recursive member *backing-image is added to reflect the backing chain
status.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
block/qapi.c | 50 ++++++++++++++++++++++++++++++++++--
include/block/qapi.h | 4 ++-
qapi-schema.json | 10 ++++++-
qmp-commands.hx | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 125 insertions(+), 8 deletions(-)
diff --git a/block/qapi.c b/block/qapi.c
index e9d8b74..a4bc411 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -94,6 +94,13 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
* @p_info: location to store image information
* @errp: location to store error information
*
+ * Store "flat" image information in @p_info.
+ *
+ * "Flat" means it does *not* query backing image information,
+ * i.e. (*pinfo)->has_backing_image will be set to false and
+ * (*pinfo)->backing_image to NULL even when the image does in fact have
+ * a backing image.
+ *
* @p_info will be set only on success. On error, store error in @errp.
*/
void bdrv_query_image_info(BlockDriverState *bs,
@@ -167,9 +174,15 @@ void bdrv_query_image_info(BlockDriverState *bs,
*p_info = info;
}
-BlockInfo *bdrv_query_info(BlockDriverState *bs)
+/* @p_info will be set only on success. */
+void bdrv_query_info(BlockDriverState *bs,
+ BlockInfo **p_info,
+ Error **errp)
{
BlockInfo *info = g_malloc0(sizeof(*info));
+ BlockDriverState *bs0;
+ ImageInfo **p_image_info;
+ Error *local_err = NULL;
info->device = g_strdup(bs->device_name);
info->type = g_strdup("unknown");
info->locked = bdrv_dev_is_medium_locked(bs);
@@ -223,8 +236,30 @@ BlockInfo *bdrv_query_info(BlockDriverState *bs)
info->inserted->iops_wr =
bs->io_limits.iops[BLOCK_IO_LIMIT_WRITE];
}
+
+ bs0 = bs;
+ p_image_info = &info->inserted->image;
+ while (1) {
+ bdrv_query_image_info(bs0, p_image_info, &local_err);
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
+ goto err;
+ }
+ if (bs0->drv && bs0->backing_hd) {
+ bs0 = bs0->backing_hd;
+ (*p_image_info)->has_backing_image = true;
+ p_image_info = &((*p_image_info)->backing_image);
+ } else {
+ break;
+ }
+ }
}
- return info;
+
+ *p_info = info;
+ return;
+
+ err:
+ qapi_free_BlockInfo(info);
}
BlockStats *bdrv_query_stats(const BlockDriverState *bs)
@@ -261,16 +296,25 @@ BlockInfoList *qmp_query_block(Error **errp)
{
BlockInfoList *head = NULL, **p_next = &head;
BlockDriverState *bs = NULL;
+ Error *local_err = NULL;
while ((bs = bdrv_next(bs))) {
BlockInfoList *info = g_malloc0(sizeof(*info));
- info->value = bdrv_query_info(bs);
+ bdrv_query_info(bs, &info->value, &local_err);
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
+ goto err;
+ }
*p_next = info;
p_next = &info->next;
}
return head;
+
+ err:
+ qapi_free_BlockInfoList(head);
+ return NULL;
}
BlockStatsList *qmp_query_blockstats(Error **errp)
diff --git a/include/block/qapi.h b/include/block/qapi.h
index ab1f48f..0496cc9 100644
--- a/include/block/qapi.h
+++ b/include/block/qapi.h
@@ -35,7 +35,9 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
void bdrv_query_image_info(BlockDriverState *bs,
ImageInfo **p_info,
Error **errp);
-BlockInfo *bdrv_query_info(BlockDriverState *s);
+void bdrv_query_info(BlockDriverState *bs,
+ BlockInfo **p_info,
+ Error **errp);
BlockStats *bdrv_query_stats(const BlockDriverState *bs);
void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,
diff --git a/qapi-schema.json b/qapi-schema.json
index ef1f657..5ad6894 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -236,6 +236,8 @@
#
# @snapshots: #optional list of VM snapshots
#
+# @backing-image: #optional info of the backing image (since 1.6)
+#
# Since: 1.3
#
##
@@ -245,7 +247,8 @@
'*actual-size': 'int', 'virtual-size': 'int',
'*cluster-size': 'int', '*encrypted': 'bool',
'*backing-filename': 'str', '*full-backing-filename': 'str',
- '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'] } }
+ '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
+ '*backing-image': 'ImageInfo' } }
##
# @ImageCheck:
@@ -756,6 +759,8 @@
#
# @iops_wr: write I/O operations per second is specified
#
+# @image: the info of image used (since: 1.6)
+#
# Since: 0.14.0
#
# Notes: This interface is only found in @BlockInfo.
@@ -765,7 +770,8 @@
'*backing_file': 'str', 'backing_file_depth': 'int',
'encrypted': 'bool', 'encryption_key_missing': 'bool',
'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
- 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int'} }
+ 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
+ 'image': 'ImageInfo' } }
##
# @BlockDeviceIoStatus:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index ffd130e..8cea5e5 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1704,6 +1704,47 @@ Each json-object contain the following:
- "iops": limit total I/O operations per second (json-int)
- "iops_rd": limit read operations per second (json-int)
- "iops_wr": limit write operations per second (json-int)
+ - "image": the detail of the image, it is a json-object containing
+ the following:
+ - "filename": image file name (json-string)
+ - "format": image format (json-string)
+ - "virtual-size": image capacity in bytes (json-int)
+ - "dirty-flag": true if image is not cleanly closed, not present
+ means clean (json-bool, optional)
+ - "actual-size": actual size on disk in bytes of the image, not
+ present when image does not support thin
+ provision (json-int, optional)
+ - "cluster-size": size of a cluster in bytes, not present if image
+ format does not support it (json-int, optional)
+ - "encrypted": true if the image is encrypted, not present means
+ false or the image format does not support
+ encryption (json-bool, optional)
+ - "backing_file": backing file name, not present means no backing
+ file is used or the image format does not
+ support backing file chain
+ (json-string, optional)
+ - "full-backing-filename": full path of the backing file, not
+ present if it equals backing_file or no
+ backing file is used
+ (json-string, optional)
+ - "backing-filename-format": the format of the backing file, not
+ present means unknown or no backing
+ file (json-string, optional)
+ - "snapshots": the internal snapshot info, it is an optional list
+ of json-object containing the following:
+ - "id": unique snapshot id (json-string)
+ - "name": snapshot name (json-string)
+ - "vm-state-size": size of the VM state in bytes (json-int)
+ - "date-sec": UTC date of the snapshot in seconds (json-int)
+ - "date-nsec": fractional part in nanoseconds to be used with
+ date-sec(json-int)
+ - "vm-clock-sec": VM clock relative to boot in seconds
+ (json-int)
+ - "vm-clock-nsec": fractional part in nanoseconds to be used
+ with vm-clock-sec (json-int)
+ - "backing-image": the detail of the backing image, it is an
+ optional json-object only present when a
+ backing image present for this image
- "io-status": I/O operation status, only present if the device supports it
and the VM is configured to stop on errors. It's always reset
@@ -1724,14 +1765,38 @@ Example:
"ro":false,
"drv":"qcow2",
"encrypted":false,
- "file":"disks/test.img",
- "backing_file_depth":0,
+ "file":"disks/test.qcow2",
+ "backing_file_depth":1,
"bps":1000000,
"bps_rd":0,
"bps_wr":0,
"iops":1000000,
"iops_rd":0,
"iops_wr":0,
+ "image":{
+ "filename":"disks/test.qcow2",
+ "format":"qcow2",
+ "virtual-size":2048000,
+ "backing_file":"base.qcow2",
+ "full-backing-filename":"disks/base.qcow2",
+ "backing-filename-format:"qcow2",
+ "snapshots":[
+ {
+ "id": "1",
+ "name": "snapshot1",
+ "vm-state-size": 0,
+ "date-sec": 10000200,
+ "date-nsec": 12,
+ "vm-clock-sec": 206,
+ "vm-clock-nsec": 30
+ }
+ ],
+ "backing-image":{
+ "filename":"disks/base.qcow2",
+ "format":"qcow2",
+ "virtual-size":2048000
+ }
+ }
},
"type":"unknown"
},
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH V15 4/5] hmp: show ImageInfo in 'info block'
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
` (2 preceding siblings ...)
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 3/5] qmp: add ImageInfo in BlockDeviceInfo used by query-block Wenchao Xia
@ 2013-06-06 4:28 ` Wenchao Xia
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 5/5] hmp: add parameters device and -v for info block Wenchao Xia
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
Now human monitor can show image details, include internal
snapshot and backing chain info for every block device.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
hmp.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/hmp.c b/hmp.c
index 4fb76ec..2aa832c 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)
{
@@ -277,6 +278,7 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
void hmp_info_block(Monitor *mon, const QDict *qdict)
{
BlockInfoList *block_list, *info;
+ ImageInfo *image_info;
block_list = qmp_query_block(NULL);
@@ -318,6 +320,18 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
info->value->inserted->iops,
info->value->inserted->iops_rd,
info->value->inserted->iops_wr);
+
+ monitor_printf(mon, " images:\n");
+ image_info = info->value->inserted->image;
+ while (1) {
+ bdrv_image_info_dump((fprintf_function)monitor_printf, mon,
+ image_info);
+ if (image_info->has_backing_image) {
+ image_info = image_info->backing_image;
+ } else {
+ break;
+ }
+ }
} else {
monitor_printf(mon, " [not inserted]");
}
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH V15 5/5] hmp: add parameters device and -v for info block
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
` (3 preceding siblings ...)
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 4/5] hmp: show ImageInfo in 'info block' Wenchao Xia
@ 2013-06-06 4:28 ` Wenchao Xia
2013-06-06 6:42 ` [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Fam Zheng
2013-06-07 11:46 ` Stefan Hajnoczi
6 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 4:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, armbru, lcapitulino, stefanha, pbonzini, Wenchao Xia
With these parameters, user can choose the information to be showed,
to avoid message flood in the monitor.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
hmp.c | 25 ++++++++++++++++---------
monitor.c | 7 ++++---
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/hmp.c b/hmp.c
index 2aa832c..9e11e07 100644
--- a/hmp.c
+++ b/hmp.c
@@ -279,10 +279,15 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
{
BlockInfoList *block_list, *info;
ImageInfo *image_info;
+ const char *device = qdict_get_try_str(qdict, "device");
+ bool verbose = qdict_get_try_bool(qdict, "verbose", 0);
block_list = qmp_query_block(NULL);
for (info = block_list; info; info = info->next) {
+ if (device && strcmp(device, info->value->device)) {
+ continue;
+ }
monitor_printf(mon, "%s: removable=%d",
info->value->device, info->value->removable);
@@ -321,15 +326,17 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
info->value->inserted->iops_rd,
info->value->inserted->iops_wr);
- monitor_printf(mon, " images:\n");
- image_info = info->value->inserted->image;
- while (1) {
- bdrv_image_info_dump((fprintf_function)monitor_printf, mon,
- image_info);
- if (image_info->has_backing_image) {
- image_info = image_info->backing_image;
- } else {
- break;
+ if (verbose) {
+ monitor_printf(mon, " images:\n");
+ image_info = info->value->inserted->image;
+ while (1) {
+ bdrv_image_info_dump((fprintf_function)monitor_printf,
+ mon, image_info);
+ if (image_info->has_backing_image) {
+ image_info = image_info->backing_image;
+ } else {
+ break;
+ }
}
}
} else {
diff --git a/monitor.c b/monitor.c
index eefc7f0..80ad531 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2472,9 +2472,10 @@ static mon_cmd_t info_cmds[] = {
},
{
.name = "block",
- .args_type = "",
- .params = "",
- .help = "show the block devices",
+ .args_type = "verbose:-v,device:B?",
+ .params = "[-v] [device]",
+ .help = "show info of one block device or all block devices "
+ "(and details of images with -v option)",
.mhandler.cmd = hmp_info_block,
},
{
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
` (4 preceding siblings ...)
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 5/5] hmp: add parameters device and -v for info block Wenchao Xia
@ 2013-06-06 6:42 ` Fam Zheng
2013-06-06 8:44 ` Wenchao Xia
2013-06-07 11:46 ` Stefan Hajnoczi
6 siblings, 1 reply; 9+ messages in thread
From: Fam Zheng @ 2013-06-06 6:42 UTC (permalink / raw)
To: Wenchao Xia; +Cc: kwolf, armbru, qemu-devel, lcapitulino, stefanha, pbonzini
On Thu, 06/06 12:27, Wenchao Xia wrote:
> This series lets qmp interface show delaied info, including internal snapshot
Typo? s/delaied/detailed/
> /backing chain on all block device at runtime, which helps management stack and
> human user, by retrieving exactly the same info of what qemu sees.
>
> Example:
> -> { "execute": "query-block" }
Fam
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info
2013-06-06 6:42 ` [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Fam Zheng
@ 2013-06-06 8:44 ` Wenchao Xia
0 siblings, 0 replies; 9+ messages in thread
From: Wenchao Xia @ 2013-06-06 8:44 UTC (permalink / raw)
To: qemu-devel, kwolf, armbru, lcapitulino, stefanha, pbonzini
于 2013-6-6 14:42, Fam Zheng 写道:
> On Thu, 06/06 12:27, Wenchao Xia wrote:
>> This series lets qmp interface show delaied info, including internal snapshot
> Typo? s/delaied/detailed/
yep, it should be detailed, mistype.
>> /backing chain on all block device at runtime, which helps management stack and
>> human user, by retrieving exactly the same info of what qemu sees.
>>
>> Example:
>> -> { "execute": "query-block" }
>
> Fam
>
--
Best Regards
Wenchao Xia
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
` (5 preceding siblings ...)
2013-06-06 6:42 ` [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Fam Zheng
@ 2013-06-07 11:46 ` Stefan Hajnoczi
6 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2013-06-07 11:46 UTC (permalink / raw)
To: Wenchao Xia; +Cc: kwolf, qemu-devel, armbru, pbonzini, lcapitulino
On Thu, Jun 06, 2013 at 12:27:56PM +0800, Wenchao Xia wrote:
> This series lets qmp interface show delaied info, including internal snapshot
> /backing chain on all block device at runtime, which helps management stack and
> human user, by retrieving exactly the same info of what qemu sees.
[...]
> V15:
> Squash "add recursive member in ImageInfo" patch into 3/6.
> Address Stefan's comments:
> 5/5: use bool instead of int for variable "verbose".
>
> Wenchao Xia (5):
> 1 block: add snapshot info query function bdrv_query_snapshot_info_list()
> 2 block: add image info query function bdrv_query_image_info()
> 3 qmp: add ImageInfo in BlockDeviceInfo used by query-block
> 4 hmp: show ImageInfo in 'info block'
> 5 hmp: add parameters device and -v for info block
>
> block/qapi.c | 148 ++++++++++++++++++++++++++++++++++++++++++--------
> hmp.c | 21 +++++++
> include/block/qapi.h | 14 +++--
> monitor.c | 7 ++-
> qapi-schema.json | 10 +++-
> qemu-img.c | 10 +++-
> qmp-commands.hx | 69 +++++++++++++++++++++++-
> 7 files changed, 242 insertions(+), 37 deletions(-)
>
>
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-06-07 11:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-06 4:27 [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 1/5] block: add snapshot info query function bdrv_query_snapshot_info_list() Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 2/5] block: add image info query function bdrv_query_image_info() Wenchao Xia
2013-06-06 4:27 ` [Qemu-devel] [PATCH V15 3/5] qmp: add ImageInfo in BlockDeviceInfo used by query-block Wenchao Xia
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 4/5] hmp: show ImageInfo in 'info block' Wenchao Xia
2013-06-06 4:28 ` [Qemu-devel] [PATCH V15 5/5] hmp: add parameters device and -v for info block Wenchao Xia
2013-06-06 6:42 ` [Qemu-devel] [PATCH V15 0/5] enhancement for qmp/hmp interfaces of block info Fam Zheng
2013-06-06 8:44 ` Wenchao Xia
2013-06-07 11:46 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).