All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
	"mreitz@redhat.com" <mreitz@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"jsnow@redhat.com" <jsnow@redhat.com>,
	Denis Lunev <den@virtuozzo.com>
Subject: Re: [Qemu-devel] [PATCH v5] qemu-img info lists bitmap directory entries
Date: Mon, 10 Dec 2018 18:50:09 +0000	[thread overview]
Message-ID: <34f9335a-1cd8-aa06-1fe7-0f2ab33515d0@virtuozzo.com> (raw)
In-Reply-To: <1544465367-16302-1-git-send-email-andrey.shinkevich@virtuozzo.com>

10.12.2018 21:09, 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:
> 

[...]

> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -4270,6 +4270,19 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
>               .refcount_bits      = s->refcount_bits,
>           };
>       } else if (s->qcow_version == 3) {
> +        bool has_bitmaps;
> +        Qcow2BitmapInfoList *bitmaps;
> +        Error *local_err = NULL;
> +
> +        bitmaps = qcow2_get_bitmap_info_list(bs, &local_err);
> +        if (local_err) {
> +            /* TODO: Report the Error up to the caller when implemented */
> +            error_free(local_err);
> +            /* The 'bitmaps' empty list designates a failure to get info */
> +            has_bitmaps = true;
> +        } else {
> +            has_bitmaps = !!bitmaps;
> +        }
>           *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){
>               .compat             = g_strdup("1.1"),
>               .lazy_refcounts     = s->compatible_features &
> @@ -4279,6 +4292,8 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs)
>                                     QCOW2_INCOMPAT_CORRUPT,
>               .has_corrupt        = true,
>               .refcount_bits      = s->refcount_bits,
> +            .has_bitmaps        = has_bitmaps,
> +            .bitmaps            = bitmaps,
>           };
>       } else {
>           /* if this assertion fails, this probably means a new version was

[..]

> index d4fe710..53820a5 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -69,6 +69,11 @@
>   # @encrypt: details about encryption parameters; only set if image
>   #           is encrypted (since 2.10)
>   #
> +# @bitmaps: list of qcow2 bitmaps details; the empty list designates
> +#           "fail to load bitmaps" if it is passed to the caller or
> +#           "no bitmaps" otherwise;
> +#           unsupported for the format QCOW2 v2 (since 4.0)


For me, it looks simpler to declare alternative approach, assuming that absence
of the field means error, like this:

@bitmaps: optional field with uncommon semantics:
           Absence of the field means that bitmaps info query failed (which doesn't
           imply the whole query failure).
           If the field exists in query results, there were no errors, and it represents
           list of qcow2 bitmaps details. So, successful result will always use empty
           list to show that there are no bitmaps.
           Note: bitmaps are not supported before QCOW2 v3, so for elder versions
           @bitmaps will always be an empty list.


The main question here: is it a first time, we are doing something like this? If not,
we must go the existing way.

I've found the only one similar thing:
in qapi/misc.json:
# If @unavailable-features is an empty list, the CPU model is
# runnable using the current host and machine-type.
# If @unavailable-features is not present, runnability
# information for the CPU is not available.

it's not about error, however..

Interesting what is the common (most common) behavior around empty-list/absent-parameter?


Aha, one point to my semantics:
we can define required field, without '*', and it implies that there should not be any errors,
and we don't have extra options (only empty list is possible to show absence of elements).
and than, '*' shows possibility of errors (if described in spec).

and with your semantics, if we want to say in general, that empty-list = error, we'll need to
use '*' for all fields, even for thous without possible errors.

(of course, we actually can not say something in general, because, I'm afraid, that we currently
have mixed semantics around empty lists)


> +#
>   # Since: 1.7
>   ##
>   { 'struct': 'ImageInfoSpecificQCow2',
> @@ -77,7 +82,8 @@
>         '*lazy-refcounts': 'bool',
>         '*corrupt': 'bool',
>         'refcount-bits': 'int',
> -      '*encrypt': 'ImageInfoSpecificQCow2Encryption'
> +      '*encrypt': 'ImageInfoSpecificQCow2Encryption',
> +      '*bitmaps': ['Qcow2BitmapInfo']
>     } }
>   
>   ##
> @@ -454,6 +460,41 @@
>              'status': 'DirtyBitmapStatus'} }
>   



-- 
Best regards,
Vladimir

  reply	other threads:[~2018-12-10 18:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 18:09 [Qemu-devel] [PATCH v5] qemu-img info lists bitmap directory entries Andrey Shinkevich
2018-12-10 18:50 ` Vladimir Sementsov-Ogievskiy [this message]
2018-12-10 19:48   ` Eric Blake
2018-12-11 12:57     ` Andrey Shinkevich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34f9335a-1cd8-aa06-1fe7-0f2ab33515d0@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.