|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 1/5] libxl: libxl_domain_need_memory shouldn't modify b_info
Wei Liu writes ("[PATCH v3 1/5] libxl: libxl_domain_need_memory shouldn't
modify b_info"):
> This function is used to return the memory needed for a guest. It's not
> in a position to modify the b_info passed in (note the _setdefault
> function).
>
> Use a copy of b_info to do the calculation. Define a macro to mark the
> change in API.
Urgh, how unpleasant.
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 5ec4c80..65af9ee 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -5123,20 +5123,24 @@ int libxl_domain_need_memory(libxl_ctx *ctx,
> libxl_domain_build_info *b_info,
> uint32_t *need_memkb)
> {
> GC_INIT(ctx);
> + libxl_domain_build_info tmp;
I would suggest, instead:
int libxl_domain_need_memory(libxl_ctx *ctx,
- libxl_domain_build_info *b_info,
+ const libxl_domain_build_info *b_info_in,
...
+ libxl_domain_build_info b_info[1];
If you do this then you do not need to change the bulk of the body of
the function at all.
> +/* LIBXL_HAVE_DOMAIN_NEED_MEMORY_V2
> + *
> + * If this is defined, libxl_domain_need_memory no longer modifies
> + * passed in b_info.
> + */
> +#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_V2
I suggest constifying it and
LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONST_B_INFO
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |