qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH for-2.10 10/10] migration: Use JSON null instead


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH for-2.10 10/10] migration: Use JSON null instead of "" to reset parameter to default
Date: Tue, 18 Jul 2017 12:46:35 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/18/2017 08:41 AM, Markus Armbruster wrote:
> migrate-set-parameters sets migration parameters according to is
> arguments like this:
> 
> * Present means "set the parameter to this value"
> 
> * Absent means "leave the parameter unchanged"
> 
> * Except for parameters tls_creds and tls_hostname, "" means "reset
>   the parameter to its default value
> 
> The first two are perfectly normal: presence of the parameter makes
> the command do something.
> 
> The third one overloads the parameter with a second meaning.  The
> overloading is *implicit*, i.e. it's not visible in the types.  Works
> here, because "" is neither a valid TLS credentials ID, nor a valid
> host name.
> 
> Pressing argument values the schema accepts, but are semantically
> invalid, into service to mean "reset to default" is not general, as
> suitable invalid values need not exist.  I also find it ugly.
> 
> To clean this up, we could add a separate flag argument to ask for
> "reset to default", or add a distinct value to @tls_creds and
> @tls_hostname.  This commit implements the latter: add JSON null to
> the values of @tls_creds and @tls_hostname, deprecate "".
> 
> Because we're so close to the 2.10 freeze, implement it in the
> stupidest way possible: have qmp_migrate_set_parameters() rewrite null
> to "" before anything else can see the null.  The proper way to do it
> would be rewriting "" to null, but that requires fixing up code to
> work with null.  Add TODO comments for that.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> +++ b/qapi-schema.json
> @@ -116,6 +116,13 @@
>  { 'command': 'qmp_capabilities' }
>  
>  ##
> +# @StrOrNull:

A little light on the documentation.

> +##
> +{ 'alternate': 'StrOrNull',
> +  'data': { 's': 'str',
> +            'n': 'null' } }
> +
> +##
>  # @LostTickPolicy:
>  #
>  # Policy for handling lost ticks in timer devices.
> @@ -1098,8 +1105,8 @@
>              '*decompress-threads': 'int',
>              '*cpu-throttle-initial': 'int',
>              '*cpu-throttle-increment': 'int',
> -            '*tls-creds': 'str',
> -            '*tls-hostname': 'str',
> +            '*tls-creds': 'StrOrNull',
> +            '*tls-hostname': 'StrOrNull',
>              '*max-bandwidth': 'int',
>              '*downtime-limit': 'int',
>              '*x-checkpoint-delay': 'int',

By splitting input from output, you guarantee that 'null' won't appear
in the output and break an unsuspecting client, but that new clients can
introspect the existence of null and use that instead of "" on input.

Reviewed-by: Eric Blake <address@hidden>

-- 
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]