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> --- Changes in v3: - In fromC, iterate over the indirect of mvg instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 17d146771e..6c3868cd69 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -214,6 +214,27 @@ 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 { + for i := range *mvg { + mvg[i] = byte(cmvg.bytes[i]) + } + + return nil +} + +func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, error) { + var cmvg C.libxl_ms_vm_genid + + for i, v := range mvg { + cmvg.bytes[i] = C.uint8_t(v) + } + + return cmvg, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream -- 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel