Re: [PATCH v2 07/12] migration: refactor: extract parameter adaption functions

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

 




On 09/10/2015 09:20 AM, Nikolay Shirokovskiy wrote:
> Extract parametes adapdation and checking which is protocol dependent into

s/parametes adapdation/parameter adaptation

> designated functions. Leave only branching and common checks in
> virDomainMigrateUnmanagedParams.
> 
> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
> ---
>  src/libvirt-domain.c |   84 +++++++++++++++++++++++++++++++++++++-------------
>  1 files changed, 62 insertions(+), 22 deletions(-)
> 

More code motion which seems OK to me, although the "Proto" could be
removed from function names for just Unmanaged3 and Unmanaged2, but I
suppose that name will be changing soon too so it's perhaps moot point.

John
> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index 79ed9f8..55efd49 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -3339,7 +3339,7 @@ virDomainMigratePeer2PeerParams(virDomainPtr domain,
>  }
>  
>  static int
> -virDomainMigrateUnmanagedParams(virDomainPtr domain,
> +virDomainMigrateUnmanagedProto2(virDomainPtr domain,
>                                  const char *dconnuri,
>                                  virTypedParameterPtr params,
>                                  int nparams,
> @@ -3362,6 +3362,63 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain,
>          return -1;
>      }
>  
> +    if (xmlin) {
> +        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> +                       _("Unable to change target guest XML during "
> +                         "migration"));
> +        return -1;
> +    }
> +
> +    if (flags & VIR_MIGRATE_PEER2PEER) {
> +        if (miguri) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                           _("Unable to override peer2peer migration URI"));
> +            return -1;
> +        }
> +        uri = dconnuri;
> +    } else {
> +        uri = miguri;
> +    }
> +
> +    return domain->conn->driver->domainMigratePerform
> +            (domain, NULL, 0, uri, flags, dname, bandwidth);
> +}
> +
> +static int
> +virDomainMigrateUnmanagedProto3(virDomainPtr domain,
> +                                const char *dconnuri,
> +                                virTypedParameterPtr params,
> +                                int nparams,
> +                                unsigned int flags)
> +{
> +    const char *miguri = NULL;
> +    const char *dname = NULL;
> +    const char *xmlin = NULL;
> +    unsigned long long bandwidth = 0;
> +
> +    if (virTypedParamsGetString(params, nparams,
> +                                VIR_MIGRATE_PARAM_URI, &miguri) < 0 ||
> +        virTypedParamsGetString(params, nparams,
> +                                VIR_MIGRATE_PARAM_DEST_NAME, &dname) < 0 ||
> +        virTypedParamsGetString(params, nparams,
> +                                VIR_MIGRATE_PARAM_DEST_XML, &xmlin) < 0 ||
> +        virTypedParamsGetULLong(params, nparams,
> +                                VIR_MIGRATE_PARAM_BANDWIDTH, &bandwidth) < 0) {
> +        return -1;
> +    }
> +
> +    return domain->conn->driver->domainMigratePerform3
> +            (domain, xmlin, NULL, 0, NULL, NULL, dconnuri,
> +             miguri, flags, dname, bandwidth);
> +}
> +
> +static int
> +virDomainMigrateUnmanagedParams(virDomainPtr domain,
> +                                const char *dconnuri,
> +                                virTypedParameterPtr params,
> +                                int nparams,
> +                                unsigned int flags)
> +{
>      VIR_DOMAIN_DEBUG(domain, "dconnuri=%s, params=%p, nparams=%d, flags=%x",
>                       dconnuri, params, nparams, flags);
>      VIR_TYPED_PARAMS_DEBUG(params, nparams);
> @@ -3376,33 +3433,16 @@ virDomainMigrateUnmanagedParams(virDomainPtr domain,
>              virReportUnsupportedError();
>              return -1;
>          }
> -        return domain->conn->driver->domainMigratePerform3
> -                (domain, xmlin, NULL, 0, NULL, NULL, dconnuri,
> -                 miguri, flags, dname, bandwidth);
> +        return virDomainMigrateUnmanagedProto3(domain, dconnuri,
> +                                               params, nparams, flags);
>      } else {
>          VIR_DEBUG("Using migration protocol 2");
>          if (!domain->conn->driver->domainMigratePerform) {
>              virReportUnsupportedError();
>              return -1;
>          }
> -        if (xmlin) {
> -            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
> -                           _("Unable to change target guest XML during "
> -                             "migration"));
> -            return -1;
> -        }
> -        if (flags & VIR_MIGRATE_PEER2PEER) {
> -            if (miguri) {
> -                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                               _("Unable to override peer2peer migration URI"));
> -                return -1;
> -            }
> -            uri = dconnuri;
> -        } else {
> -            uri = miguri;
> -        }
> -        return domain->conn->driver->domainMigratePerform
> -                (domain, NULL, 0, uri, flags, dname, bandwidth);
> +        return virDomainMigrateUnmanagedProto2(domain, dconnuri,
> +                                               params, nparams, flags);
>      }
>  }
>  
> 

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