On 11/15/19 7:44 PM, Nick Rosbrook wrote: > From: Nick Rosbrook <rosbro...@ainfosec.com> > > Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC > and toC functions. > > Signed-off-by: Nick Rosbrook <rosbro...@ainfosec.com> > Reviewed-by: George Dunlap <george.dun...@citrix.com> > --- > tools/golang/xenlight/xenlight.go | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/tools/golang/xenlight/xenlight.go > b/tools/golang/xenlight/xenlight.go > index eb0d309543..108b50124a 100644 > --- a/tools/golang/xenlight/xenlight.go > +++ b/tools/golang/xenlight/xenlight.go > @@ -216,6 +216,29 @@ func (mac Mac) toC() (C.libxl_mac, error) { > return cmac, nil > } > > +// MsVmGenid represents a libxl_ms_vm_genid. > +type MsVmGenid [int(C.LIBXL_MS_VM_GENID_LEN)]byte > + > +func (mvg *MsVmGenid) fromC(cmvg *C.libxl_ms_vm_genid) error { > + b := > (*[int(C.LIBXL_MS_VM_GENID_LEN)]C.uint8_t)(unsafe.Pointer(&cmvg.bytes[0])) > + > + for i, v := range b { > + mvg[i] = byte(v) > + }
Sorry to come back to this -- is there a reason we can't just do something like this? func (u *Uuid) fromC(c *C.libxl_uuid) error { for i := range *u { u[i] = byte(c.uuid[i]) } return nil } I.e., the only reason we seem to be doing the cast is to have an appropriate type to range over; but we can just range over `*u` instead. -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel