OSDN Git Service

hmp: Clean up and simplify hmp_migrate_set_parameter()
authorMarkus Armbruster <armbru@redhat.com>
Tue, 18 Jul 2017 09:23:08 +0000 (11:23 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 24 Jul 2017 11:35:11 +0000 (13:35 +0200)
commit7e91e82044f8d23acfb9949a2cdd667a6b239acd
tree4b6e393175aa5086df8a149684b644696c3fec5b
parentc42e8742f527476839bcc5f91c3d2ea456ca6a45
hmp: Clean up and simplify hmp_migrate_set_parameter()

The bulk of hmp_migrate_set_parameter()'s code sets one member of
MigrationParameters according to the command's arguments.  It uses a
string visitor for integer and boolean members, but not for string and
size members.  It calls visit_type_bool() right away, but delays
visit_type_int() some.  The delaying requires a flag variable and a
bit of trickery: we set all integer members instead of just the one we
want, and rely on the has_FOOs to mask the unwanted ones.

Clean this up as follows.  Don't delay calling visit_type_int().  Use
the string visitor for strings, too.  This involves extra allocations
and cleanup, but doing them is simpler and cleaner than avoiding them.

Sadly, using the string visitor for sizes isn't possible, because it
defaults to Bytes rather than Mebibytes.  Add a comment explaining
that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
hmp.c