]> xenbits.xensource.com Git - xen.git/commitdiff
golang/xenlight: define MsVmGenid builtin type
authorNick Rosbrook <rosbrookn@ainfosec.com>
Mon, 16 Dec 2019 18:08:04 +0000 (18:08 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Mon, 16 Dec 2019 18:08:04 +0000 (18:08 +0000)
Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC and toC functions.

Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
tools/golang/xenlight/xenlight.go

index 17d146771e7865cabcb7f012dbdbd866cb7919d6..6c3868cd69af211dfbd63ccee6740473423d473c 100644 (file)
@@ -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