On 10/7/19 4:12 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> > --- > Cc: George Dunlap <george.dun...@citrix.com> > Cc: Ian Jackson <ian.jack...@eu.citrix.com> > Cc: Wei Liu <w...@xen.org> > > 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 3b7824b284..6aca5b89c0 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) > + }
It's slightly annoying to have to do this loop, but I guess given that we have to technically cast each element of the array. Hopefully the compiler will eventually be able to figure out what's going on here and just do a memcpy. > + > + return nil > +} > + > +func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, error) { Hmm, I guess we want a pointer receiver here to make sure we don't end up doing a 16-byte copy. Reviewed-by: George Dunlap <george.dun...@citrix.com> -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel