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

Re: [PATCH 1/4] golang/xenlight: add NameToDomid and DomidToName util functions


  • To: Nick Rosbrook <rosbrookn@xxxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Thu, 23 Apr 2020 10:21:05 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa5.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: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Ian Jackson <Ian.Jackson@xxxxxxxxxx>
  • Delivery-date: Thu, 23 Apr 2020 10:21:17 +0000
  • Ironport-sdr: P4ReK/0z2/dmlBVctSBcoBjuqdgwkuyGughgFn629lBWAV6pAYQdZI4j5rk1arYqoNuUyXxVcu 8TUi1VG3YMq9uX9eP2lH7ZQ5UE28ecSdIIynw2GNE37g5b3MllfLU3rpB9Q+HUe1QFihVHZUIb BysRo1ot3YoElvRecOhywT0ZpRRgEzhLgUbfmUTUWIYz8/1M7+74ZQ5M/OuZhhMkNlGHP5xOGK E1u+I9UeBQKpNNWlaWrINaDQHW0ekU8NXrekH5DszVDWV7sDIgvlOpXMhBZHZB7OpbMP2X3Z3R BCA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWERYbx3dgi/1zV0KyTdtBFGxU1KiFXiqAgAAbqgCAAPRDgA==
  • Thread-topic: [PATCH 1/4] golang/xenlight: add NameToDomid and DomidToName util functions


> On Apr 22, 2020, at 8:46 PM, Nick Rosbrook <rosbrookn@xxxxxxxxx> wrote:
> 
>> libxl.h defines INVALID_DOMID — do we want to define an exported constant 
>> with the same name and use that here?  (Although part of me wonders if 
>> DOMID_INVALID would be a better option.)
> 
> Yeah, that makes sense. I'll add that.
> 
>>> +     }
>>> +
>>> +     return Domid(domid), nil
>>> +}
>>> +
>>> +// DomidToName returns the name for a domain, given its domid.
>>> +func (Ctx *Context) DomidToName(domid Domid) string {
>>> +     cname := C.libxl_domid_to_name(Ctx.ctx, C.uint32_t(domid))
>>> +     defer C.free(unsafe.Pointer(cname))
>>> +
>>> +     return C.GoString(cname)
>>> +}
>> 
>> It looks to me like if the domid doesn’t exist, libxl_domid_to_name() will 
>> return NULL; and then DomidToName will return “”.  Is that what we want?
>> 
>> If so, it should probably be documented.
> 
> I considered returning an error if C.GoString(cname) == "". But, with
> these functions (as well as the others in these series), I opted to
> keep the signatures aligned with their libxl counterparts since we're
> keeping the package API mostly one-to-one with libxl. I can add a
> second return value if you prefer, otherwise I'll just add a note in
> the comment.

OK — adding a note in the comment is fine.  I mainly wanted to make sure the 
question had actually been considered (although of course documenting that 
behavior is also important).

Thanks,
 -George


 


Rackspace

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