qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v6] qemu-img info lists bitmap directory entries


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH v6] qemu-img info lists bitmap directory entries
Date: Wed, 12 Dec 2018 12:58:26 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

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 <address@hidden>
---


+
+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 <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]