Re: [PATCH v3 07/14] migration: refactor: introduce params version of unmanaged

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

 



On Fri, Sep 18, 2015 at 18:05:45 +0300, Nikolay Shirokovskiy wrote:
> Let's put main functionality into params version of virDomainMigrateUnmanaged
> as a preparation step for merging it with virDomainMigratePeer2PeerParams.
> virDomainMigrateUnmanaged then does nothing more then just adapting arguments.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
> ---
>  src/libvirt-domain.c |   92 +++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 61 insertions(+), 31 deletions(-)
> 
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index f52c3bf..330ccab 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
...
> +static int
> +virDomainMigrateUnmanaged(virDomainPtr domain,
> +                          const char *xmlin,
> +                          unsigned int flags,
> +                          const char *dname,
> +                          const char *dconnuri,
> +                          const char *miguri,
> +                          unsigned long long bandwidth)
> +{
> +    int ret = -1;
> +    virTypedParameterPtr params = NULL;
> +    int nparams = 0;
> +    int maxparams = 0;
> +
> +    if (virTypedParamsAddString(&params, &nparams, &maxparams,
> +                                VIR_MIGRATE_PARAM_URI, miguri) < 0 ||
> +        virTypedParamsAddString(&params, &nparams, &maxparams,
> +                                VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0 ||
> +        virTypedParamsAddString(&params, &nparams, &maxparams,
> +                                VIR_MIGRATE_PARAM_DEST_XML, xmlin) < 0 ||
> +        virTypedParamsAddULLong(&params, &nparams, &maxparams,
> +                                VIR_MIGRATE_PARAM_BANDWIDTH, bandwidth) < 0)
> +        goto cleanup;

All the *AddString calls should only be done when the appropriate value
is not NULL, otherwise *AddString will actually add "" into params and
thus you will get "" rather than NULL in virDomainMigrateUnmanagedParams.

In other words, something like

    if (miguri &&
        virTypedParamsAddString(&params, &nparams, &maxparams,
                                VIR_MIGRATE_PARAM_URI, miguri) < 0)
        goto cleanup;
    ...

Jirka

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]