qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH V2 5/8] block/qcow2: read and write the compress


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH V2 5/8] block/qcow2: read and write the compress format extension
Date: Thu, 13 Jul 2017 10:21:56 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/13/2017 10:13 AM, Peter Lieven wrote:
>>>>>>
>>>>>>> I currently have the following:
>>>>>>>
>>>>>>>        options = qemu_opts_to_qdict(opts, NULL);
>>>>>>>        qdict_extract_subqdict(options, &compressopts, "compress.");

Can you show your .json patches as well?

> Yes, but visit_type_Qcow2Compress_members always returns an error if
> compress.format
> is missing from the options. So I should not call it an error out if
> compress.format is not in the
> options. Thus the check if either compress.format or compress.level is
> specified at all.

In the JSON, you want '*compress':'CompressUnion' (or some such name)
(overall, the user does not have to specify compression); but within
CompressUnion, you want 'format' to be unconditional (it is the
discriminator), and then branches of the union to add whatever other
fields match the enum members covered by 'format'.

{ 'enum': 'CompressionType', 'data': [ 'gzip', 'lzo' ] }
{ 'union': 'CompressUnion', 'discriminator': 'format',
  'base': { 'format': 'CompressionType', '*level': 'int' },
  'data': { 'gzip': {...any gzip-specific extras}, 'lzo': {...any
lzo-specific extras} } }

[hmm, I think I'm STILL missing my patches to allow for an anonymous
base...  I should rebase and send those; but in the meantime, you'll
have to create a separate 'CompressBase' struct and use
'base':'CompressBase' instead]

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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