• M
    hmp: Clean up and simplify hmp_migrate_set_parameter() · 7e91e820
    Markus Armbruster 提交于
    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: NMarkus Armbruster <armbru@redhat.com>
    Reviewed-by: NDaniel P. Berrange <berrange@redhat.com>
    Reviewed-by: NDr. David Alan Gilbert <dgilbert@redhat.com>
    Reviewed-by: NEric Blake <eblake@redhat.com>
    7e91e820
hmp.c 87.9 KB