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

Re: [Xen-devel] [PATCH v2] golang/xenlight: Add libxl_utils support


  • To: Nicolas Belouin <nicolas.belouin@xxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Thu, 18 Jul 2019 21:54:52 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=George.Dunlap@xxxxxxxxxx; spf=Pass smtp.mailfrom=George.Dunlap@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 18 Jul 2019 21:55:00 +0000
  • Ironport-sdr: k/OBWeibHCVeuS4VwCvQDXBkpc5U/nlGtZAm+SPdQau0RAjqEYJ6zsQepA3hYvqp24gj0GvXKx ks8o9YK02AcRHM+WPdfkLqFIbvhyTv3U5NT8bZHpjYzVlWQqso6c0jjiDIZCsBsyBiQrweGe/n 15WFbWSlzteKLXWU64ZiRjLlYl1oPy9RmRhgmgDGM2ytwLm6a/nmgwW8qzFOqgpzBq+Jh4/RLo xqpVUvbnBhDPgrB3OGzuCjNm0TD/i/ZHfDCKV8efpC1x/12Uw5A2K8L1dCcH8fS6u9l0J6KMNH qhY=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVLYvHEU6KjG4cT0aCzUsgCJvyEKaxMkeAgAApqYCAH45KgA==
  • Thread-topic: [PATCH v2] golang/xenlight: Add libxl_utils support


> On Jun 28, 2019, at 9:01 PM, George Dunlap <george.dunlap@xxxxxxxxxx> wrote:
> 
> 
> 
>> On Jun 28, 2019, at 5:32 PM, George Dunlap <george.dunlap@xxxxxxxxxx> wrote:
>> 
>> On 6/28/19 9:25 AM, Nicolas Belouin wrote:
>>> The Go bindings for libxl miss functions from libxl_utils, let's start
>>> with the simple libxl_domid_to_name and its counterpart
>>> libxl_name_to_domid.
>>> 
>>> Signed-off-by: Nicolas Belouin <nicolas.belouin@xxxxxxxxx>
>> 
>> Just for future reference, below your SoB, it's good practice to put a
>> `---` line (below which everything will be ignored), and a list of the
>> changes you made.  E.g,:
>> 
>> Signed-off-by: Nicolas Belouin <nicolas.belouin@xxxxxxxxx>
>> ---
>> v2:
>> - Don't leak C string returned by libxl_domid_to_name
>> 
>> One more thing...
>> 
>>> +//char* libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid);
>>> +func (Ctx *Context) DomidToName(id Domid) (name string) {
>>> +   cDomName := C.libxl_domid_to_name(Ctx.ctx, C.uint32_t(id))
>>> +   defer C.free(unsafe.Pointer(cDomName))
>>> +
>>> +   name = C.GoString(cDomName)
>> 
>> libxl_domid_to_name() returns NULL if domid doesn't exist.  Will this
>> code DTRT (returning 'nil' in that case)?  Or will it crash / do
>> something else?
>> 
>> I couldn't actually find the answer in a quick search for the
>> documentation.  Any chance you could build a test program to see what
>> happens?
>> 
>> Alternately, we could play it safe and always check cDomName for `nil`
>> before passing it to C.GoString().
> 
> I just asked, and it turns out if C.GoString() is passed a nil pointer, it 
> returns the empty string (“”), which is what we want.  It’s not documented 
> yet, but there’s a ticket to document it soon.
> 
> https://github.com/golang/go/issues/32734
> 
> So this is ready to go in:

Actually, turns out it’s not:  You added a file, but it’s not wired into the 
build system.  You need to add xenlight_utils.go to PKGSOURCES in the Makefile. 
 I’ve just sent an updated patch.

 -George
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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