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

Re: [Xen-devel] [PATCH 1/5] Don't pass virDomainObjPtr to libxlBuildDomainConfig



Daniel P. Berrange wrote:
> To make it easier to unit test, change libxlBuildDomainConfig
> so that it takes 'virDomainDefPtr' and 'libxl_ctx *' objects
> as separate parameters.
>
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/libxl/libxl_conf.c   | 19 +++++++++----------
>  src/libxl/libxl_conf.h   |  4 +++-
>  src/libxl/libxl_domain.c |  3 ++-
>  3 files changed, 14 insertions(+), 12 deletions(-)
>   

ACK.

Regards,
Jim

> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index b7fed7f..a98e27a 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -567,10 +567,10 @@ libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
>  }
>  
>  static int
> -libxlMakeDomBuildInfo(virDomainObjPtr vm, libxl_domain_config *d_config)
> +libxlMakeDomBuildInfo(virDomainDefPtr def,
> +                      libxl_ctx *ctx,
> +                      libxl_domain_config *d_config)
>  {
> -    virDomainDefPtr def = vm->def;
> -    libxlDomainObjPrivatePtr priv = vm->privateData;
>      libxl_domain_build_info *b_info = &d_config->b_info;
>      int hvm = STREQ(def->os.type, "hvm");
>      size_t i;
> @@ -583,7 +583,7 @@ libxlMakeDomBuildInfo(virDomainObjPtr vm, 
> libxl_domain_config *d_config)
>          libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
>  
>      b_info->max_vcpus = def->maxvcpus;
> -    if (libxl_cpu_bitmap_alloc(priv->ctx, &b_info->avail_vcpus, 
> def->maxvcpus))
> +    if (libxl_cpu_bitmap_alloc(ctx, &b_info->avail_vcpus, def->maxvcpus))
>          goto error;
>      libxl_bitmap_set_none(&b_info->avail_vcpus);
>      for (i = 0; i < def->vcpus; i++)
> @@ -1306,17 +1306,16 @@ libxlMakeCapabilities(libxl_ctx *ctx)
>  
>  int
>  libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
> -                       virDomainObjPtr vm, libxl_domain_config *d_config)
> +                       virDomainDefPtr def,
> +                       libxl_ctx *ctx,
> +                       libxl_domain_config *d_config)
>  {
> -    virDomainDefPtr def = vm->def;
> -    libxlDomainObjPrivatePtr priv = vm->privateData;
> -
>      libxl_domain_config_init(d_config);
>  
> -    if (libxlMakeDomCreateInfo(priv->ctx, def, &d_config->c_info) < 0)
> +    if (libxlMakeDomCreateInfo(ctx, def, &d_config->c_info) < 0)
>          return -1;
>  
> -    if (libxlMakeDomBuildInfo(vm, d_config) < 0)
> +    if (libxlMakeDomBuildInfo(def, ctx, d_config) < 0)
>          return -1;
>  
>      if (libxlMakeDiskList(def, d_config) < 0)
> diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
> index 24e1720..1dd9de3 100644
> --- a/src/libxl/libxl_conf.h
> +++ b/src/libxl/libxl_conf.h
> @@ -160,7 +160,9 @@ libxlMakePCI(virDomainHostdevDefPtr hostdev, 
> libxl_device_pci *pcidev);
>  
>  int
>  libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
> -                       virDomainObjPtr vm, libxl_domain_config *d_config);
> +                       virDomainDefPtr def,
> +                       libxl_ctx *ctx,
> +                       libxl_domain_config *d_config);
>  
>  static inline void
>  libxlDriverLock(libxlDriverPrivatePtr driver)
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 80d5280..f95f8ce 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -1151,7 +1151,8 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
> virDomainObjPtr vm,
>  
>      libxl_domain_config_init(&d_config);
>  
> -    if (libxlBuildDomainConfig(driver, vm, &d_config) < 0)
> +    if (libxlBuildDomainConfig(driver, vm->def,
> +                               priv->ctx, &d_config) < 0)
>          goto endjob;
>  
>      if (cfg->autoballoon && libxlDomainFreeMem(priv, &d_config) < 0) {
>   

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.