From patchwork Mon Dec 23 15:17:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11308449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D4EC138D for ; Mon, 23 Dec 2019 15:19:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2E26206CB for ; Mon, 23 Dec 2019 15:19:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hCNfW5Rx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2E26206CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijPSy-0006Jx-WE; Mon, 23 Dec 2019 15:17:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijPSx-0006Jo-IP for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 15:17:51 +0000 X-Inumbo-ID: 602dde54-2597-11ea-a1e1-bc764e2007e4 Received: from mail-qt1-x82a.google.com (unknown [2607:f8b0:4864:20::82a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 602dde54-2597-11ea-a1e1-bc764e2007e4; Mon, 23 Dec 2019 15:17:47 +0000 (UTC) Received: by mail-qt1-x82a.google.com with SMTP id l12so15610820qtq.12 for ; Mon, 23 Dec 2019 07:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=wsNbrXzTC4fbTgB0S7XOhOTybKwrAmTKHy13zlzg6dU=; b=hCNfW5Rxp00tKrKwd58mUjxr1ONqQ4ByU5C31vpw0/I993FU/kpbCxfgXIlo23qIef o0oLct4e73YsoQghYBFZJgQFUnQWqLHaqfkIKi3PI+ti9cTVZkz86HT2URuPKjCjS5FW Iz+dZMkm6J/Aw9eFa96dv5MXq29fH58LgSSAHhWPel3dDaMa/5wZhmZu2Lr3XDit0QeH sWpoSrZjKYMI2HUTiTlQK1maVkOoEmBtTJaLbnDZztGKpnjCqQjISFkImU2osVTqaxVf DspOEhTRht8y4yPwDgneXHlCgKKpDsOz0lDbAD7iRfD9ZZTucJE0FwfDPJKBkojyG7qJ bUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=wsNbrXzTC4fbTgB0S7XOhOTybKwrAmTKHy13zlzg6dU=; b=IE8fEras6eRWPLRplnPO3HPtC3POLLJt3moEDvND+Z2UwTSg9/wVbm2S5uMCy+i6lA XV+anIuWhS0eNXV5gm0WetSEXJhjBQMSghY2knAI2gT/1P/grAvgGwZJZDZ2VF+n3Nwp zcc9ok4NR6Gzx4VIhVT0Ml9hG/jS32XU/426Xqg+LARHIL3p87kdK6OoxgdwJ6gwjDuS 1l0OkHhijYKIrlHoCHNMLP3A+4Az/pIEWEj2D/T0dqBWybT0gjIQlhakTFHhrEpmQv6V JyOTbfNzj6L9JN1U+MInVkWOngJ/xG1qH2coUrKoLtldyS3nl7jj64rT6EBuSUQCg7WJ Uo0g== X-Gm-Message-State: APjAAAXyW93Y50QOAglmiYObknZjgEMX8UreHd9BFwBV4xCJxGShIrdg hAZdf/N0RKXW6wUWqtN7soDZkXGE X-Google-Smtp-Source: APXvYqyesthus1zMDBZt2DD8FJFcib1HkmnRn/UtVS6to44Opf5crhRCJl3uDLeMQbL6SggCC1Bldg== X-Received: by 2002:ac8:787:: with SMTP id l7mr21833596qth.99.1577114266339; Mon, 23 Dec 2019 07:17:46 -0800 (PST) Received: from four.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id u15sm5823907qku.67.2019.12.23.07.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2019 07:17:45 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Mon, 23 Dec 2019 10:17:02 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 1/6] golang/xenlight: implement array C to Go marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v4: - Call fromC using slice expression instead of creating temporary variable and assigning later. --- tools/golang/xenlight/gengotypes.py | 37 +++- tools/golang/xenlight/helpers.gen.go | 246 +++++++++++++++++++++++++++ 2 files changed, 282 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index b68c1aa66b..8857e2e8fd 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -252,7 +252,7 @@ def xenlight_golang_define_from_C(ty = None): for f in ty.fields: if f.type.typename is not None: if isinstance(f.type, idl.Array): - # TODO + body += xenlight_golang_array_from_C(f) continue body += xenlight_golang_convert_from_C(f) @@ -399,6 +399,41 @@ def xenlight_golang_union_from_C(ty = None, union_name = '', struct_name = ''): return (s,extras) +def xenlight_golang_array_from_C(ty = None): + """ + Convert C array to Go slice using the method + described here: + + https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices + """ + s = '' + + gotypename = xenlight_golang_fmt_name(ty.type.elem_type.typename) + goname = xenlight_golang_fmt_name(ty.name) + ctypename = ty.type.elem_type.typename + cname = ty.name + cslice = 'c{}'.format(goname) + clenvar = ty.type.lenvar.name + golenvar = xenlight_golang_fmt_name(clenvar,exported=False) + + s += '{} := int(xc.{})\n'.format(golenvar, clenvar) + s += '{} := '.format(cslice) + s +='(*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.format(ctypename, cname, + golenvar, golenvar) + s += 'x.{} = make([]{}, {})\n'.format(goname, gotypename, golenvar) + s += 'for i, v := range {} {{\n'.format(cslice) + + is_enum = isinstance(ty.type.elem_type,idl.Enumeration) + if gotypename in go_builtin_types or is_enum: + s += 'x.{}[i] = {}(v)\n'.format(goname, gotypename) + else: + s += 'if err := x.{}[i].fromC(&v); err != nil {{\n'.format(goname) + s += 'return err }\n' + + s += '}\n' + + return s + def xenlight_golang_fmt_name(name, exported = True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go index e6eee234c0..25294ba292 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -263,6 +263,14 @@ func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { x.Sched = Scheduler(xc.sched) + numVcpus := int(xc.num_vcpus) + cVcpus := (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:numVcpus:numVcpus] + x.Vcpus = make([]SchedParams, numVcpus) + for i, v := range cVcpus { + if err := x.Vcpus[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -282,6 +290,12 @@ func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { x.Memkb = uint64(xc.memkb) + numDistances := int(xc.num_distances) + cDistances := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:numDistances:numDistances] + x.Distances = make([]uint32, numDistances) + for i, v := range cDistances { + x.Distances[i] = uint32(v) + } x.Pnode = uint32(xc.pnode) if err := x.Vcpus.fromC(&xc.vcpus); err != nil { return err @@ -308,6 +322,22 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error { if err := x.Nodemap.fromC(&xc.nodemap); err != nil { return err } + numVcpuHardAffinity := int(xc.num_vcpu_hard_affinity) + cVcpuHardAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity] + x.VcpuHardAffinity = make([]Bitmap, numVcpuHardAffinity) + for i, v := range cVcpuHardAffinity { + if err := x.VcpuHardAffinity[i].fromC(&v); err != nil { + return err + } + } + numVcpuSoftAffinity := int(xc.num_vcpu_soft_affinity) + cVcpuSoftAffinity := (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity] + x.VcpuSoftAffinity = make([]Bitmap, numVcpuSoftAffinity) + for i, v := range cVcpuSoftAffinity { + if err := x.VcpuSoftAffinity[i].fromC(&v); err != nil { + return err + } + } if err := x.NumaPlacement.fromC(&xc.numa_placement); err != nil { return err } @@ -330,6 +360,14 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error { return err } x.BlkdevStart = C.GoString(xc.blkdev_start) + numVnumaNodes := int(xc.num_vnuma_nodes) + cVnumaNodes := (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_nodes))[:numVnumaNodes:numVnumaNodes] + x.VnumaNodes = make([]VnodeInfo, numVnumaNodes) + for i, v := range cVnumaNodes { + if err := x.VnumaNodes[i].fromC(&v); err != nil { + return err + } + } x.MaxGrantFrames = uint32(xc.max_grant_frames) x.MaxMaptrackFrames = uint32(xc.max_maptrack_frames) x.DeviceModelVersion = DeviceModelVersion(xc.device_model_version) @@ -352,6 +390,28 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error { if err := x.SchedParams.fromC(&xc.sched_params); err != nil { return err } + numIoports := int(xc.num_ioports) + cIoports := (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports))[:numIoports:numIoports] + x.Ioports = make([]IoportRange, numIoports) + for i, v := range cIoports { + if err := x.Ioports[i].fromC(&v); err != nil { + return err + } + } + numIrqs := int(xc.num_irqs) + cIrqs := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:numIrqs:numIrqs] + x.Irqs = make([]uint32, numIrqs) + for i, v := range cIrqs { + x.Irqs[i] = uint32(v) + } + numIomem := int(xc.num_iomem) + cIomem := (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:numIomem:numIomem] + x.Iomem = make([]IomemRange, numIomem) + for i, v := range cIomem { + if err := x.Iomem[i].fromC(&v); err != nil { + return err + } + } if err := x.ClaimMode.fromC(&xc.claim_mode); err != nil { return err } @@ -831,11 +891,31 @@ func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdispl) error { x.BackendDomname = C.GoString(xc.backend_domname) x.Devid = Devid(xc.devid) x.BeAlloc = bool(xc.be_alloc) + numConnectors := int(xc.num_connectors) + cConnectors := (*[1 << 28]C.libxl_connector_param)(unsafe.Pointer(xc.connectors))[:numConnectors:numConnectors] + x.Connectors = make([]ConnectorParam, numConnectors) + for i, v := range cConnectors { + if err := x.Connectors[i].fromC(&v); err != nil { + return err + } + } return nil } func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { + numSampleRates := int(xc.num_sample_rates) + cSampleRates := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates))[:numSampleRates:numSampleRates] + x.SampleRates = make([]uint32, numSampleRates) + for i, v := range cSampleRates { + x.SampleRates[i] = uint32(v) + } + numSampleFormats := int(xc.num_sample_formats) + cSampleFormats := (*[1 << 28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(xc.sample_formats))[:numSampleFormats:numSampleFormats] + x.SampleFormats = make([]VsndPcmFormat, numSampleFormats) + for i, v := range cSampleFormats { + x.SampleFormats[i] = VsndPcmFormat(v) + } x.ChannelsMin = uint32(xc.channels_min) x.ChannelsMax = uint32(xc.channels_max) x.BufferSize = uint32(xc.buffer_size) @@ -858,6 +938,14 @@ func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { if err := x.Params.fromC(&xc.params); err != nil { return err } + numVsndStreams := int(xc.num_vsnd_streams) + cStreams := (*[1 << 28]C.libxl_vsnd_stream)(unsafe.Pointer(xc.streams))[:numVsndStreams:numVsndStreams] + x.Streams = make([]VsndStream, numVsndStreams) + for i, v := range cStreams { + if err := x.Streams[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -871,6 +959,14 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error { if err := x.Params.fromC(&xc.params); err != nil { return err } + numVsndPcms := int(xc.num_vsnd_pcms) + cPcms := (*[1 << 28]C.libxl_vsnd_pcm)(unsafe.Pointer(xc.pcms))[:numVsndPcms:numVsndPcms] + x.Pcms = make([]VsndPcm, numVsndPcms) + for i, v := range cPcms { + if err := x.Pcms[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -882,6 +978,126 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error { if err := x.BInfo.fromC(&xc.b_info); err != nil { return err } + numDisks := int(xc.num_disks) + cDisks := (*[1 << 28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:numDisks:numDisks] + x.Disks = make([]DeviceDisk, numDisks) + for i, v := range cDisks { + if err := x.Disks[i].fromC(&v); err != nil { + return err + } + } + numNics := int(xc.num_nics) + cNics := (*[1 << 28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:numNics:numNics] + x.Nics = make([]DeviceNic, numNics) + for i, v := range cNics { + if err := x.Nics[i].fromC(&v); err != nil { + return err + } + } + numPcidevs := int(xc.num_pcidevs) + cPcidevs := (*[1 << 28]C.libxl_device_pci)(unsafe.Pointer(xc.pcidevs))[:numPcidevs:numPcidevs] + x.Pcidevs = make([]DevicePci, numPcidevs) + for i, v := range cPcidevs { + if err := x.Pcidevs[i].fromC(&v); err != nil { + return err + } + } + numRdms := int(xc.num_rdms) + cRdms := (*[1 << 28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:numRdms:numRdms] + x.Rdms = make([]DeviceRdm, numRdms) + for i, v := range cRdms { + if err := x.Rdms[i].fromC(&v); err != nil { + return err + } + } + numDtdevs := int(xc.num_dtdevs) + cDtdevs := (*[1 << 28]C.libxl_device_dtdev)(unsafe.Pointer(xc.dtdevs))[:numDtdevs:numDtdevs] + x.Dtdevs = make([]DeviceDtdev, numDtdevs) + for i, v := range cDtdevs { + if err := x.Dtdevs[i].fromC(&v); err != nil { + return err + } + } + numVfbs := int(xc.num_vfbs) + cVfbs := (*[1 << 28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:numVfbs:numVfbs] + x.Vfbs = make([]DeviceVfb, numVfbs) + for i, v := range cVfbs { + if err := x.Vfbs[i].fromC(&v); err != nil { + return err + } + } + numVkbs := int(xc.num_vkbs) + cVkbs := (*[1 << 28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:numVkbs:numVkbs] + x.Vkbs = make([]DeviceVkb, numVkbs) + for i, v := range cVkbs { + if err := x.Vkbs[i].fromC(&v); err != nil { + return err + } + } + numVtpms := int(xc.num_vtpms) + cVtpms := (*[1 << 28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:numVtpms:numVtpms] + x.Vtpms = make([]DeviceVtpm, numVtpms) + for i, v := range cVtpms { + if err := x.Vtpms[i].fromC(&v); err != nil { + return err + } + } + numP9S := int(xc.num_p9s) + cP9S := (*[1 << 28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:numP9S:numP9S] + x.P9S = make([]DeviceP9, numP9S) + for i, v := range cP9S { + if err := x.P9S[i].fromC(&v); err != nil { + return err + } + } + numPvcallsifs := int(xc.num_pvcallsifs) + cPvcallsifs := (*[1 << 28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.pvcallsifs))[:numPvcallsifs:numPvcallsifs] + x.Pvcallsifs = make([]DevicePvcallsif, numPvcallsifs) + for i, v := range cPvcallsifs { + if err := x.Pvcallsifs[i].fromC(&v); err != nil { + return err + } + } + numVdispls := int(xc.num_vdispls) + cVdispls := (*[1 << 28]C.libxl_device_vdispl)(unsafe.Pointer(xc.vdispls))[:numVdispls:numVdispls] + x.Vdispls = make([]DeviceVdispl, numVdispls) + for i, v := range cVdispls { + if err := x.Vdispls[i].fromC(&v); err != nil { + return err + } + } + numVsnds := int(xc.num_vsnds) + cVsnds := (*[1 << 28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:numVsnds:numVsnds] + x.Vsnds = make([]DeviceVsnd, numVsnds) + for i, v := range cVsnds { + if err := x.Vsnds[i].fromC(&v); err != nil { + return err + } + } + numChannels := int(xc.num_channels) + cChannels := (*[1 << 28]C.libxl_device_channel)(unsafe.Pointer(xc.channels))[:numChannels:numChannels] + x.Channels = make([]DeviceChannel, numChannels) + for i, v := range cChannels { + if err := x.Channels[i].fromC(&v); err != nil { + return err + } + } + numUsbctrls := int(xc.num_usbctrls) + cUsbctrls := (*[1 << 28]C.libxl_device_usbctrl)(unsafe.Pointer(xc.usbctrls))[:numUsbctrls:numUsbctrls] + x.Usbctrls = make([]DeviceUsbctrl, numUsbctrls) + for i, v := range cUsbctrls { + if err := x.Usbctrls[i].fromC(&v); err != nil { + return err + } + } + numUsbdevs := int(xc.num_usbdevs) + cUsbdevs := (*[1 << 28]C.libxl_device_usbdev)(unsafe.Pointer(xc.usbdevs))[:numUsbdevs:numUsbdevs] + x.Usbdevs = make([]DeviceUsbdev, numUsbdevs) + for i, v := range cUsbdevs { + if err := x.Usbdevs[i].fromC(&v); err != nil { + return err + } + } x.OnPoweroff = ActionOnShutdown(xc.on_poweroff) x.OnReboot = ActionOnShutdown(xc.on_reboot) x.OnWatchdog = ActionOnShutdown(xc.on_watchdog) @@ -1015,6 +1231,14 @@ func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error { x.Devid = Devid(xc.devid) x.State = int(xc.state) x.BeAlloc = bool(xc.be_alloc) + numConnectors := int(xc.num_connectors) + cConnectors := (*[1 << 28]C.libxl_connectorinfo)(unsafe.Pointer(xc.connectors))[:numConnectors:numConnectors] + x.Connectors = make([]Connectorinfo, numConnectors) + for i, v := range cConnectors { + if err := x.Connectors[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -1027,6 +1251,14 @@ func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error { } func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { + numVsndStreams := int(xc.num_vsnd_streams) + cStreams := (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))[:numVsndStreams:numVsndStreams] + x.Streams = make([]Streaminfo, numVsndStreams) + for i, v := range cStreams { + if err := x.Streams[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -1038,6 +1270,14 @@ func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error { x.FrontendId = uint32(xc.frontend_id) x.Devid = Devid(xc.devid) x.State = int(xc.state) + numVsndPcms := int(xc.num_vsnd_pcms) + cPcms := (*[1 << 28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:numVsndPcms:numVsndPcms] + x.Pcms = make([]Pcminfo, numVsndPcms) + for i, v := range cPcms { + if err := x.Pcms[i].fromC(&v); err != nil { + return err + } + } return nil } @@ -1058,6 +1298,12 @@ func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { func (x *Numainfo) fromC(xc *C.libxl_numainfo) error { x.Size = uint64(xc.size) x.Free = uint64(xc.free) + numDists := int(xc.num_dists) + cDists := (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.dists))[:numDists:numDists] + x.Dists = make([]uint32, numDists) + for i, v := range cDists { + x.Dists[i] = uint32(v) + } return nil }