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

[Xen-devel] [PATCH v3 08/22] golang/xenlight: define MsVmGenid builtin type



From: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>

Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC and 
toC functions.

Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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