From: Ronald Rojas <ronladred@gmail.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 3/5] golang/xenlight: Add host-related functionality
Date: Fri, 3 Mar 2017 13:49:40 -0500 [thread overview]
Message-ID: <20170303184940.GA9268@debian.rojas> (raw)
In-Reply-To: <0c50b07d-9c28-7c33-8ac0-b96883fb7ae2@citrix.com>
On Fri, Mar 03, 2017 at 02:54:56PM +0000, George Dunlap wrote:
> On 02/03/17 16:07, Ronald Rojas wrote:
> > Add calls for the following host-related functionality:
> > - libxl_get_max_cpus
> > - libxl_get_online_cpus
> > - libxl_get_max_nodes
> > - libxl_get_free_memory
> > - libxl_get_physinfo
> > - libxl_get_version_info
> >
> > Include Golang versions of the following structs:
> > - libxl_physinfo as Physinfo
> > - libxl_version_info as VersionInfo
> > - libxl_hwcap as Hwcap
> >
> > Signed-off-by: Ronald Rojas <ronladred@gmail.com>
>
> Looks good -- just two minor comments...
>
> > ---
> > Changes since last version
> >
> > - Refactored creating Physinfo and VersionInfo types into
> > seperate toGo() functions.
> >
> > - Used libxl_<type>_init() and libxl_<type>_dispose() on IDL
> > type physinfo
> >
> > - Whitespace fixes
> >
> > CC: xen-devel@lists.xen.org
> > CC: george.dunlap@citrix.com
> > CC: ian.jackson@eu.citrix.com
> > CC: wei.liu2@citrix.com
> > ---
> > ---
> > tools/golang/xenlight/xenlight.go | 200 ++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 200 insertions(+)
> >
> > diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go
> > index cbd3527..63cc805 100644
> > --- a/tools/golang/xenlight/xenlight.go
> > +++ b/tools/golang/xenlight/xenlight.go
> > @@ -106,6 +106,103 @@ type Context struct {
> > ctx *C.libxl_ctx
> > }
> >
> > +type Hwcap []C.uint32_t
> > +
> > +func (chwcap C.libxl_hwcap) CToGo() (ghwcap Hwcap) {
>
> Was there a reason you left this as CToGo() rather than just toGo()?
>
No. This should be changed to toGo()
[snip]
> > +//int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
> > +func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo, err error) {
> > + err = Ctx.CheckOpen()
> > + if err != nil {
> > + return
> > + }
> > + var cphys C.libxl_physinfo
> > + C.libxl_physinfo_init(&cphys)
> > +
> > + ret := C.libxl_get_physinfo(Ctx.ctx, &cphys)
> > +
> > + if ret < 0 {
> > + err = Error(ret)
> > + return
> > + }
> > + physinfo = cphys.toGo()
> > + C.libxl_physinfo_dispose(&cphys)
>
> I think it would probably be more idiomatic to write "defer
> C.libxl_physinfo_dispose()" just after the physinfo_init.
>
> If the init() actually allocated any memory, the current code would
> return without disposing of it if there was an error. `defer` avoids
> that by ensuring that *all* return paths call the clean-up function.
Yep. Using defer is the better approach here. I will change
it in all instances where I use the init/dispose functions.
>
> Other than that, looks great, thanks!
>
> -George
>
Thanks,
Ronald
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-03 18:49 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-02 16:07 [PATCH v2 1/5] golang/xenlight: Create stub package Ronald Rojas
2017-03-02 16:07 ` [PATCH v2 2/5] golang/xenlight: Add error constants and standard handling Ronald Rojas
2017-03-03 14:47 ` George Dunlap
2017-03-02 16:07 ` [PATCH v2 3/5] golang/xenlight: Add host-related functionality Ronald Rojas
2017-03-03 14:54 ` George Dunlap
2017-03-03 18:49 ` Ronald Rojas [this message]
2017-03-02 16:07 ` [PATCH v2 4/5] golang/xenlight: Implement libxl_domain_info and libxl_domain_unpause Ronald Rojas
2017-03-03 15:15 ` George Dunlap
2017-03-03 19:31 ` Ronald Rojas
2017-03-02 16:07 ` [PATCH v2 5/5] golang/xenlight: Add tests host related functionality functions Ronald Rojas
2017-03-02 17:36 ` Ian Jackson
2017-03-02 17:53 ` George Dunlap
2017-03-02 17:55 ` Ian Jackson
2017-03-02 18:01 ` George Dunlap
2017-03-03 15:02 ` Ian Jackson
2017-03-03 15:10 ` George Dunlap
2017-03-03 15:41 ` Ian Jackson
2017-03-02 18:22 ` Ronald Rojas
2017-03-03 16:20 ` George Dunlap
2017-03-03 14:42 ` [PATCH v2 1/5] golang/xenlight: Create stub package George Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170303184940.GA9268@debian.rojas \
--to=ronladred@gmail.com \
--cc=george.dunlap@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).