On 07/21/2016 01:40 PM, Denis V. Lunev wrote:
> From: Pavel Butsykin <pbutsy...@virtuozzo.com>
> 
> Now that we can support boxed commands, use it to greatly reduce the
> number of parameters (and likelihood of getting out of sync) when
> adjusting drive-backup parameters..

s/.././

> 
> Signed-off-by: Pavel Butsykin <pbutsy...@virtuozzo.com>
> Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
> Signed-off-by: Denis V. Lunev <d...@openvz.org>
> CC: Jeff Cody <jc...@redhat.com>
> CC: Markus Armbruster <arm...@redhat.com>
> CC: Eric Blake <ebl...@redhat.com>
> CC: John Snow <js...@redhat.com>
> CC: Stefan Hajnoczi <stefa...@redhat.com>
> CC: Kevin Wolf <kw...@redhat.com>
> ---
>  blockdev.c           | 115 
> +++++++++++++++++----------------------------------
>  hmp.c                |  29 ++++++++-----
>  qapi/block-core.json |   3 +-
>  3 files changed, 58 insertions(+), 89 deletions(-)
> 

> +++ b/hmp.c
> @@ -1109,8 +1109,24 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
>      const char *format = qdict_get_try_str(qdict, "format");
>      bool reuse = qdict_get_try_bool(qdict, "reuse", false);
>      bool full = qdict_get_try_bool(qdict, "full", false);
> -    enum NewImageMode mode;
>      Error *err = NULL;
> +    DriveBackup backup = {
> +        .device = (char *)device,
> +        .target = (char *)filename,
> +        .has_format = !!format,
> +        .format = (char *)format,
> +        .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
> +        .has_mode = true,
> +        .mode = reuse ? NEW_IMAGE_MODE_EXISTING : 
> NEW_IMAGE_MODE_ABSOLUTE_PATHS,

Good.

> +        .has_speed = false,
> +        .speed = 0,
> +        .has_bitmap = false,
> +        .bitmap = NULL,
> +        .has_on_source_error = false,
> +        .on_source_error = 0,
> +        .has_on_target_error = false,
> +        .on_target_error = 0,

I'd drop these. C guarantees that they'll be zero-initialized, and
unless HMP has a way to set them to non-default values, it's not worth
wasting the lines of code.

With those fixups,
Reviewed-by: Eric Blake <ebl...@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to