On 12/11/18 6:51 AM, Andrey Shinkevich wrote:
In the 'Format specific information' section of the 'qemu-img info'
command output, the supplemental information about existing QCOW2
bitmaps will be shown, such as a bitmap name, flags and granularity:
image: /vz/vmprivate/VM1/harddisk.hdd
file format: qcow2
virtual size: 64G (68719476736 bytes)
disk size: 3.0M
cluster_size: 1048576
Format specific information:
compat: 1.1
lazy refcounts: true
bitmaps:
[0]:
flags:
[0]: in-use
[1]: auto
name: back-up1
unknown flags: 4
granularity: 65536
[1]:
flags:
[0]: in-use
[1]: auto
name: back-up2
unknown flags: 8
granularity: 65536
refcount bits: 16
corrupt: false
Signed-off-by: Andrey Shinkevich <andrey.shinkev...@virtuozzo.com>
---
+
+Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
+ Error **errp)
+{
Might be worth a function comment that this returns NULL...
+ BDRVQcow2State *s = bs->opaque;
+ Qcow2BitmapList *bm_list;
+ Qcow2Bitmap *bm;
+ Qcow2BitmapInfoList *list = NULL;
+ Qcow2BitmapInfoList **plist = &list;
+
+ if (s->nb_bitmaps == 0) {
+ return NULL;
+ }
...both when errp is clear (for a 0-length list in the QMP),
+
+ bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
+ s->bitmap_directory_size, errp);
+ if (bm_list == NULL) {
+ return NULL;
+ }
...and when errp is set (for a problem in obtaining the information, for
omitting the list in QMP).
+++ b/block/qcow2.c
@@ -4270,6 +4270,10 @@ static ImageInfoSpecific
*qcow2_get_specific_info(BlockDriverState *bs)
.refcount_bits = s->refcount_bits,
};
} else if (s->qcow_version == 3) {
+ Qcow2BitmapInfoList *bitmaps;
+ Error *local_err = NULL;
+
+ bitmaps = qcow2_get_bitmap_info_list(bs, &local_err);
*spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){
.compat = g_strdup("1.1"),
.lazy_refcounts = s->compatible_features &
@@ -4279,7 +4283,12 @@ static ImageInfoSpecific
*qcow2_get_specific_info(BlockDriverState *bs)
QCOW2_INCOMPAT_CORRUPT,
.has_corrupt = true,
.refcount_bits = s->refcount_bits,
+ .has_bitmaps = !local_err,
+ .bitmaps = bitmaps,
};
+ /* TODO: Report the Error up to the caller when
+ * an error propagation algorithm is implemented */
+ error_free(local_err);
Otherwise, this works for me. Up to John if he wants to add a comment
as part of staging this, or require a v7, but either way, I'm happy with:
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org