|
|
218e99 |
From 5c10b431d0dd4538d33c21d7a46f7c8754f42a83 Mon Sep 17 00:00:00 2001
|
|
|
218e99 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Date: Wed, 6 Nov 2013 16:53:29 +0100
|
|
|
218e99 |
Subject: [PATCH 72/87] qmp: add ImageInfo in BlockDeviceInfo used by query-block
|
|
|
218e99 |
|
|
|
218e99 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
Message-id: <1383756824-6921-7-git-send-email-mreitz@redhat.com>
|
|
|
218e99 |
Patchwork-id: 55561
|
|
|
218e99 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 06/21] qmp: add ImageInfo in BlockDeviceInfo used by query-block
|
|
|
218e99 |
Bugzilla: 980771
|
|
|
218e99 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
218e99 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
218e99 |
|
|
|
218e99 |
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
218e99 |
|
|
|
218e99 |
BZ: 980771
|
|
|
218e99 |
|
|
|
218e99 |
Now image info will be retrieved as an embbed json object inside
|
|
|
218e99 |
BlockDeviceInfo, backing chain info and all related internal snapshot
|
|
|
218e99 |
info can be got in the enhanced recursive structure of ImageInfo. New
|
|
|
218e99 |
recursive member *backing-image is added to reflect the backing chain
|
|
|
218e99 |
status.
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
218e99 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
218e99 |
(cherry picked from commit 553a7e871822d933beaefbd596f0e4eed1614373)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/qapi.c | 50 ++++++++++++++++++++++++++++++++++---
|
|
|
218e99 |
include/block/qapi.h | 4 ++-
|
|
|
218e99 |
qapi-schema.json | 10 ++++++--
|
|
|
218e99 |
qmp-commands.hx | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
218e99 |
4 files changed, 125 insertions(+), 8 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
218e99 |
---
|
|
|
218e99 |
block/qapi.c | 50 ++++++++++++++++++++++++++++++++++--
|
|
|
218e99 |
include/block/qapi.h | 4 ++-
|
|
|
218e99 |
qapi-schema.json | 10 ++++++-
|
|
|
218e99 |
qmp-commands.hx | 69 ++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
218e99 |
4 files changed, 125 insertions(+), 8 deletions(-)
|
|
|
218e99 |
|
|
|
218e99 |
diff --git a/block/qapi.c b/block/qapi.c
|
|
|
218e99 |
index e9d8b74..a4bc411 100644
|
|
|
218e99 |
--- a/block/qapi.c
|
|
|
218e99 |
+++ b/block/qapi.c
|
|
|
218e99 |
@@ -94,6 +94,13 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
|
|
|
218e99 |
* @p_info: location to store image information
|
|
|
218e99 |
* @errp: location to store error information
|
|
|
218e99 |
*
|
|
|
218e99 |
+ * Store "flat" image information in @p_info.
|
|
|
218e99 |
+ *
|
|
|
218e99 |
+ * "Flat" means it does *not* query backing image information,
|
|
|
218e99 |
+ * i.e. (*pinfo)->has_backing_image will be set to false and
|
|
|
218e99 |
+ * (*pinfo)->backing_image to NULL even when the image does in fact have
|
|
|
218e99 |
+ * a backing image.
|
|
|
218e99 |
+ *
|
|
|
218e99 |
* @p_info will be set only on success. On error, store error in @errp.
|
|
|
218e99 |
*/
|
|
|
218e99 |
void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
218e99 |
@@ -167,9 +174,15 @@ void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
218e99 |
*p_info = info;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
-BlockInfo *bdrv_query_info(BlockDriverState *bs)
|
|
|
218e99 |
+/* @p_info will be set only on success. */
|
|
|
218e99 |
+void bdrv_query_info(BlockDriverState *bs,
|
|
|
218e99 |
+ BlockInfo **p_info,
|
|
|
218e99 |
+ Error **errp)
|
|
|
218e99 |
{
|
|
|
218e99 |
BlockInfo *info = g_malloc0(sizeof(*info));
|
|
|
218e99 |
+ BlockDriverState *bs0;
|
|
|
218e99 |
+ ImageInfo **p_image_info;
|
|
|
218e99 |
+ Error *local_err = NULL;
|
|
|
218e99 |
info->device = g_strdup(bs->device_name);
|
|
|
218e99 |
info->type = g_strdup("unknown");
|
|
|
218e99 |
info->locked = bdrv_dev_is_medium_locked(bs);
|
|
|
218e99 |
@@ -223,8 +236,30 @@ BlockInfo *bdrv_query_info(BlockDriverState *bs)
|
|
|
218e99 |
info->inserted->iops_wr =
|
|
|
218e99 |
bs->io_limits.iops[BLOCK_IO_LIMIT_WRITE];
|
|
|
218e99 |
}
|
|
|
218e99 |
+
|
|
|
218e99 |
+ bs0 = bs;
|
|
|
218e99 |
+ p_image_info = &info->inserted->image;
|
|
|
218e99 |
+ while (1) {
|
|
|
218e99 |
+ bdrv_query_image_info(bs0, p_image_info, &local_err);
|
|
|
218e99 |
+ if (error_is_set(&local_err)) {
|
|
|
218e99 |
+ error_propagate(errp, local_err);
|
|
|
218e99 |
+ goto err;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ if (bs0->drv && bs0->backing_hd) {
|
|
|
218e99 |
+ bs0 = bs0->backing_hd;
|
|
|
218e99 |
+ (*p_image_info)->has_backing_image = true;
|
|
|
218e99 |
+ p_image_info = &((*p_image_info)->backing_image);
|
|
|
218e99 |
+ } else {
|
|
|
218e99 |
+ break;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ }
|
|
|
218e99 |
}
|
|
|
218e99 |
- return info;
|
|
|
218e99 |
+
|
|
|
218e99 |
+ *p_info = info;
|
|
|
218e99 |
+ return;
|
|
|
218e99 |
+
|
|
|
218e99 |
+ err:
|
|
|
218e99 |
+ qapi_free_BlockInfo(info);
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
BlockStats *bdrv_query_stats(const BlockDriverState *bs)
|
|
|
218e99 |
@@ -261,16 +296,25 @@ BlockInfoList *qmp_query_block(Error **errp)
|
|
|
218e99 |
{
|
|
|
218e99 |
BlockInfoList *head = NULL, **p_next = &head;
|
|
|
218e99 |
BlockDriverState *bs = NULL;
|
|
|
218e99 |
+ Error *local_err = NULL;
|
|
|
218e99 |
|
|
|
218e99 |
while ((bs = bdrv_next(bs))) {
|
|
|
218e99 |
BlockInfoList *info = g_malloc0(sizeof(*info));
|
|
|
218e99 |
- info->value = bdrv_query_info(bs);
|
|
|
218e99 |
+ bdrv_query_info(bs, &info->value, &local_err);
|
|
|
218e99 |
+ if (error_is_set(&local_err)) {
|
|
|
218e99 |
+ error_propagate(errp, local_err);
|
|
|
218e99 |
+ goto err;
|
|
|
218e99 |
+ }
|
|
|
218e99 |
|
|
|
218e99 |
*p_next = info;
|
|
|
218e99 |
p_next = &info->next;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
return head;
|
|
|
218e99 |
+
|
|
|
218e99 |
+ err:
|
|
|
218e99 |
+ qapi_free_BlockInfoList(head);
|
|
|
218e99 |
+ return NULL;
|
|
|
218e99 |
}
|
|
|
218e99 |
|
|
|
218e99 |
BlockStatsList *qmp_query_blockstats(Error **errp)
|
|
|
218e99 |
diff --git a/include/block/qapi.h b/include/block/qapi.h
|
|
|
218e99 |
index ab1f48f..0496cc9 100644
|
|
|
218e99 |
--- a/include/block/qapi.h
|
|
|
218e99 |
+++ b/include/block/qapi.h
|
|
|
218e99 |
@@ -35,7 +35,9 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
|
|
|
218e99 |
void bdrv_query_image_info(BlockDriverState *bs,
|
|
|
218e99 |
ImageInfo **p_info,
|
|
|
218e99 |
Error **errp);
|
|
|
218e99 |
-BlockInfo *bdrv_query_info(BlockDriverState *s);
|
|
|
218e99 |
+void bdrv_query_info(BlockDriverState *bs,
|
|
|
218e99 |
+ BlockInfo **p_info,
|
|
|
218e99 |
+ Error **errp);
|
|
|
218e99 |
BlockStats *bdrv_query_stats(const BlockDriverState *bs);
|
|
|
218e99 |
|
|
|
218e99 |
void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f,
|
|
|
218e99 |
diff --git a/qapi-schema.json b/qapi-schema.json
|
|
|
218e99 |
index 32b41b0..4091b99 100644
|
|
|
218e99 |
--- a/qapi-schema.json
|
|
|
218e99 |
+++ b/qapi-schema.json
|
|
|
218e99 |
@@ -236,6 +236,8 @@
|
|
|
218e99 |
#
|
|
|
218e99 |
# @snapshots: #optional list of VM snapshots
|
|
|
218e99 |
#
|
|
|
218e99 |
+# @backing-image: #optional info of the backing image (since 1.6)
|
|
|
218e99 |
+#
|
|
|
218e99 |
# Since: 1.3
|
|
|
218e99 |
#
|
|
|
218e99 |
##
|
|
|
218e99 |
@@ -245,7 +247,8 @@
|
|
|
218e99 |
'*actual-size': 'int', 'virtual-size': 'int',
|
|
|
218e99 |
'*cluster-size': 'int', '*encrypted': 'bool',
|
|
|
218e99 |
'*backing-filename': 'str', '*full-backing-filename': 'str',
|
|
|
218e99 |
- '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'] } }
|
|
|
218e99 |
+ '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'],
|
|
|
218e99 |
+ '*backing-image': 'ImageInfo' } }
|
|
|
218e99 |
|
|
|
218e99 |
##
|
|
|
218e99 |
# @ImageCheck:
|
|
|
218e99 |
@@ -768,6 +771,8 @@
|
|
|
218e99 |
#
|
|
|
218e99 |
# @iops_wr: write I/O operations per second is specified
|
|
|
218e99 |
#
|
|
|
218e99 |
+# @image: the info of image used (since: 1.6)
|
|
|
218e99 |
+#
|
|
|
218e99 |
# Since: 0.14.0
|
|
|
218e99 |
#
|
|
|
218e99 |
# Notes: This interface is only found in @BlockInfo.
|
|
|
218e99 |
@@ -777,7 +782,8 @@
|
|
|
218e99 |
'*backing_file': 'str', 'backing_file_depth': 'int',
|
|
|
218e99 |
'encrypted': 'bool', 'encryption_key_missing': 'bool',
|
|
|
218e99 |
'bps': 'int', 'bps_rd': 'int', 'bps_wr': 'int',
|
|
|
218e99 |
- 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int'} }
|
|
|
218e99 |
+ 'iops': 'int', 'iops_rd': 'int', 'iops_wr': 'int',
|
|
|
218e99 |
+ 'image': 'ImageInfo' } }
|
|
|
218e99 |
|
|
|
218e99 |
##
|
|
|
218e99 |
# @BlockDeviceIoStatus:
|
|
|
218e99 |
diff --git a/qmp-commands.hx b/qmp-commands.hx
|
|
|
218e99 |
index d1f6f8b..f71c34e 100644
|
|
|
218e99 |
--- a/qmp-commands.hx
|
|
|
218e99 |
+++ b/qmp-commands.hx
|
|
|
218e99 |
@@ -1713,6 +1713,47 @@ Each json-object contain the following:
|
|
|
218e99 |
- "iops": limit total I/O operations per second (json-int)
|
|
|
218e99 |
- "iops_rd": limit read operations per second (json-int)
|
|
|
218e99 |
- "iops_wr": limit write operations per second (json-int)
|
|
|
218e99 |
+ - "image": the detail of the image, it is a json-object containing
|
|
|
218e99 |
+ the following:
|
|
|
218e99 |
+ - "filename": image file name (json-string)
|
|
|
218e99 |
+ - "format": image format (json-string)
|
|
|
218e99 |
+ - "virtual-size": image capacity in bytes (json-int)
|
|
|
218e99 |
+ - "dirty-flag": true if image is not cleanly closed, not present
|
|
|
218e99 |
+ means clean (json-bool, optional)
|
|
|
218e99 |
+ - "actual-size": actual size on disk in bytes of the image, not
|
|
|
218e99 |
+ present when image does not support thin
|
|
|
218e99 |
+ provision (json-int, optional)
|
|
|
218e99 |
+ - "cluster-size": size of a cluster in bytes, not present if image
|
|
|
218e99 |
+ format does not support it (json-int, optional)
|
|
|
218e99 |
+ - "encrypted": true if the image is encrypted, not present means
|
|
|
218e99 |
+ false or the image format does not support
|
|
|
218e99 |
+ encryption (json-bool, optional)
|
|
|
218e99 |
+ - "backing_file": backing file name, not present means no backing
|
|
|
218e99 |
+ file is used or the image format does not
|
|
|
218e99 |
+ support backing file chain
|
|
|
218e99 |
+ (json-string, optional)
|
|
|
218e99 |
+ - "full-backing-filename": full path of the backing file, not
|
|
|
218e99 |
+ present if it equals backing_file or no
|
|
|
218e99 |
+ backing file is used
|
|
|
218e99 |
+ (json-string, optional)
|
|
|
218e99 |
+ - "backing-filename-format": the format of the backing file, not
|
|
|
218e99 |
+ present means unknown or no backing
|
|
|
218e99 |
+ file (json-string, optional)
|
|
|
218e99 |
+ - "snapshots": the internal snapshot info, it is an optional list
|
|
|
218e99 |
+ of json-object containing the following:
|
|
|
218e99 |
+ - "id": unique snapshot id (json-string)
|
|
|
218e99 |
+ - "name": snapshot name (json-string)
|
|
|
218e99 |
+ - "vm-state-size": size of the VM state in bytes (json-int)
|
|
|
218e99 |
+ - "date-sec": UTC date of the snapshot in seconds (json-int)
|
|
|
218e99 |
+ - "date-nsec": fractional part in nanoseconds to be used with
|
|
|
218e99 |
+ date-sec(json-int)
|
|
|
218e99 |
+ - "vm-clock-sec": VM clock relative to boot in seconds
|
|
|
218e99 |
+ (json-int)
|
|
|
218e99 |
+ - "vm-clock-nsec": fractional part in nanoseconds to be used
|
|
|
218e99 |
+ with vm-clock-sec (json-int)
|
|
|
218e99 |
+ - "backing-image": the detail of the backing image, it is an
|
|
|
218e99 |
+ optional json-object only present when a
|
|
|
218e99 |
+ backing image present for this image
|
|
|
218e99 |
|
|
|
218e99 |
- "io-status": I/O operation status, only present if the device supports it
|
|
|
218e99 |
and the VM is configured to stop on errors. It's always reset
|
|
|
218e99 |
@@ -1733,14 +1774,38 @@ Example:
|
|
|
218e99 |
"ro":false,
|
|
|
218e99 |
"drv":"qcow2",
|
|
|
218e99 |
"encrypted":false,
|
|
|
218e99 |
- "file":"disks/test.img",
|
|
|
218e99 |
- "backing_file_depth":0,
|
|
|
218e99 |
+ "file":"disks/test.qcow2",
|
|
|
218e99 |
+ "backing_file_depth":1,
|
|
|
218e99 |
"bps":1000000,
|
|
|
218e99 |
"bps_rd":0,
|
|
|
218e99 |
"bps_wr":0,
|
|
|
218e99 |
"iops":1000000,
|
|
|
218e99 |
"iops_rd":0,
|
|
|
218e99 |
"iops_wr":0,
|
|
|
218e99 |
+ "image":{
|
|
|
218e99 |
+ "filename":"disks/test.qcow2",
|
|
|
218e99 |
+ "format":"qcow2",
|
|
|
218e99 |
+ "virtual-size":2048000,
|
|
|
218e99 |
+ "backing_file":"base.qcow2",
|
|
|
218e99 |
+ "full-backing-filename":"disks/base.qcow2",
|
|
|
218e99 |
+ "backing-filename-format:"qcow2",
|
|
|
218e99 |
+ "snapshots":[
|
|
|
218e99 |
+ {
|
|
|
218e99 |
+ "id": "1",
|
|
|
218e99 |
+ "name": "snapshot1",
|
|
|
218e99 |
+ "vm-state-size": 0,
|
|
|
218e99 |
+ "date-sec": 10000200,
|
|
|
218e99 |
+ "date-nsec": 12,
|
|
|
218e99 |
+ "vm-clock-sec": 206,
|
|
|
218e99 |
+ "vm-clock-nsec": 30
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ ],
|
|
|
218e99 |
+ "backing-image":{
|
|
|
218e99 |
+ "filename":"disks/base.qcow2",
|
|
|
218e99 |
+ "format":"qcow2",
|
|
|
218e99 |
+ "virtual-size":2048000
|
|
|
218e99 |
+ }
|
|
|
218e99 |
+ }
|
|
|
218e99 |
},
|
|
|
218e99 |
"type":"unknown"
|
|
|
218e99 |
},
|
|
|
218e99 |
--
|
|
|
218e99 |
1.7.1
|
|
|
218e99 |
|