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

Re: [Xen-devel] [PATCH] libxl: correct libxl to obey libxl's programming paramdigm



Hi Wei,

2014-07-31 22:11 GMT+08:00 Wei Liu <wei.liu2@xxxxxxxxxx>:
On Wed, Jul 30, 2014 at 12:18:55PM -0400, Meng Xu wrote:
> When sched_domain_get() return rc != 0, scinfo will not be disposed.
> This violates the libxl programming paradigm:
> 272 Â* The user must always calls "dispose" exactly
> 273 Â* once afterwards, to clean up, regardless of whether operations
> on
> 274 Â* this object succeeded or failed.
>

I would remove the line number because the header file changes as much
sutffs added in.


âAgree and will remove it.â

Â
> Signed-off-by: Meng Xu <mengxu@xxxxxxxxxxxxx>
> ---
> Âtools/libxl/xl_cmdimpl.c | Â Â9 ++++++---
> Â1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 01bce2f..d1efdd7 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -5014,7 +5014,7 @@ static int sched_credit_domain_output(int domid)
> Â Â Â}
> Â Â Ârc = sched_domain_get(LIBXL_SCHEDULER_CREDIT, domid, &scinfo);
> Â Â Âif (rc)
> - Â Â Â Âreturn rc;
> + Â Â Â Âgoto out;
> Â Â Âdomname = libxl_domid_to_name(ctx, domid);
> Â Â Âprintf("%-33s %4d %6d %4d\n",
> Â Â Â Â Âdomname,
> @@ -5022,6 +5022,7 @@ static int sched_credit_domain_output(int domid)
> Â Â Â Â Âscinfo.weight,
> Â Â Â Â Âscinfo.cap);
> Â Â Âfree(domname);
> +out:
> Â Â Âlibxl_domain_sched_params_dispose(&scinfo);

And you seem to miss this part of that paradigm:

* IDL-generated libxl types should be used as follows: the user must
* always call the "init" function before using a type, even if the
* variable is simply being passed by reference as an out parameter
* to a libxl function.

So calling dispose in the end while not calling init at the beginning is
still bogus.

âI didn't call the init function at the beginning because the init function is called in the function âlibxl_domain_sched_params_get() at file tools/libxl/libxl.c.

My question is: should I call the init function again in xl_cmdimpl.c?Â
(Although calling it twice seems causing no damage, I'm not sure if it's a good idea.)

Thanks,

Meng


--


-----------
Meng Xu
PhD Student in Computer and Information Science
University of Pennsylvania
_______________________________________________
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®.