|
[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
On Fri, Jul 08, 2016 at 06:35:59PM +0100, Ian Jackson wrote:
> 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.
>
This is a good idea.
Just that I discover there is another unpleasant fact: all the generated
copy function doesn't constify their source parameter. I will need to
write a patch to fix that first.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |