From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: quintela@redhat.com, qemu-devel@nongnu.org,
peter.huangpeng@huawei.com, amit.shah@redhat.com,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] Adding new migration-parameters - any easier way?
Date: Tue, 23 Jun 2015 09:43:36 +0800 [thread overview]
Message-ID: <5588B9C8.9060800@huawei.com> (raw)
In-Reply-To: <87d20st8vt.fsf@blackfin.pond.sub.org>
On 2015/6/19 16:11, Markus Armbruster wrote:
> zhanghailiang <zhang.zhanghailiang@huawei.com> writes:
>
>> Hi,
>>
>> Is there any news about this discussion?
>> Is anyone working on it? ;)
>>
>> Since the 'hard feature freeze' time is closer, we'd better to fix it in 2.4
>> before libvirt uses it.
>>
>> I have sent a RFC patch "[RFC] migration: Re-implement 'migrate-set-parameters' to make it easily for extension"
>> http://patchwork.ozlabs.org/patch/482125/
>> Which just changes qmp command to
>> '{ "execute": "migrate-set-parameters" , "arguments":
>> { "compression": { "compress-level": 1 } } }',
>> Compared with its original way, it seems to be more easy for reading and extension, but
>> it can't address most problems discussed here...
>
>>From a QMP wire protocol point of view, @migrate-set-parameters is just
> fine as it is:
>
> #
> # @migrate-set-parameters
> #
> # Set the following migration parameters
> #
> # @compress-level: compression level
> #
> # @compress-threads: compression thread count
> #
> # @decompress-threads: decompression thread count
> #
> # Since: 2.4
> ##
> { 'command': 'migrate-set-parameters',
> 'data': { '*compress-level': 'int',
> '*compress-threads': 'int',
> '*decompress-threads': 'int'} }
>
> However, as the number of parameters grows, the generated C interface
> becomes more and more unwieldy:
>
> void qmp_migrate_set_parameters(bool has_compress_level,
> int64_t compress_level,
> bool has_compress_threads,
> int64_t compress_threads,
> bool has_decompress_threads,
> int64_t decompress_threads,
> ... more ...
> Error **errp)
>
Yes, this is the problem.
> Your [RFC PATCH] hides away some of the parameters in a separate
> MigrationCompressParameter (misnamed, should be plural). Leads to
>
> void qmp_migrate_set_parameters(bool has_compress,
> MigrationCompressParameters *compress,
> ... more ...
> Error **errp)
>
> Makes the QMP wire protocol more complex, because now you have to
> collect some parameters in extra curlies.
>
> Note the two levels of optionalness: one for the wrapping struct, one
> for each of its members. If you made the members non-optional, we'd
> have to specify none or all, which is not what we want. If you made the
> wrapping struct non-optional, you'd have to add a stupid 'compress': {}
> when you want to set something else. So we need both.
>
> In C, the relatively simple test has_compress_level becomes compress &&
> compress->has_level.
>
Hmm, i see, thanks for your explanation.
> If we ever want to set migration parameters from the command line, the
> nesting will be in the way. Our tool to parse command line into
> QAPI-generated data types (OptsVisitor) by design doesn't cope with
> nested structs.
>
> Perhaps the extra complexity is worthwhile, but it's certainly not
> obvious.
>
> If all we want is making adding new parameters easier (this thread's
> stated subject), then I guess having the function take a single struct
> parameter for all its arguments would do:
>
> void qmp_migrate_set_parameters(MigrationParameters *parms,
> Error **errp)
>
> To get that from the current QAPI code generator, we'd have to do
> something like
>
> { 'command': 'migrate-set-parameters',
> 'data': { 'parms': 'MigrationParameters' } }
>
> Trouble is this messes up the QMP wire interface: you now have to wrap
> the actual arguments in two curlies instead of one.
>
> Not a backward-compatibility issue, because the command is new.
>
> Ugly all the same.
>
> To avoid the ugliness, we could change the QAPI generator. Currently,
>
> { 'command': 'migrate-set-parameters',
> 'data': 'MigrationParameters' }
>
> generates the same interface as when you inline MigrationParameters,
> namely
>
> void qmp_migrate_set_parameters(bool has_compress_level,
> int64_t compress_level,
> bool has_compress_threads,
> int64_t compress_threads,
> bool has_decompress_threads,
> int64_t decompress_threads,
> ... more ...
> Error **errp)
>
> It could instead generate
>
> void qmp_migrate_set_parameters(MigrationParameters *parms,
> Error **errp)
>
> No change to the wire protocol. Fairly big, but relatively mechanical
> change to the handler functions. I'd be willing to give it a shot and
> see how it turns out, but I can't do it for 2.4, sorry.
>
Great, that would be fine~ Thanks.
next prev parent reply other threads:[~2015-06-23 1:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 9:50 [Qemu-devel] Adding new migration-parameters - any easier way? Dr. David Alan Gilbert
2015-06-05 10:23 ` Dr. David Alan Gilbert
2015-06-05 12:30 ` Eric Blake
2015-06-05 14:00 ` Dr. David Alan Gilbert
2015-06-08 12:48 ` Markus Armbruster
2015-06-08 14:57 ` Dr. David Alan Gilbert
2015-06-09 6:36 ` Markus Armbruster
2015-06-09 8:42 ` [Qemu-devel] qapi: What does "'gen': false" actually do, and when should I use it? (was: Adding new migration-parameters - any easier way?) Markus Armbruster
2015-06-19 10:40 ` [Qemu-devel] qapi: What does "'gen': false" actually do, and when should I use it? Paolo Bonzini
2015-07-02 12:07 ` Markus Armbruster
2015-07-02 12:32 ` Markus Armbruster
2015-06-17 10:46 ` [Qemu-devel] Adding new migration-parameters - any easier way? zhanghailiang
2015-06-19 8:11 ` Markus Armbruster
2015-06-23 1:43 ` zhanghailiang [this message]
2015-06-23 7:50 ` Markus Armbruster
2015-06-23 8:03 ` zhanghailiang
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=5588B9C8.9060800@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=amit.shah@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).