[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 4/7] nbd: Update qapi to support exporting multiple bitmap
From: |
Markus Armbruster |
Subject: |
Re: [PATCH v4 4/7] nbd: Update qapi to support exporting multiple bitmaps |
Date: |
Tue, 20 Oct 2020 10:51:37 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Eric Blake <eblake@redhat.com> writes:
> On 10/14/20 7:15 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 10.10.2020 00:55, Eric Blake wrote:
>>> Since 'nbd-server-add' is deprecated, and 'block-export-add' is new to
>>> 5.2, we can still tweak the interface. Allowing 'bitmaps':['str'] is
>>> nicer than 'bitmap':'str'. This wires up the qapi and qemu-nbd
>>> changes to permit passing multiple bitmaps as distinct metadata
>>> contexts that the NBD client may request, but the actual support for
>>> more than one will require a further patch to the server.
>>>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>> ---
>> [..]
>>
>>> break;
>>> case 'B':
>>> - bitmap = optarg;
>>> + tmp = g_new(strList, 1);
>>> + tmp->value = g_strdup(optarg);
>>> + tmp->next = bitmaps;
>>> + bitmaps = tmp;
>> If publish QAPI_LIST_ADD, defined in block.c, it would look like:
>> QAPI_LIST_ADD(bitmaps, g_strdup(optarg));
>
> #define QAPI_LIST_ADD(list, element) do { \
> typeof(list) _tmp = g_new(typeof(*(list)), 1); \
> _tmp->value = (element); \
> _tmp->next = (list); \
> (list) = _tmp; \
> } while (0)
>
>
> Markus, thoughts on if we should publish this macro,
If it's widely useful.
"git-grep -- '->value ='" matches ~200 times. A patch converting these
to the macro where possible would make a strong case for having the
macro.
> and if so, which
> header would be best?
The macro is generic: @list's type may be any of the struct TYPEList we
generate for the QAPI type ['TYPE'].
We don't want to generate this macro next to each of these struct
definitions. A non-generic macro would go there, but let's not generate
almost a hundred non-generic macros where a single generic one can do
the job.
The closest we have to a common base is GenericList. It's in in
visitor.h because it's only used by visitors so far. Adding the macro
next it is not so smart, because we don't want non-visitor code to
include visitor.h just for this macro.
Perhaps the macro should go into qapi/util.h, and perhaps GenericList
and GenericAlternate should move there, too.
[...]
- Re: [PATCH v4 1/7] nbd: Utilize QAPI_CLONE for type conversion, (continued)
[PATCH v4 5/7] nbd: Simplify qemu bitmap context name, Eric Blake, 2020/10/09
[PATCH v4 7/7] nbd: Allow export of multiple bitmaps for one device, Eric Blake, 2020/10/09
Message not available