All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Rosbrook <rosbrookn@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: Nick Rosbrook <rosbrookn@ainfosec.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	kerriganb@ainfosec.com, George Dunlap <george.dunlap@citrix.com>,
	Wei Liu <wl@xen.org>
Subject: [Xen-devel] [PATCH 16/24] golang/xenlight: begin C to Go type marshaling
Date: Mon,  7 Oct 2019 11:13:03 -0400	[thread overview]
Message-ID: <e6fbc6a1e481ed9c1713bee8106c9bbeca626651.1570456846.git.rosbrookn@ainfosec.com> (raw)
In-Reply-To: <cover.1570456846.git.rosbrookn@ainfosec.com>

From: Nick Rosbrook <rosbrookn@ainfosec.com>

Implement basic type conversion in fromC functions such as strings and
integer types. Also, remove existing toGo functions from xenlight.go in
favor of the new generated functions.

Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
---
Cc: George Dunlap <george.dunlap@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wl@xen.org>

 tools/golang/xenlight/gengotypes.py       | 120 +++
 tools/golang/xenlight/xenlight.go         | 111 +--
 tools/golang/xenlight/xenlight_helpers.go | 967 ++++++++++++++++++++++
 3 files changed, 1098 insertions(+), 100 deletions(-)
 create mode 100644 tools/golang/xenlight/xenlight_helpers.go

diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
index c8513b79e0..75dcd01724 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -18,6 +18,12 @@ builtin_type_names = {
     idl.uint64.typename: 'uint64',
 }
 
+# Some go keywords that conflict with field names in libxl structs.
+go_keywords = ['type', 'func']
+
+go_builtin_types = ['bool', 'string', 'int', 'byte',
+                    'uint16', 'uint32', 'uint64']
+
 # List of strings that need to be written to a file
 # after a struct definition.
 type_extras = []
@@ -168,6 +174,118 @@ def xenlight_golang_define_union(ty = None, structname = ''):
 
     return s
 
