|
From: | Leonid Bloch |
Subject: | Re: [Qemu-devel] [PATCH v3 3/5] qcow2: Introduce an option for sufficient L2 cache for the entire image |
Date: | Fri, 27 Jul 2018 00:51:35 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 07/27/2018 12:28 AM, Kevin Wolf wrote>
That makes sense. You probably need to clone the QDict before passing it to qcow2_update_options(), with qdict_clone_shallow().
Sounds like a solution! Great, thanks!
Can QAPI be the solution? I've seen some examples, and it looks liketheqcow2 driver already uses QAPI to some extent - I mean all the qdictstuffis from QAPI, no? Can you please point me to an example of how QAPIcansolve the issue of an option that can accept both a size and astring? By using QAPI I mean using types like BlockdevOptionsQcow2. These types are directly generated from the JSON schema, where it's possible to specify an alternate of a string and an integer. One example for an alternate in the JSON schema is BlockdevRef, where you can give a string (to reference a node-name) or an inline declaration of a block device. In JSON, it looks like this: { 'alternate': 'BlockdevRef', 'data': { 'definition': 'BlockdevOptions', 'reference': 'str' } } And the generated C type for it is: struct BlockdevRef { QType type; union { /* union tag is @type */ BlockdevOptions definition; char *reference; } u; }; In our case, we would get a union of int64_t and char* instead, and still the QType type as a discriminator.Thanks for the explanation! But qcow2 already has the options in the JSON file, they're just not used for some reason?The block layer configuration is a bit of a mess because of backwards compatibility. The JSON schema is in fact used for -blockdev and for the blockdev-add QMP command, but not for the old option -drive and drive_add. In the case of -blockdev/blockdev-add, after validating the input against the schema, the QAPI objects are converted to QDicts so they can use the same code path as the old code. Eventually, we want to use QAPI objects all the way, but that requires either expressing all -drive options in terms of QAPI object or getting rid of -driver altogether. This is still going to take some time.
Thanks for the details! It's clear now! Leonid.
Kevin
[Prev in Thread] | Current Thread | [Next in Thread] |