+def xenlight_golang_generate_helpers(path = None, types = None, comment = None):
+    """
+    Generate a .go file (xenlight_helpers.go by default)
+    that contains helper functions for marshaling between
+    C and Go types.
+    """
+    if path is None:
+        path = 'xenlight_helpers.go'
+
+    with open(path, 'w') as f:
+        if comment is not None:
+            f.write(comment)
+        f.write('package xenlight\n')
+
+        # Cgo preamble
+        f.write('/*\n')
+        f.write('#cgo LDFLAGS: -lxenlight\n')
+        f.write('#include <stdlib.h>\n')
+        f.write('#include <libxl.h>\n')
+        f.write('\n')
+
+        f.write('*/\nimport "C"\n')
+
+        for ty in types:
+            if not isinstance(ty, idl.Struct):
+                continue
+
+            f.write(xenlight_golang_define_from_C(ty))
+            f.write('\n')
+
+    go_fmt(path)
+
+def xenlight_golang_define_from_C(ty = None, typename = None, nested = False):
+    s = ''
+
+    gotypename = ctypename = ''
+
+    if typename is not None:
+        gotypename = xenlight_golang_fmt_name(typename)
+        ctypename  = typename
+    else:
+        gotypename = xenlight_golang_fmt_name(ty.typename)
+        ctypename  = ty.typename
+
+    if not nested:
+        s += 'func (x *{}) fromC(xc *C.{}) error {{\n'.format(gotypename,ctypename)
+
+    for f in ty.fields:
+        if f.type.typename is not None:
+            if isinstance(f.type, idl.Array):
+                # TODO
+                continue
+
+            gotypename = xenlight_golang_fmt_name(f.type.typename)
+            gofname    = xenlight_golang_fmt_name(f.name)
+            cfname     = f.name
+
+            # In cgo, C names that conflict with Go keywords can be
+            # accessed by prepending an underscore to the name.
+            if cfname in go_keywords:
+                cfname = '_' + cfname
+
+            # If this is nested, we need the outer name too.
+            if nested and typename is not None:
+                goname = xenlight_golang_fmt_name(typename)
+                goname = '{}.{}'.format(goname, gofname)
+                cname  = '{}.{}'.format(typename, cfname)
+
+            else:
+                goname = gofname
+                cname  = cfname
+
+            # Types that satisfy this condition can be easily casted or
+            # converted to a Go builtin type.
+            is_castable = (f.type.json_parse_type == 'JSON_INTEGER' or
+                           isinstance(f.type, idl.Enumeration) or
+                           gotypename in go_builtin_types)
+
+            if is_castable:
+                # Use the cgo helper for converting C strings.
+                if gotypename == 'string':
+                    s += 'x.{} = C.GoString(xc.{})\n'.format(goname, cname)
+                    continue
+
+                s += 'x.{} = {}(xc.{})\n'.format(goname, gotypename, cname)
+
+            else:
+                # If the type is not castable, we need to call its fromC
+                # function.
+                varname = '{}_{}'.format(f.type.typename,f.name)
+                varname = xenlight_golang_fmt_name(varname, exported=False)
+
+                s += 'var {} {}\n'.format(varname, gotypename)
+                s += 'if err := {}.fromC(&xc.{});'.format(varname, cname)
+                s += 'err != nil {\n return err\n}\n'
+                s += 'x.{} = {}\n'.format(goname, varname)
+
+        elif isinstance(f.type, idl.Struct):
+            s += xenlight_golang_define_from_C(f.type, typename=f.name, nested=True)
+
+        elif isinstance(f.type, idl.KeyedUnion):
+            pass
+
+        else:
+            raise Exception('type {} not supported'.format(f.type))
+
+    if not nested:
+        s += 'return nil'
+        s += '}\n'
+
+    return s
+
 def xenlight_golang_fmt_name(name, exported = True):
     """
     Take a given type name and return an
@@ -210,3 +328,5 @@ if __name__ == '__main__':
 
     xenlight_golang_generate_types(types=types,
                                    comment=header_comment)
+    xenlight_golang_generate_helpers(types=types,
+                                     comment=header_comment)
diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go
index f91c0d2be2..a8f933c75f 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -432,47 +432,6 @@ func (bm *Bitmap) toC() (C.libxl_bitmap, error) {
 	return cbm, nil
 }
 
-func (cphys *C.libxl_physinfo) toGo() (physinfo *Physinfo) {
-
-	physinfo = &Physinfo{}
-	physinfo.ThreadsPerCore = uint32(cphys.threads_per_core)
-	physinfo.CoresPerSocket = uint32(cphys.cores_per_socket)
-	physinfo.MaxCpuId = uint32(cphys.max_cpu_id)
-	physinfo.NrCpus = uint32(cphys.nr_cpus)
-	physinfo.CpuKhz = uint32(cphys.cpu_khz)
-	physinfo.TotalPages = uint64(cphys.total_pages)
-	physinfo.FreePages = uint64(cphys.free_pages)
-	physinfo.ScrubPages = uint64(cphys.scrub_pages)
-	physinfo.ScrubPages = uint64(cphys.scrub_pages)
-	physinfo.SharingFreedPages = uint64(cphys.sharing_freed_pages)
-	physinfo.SharingUsedFrames = uint64(cphys.sharing_used_frames)
-	physinfo.NrNodes = uint32(cphys.nr_nodes)
-	physinfo.HwCap.fromC(&cphys.hw_cap)
-	physinfo.CapHvm = bool(cphys.cap_hvm)
-	physinfo.CapHvmDirectio = bool(cphys.cap_hvm_directio)
-
-	return
-}
-
-func (cinfo *C.libxl_version_info) toGo() (info *VersionInfo) {
-	info = &VersionInfo{}
-	info.XenVersionMajor = int(cinfo.xen_version_major)
-	info.XenVersionMinor = int(cinfo.xen_version_minor)
-	info.XenVersionExtra = C.GoString(cinfo.xen_version_extra)
-	info.Compiler = C.GoString(cinfo.compiler)
-	info.CompileBy = C.GoString(cinfo.compile_by)
-	info.CompileDomain = C.GoString(cinfo.compile_domain)
-	info.CompileDate = C.GoString(cinfo.compile_date)
-	info.Capabilities = C.GoString(cinfo.capabilities)
-	info.Changeset = C.GoString(cinfo.changeset)
-	info.VirtStart = uint64(cinfo.virt_start)
-	info.Pagesize = int(cinfo.pagesize)
-	info.Commandline = C.GoString(cinfo.commandline)
-	info.BuildId = C.GoString(cinfo.build_id)
-
-	return
-}
-
 func (sr ShutdownReason) String() (str string) {
 	cstr := C.libxl_shutdown_reason_to_string(C.libxl_shutdown_reason(sr))
 	str = C.GoString(cstr)
@@ -487,34 +446,6 @@ func (dt DomainType) String() (str string) {
 	return
 }
 
-func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) {
-
-	di = &Dominfo{}
-	di.Uuid.fromC(&cdi.uuid)
-	di.Domid = Domid(cdi.domid)
-	di.Ssidref = uint32(cdi.ssidref)
-	di.SsidLabel = C.GoString(cdi.ssid_label)
-	di.Running = bool(cdi.running)
-	di.Blocked = bool(cdi.blocked)
-	di.Paused = bool(cdi.paused)
-	di.Shutdown = bool(cdi.shutdown)
-	di.Dying = bool(cdi.dying)
-	di.NeverStop = bool(cdi.never_stop)
-	di.ShutdownReason = ShutdownReason(cdi.shutdown_reason)
-	di.OutstandingMemkb = uint64(cdi.outstanding_memkb)
-	di.CurrentMemkb = uint64(cdi.current_memkb)
-	di.SharedMemkb = uint64(cdi.shared_memkb)
-	di.PagedMemkb = uint64(cdi.paged_memkb)
-	di.MaxMemkb = uint64(cdi.max_memkb)
-	di.CpuTime = uint64(cdi.cpu_time)
-	di.VcpuMaxId = uint32(cdi.vcpu_max_id)
-	di.VcpuOnline = uint32(cdi.vcpu_online)
-	di.Cpupool = uint32(cdi.cpupool)
-	di.DomainType = DomainType(cdi.domain_type)
-
-	return
-}
-
 // const char *libxl_scheduler_to_string(libxl_scheduler p);
 func (s Scheduler) String() string {
 	cs := C.libxl_scheduler_to_string(C.libxl_scheduler(s))
@@ -546,16 +477,6 @@ func SchedulerFromString(name string) (s Scheduler, err error) {
 	return
 }
 
-func (cci C.libxl_cpupoolinfo) toGo() (gci Cpupoolinfo) {
-	gci.Poolid = uint32(cci.poolid)
-	gci.PoolName = C.GoString(cci.pool_name)
-	gci.Sched = Scheduler(cci.sched)
-	gci.NDom = uint32(cci.n_dom)
-	gci.Cpumap.fromC(&cci.cpumap)
-
-	return
-}
-
 // libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out);
 // void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool);
 func (Ctx *Context) ListCpupool() (list []Cpupoolinfo) {
@@ -577,7 +498,8 @@ func (Ctx *Context) ListCpupool() (list []Cpupoolinfo) {
 	// Magic
 	cpupoolListSlice := (*[1 << 30]C.libxl_cpupoolinfo)(unsafe.Pointer(c_cpupool_list))[:nbPool:nbPool]
 	for i := range cpupoolListSlice {
-		info := cpupoolListSlice[i].toGo()
+		var info Cpupoolinfo
+		_ = info.fromC(&cpupoolListSlice[i])
 		list = append(list, info)
 	}
 
@@ -600,7 +522,7 @@ func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool Cpupoolinfo) {
 	}
 	defer C.libxl_cpupoolinfo_dispose(&c_cpupool)
 
-	pool = c_cpupool.toGo()
+	_ = pool.fromC(&c_cpupool)
 
 	return
 }
@@ -1091,7 +1013,7 @@ func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo, err error) {
 		err = Error(ret)
 		return
 	}
-	physinfo = cphys.toGo()
+	err = physinfo.fromC(&cphys)
 
 	return
 }
@@ -1107,7 +1029,7 @@ func (Ctx *Context) GetVersionInfo() (info *VersionInfo, err error) {
 
 	cinfo = C.libxl_get_version_info(Ctx.ctx)
 
-	info = cinfo.toGo()
+	err = info.fromC(cinfo)
 
 	return
 }
@@ -1129,7 +1051,7 @@ func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) {
 		return
 	}
 
-	di = cdi.toGo()
+	err = di.fromC(&cdi)
 
 	return
 }
@@ -1211,26 +1133,14 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) {
 
 	gslice := (*[1 << 30]C.libxl_dominfo)(unsafe.Pointer(clist))[:nbDomain:nbDomain]
 	for i := range gslice {
-		info := gslice[i].toGo()
-		glist = append(glist, *info)
+		var info Dominfo
+		_ = info.fromC(&gslice[i])
+		glist = append(glist, info)
 	}
 
 	return
 }
 
-func (cvci C.libxl_vcpuinfo) toGo() (gvci Vcpuinfo) {
-	gvci.Vcpuid = uint32(cvci.vcpuid)
-	gvci.Cpu = uint32(cvci.cpu)
-	gvci.Online = bool(cvci.online)
-	gvci.Blocked = bool(cvci.blocked)
-	gvci.Running = bool(cvci.running)
-	gvci.VcpuTime = uint64(cvci.vcpu_time)
-	gvci.Cpumap.fromC(&cvci.cpumap)
-	gvci.CpumapSoft.fromC(&cvci.cpumap_soft)
-
-	return
-}
-
 //libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
 //				int *nb_vcpu, int *nr_cpus_out);
 //void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
@@ -1252,7 +1162,8 @@ func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) {
 
 	gslice := (*[1 << 30]C.libxl_vcpuinfo)(unsafe.Pointer(clist))[:nbVcpu:nbVcpu]
 	for i := range gslice {
-		info := gslice[i].toGo()
+		var info Vcpuinfo
+		_ = info.fromC(&gslice[i])
 		glist = append(glist, info)
 	}
 
diff --git a/tools/golang/xenlight/xenlight_helpers.go b/tools/golang/xenlight/xenlight_helpers.go
new file mode 100644
index 0000000000..4ece90dc6b
--- /dev/null
+++ b/tools/golang/xenlight/xenlight_helpers.go
@@ -0,0 +1,967 @@
+// DO NOT EDIT.
+//
+// This file is generated by:
+// gengotypes.py ../../libxl/libxl_types.idl
+//
+package xenlight
+
+/*
+#cgo LDFLAGS: -lxenlight
+#include <stdlib.h>
+#include <libxl.h>
+
+*/
+import "C"
+
+func (x *IoportRange) fromC(xc *C.libxl_ioport_range) error {
+	x.First = uint32(xc.first)
+	x.Number = uint32(xc.number)
+	return nil
+}
+
+func (x *IomemRange) fromC(xc *C.libxl_iomem_range) error {
+	x.Start = uint64(xc.start)
+	x.Number = uint64(xc.number)
+	x.Gfn = uint64(xc.gfn)
+	return nil
+}
+
+func (x *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error {
+	x.Kind = VgaInterfaceType(xc.kind)
+	return nil
+}
+
+func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error {
+	var defboolEnable Defbool
+	if err := defboolEnable.fromC(&xc.enable); err != nil {
+		return err
+	}
+	x.Enable = defboolEnable
+	x.Listen = C.GoString(xc.listen)
+	x.Passwd = C.GoString(xc.passwd)
+	x.Display = int(xc.display)
+	var defboolFindunused Defbool
+	if err := defboolFindunused.fromC(&xc.findunused); err != nil {
+		return err
+	}
+	x.Findunused = defboolFindunused
+	return nil
+}
+
+func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error {
+	var defboolEnable Defbool
+	if err := defboolEnable.fromC(&xc.enable); err != nil {
+		return err
+	}
+	x.Enable = defboolEnable
+	x.Port = int(xc.port)
+	x.TlsPort = int(xc.tls_port)
+	x.Host = C.GoString(xc.host)
+	var defboolDisableTicketing Defbool
+	if err := defboolDisableTicketing.fromC(&xc.disable_ticketing); err != nil {
+		return err
+	}
+	x.DisableTicketing = defboolDisableTicketing
+	x.Passwd = C.GoString(xc.passwd)
+	var defboolAgentMouse Defbool
+	if err := defboolAgentMouse.fromC(&xc.agent_mouse); err != nil {
+		return err
+	}
+	x.AgentMouse = defboolAgentMouse
+	var defboolVdagent Defbool
+	if err := defboolVdagent.fromC(&xc.vdagent); err != nil {
+		return err
+	}
+	x.Vdagent = defboolVdagent
+	var defboolClipboardSharing Defbool
+	if err := defboolClipboardSharing.fromC(&xc.clipboard_sharing); err != nil {
+		return err
+	}
+	x.ClipboardSharing = defboolClipboardSharing
+	x.Usbredirection = int(xc.usbredirection)
+	x.ImageCompression = C.GoString(xc.image_compression)
+	x.StreamingVideo = C.GoString(xc.streaming_video)
+	return nil
+}
+
+func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error {
+	var defboolEnable Defbool
+	if err := defboolEnable.fromC(&xc.enable); err != nil {
+		return err
+	}
+	x.Enable = defboolEnable
+	var defboolOpengl Defbool
+	if err := defboolOpengl.fromC(&xc.opengl); err != nil {
+		return err
+	}
+	x.Opengl = defboolOpengl
+	x.Display = C.GoString(xc.display)
+	x.Xauthority = C.GoString(xc.xauthority)
+	return nil
+}
+
+func (x *Dominfo) fromC(xc *C.libxl_dominfo) error {
+	var uuidUuid Uuid
+	if err := uuidUuid.fromC(&xc.uuid); err != nil {
+		return err
+	}
+	x.Uuid = uuidUuid
+	x.Domid = Domid(xc.domid)
+	x.Ssidref = uint32(xc.ssidref)
+	x.SsidLabel = C.GoString(xc.ssid_label)
+	x.Running = bool(xc.running)
+	x.Blocked = bool(xc.blocked)
+	x.Paused = bool(xc.paused)
+	x.Shutdown = bool(xc.shutdown)
+	x.Dying = bool(xc.dying)
+	x.NeverStop = bool(xc.never_stop)
+	x.ShutdownReason = ShutdownReason(xc.shutdown_reason)
+	x.OutstandingMemkb = uint64(xc.outstanding_memkb)
+	x.CurrentMemkb = uint64(xc.current_memkb)
+	x.SharedMemkb = uint64(xc.shared_memkb)
+	x.PagedMemkb = uint64(xc.paged_memkb)
+	x.MaxMemkb = uint64(xc.max_memkb)
+	x.CpuTime = uint64(xc.cpu_time)
+	x.VcpuMaxId = uint32(xc.vcpu_max_id)
+	x.VcpuOnline = uint32(xc.vcpu_online)
+	x.Cpupool = uint32(xc.cpupool)
+	x.DomainType = DomainType(xc.domain_type)
+	return nil
+}
+
+func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error {
+	x.Poolid = uint32(xc.poolid)
+	x.PoolName = C.GoString(xc.pool_name)
+	x.Sched = Scheduler(xc.sched)
+	x.NDom = uint32(xc.n_dom)
+	var bitmapCpumap Bitmap
+	if err := bitmapCpumap.fromC(&xc.cpumap); err != nil {
+		return err
+	}
+	x.Cpumap = bitmapCpumap
+	return nil
+}
+
+func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.Rref = int(xc.rref)
+	return nil
+}
+
+func (x *Vminfo) fromC(xc *C.libxl_vminfo) error {
+	var uuidUuid Uuid
+	if err := uuidUuid.fromC(&xc.uuid); err != nil {
+		return err
+	}
+	x.Uuid = uuidUuid
+	x.Domid = Domid(xc.domid)
+	return nil
+}
+
+func (x *VersionInfo) fromC(xc *C.libxl_version_info) error {
+	x.XenVersionMajor = int(xc.xen_version_major)
+	x.XenVersionMinor = int(xc.xen_version_minor)
+	x.XenVersionExtra = C.GoString(xc.xen_version_extra)
+	x.Compiler = C.GoString(xc.compiler)
+	x.CompileBy = C.GoString(xc.compile_by)
+	x.CompileDomain = C.GoString(xc.compile_domain)
+	x.CompileDate = C.GoString(xc.compile_date)
+	x.Capabilities = C.GoString(xc.capabilities)
+	x.Changeset = C.GoString(xc.changeset)
+	x.VirtStart = uint64(xc.virt_start)
+	x.Pagesize = int(xc.pagesize)
+	x.Commandline = C.GoString(xc.commandline)
+	x.BuildId = C.GoString(xc.build_id)
+	return nil
+}
+
+func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_create_info) error {
+	x.Type = DomainType(xc._type)
+	var defboolHap Defbool
+	if err := defboolHap.fromC(&xc.hap); err != nil {
+		return err
+	}
+	x.Hap = defboolHap
+	var defboolOos Defbool
+	if err := defboolOos.fromC(&xc.oos); err != nil {
+		return err
+	}
+	x.Oos = defboolOos
+	x.Ssidref = uint32(xc.ssidref)
+	x.SsidLabel = C.GoString(xc.ssid_label)
+	x.Name = C.GoString(xc.name)
+	var uuidUuid Uuid
+	if err := uuidUuid.fromC(&xc.uuid); err != nil {
+		return err
+	}
+	x.Uuid = uuidUuid
+	var keyValueListXsdata KeyValueList
+	if err := keyValueListXsdata.fromC(&xc.xsdata); err != nil {
+		return err
+	}
+	x.Xsdata = keyValueListXsdata
+	var keyValueListPlatformdata KeyValueList
+	if err := keyValueListPlatformdata.fromC(&xc.platformdata); err != nil {
+		return err
+	}
+	x.Platformdata = keyValueListPlatformdata
+	x.Poolid = uint32(xc.poolid)
+	x.PoolName = C.GoString(xc.pool_name)
+	var defboolRunHotplugScripts Defbool
+	if err := defboolRunHotplugScripts.fromC(&xc.run_hotplug_scripts); err != nil {
+		return err
+	}
+	x.RunHotplugScripts = defboolRunHotplugScripts
+	var defboolDriverDomain Defbool
+	if err := defboolDriverDomain.fromC(&xc.driver_domain); err != nil {
+		return err
+	}
+	x.DriverDomain = defboolDriverDomain
+	return nil
+}
+
+func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) error {
+	x.CheckpointedStream = int(xc.checkpointed_stream)
+	x.StreamVersion = uint32(xc.stream_version)
+	x.ColoProxyScript = C.GoString(xc.colo_proxy_script)
+	var defboolUserspaceColoProxy Defbool
+	if err := defboolUserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != nil {
+		return err
+	}
+	x.UserspaceColoProxy = defboolUserspaceColoProxy
+	return nil
+}
+
+func (x *SchedParams) fromC(xc *C.libxl_sched_params) error {
+	x.Vcpuid = int(xc.vcpuid)
+	x.Weight = int(xc.weight)
+	x.Cap = int(xc.cap)
+	x.Period = int(xc.period)
+	x.Extratime = int(xc.extratime)
+	x.Budget = int(xc.budget)
+	return nil
+}
+
+func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error {
+	x.Sched = Scheduler(xc.sched)
+	return nil
+}
+
+func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error {
+	x.Sched = Scheduler(xc.sched)
+	x.Weight = int(xc.weight)
+	x.Cap = int(xc.cap)
+	x.Period = int(xc.period)
+	x.Budget = int(xc.budget)
+	x.Extratime = int(xc.extratime)
+	x.Slice = int(xc.slice)
+	x.Latency = int(xc.latency)
+	return nil
+}
+
+func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error {
+	x.Memkb = uint64(xc.memkb)
+	x.Pnode = uint32(xc.pnode)
+	var bitmapVcpus Bitmap
+	if err := bitmapVcpus.fromC(&xc.vcpus); err != nil {
+		return err
+	}
+	x.Vcpus = bitmapVcpus
+	return nil
+}
+
+func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error {
+	x.Strategy = RdmReserveStrategy(xc.strategy)
+	x.Policy = RdmReservePolicy(xc.policy)
+	return nil
+}
+
+func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error {
+	x.MaxVcpus = int(xc.max_vcpus)
+	var bitmapAvailVcpus Bitmap
+	if err := bitmapAvailVcpus.fromC(&xc.avail_vcpus); err != nil {
+		return err
+	}
+	x.AvailVcpus = bitmapAvailVcpus
+	var bitmapCpumap Bitmap
+	if err := bitmapCpumap.fromC(&xc.cpumap); err != nil {
+		return err
+	}
+	x.Cpumap = bitmapCpumap
+	var bitmapNodemap Bitmap
+	if err := bitmapNodemap.fromC(&xc.nodemap); err != nil {
+		return err
+	}
+	x.Nodemap = bitmapNodemap
+	var defboolNumaPlacement Defbool
+	if err := defboolNumaPlacement.fromC(&xc.numa_placement); err != nil {
+		return err
+	}
+	x.NumaPlacement = defboolNumaPlacement
+	x.TscMode = TscMode(xc.tsc_mode)
+	x.MaxMemkb = uint64(xc.max_memkb)
+	x.TargetMemkb = uint64(xc.target_memkb)
+	x.VideoMemkb = uint64(xc.video_memkb)
+	x.ShadowMemkb = uint64(xc.shadow_memkb)
+	x.RtcTimeoffset = uint32(xc.rtc_timeoffset)
+	x.ExecSsidref = uint32(xc.exec_ssidref)
+	x.ExecSsidLabel = C.GoString(xc.exec_ssid_label)
+	var defboolLocaltime Defbool
+	if err := defboolLocaltime.fromC(&xc.localtime); err != nil {
+		return err
+	}
+	x.Localtime = defboolLocaltime
+	var defboolDisableMigrate Defbool
+	if err := defboolDisableMigrate.fromC(&xc.disable_migrate); err != nil {
+		return err
+	}
+	x.DisableMigrate = defboolDisableMigrate
+	var cpuidPolicyListCpuid CpuidPolicyList
+	if err := cpuidPolicyListCpuid.fromC(&xc.cpuid); err != nil {
+		return err
+	}
+	x.Cpuid = cpuidPolicyListCpuid
+	x.BlkdevStart = C.GoString(xc.blkdev_start)
+	x.MaxGrantFrames = uint32(xc.max_grant_frames)
+	x.MaxMaptrackFrames = uint32(xc.max_maptrack_frames)
+	x.DeviceModelVersion = DeviceModelVersion(xc.device_model_version)
+	var defboolDeviceModelStubdomain Defbool
+	if err := defboolDeviceModelStubdomain.fromC(&xc.device_model_stubdomain); err != nil {
+		return err
+	}
+	x.DeviceModelStubdomain = defboolDeviceModelStubdomain
+	x.DeviceModel = C.GoString(xc.device_model)
+	x.DeviceModelSsidref = uint32(xc.device_model_ssidref)
+	x.DeviceModelSsidLabel = C.GoString(xc.device_model_ssid_label)
+	x.DeviceModelUser = C.GoString(xc.device_model_user)
+	var stringListExtra StringList
+	if err := stringListExtra.fromC(&xc.extra); err != nil {
+		return err
+	}
+	x.Extra = stringListExtra
+	var stringListExtraPv StringList
+	if err := stringListExtraPv.fromC(&xc.extra_pv); err != nil {
+		return err
+	}
+	x.ExtraPv = stringListExtraPv
+	var stringListExtraHvm StringList
+	if err := stringListExtraHvm.fromC(&xc.extra_hvm); err != nil {
+		return err
+	}
+	x.ExtraHvm = stringListExtraHvm
+	var domainSchedParamsSchedParams DomainSchedParams
+	if err := domainSchedParamsSchedParams.fromC(&xc.sched_params); err != nil {
+		return err
+	}
+	x.SchedParams = domainSchedParamsSchedParams
+	var defboolClaimMode Defbool
+	if err := defboolClaimMode.fromC(&xc.claim_mode); err != nil {
+		return err
+	}
+	x.ClaimMode = defboolClaimMode
+	x.EventChannels = uint32(xc.event_channels)
+	x.Kernel = C.GoString(xc.kernel)
+	x.Cmdline = C.GoString(xc.cmdline)
+	x.Ramdisk = C.GoString(xc.ramdisk)
+	x.DeviceTree = C.GoString(xc.device_tree)
+	var defboolAcpi Defbool
+	if err := defboolAcpi.fromC(&xc.acpi); err != nil {
+		return err
+	}
+	x.Acpi = defboolAcpi
+	x.Bootloader = C.GoString(xc.bootloader)
+	var stringListBootloaderArgs StringList
+	if err := stringListBootloaderArgs.fromC(&xc.bootloader_args); err != nil {
+		return err
+	}
+	x.BootloaderArgs = stringListBootloaderArgs
+	x.TimerMode = TimerMode(xc.timer_mode)
+	var defboolNestedHvm Defbool
+	if err := defboolNestedHvm.fromC(&xc.nested_hvm); err != nil {
+		return err
+	}
+	x.NestedHvm = defboolNestedHvm
+	var defboolApic Defbool
+	if err := defboolApic.fromC(&xc.apic); err != nil {
+		return err
+	}
+	x.Apic = defboolApic
+	var defboolDmRestrict Defbool
+	if err := defboolDmRestrict.fromC(&xc.dm_restrict); err != nil {
+		return err
+	}
+	x.DmRestrict = defboolDmRestrict
+	x.Tee = TeeType(xc.tee)
+	x.ArchArm.GicVersion = GicVersion(xc.arch_arm.gic_version)
+	x.ArchArm.Vuart = VuartType(xc.arch_arm.vuart)
+	x.Altp2M = Altp2MMode(xc.altp2m)
+	return nil
+}
+
+func (x *DeviceVfb) fromC(xc *C.libxl_device_vfb) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	var vncInfoVnc VncInfo
+	if err := vncInfoVnc.fromC(&xc.vnc); err != nil {
+		return err
+	}
+	x.Vnc = vncInfoVnc
+	var sdlInfoSdl SdlInfo
+	if err := sdlInfoSdl.fromC(&xc.sdl); err != nil {
+		return err
+	}
+	x.Sdl = sdlInfoSdl
+	x.Keymap = C.GoString(xc.keymap)
+	return nil
+}
+
+func (x *DeviceVkb) fromC(xc *C.libxl_device_vkb) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	x.BackendType = VkbBackend(xc.backend_type)
+	x.UniqueId = C.GoString(xc.unique_id)
+	x.FeatureDisableKeyboard = bool(xc.feature_disable_keyboard)
+	x.FeatureDisablePointer = bool(xc.feature_disable_pointer)
+	x.FeatureAbsPointer = bool(xc.feature_abs_pointer)
+	x.FeatureRawPointer = bool(xc.feature_raw_pointer)
+	x.FeatureMultiTouch = bool(xc.feature_multi_touch)
+	x.Width = uint32(xc.width)
+	x.Height = uint32(xc.height)
+	x.MultiTouchWidth = uint32(xc.multi_touch_width)
+	x.MultiTouchHeight = uint32(xc.multi_touch_height)
+	x.MultiTouchNumContacts = uint32(xc.multi_touch_num_contacts)
+	return nil
+}
+
+func (x *DeviceDisk) fromC(xc *C.libxl_device_disk) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.PdevPath = C.GoString(xc.pdev_path)
+	x.Vdev = C.GoString(xc.vdev)
+	x.Backend = DiskBackend(xc.backend)
+	x.Format = DiskFormat(xc.format)
+	x.Script = C.GoString(xc.script)
+	x.Removable = int(xc.removable)
+	x.Readwrite = int(xc.readwrite)
+	x.IsCdrom = int(xc.is_cdrom)
+	x.DirectIoSafe = bool(xc.direct_io_safe)
+	var defboolDiscardEnable Defbool
+	if err := defboolDiscardEnable.fromC(&xc.discard_enable); err != nil {
+		return err
+	}
+	x.DiscardEnable = defboolDiscardEnable
+	var defboolColoEnable Defbool
+	if err := defboolColoEnable.fromC(&xc.colo_enable); err != nil {
+		return err
+	}
+	x.ColoEnable = defboolColoEnable
+	var defboolColoRestoreEnable Defbool
+	if err := defboolColoRestoreEnable.fromC(&xc.colo_restore_enable); err != nil {
+		return err
+	}
+	x.ColoRestoreEnable = defboolColoRestoreEnable
+	x.ColoHost = C.GoString(xc.colo_host)
+	x.ColoPort = int(xc.colo_port)
+	x.ColoExport = C.GoString(xc.colo_export)
+	x.ActiveDisk = C.GoString(xc.active_disk)
+	x.HiddenDisk = C.GoString(xc.hidden_disk)
+	return nil
+}
+
+func (x *DeviceNic) fromC(xc *C.libxl_device_nic) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	x.Mtu = int(xc.mtu)
+	x.Model = C.GoString(xc.model)
+	var macMac Mac
+	if err := macMac.fromC(&xc.mac); err != nil {
+		return err
+	}
+	x.Mac = macMac
+	x.Ip = C.GoString(xc.ip)
+	x.Bridge = C.GoString(xc.bridge)
+	x.Ifname = C.GoString(xc.ifname)
+	x.Script = C.GoString(xc.script)
+	x.Nictype = NicType(xc.nictype)
+	x.RateBytesPerInterval = uint64(xc.rate_bytes_per_interval)
+	x.RateIntervalUsecs = uint32(xc.rate_interval_usecs)
+	x.Gatewaydev = C.GoString(xc.gatewaydev)
+	x.ColoftForwarddev = C.GoString(xc.coloft_forwarddev)
+	x.ColoSockMirrorId = C.GoString(xc.colo_sock_mirror_id)
+	x.ColoSockMirrorIp = C.GoString(xc.colo_sock_mirror_ip)
+	x.ColoSockMirrorPort = C.GoString(xc.colo_sock_mirror_port)
+	x.ColoSockComparePriInId = C.GoString(xc.colo_sock_compare_pri_in_id)
+	x.ColoSockComparePriInIp = C.GoString(xc.colo_sock_compare_pri_in_ip)
+	x.ColoSockComparePriInPort = C.GoString(xc.colo_sock_compare_pri_in_port)
+	x.ColoSockCompareSecInId = C.GoString(xc.colo_sock_compare_sec_in_id)
+	x.ColoSockCompareSecInIp = C.GoString(xc.colo_sock_compare_sec_in_ip)
+	x.ColoSockCompareSecInPort = C.GoString(xc.colo_sock_compare_sec_in_port)
+	x.ColoSockCompareNotifyId = C.GoString(xc.colo_sock_compare_notify_id)
+	x.ColoSockCompareNotifyIp = C.GoString(xc.colo_sock_compare_notify_ip)
+	x.ColoSockCompareNotifyPort = C.GoString(xc.colo_sock_compare_notify_port)
+	x.ColoSockRedirector0Id = C.GoString(xc.colo_sock_redirector0_id)
+	x.ColoSockRedirector0Ip = C.GoString(xc.colo_sock_redirector0_ip)
+	x.ColoSockRedirector0Port = C.GoString(xc.colo_sock_redirector0_port)
+	x.ColoSockRedirector1Id = C.GoString(xc.colo_sock_redirector1_id)
+	x.ColoSockRedirector1Ip = C.GoString(xc.colo_sock_redirector1_ip)
+	x.ColoSockRedirector1Port = C.GoString(xc.colo_sock_redirector1_port)
+	x.ColoSockRedirector2Id = C.GoString(xc.colo_sock_redirector2_id)
+	x.ColoSockRedirector2Ip = C.GoString(xc.colo_sock_redirector2_ip)
+	x.ColoSockRedirector2Port = C.GoString(xc.colo_sock_redirector2_port)
+	x.ColoFilterMirrorQueue = C.GoString(xc.colo_filter_mirror_queue)
+	x.ColoFilterMirrorOutdev = C.GoString(xc.colo_filter_mirror_outdev)
+	x.ColoFilterRedirector0Queue = C.GoString(xc.colo_filter_redirector0_queue)
+	x.ColoFilterRedirector0Indev = C.GoString(xc.colo_filter_redirector0_indev)
+	x.ColoFilterRedirector0Outdev = C.GoString(xc.colo_filter_redirector0_outdev)
+	x.ColoFilterRedirector1Queue = C.GoString(xc.colo_filter_redirector1_queue)
+	x.ColoFilterRedirector1Indev = C.GoString(xc.colo_filter_redirector1_indev)
+	x.ColoFilterRedirector1Outdev = C.GoString(xc.colo_filter_redirector1_outdev)
+	x.ColoComparePriIn = C.GoString(xc.colo_compare_pri_in)
+	x.ColoCompareSecIn = C.GoString(xc.colo_compare_sec_in)
+	x.ColoCompareOut = C.GoString(xc.colo_compare_out)
+	x.ColoCompareNotifyDev = C.GoString(xc.colo_compare_notify_dev)
+	x.ColoSockSecRedirector0Id = C.GoString(xc.colo_sock_sec_redirector0_id)
+	x.ColoSockSecRedirector0Ip = C.GoString(xc.colo_sock_sec_redirector0_ip)
+	x.ColoSockSecRedirector0Port = C.GoString(xc.colo_sock_sec_redirector0_port)
+	x.ColoSockSecRedirector1Id = C.GoString(xc.colo_sock_sec_redirector1_id)
+	x.ColoSockSecRedirector1Ip = C.GoString(xc.colo_sock_sec_redirector1_ip)
+	x.ColoSockSecRedirector1Port = C.GoString(xc.colo_sock_sec_redirector1_port)
+	x.ColoFilterSecRedirector0Queue = C.GoString(xc.colo_filter_sec_redirector0_queue)
+	x.ColoFilterSecRedirector0Indev = C.GoString(xc.colo_filter_sec_redirector0_indev)
+	x.ColoFilterSecRedirector0Outdev = C.GoString(xc.colo_filter_sec_redirector0_outdev)
+	x.ColoFilterSecRedirector1Queue = C.GoString(xc.colo_filter_sec_redirector1_queue)
+	x.ColoFilterSecRedirector1Indev = C.GoString(xc.colo_filter_sec_redirector1_indev)
+	x.ColoFilterSecRedirector1Outdev = C.GoString(xc.colo_filter_sec_redirector1_outdev)
+	x.ColoFilterSecRewriter0Queue = C.GoString(xc.colo_filter_sec_rewriter0_queue)
+	x.ColoCheckpointHost = C.GoString(xc.colo_checkpoint_host)
+	x.ColoCheckpointPort = C.GoString(xc.colo_checkpoint_port)
+	return nil
+}
+
+func (x *DevicePci) fromC(xc *C.libxl_device_pci) error {
+	x.Func = byte(xc._func)
+	x.Dev = byte(xc.dev)
+	x.Bus = byte(xc.bus)
+	x.Domain = int(xc.domain)
+	x.Vdevfn = uint32(xc.vdevfn)
+	x.VfuncMask = uint32(xc.vfunc_mask)
+	x.Msitranslate = bool(xc.msitranslate)
+	x.PowerMgmt = bool(xc.power_mgmt)
+	x.Permissive = bool(xc.permissive)
+	x.Seize = bool(xc.seize)
+	x.RdmPolicy = RdmReservePolicy(xc.rdm_policy)
+	return nil
+}
+
+func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) error {
+	x.Start = uint64(xc.start)
+	x.Size = uint64(xc.size)
+	x.Policy = RdmReservePolicy(xc.policy)
+	return nil
+}
+
+func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbctrl) error {
+	x.Type = UsbctrlType(xc._type)
+	x.Devid = Devid(xc.devid)
+	x.Version = int(xc.version)
+	x.Ports = int(xc.ports)
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	return nil
+}
+
+func (x *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error {
+	x.Ctrl = Devid(xc.ctrl)
+	x.Port = int(xc.port)
+	return nil
+}
+
+func (x *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error {
+	x.Path = C.GoString(xc.path)
+	return nil
+}
+
+func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	var uuidUuid Uuid
+	if err := uuidUuid.fromC(&xc.uuid); err != nil {
+		return err
+	}
+	x.Uuid = uuidUuid
+	return nil
+}
+
+func (x *DeviceP9) fromC(xc *C.libxl_device_p9) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Tag = C.GoString(xc.tag)
+	x.Path = C.GoString(xc.path)
+	x.SecurityModel = C.GoString(xc.security_model)
+	x.Devid = Devid(xc.devid)
+	return nil
+}
+
+func (x *DevicePvcallsif) fromC(xc *C.libxl_device_pvcallsif) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	return nil
+}
+
+func (x *DeviceChannel) fromC(xc *C.libxl_device_channel) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	x.Name = C.GoString(xc.name)
+	return nil
+}
+
+func (x *ConnectorParam) fromC(xc *C.libxl_connector_param) error {
+	x.UniqueId = C.GoString(xc.unique_id)
+	x.Width = uint32(xc.width)
+	x.Height = uint32(xc.height)
+	return nil
+}
+
+func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdispl) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	x.BeAlloc = bool(xc.be_alloc)
+	return nil
+}
+
+func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error {
+	x.ChannelsMin = uint32(xc.channels_min)
+	x.ChannelsMax = uint32(xc.channels_max)
+	x.BufferSize = uint32(xc.buffer_size)
+	return nil
+}
+
+func (x *VsndStream) fromC(xc *C.libxl_vsnd_stream) error {
+	x.UniqueId = C.GoString(xc.unique_id)
+	x.Type = VsndStreamType(xc._type)
+	var vsndParamsParams VsndParams
+	if err := vsndParamsParams.fromC(&xc.params); err != nil {
+		return err
+	}
+	x.Params = vsndParamsParams
+	return nil
+}
+
+func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error {
+	x.Name = C.GoString(xc.name)
+	var vsndParamsParams VsndParams
+	if err := vsndParamsParams.fromC(&xc.params); err != nil {
+		return err
+	}
+	x.Params = vsndParamsParams
+	return nil
+}
+
+func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error {
+	x.BackendDomid = Domid(xc.backend_domid)
+	x.BackendDomname = C.GoString(xc.backend_domname)
+	x.Devid = Devid(xc.devid)
+	x.ShortName = C.GoString(xc.short_name)
+	x.LongName = C.GoString(xc.long_name)
+	var vsndParamsParams VsndParams
+	if err := vsndParamsParams.fromC(&xc.params); err != nil {
+		return err
+	}
+	x.Params = vsndParamsParams
+	return nil
+}
+
+func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error {
+	var domainCreateInfoCInfo DomainCreateInfo
+	if err := domainCreateInfoCInfo.fromC(&xc.c_info); err != nil {
+		return err
+	}
+	x.CInfo = domainCreateInfoCInfo
+	var domainBuildInfoBInfo DomainBuildInfo
+	if err := domainBuildInfoBInfo.fromC(&xc.b_info); err != nil {
+		return err
+	}
+	x.BInfo = domainBuildInfoBInfo
+	x.OnPoweroff = ActionOnShutdown(xc.on_poweroff)
+	x.OnReboot = ActionOnShutdown(xc.on_reboot)
+	x.OnWatchdog = ActionOnShutdown(xc.on_watchdog)
+	x.OnCrash = ActionOnShutdown(xc.on_crash)
+	x.OnSoftReset = ActionOnShutdown(xc.on_soft_reset)
+	return nil
+}
+
+func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.Rref = int(xc.rref)
+	return nil
+}
+
+func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.RrefTx = int(xc.rref_tx)
+	x.RrefRx = int(xc.rref_rx)
+	return nil
+}
+
+func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.Rref = int(xc.rref)
+	var uuidUuid Uuid
+	if err := uuidUuid.fromC(&xc.uuid); err != nil {
+		return err
+	}
+	x.Uuid = uuidUuid
+	return nil
+}
+
+func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo) error {
+	x.Type = UsbctrlType(xc._type)
+	x.Devid = Devid(xc.devid)
+	x.Version = int(xc.version)
+	x.Ports = int(xc.ports)
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.RefUrb = int(xc.ref_urb)
+	x.RefConn = int(xc.ref_conn)
+	return nil
+}
+
+func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error {
+	x.Vcpuid = uint32(xc.vcpuid)
+	x.Cpu = uint32(xc.cpu)
+	x.Online = bool(xc.online)
+	x.Blocked = bool(xc.blocked)
+	x.Running = bool(xc.running)
+	x.VcpuTime = uint64(xc.vcpu_time)
+	var bitmapCpumap Bitmap
+	if err := bitmapCpumap.fromC(&xc.cpumap); err != nil {
+		return err
+	}
+	x.Cpumap = bitmapCpumap
+	var bitmapCpumapSoft Bitmap
+	if err := bitmapCpumapSoft.fromC(&xc.cpumap_soft); err != nil {
+		return err
+	}
+	x.CpumapSoft = bitmapCpumapSoft
+	return nil
+}
+
+func (x *Physinfo) fromC(xc *C.libxl_physinfo) error {
+	x.ThreadsPerCore = uint32(xc.threads_per_core)
+	x.CoresPerSocket = uint32(xc.cores_per_socket)
+	x.MaxCpuId = uint32(xc.max_cpu_id)
+	x.NrCpus = uint32(xc.nr_cpus)
+	x.CpuKhz = uint32(xc.cpu_khz)
+	x.TotalPages = uint64(xc.total_pages)
+	x.FreePages = uint64(xc.free_pages)
+	x.ScrubPages = uint64(xc.scrub_pages)
+	x.OutstandingPages = uint64(xc.outstanding_pages)
+	x.SharingFreedPages = uint64(xc.sharing_freed_pages)
+	x.SharingUsedFrames = uint64(xc.sharing_used_frames)
+	x.MaxPossibleMfn = uint64(xc.max_possible_mfn)
+	x.NrNodes = uint32(xc.nr_nodes)
+	var hwcapHwCap Hwcap
+	if err := hwcapHwCap.fromC(&xc.hw_cap); err != nil {
+		return err
+	}
+	x.HwCap = hwcapHwCap
+	x.CapHvm = bool(xc.cap_hvm)
+	x.CapPv = bool(xc.cap_pv)
+	x.CapHvmDirectio = bool(xc.cap_hvm_directio)
+	x.CapHap = bool(xc.cap_hap)
+	x.CapShadow = bool(xc.cap_shadow)
+	x.CapIommuHapPtShare = bool(xc.cap_iommu_hap_pt_share)
+	return nil
+}
+
+func (x *Connectorinfo) fromC(xc *C.libxl_connectorinfo) error {
+	x.UniqueId = C.GoString(xc.unique_id)
+	x.Width = uint32(xc.width)
+	x.Height = uint32(xc.height)
+	x.ReqEvtch = int(xc.req_evtch)
+	x.ReqRref = int(xc.req_rref)
+	x.EvtEvtch = int(xc.evt_evtch)
+	x.EvtRref = int(xc.evt_rref)
+	return nil
+}
+
+func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.BeAlloc = bool(xc.be_alloc)
+	return nil
+}
+
+func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error {
+	x.ReqEvtch = int(xc.req_evtch)
+	x.ReqRref = int(xc.req_rref)
+	return nil
+}
+
+func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error {
+	return nil
+}
+
+func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	return nil
+}
+
+func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error {
+	x.Backend = C.GoString(xc.backend)
+	x.BackendId = uint32(xc.backend_id)
+	x.Frontend = C.GoString(xc.frontend)
+	x.FrontendId = uint32(xc.frontend_id)
+	x.Devid = Devid(xc.devid)
+	x.State = int(xc.state)
+	x.Evtch = int(xc.evtch)
+	x.Rref = int(xc.rref)
+	return nil
+}
+
+func (x *Numainfo) fromC(xc *C.libxl_numainfo) error {
+	x.Size = uint64(xc.size)
+	x.Free = uint64(xc.free)
+	return nil
+}
+
+func (x *Cputopology) fromC(xc *C.libxl_cputopology) error {
+	x.Core = uint32(xc.core)
+	x.Socket = uint32(xc.socket)
+	x.Node = uint32(xc.node)
+	return nil
+}
+
+func (x *Pcitopology) fromC(xc *C.libxl_pcitopology) error {
+	x.Seg = uint16(xc.seg)
+	x.Bus = byte(xc.bus)
+	x.Devfn = byte(xc.devfn)
+	x.Node = uint32(xc.node)
+	return nil
+}
+
+func (x *SchedCreditParams) fromC(xc *C.libxl_sched_credit_params) error {
+	x.TsliceMs = int(xc.tslice_ms)
+	x.RatelimitUs = int(xc.ratelimit_us)
+	x.VcpuMigrDelayUs = int(xc.vcpu_migr_delay_us)
+	return nil
+}
+
+func (x *SchedCredit2Params) fromC(xc *C.libxl_sched_credit2_params) error {
+	x.RatelimitUs = int(xc.ratelimit_us)
+	return nil
+}
+
+func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_remus_info) error {
+	x.Interval = int(xc.interval)
+	var defboolAllowUnsafe Defbool
+	if err := defboolAllowUnsafe.fromC(&xc.allow_unsafe); err != nil {
+		return err
+	}
+	x.AllowUnsafe = defboolAllowUnsafe
+	var defboolBlackhole Defbool
+	if err := defboolBlackhole.fromC(&xc.blackhole); err != nil {
+		return err
+	}
+	x.Blackhole = defboolBlackhole
+	var defboolCompression Defbool
+	if err := defboolCompression.fromC(&xc.compression); err != nil {
+		return err
+	}
+	x.Compression = defboolCompression
+	var defboolNetbuf Defbool
+	if err := defboolNetbuf.fromC(&xc.netbuf); err != nil {
+		return err
+	}
+	x.Netbuf = defboolNetbuf
+	x.Netbufscript = C.GoString(xc.netbufscript)
+	var defboolDiskbuf Defbool
+	if err := defboolDiskbuf.fromC(&xc.diskbuf); err != nil {
+		return err
+	}
+	x.Diskbuf = defboolDiskbuf
+	var defboolColo Defbool
+	if err := defboolColo.fromC(&xc.colo); err != nil {
+		return err
+	}
+	x.Colo = defboolColo
+	var defboolUserspaceColoProxy Defbool
+	if err := defboolUserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != nil {
+		return err
+	}
+	x.UserspaceColoProxy = defboolUserspaceColoProxy
+	return nil
+}
+
+func (x *Event) fromC(xc *C.libxl_event) error {
+	var evLinkLink EvLink
+	if err := evLinkLink.fromC(&xc.link); err != nil {
+		return err
+	}
+	x.Link = evLinkLink
+	x.Domid = Domid(xc.domid)
+	var uuidDomuuid Uuid
+	if err := uuidDomuuid.fromC(&xc.domuuid); err != nil {
+		return err
+	}
+	x.Domuuid = uuidDomuuid
+	x.ForUser = uint64(xc.for_user)
+	return nil
+}
+
+func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info) error {
+	x.Id = uint32(xc.id)
+	x.CosMax = uint32(xc.cos_max)
+	x.CbmLen = uint32(xc.cbm_len)
+	x.CdpEnabled = bool(xc.cdp_enabled)
+	return nil
+}
+
+func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error {
+	x.Id = uint32(xc.id)
+	return nil
+}
-- 
2.19.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-10-07 15:15 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 15:12 [Xen-devel] [PATCH 00/24] generated Go libxl bindings using IDL Nick Rosbrook
2019-10-07 15:12 ` [Xen-devel] [PATCH 01/24] golang/xenlight: fix calls to libxl_domain_unpause/pause Nick Rosbrook
2019-10-07 16:39   ` George Dunlap
2019-10-08  4:17     ` Jürgen Groß
2019-10-07 15:12 ` [Xen-devel] [PATCH 02/24] golang/xenlight: generate enum types from IDL Nick Rosbrook
2019-10-24 14:35   ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 03/24] golang/xenlight: define Defbool builtin type Nick Rosbrook
2019-10-24 15:17   ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 04/24] golang/xenlight: define Devid type as int Nick Rosbrook
2019-10-24 15:20   ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 05/24] golang/xenlight: define KeyValueList builtin type Nick Rosbrook
2019-10-24 16:34   ` George Dunlap
2019-10-24 19:54     ` Nick Rosbrook
2019-10-25 11:26       ` George Dunlap
2019-10-25 12:30         ` Nick Rosbrook
2019-10-07 15:12 ` [Xen-devel] [PATCH 06/24] golang/xenlight: re-name Bitmap marshaling functions Nick Rosbrook
2019-11-13 15:21   ` George Dunlap
2019-11-13 20:53     ` Nick Rosbrook
2019-11-14 11:44       ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 07/24] golang/xenlight: define StringList builtin type Nick Rosbrook
2019-11-13 15:37   ` George Dunlap
2019-11-13 21:14     ` Nick Rosbrook
2019-10-07 15:12 ` [Xen-devel] [PATCH 08/24] golang/xenlight: define Mac " Nick Rosbrook
2019-11-13 15:51   ` George Dunlap
2019-11-13 21:50     ` Nick Rosbrook
2019-11-14 12:27       ` George Dunlap
2019-11-14 15:34         ` Nick Rosbrook
2019-10-07 15:12 ` [Xen-devel] [PATCH 09/24] golang/xenlight: define MsVmGenid " Nick Rosbrook
2019-11-13 16:20   ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 10/24] golang/xenlight: define EvLink builtin as empty struct Nick Rosbrook
2019-11-13 16:23   ` George Dunlap
2019-10-07 15:12 ` [Xen-devel] [PATCH 11/24] golang/xenlight: define CpuidPolicyList builtin type Nick Rosbrook
2019-11-13 17:34   ` George Dunlap
2019-11-14 14:58     ` Nick Rosbrook
2019-11-14 17:44       ` George Dunlap
2019-11-15 15:26         ` Nick Rosbrook
2019-11-15 15:42           ` George Dunlap
2019-11-15 15:51             ` Nick Rosbrook
2019-11-15 15:58               ` George Dunlap
2019-11-15 16:06                 ` Nick Rosbrook
2019-10-07 15:12 ` [Xen-devel] [PATCH 12/24] golang/xenlight: re-factor Uuid type implementation Nick Rosbrook
2019-11-13 17:47   ` George Dunlap
2019-10-07 15:13 ` [Xen-devel] [PATCH 13/24] golang/xenlight: re-factor Hwcap " Nick Rosbrook
2019-11-13 17:58   ` George Dunlap
2019-10-07 15:13 ` [Xen-devel] [PATCH 14/24] golang/xenlight: generate structs from the IDL Nick Rosbrook
2019-11-14 14:18   ` George Dunlap
2019-11-14 16:15     ` Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 15/24] golang/xenlight: remove no-longer used type MemKB Nick Rosbrook
2019-11-14 14:18   ` George Dunlap
2019-10-07 15:13 ` Nick Rosbrook [this message]
2019-10-07 15:13 ` [Xen-devel] [PATCH 17/24] golang/xenlight: implement keyed union C to Go marshaling Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 18/24] golang/xenlight: implement array " Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 19/24] golang/xenlight: begin Go to C type marshaling Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 20/24] golang/xenlight: implement keyed union Go to C marshaling Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 21/24] golang/xenlight: implement array " Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 22/24] golang/xenlight: revise use of Context type Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 23/24] golang/xenlight: add error return type to Context.Cpupoolinfo Nick Rosbrook
2019-10-07 15:13 ` [Xen-devel] [PATCH 24/24] golang/xenlight: add make target for generated files Nick Rosbrook
2019-10-24 14:26   ` George Dunlap
2019-10-24 18:49     ` Nick Rosbrook
2019-11-14 17:19       ` George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6fbc6a1e481ed9c1713bee8106c9bbeca626651.1570456846.git.rosbrookn@ainfosec.com \
    --to=rosbrookn@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=kerriganb@ainfosec.com \
    --cc=rosbrookn@ainfosec.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.