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

[Xen-changelog] [xen master] golang/xenlight: implement array Go to C marshaling



commit 2572c7d76e1aee9b11a23c548cee69b15a35401f
Author:     Nick Rosbrook <rosbrookn@xxxxxxxxx>
AuthorDate: Sat Jan 4 16:00:53 2020 -0500
Commit:     George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Thu Jan 16 18:18:03 2020 +0000

    golang/xenlight: implement array Go to C marshaling
    
    Signed-off-by: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 tools/golang/xenlight/gengotypes.py  |  41 ++++-
 tools/golang/xenlight/helpers.gen.go | 311 +++++++++++++++++++++++++++++++++++
 2 files changed, 351 insertions(+), 1 deletion(-)

diff --git a/tools/golang/xenlight/gengotypes.py 
b/tools/golang/xenlight/gengotypes.py
index 8ab6768e61..27edf66241 100644
--- a/tools/golang/xenlight/gengotypes.py
+++ b/tools/golang/xenlight/gengotypes.py
@@ -454,7 +454,7 @@ def xenlight_golang_define_to_C(ty = None, typename = None, 
nested = False):
     for f in ty.fields:
         if f.type.typename is not None:
             if isinstance(f.type, idl.Array):
-                # TODO
+                body += xenlight_golang_array_to_C(f)
                 continue
 
             body += xenlight_golang_convert_to_C(f)
@@ -580,6 +580,45 @@ def xenlight_golang_union_to_C(ty = None, union_name = '',
 
     return s
 
+def xenlight_golang_array_to_C(ty = None):
+    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
+    clenvar    = ty.type.lenvar.name
+    golenvar   = xenlight_golang_fmt_name(clenvar,exported=False)
+
+    is_enum = isinstance(ty.type.elem_type,idl.Enumeration)
+    if gotypename in go_builtin_types or is_enum:
+        s += 'if {} := len(x.{}); {} > 0 {{\n'.format(golenvar,goname,golenvar)
+        s += 'xc.{} = 
(*C.{})(C.malloc(C.size_t({}*{})))\n'.format(cname,ctypename,
+                                                                   
golenvar,golenvar)
+        s += 'xc.{} = C.int({})\n'.format(clenvar,golenvar)
+        s += 'c{} := 
(*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.format(goname,
+                                                                      
ctypename,cname,
+                                                                      
golenvar,golenvar)
+        s += 'for i,v := range x.{} {{\n'.format(goname)
+        s += 'c{}[i] = C.{}(v)\n'.format(goname,ctypename)
+        s += '}\n}\n'
+
+        return s
+
+    s += 'if {} := len(x.{}); {} > 0 {{\n'.format(golenvar,goname,golenvar)
+    s += 'xc.{} = 
(*C.{})(C.malloc(C.ulong({})*C.sizeof_{}))\n'.format(cname,ctypename,
+                                                                   
golenvar,ctypename)
+    s += 'xc.{} = C.int({})\n'.format(clenvar,golenvar)
+    s += 'c{} := 
(*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.format(goname,
+                                                                         
ctypename,cname,
+                                                                         
golenvar,golenvar)
+    s += 'for i,v := range x.{} {{\n'.format(goname)
+    s += 'if err := v.toC(&c{}[i]); err != nil {{\n'.format(goname)
+    s += 'return err\n'
+    s += '}\n}\n}\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 0bf2b0ddef..b9a7e828a0 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -643,6 +643,16 @@ func (x *VcpuSchedParams) toC(xc 
*C.libxl_vcpu_sched_params) (err error) {
        }()
 
        xc.sched = C.libxl_scheduler(x.Sched)
+       if numVcpus := len(x.Vcpus); numVcpus > 0 {
+               xc.vcpus = (*C.libxl_sched_params)(C.malloc(C.ulong(numVcpus) * 
C.sizeof_libxl_sched_params))
+               xc.num_vcpus = C.int(numVcpus)
+               cVcpus := (*[1 << 
28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:numVcpus:numVcpus]
+               for i, v := range x.Vcpus {
+                       if err := v.toC(&cVcpus[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -703,6 +713,14 @@ func (x *VnodeInfo) toC(xc *C.libxl_vnode_info) (err 
error) {
        }()
 
        xc.memkb = C.uint64_t(x.Memkb)
+       if numDistances := len(x.Distances); numDistances > 0 {
+               xc.distances = (*C.uint32_t)(C.malloc(C.size_t(numDistances * 
numDistances)))
+               xc.num_distances = C.int(numDistances)
+               cDistances := (*[1 << 
28]C.uint32_t)(unsafe.Pointer(xc.distances))[:numDistances:numDistances]
+               for i, v := range x.Distances {
+                       cDistances[i] = C.uint32_t(v)
+               }
+       }
        xc.pnode = C.uint32_t(x.Pnode)
        if err := x.Vcpus.toC(&xc.vcpus); err != nil {
                return err
@@ -1050,6 +1068,26 @@ func (x *DomainBuildInfo) toC(xc 
*C.libxl_domain_build_info) (err error) {
        if err := x.Nodemap.toC(&xc.nodemap); err != nil {
                return err
        }
+       if numVcpuHardAffinity := len(x.VcpuHardAffinity); numVcpuHardAffinity 
> 0 {
+               xc.vcpu_hard_affinity = 
(*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuHardAffinity) * 
C.sizeof_libxl_bitmap))
+               xc.num_vcpu_hard_affinity = C.int(numVcpuHardAffinity)
+               cVcpuHardAffinity := (*[1 << 
28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity]
+               for i, v := range x.VcpuHardAffinity {
+                       if err := v.toC(&cVcpuHardAffinity[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVcpuSoftAffinity := len(x.VcpuSoftAffinity); numVcpuSoftAffinity 
> 0 {
+               xc.vcpu_soft_affinity = 
(*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuSoftAffinity) * 
C.sizeof_libxl_bitmap))
+               xc.num_vcpu_soft_affinity = C.int(numVcpuSoftAffinity)
+               cVcpuSoftAffinity := (*[1 << 
28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity]
+               for i, v := range x.VcpuSoftAffinity {
+                       if err := v.toC(&cVcpuSoftAffinity[i]); err != nil {
+                               return err
+                       }
+               }
+       }
        if err := x.NumaPlacement.toC(&xc.numa_placement); err != nil {
                return err
        }
@@ -1076,6 +1114,16 @@ func (x *DomainBuildInfo) toC(xc 
*C.libxl_domain_build_info) (err error) {
        if x.BlkdevStart != "" {
                xc.blkdev_start = C.CString(x.BlkdevStart)
        }
+       if numVnumaNodes := len(x.VnumaNodes); numVnumaNodes > 0 {
+               xc.vnuma_nodes = 
(*C.libxl_vnode_info)(C.malloc(C.ulong(numVnumaNodes) * 
C.sizeof_libxl_vnode_info))
+               xc.num_vnuma_nodes = C.int(numVnumaNodes)
+               cVnumaNodes := (*[1 << 
28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_nodes))[:numVnumaNodes:numVnumaNodes]
+               for i, v := range x.VnumaNodes {
+                       if err := v.toC(&cVnumaNodes[i]); err != nil {
+                               return err
+                       }
+               }
+       }
        xc.max_grant_frames = C.uint32_t(x.MaxGrantFrames)
        xc.max_maptrack_frames = C.uint32_t(x.MaxMaptrackFrames)
        xc.device_model_version = 
C.libxl_device_model_version(x.DeviceModelVersion)
@@ -1104,6 +1152,34 @@ func (x *DomainBuildInfo) toC(xc 
*C.libxl_domain_build_info) (err error) {
        if err := x.SchedParams.toC(&xc.sched_params); err != nil {
                return err
        }
+       if numIoports := len(x.Ioports); numIoports > 0 {
+               xc.ioports = 
(*C.libxl_ioport_range)(C.malloc(C.ulong(numIoports) * 
C.sizeof_libxl_ioport_range))
+               xc.num_ioports = C.int(numIoports)
+               cIoports := (*[1 << 
28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports))[:numIoports:numIoports]
+               for i, v := range x.Ioports {
+                       if err := v.toC(&cIoports[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numIrqs := len(x.Irqs); numIrqs > 0 {
+               xc.irqs = (*C.uint32_t)(C.malloc(C.size_t(numIrqs * numIrqs)))
+               xc.num_irqs = C.int(numIrqs)
+               cIrqs := (*[1 << 
28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:numIrqs:numIrqs]
+               for i, v := range x.Irqs {
+                       cIrqs[i] = C.uint32_t(v)
+               }
+       }
+       if numIomem := len(x.Iomem); numIomem > 0 {
+               xc.iomem = (*C.libxl_iomem_range)(C.malloc(C.ulong(numIomem) * 
C.sizeof_libxl_iomem_range))
+               xc.num_iomem = C.int(numIomem)
+               cIomem := (*[1 << 
28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:numIomem:numIomem]
+               for i, v := range x.Iomem {
+                       if err := v.toC(&cIomem[i]); err != nil {
+                               return err
+                       }
+               }
+       }
        if err := x.ClaimMode.toC(&xc.claim_mode); err != nil {
                return err
        }
@@ -2136,6 +2212,16 @@ func (x *DeviceVdispl) toC(xc *C.libxl_device_vdispl) 
(err error) {
        }
        xc.devid = C.libxl_devid(x.Devid)
        xc.be_alloc = C.bool(x.BeAlloc)
+       if numConnectors := len(x.Connectors); numConnectors > 0 {
+               xc.connectors = 
(*C.libxl_connector_param)(C.malloc(C.ulong(numConnectors) * 
C.sizeof_libxl_connector_param))
+               xc.num_connectors = C.int(numConnectors)
+               cConnectors := (*[1 << 
28]C.libxl_connector_param)(unsafe.Pointer(xc.connectors))[:numConnectors:numConnectors]
+               for i, v := range x.Connectors {
+                       if err := v.toC(&cConnectors[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -2167,6 +2253,22 @@ func (x *VsndParams) toC(xc *C.libxl_vsnd_params) (err 
error) {
                }
        }()
 
+       if numSampleRates := len(x.SampleRates); numSampleRates > 0 {
+               xc.sample_rates = 
(*C.uint32_t)(C.malloc(C.size_t(numSampleRates * numSampleRates)))
+               xc.num_sample_rates = C.int(numSampleRates)
+               cSampleRates := (*[1 << 
28]C.uint32_t)(unsafe.Pointer(xc.sample_rates))[:numSampleRates:numSampleRates]
+               for i, v := range x.SampleRates {
+                       cSampleRates[i] = C.uint32_t(v)
+               }
+       }
+       if numSampleFormats := len(x.SampleFormats); numSampleFormats > 0 {
+               xc.sample_formats = 
(*C.libxl_vsnd_pcm_format)(C.malloc(C.size_t(numSampleFormats * 
numSampleFormats)))
+               xc.num_sample_formats = C.int(numSampleFormats)
+               cSampleFormats := (*[1 << 
28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(xc.sample_formats))[:numSampleFormats:numSampleFormats]
+               for i, v := range x.SampleFormats {
+                       cSampleFormats[i] = C.libxl_vsnd_pcm_format(v)
+               }
+       }
        xc.channels_min = C.uint32_t(x.ChannelsMin)
        xc.channels_max = C.uint32_t(x.ChannelsMax)
        xc.buffer_size = C.uint32_t(x.BufferSize)
@@ -2232,6 +2334,16 @@ func (x *VsndPcm) toC(xc *C.libxl_vsnd_pcm) (err error) {
        if err := x.Params.toC(&xc.params); err != nil {
                return err
        }
+       if numVsndStreams := len(x.Streams); numVsndStreams > 0 {
+               xc.streams = 
(*C.libxl_vsnd_stream)(C.malloc(C.ulong(numVsndStreams) * 
C.sizeof_libxl_vsnd_stream))
+               xc.num_vsnd_streams = C.int(numVsndStreams)
+               cStreams := (*[1 << 
28]C.libxl_vsnd_stream)(unsafe.Pointer(xc.streams))[:numVsndStreams:numVsndStreams]
+               for i, v := range x.Streams {
+                       if err := v.toC(&cStreams[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -2278,6 +2390,16 @@ func (x *DeviceVsnd) toC(xc *C.libxl_device_vsnd) (err 
error) {
        if err := x.Params.toC(&xc.params); err != nil {
                return err
        }
+       if numVsndPcms := len(x.Pcms); numVsndPcms > 0 {
+               xc.pcms = (*C.libxl_vsnd_pcm)(C.malloc(C.ulong(numVsndPcms) * 
C.sizeof_libxl_vsnd_pcm))
+               xc.num_vsnd_pcms = C.int(numVsndPcms)
+               cPcms := (*[1 << 
28]C.libxl_vsnd_pcm)(unsafe.Pointer(xc.pcms))[:numVsndPcms:numVsndPcms]
+               for i, v := range x.Pcms {
+                       if err := v.toC(&cPcms[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -2431,6 +2553,156 @@ func (x *DomainConfig) toC(xc *C.libxl_domain_config) 
(err error) {
        if err := x.BInfo.toC(&xc.b_info); err != nil {
                return err
        }
+       if numDisks := len(x.Disks); numDisks > 0 {
+               xc.disks = (*C.libxl_device_disk)(C.malloc(C.ulong(numDisks) * 
C.sizeof_libxl_device_disk))
+               xc.num_disks = C.int(numDisks)
+               cDisks := (*[1 << 
28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:numDisks:numDisks]
+               for i, v := range x.Disks {
+                       if err := v.toC(&cDisks[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numNics := len(x.Nics); numNics > 0 {
+               xc.nics = (*C.libxl_device_nic)(C.malloc(C.ulong(numNics) * 
C.sizeof_libxl_device_nic))
+               xc.num_nics = C.int(numNics)
+               cNics := (*[1 << 
28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:numNics:numNics]
+               for i, v := range x.Nics {
+                       if err := v.toC(&cNics[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numPcidevs := len(x.Pcidevs); numPcidevs > 0 {
+               xc.pcidevs = (*C.libxl_device_pci)(C.malloc(C.ulong(numPcidevs) 
* C.sizeof_libxl_device_pci))
+               xc.num_pcidevs = C.int(numPcidevs)
+               cPcidevs := (*[1 << 
28]C.libxl_device_pci)(unsafe.Pointer(xc.pcidevs))[:numPcidevs:numPcidevs]
+               for i, v := range x.Pcidevs {
+                       if err := v.toC(&cPcidevs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numRdms := len(x.Rdms); numRdms > 0 {
+               xc.rdms = (*C.libxl_device_rdm)(C.malloc(C.ulong(numRdms) * 
C.sizeof_libxl_device_rdm))
+               xc.num_rdms = C.int(numRdms)
+               cRdms := (*[1 << 
28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:numRdms:numRdms]
+               for i, v := range x.Rdms {
+                       if err := v.toC(&cRdms[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numDtdevs := len(x.Dtdevs); numDtdevs > 0 {
+               xc.dtdevs = (*C.libxl_device_dtdev)(C.malloc(C.ulong(numDtdevs) 
* C.sizeof_libxl_device_dtdev))
+               xc.num_dtdevs = C.int(numDtdevs)
+               cDtdevs := (*[1 << 
28]C.libxl_device_dtdev)(unsafe.Pointer(xc.dtdevs))[:numDtdevs:numDtdevs]
+               for i, v := range x.Dtdevs {
+                       if err := v.toC(&cDtdevs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVfbs := len(x.Vfbs); numVfbs > 0 {
+               xc.vfbs = (*C.libxl_device_vfb)(C.malloc(C.ulong(numVfbs) * 
C.sizeof_libxl_device_vfb))
+               xc.num_vfbs = C.int(numVfbs)
+               cVfbs := (*[1 << 
28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:numVfbs:numVfbs]
+               for i, v := range x.Vfbs {
+                       if err := v.toC(&cVfbs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVkbs := len(x.Vkbs); numVkbs > 0 {
+               xc.vkbs = (*C.libxl_device_vkb)(C.malloc(C.ulong(numVkbs) * 
C.sizeof_libxl_device_vkb))
+               xc.num_vkbs = C.int(numVkbs)
+               cVkbs := (*[1 << 
28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:numVkbs:numVkbs]
+               for i, v := range x.Vkbs {
+                       if err := v.toC(&cVkbs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVtpms := len(x.Vtpms); numVtpms > 0 {
+               xc.vtpms = (*C.libxl_device_vtpm)(C.malloc(C.ulong(numVtpms) * 
C.sizeof_libxl_device_vtpm))
+               xc.num_vtpms = C.int(numVtpms)
+               cVtpms := (*[1 << 
28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:numVtpms:numVtpms]
+               for i, v := range x.Vtpms {
+                       if err := v.toC(&cVtpms[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numP9S := len(x.P9S); numP9S > 0 {
+               xc.p9s = (*C.libxl_device_p9)(C.malloc(C.ulong(numP9S) * 
C.sizeof_libxl_device_p9))
+               xc.num_p9s = C.int(numP9S)
+               cP9S := (*[1 << 
28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:numP9S:numP9S]
+               for i, v := range x.P9S {
+                       if err := v.toC(&cP9S[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numPvcallsifs := len(x.Pvcallsifs); numPvcallsifs > 0 {
+               xc.pvcallsifs = 
(*C.libxl_device_pvcallsif)(C.malloc(C.ulong(numPvcallsifs) * 
C.sizeof_libxl_device_pvcallsif))
+               xc.num_pvcallsifs = C.int(numPvcallsifs)
+               cPvcallsifs := (*[1 << 
28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.pvcallsifs))[:numPvcallsifs:numPvcallsifs]
+               for i, v := range x.Pvcallsifs {
+                       if err := v.toC(&cPvcallsifs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVdispls := len(x.Vdispls); numVdispls > 0 {
+               xc.vdispls = 
(*C.libxl_device_vdispl)(C.malloc(C.ulong(numVdispls) * 
C.sizeof_libxl_device_vdispl))
+               xc.num_vdispls = C.int(numVdispls)
+               cVdispls := (*[1 << 
28]C.libxl_device_vdispl)(unsafe.Pointer(xc.vdispls))[:numVdispls:numVdispls]
+               for i, v := range x.Vdispls {
+                       if err := v.toC(&cVdispls[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numVsnds := len(x.Vsnds); numVsnds > 0 {
+               xc.vsnds = (*C.libxl_device_vsnd)(C.malloc(C.ulong(numVsnds) * 
C.sizeof_libxl_device_vsnd))
+               xc.num_vsnds = C.int(numVsnds)
+               cVsnds := (*[1 << 
28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:numVsnds:numVsnds]
+               for i, v := range x.Vsnds {
+                       if err := v.toC(&cVsnds[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numChannels := len(x.Channels); numChannels > 0 {
+               xc.channels = 
(*C.libxl_device_channel)(C.malloc(C.ulong(numChannels) * 
C.sizeof_libxl_device_channel))
+               xc.num_channels = C.int(numChannels)
+               cChannels := (*[1 << 
28]C.libxl_device_channel)(unsafe.Pointer(xc.channels))[:numChannels:numChannels]
+               for i, v := range x.Channels {
+                       if err := v.toC(&cChannels[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numUsbctrls := len(x.Usbctrls); numUsbctrls > 0 {
+               xc.usbctrls = 
(*C.libxl_device_usbctrl)(C.malloc(C.ulong(numUsbctrls) * 
C.sizeof_libxl_device_usbctrl))
+               xc.num_usbctrls = C.int(numUsbctrls)
+               cUsbctrls := (*[1 << 
28]C.libxl_device_usbctrl)(unsafe.Pointer(xc.usbctrls))[:numUsbctrls:numUsbctrls]
+               for i, v := range x.Usbctrls {
+                       if err := v.toC(&cUsbctrls[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+       if numUsbdevs := len(x.Usbdevs); numUsbdevs > 0 {
+               xc.usbdevs = 
(*C.libxl_device_usbdev)(C.malloc(C.ulong(numUsbdevs) * 
C.sizeof_libxl_device_usbdev))
+               xc.num_usbdevs = C.int(numUsbdevs)
+               cUsbdevs := (*[1 << 
28]C.libxl_device_usbdev)(unsafe.Pointer(xc.usbdevs))[:numUsbdevs:numUsbdevs]
+               for i, v := range x.Usbdevs {
+                       if err := v.toC(&cUsbdevs[i]); err != nil {
+                               return err
+                       }
+               }
+       }
        xc.on_poweroff = C.libxl_action_on_shutdown(x.OnPoweroff)
        xc.on_reboot = C.libxl_action_on_shutdown(x.OnReboot)
        xc.on_watchdog = C.libxl_action_on_shutdown(x.OnWatchdog)
@@ -2770,6 +3042,16 @@ func (x *Vdisplinfo) toC(xc *C.libxl_vdisplinfo) (err 
error) {
        xc.devid = C.libxl_devid(x.Devid)
        xc.state = C.int(x.State)
        xc.be_alloc = C.bool(x.BeAlloc)
+       if numConnectors := len(x.Connectors); numConnectors > 0 {
+               xc.connectors = 
(*C.libxl_connectorinfo)(C.malloc(C.ulong(numConnectors) * 
C.sizeof_libxl_connectorinfo))
+               xc.num_connectors = C.int(numConnectors)
+               cConnectors := (*[1 << 
28]C.libxl_connectorinfo)(unsafe.Pointer(xc.connectors))[:numConnectors:numConnectors]
+               for i, v := range x.Connectors {
+                       if err := v.toC(&cConnectors[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -2814,6 +3096,17 @@ func (x *Pcminfo) toC(xc *C.libxl_pcminfo) (err error) {
                }
        }()
 
+       if numVsndStreams := len(x.Streams); numVsndStreams > 0 {
+               xc.streams = 
(*C.libxl_streaminfo)(C.malloc(C.ulong(numVsndStreams) * 
C.sizeof_libxl_streaminfo))
+               xc.num_vsnd_streams = C.int(numVsndStreams)
+               cStreams := (*[1 << 
28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))[:numVsndStreams:numVsndStreams]
+               for i, v := range x.Streams {
+                       if err := v.toC(&cStreams[i]); err != nil {
+                               return err
+                       }
+               }
+       }
+
        return nil
 }
 
@@ -2853,6 +3146,16 @@ func (x *Vsndinfo) toC(xc *C.libxl_vsndinfo) (err error) 
{
        xc.frontend_id = C.uint32_t(x.FrontendId)
        xc.devid = C.libxl_devid(x.Devid)
        xc.state = C.int(x.State)
+       if numVsndPcms := len(x.Pcms); numVsndPcms > 0 {
+               xc.pcms = (*C.libxl_pcminfo)(C.malloc(C.ulong(numVsndPcms) * 
C.sizeof_libxl_pcminfo))
+               xc.num_vsnd_pcms = C.int(numVsndPcms)
+               cPcms := (*[1 << 
28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:numVsndPcms:numVsndPcms]
+               for i, v := range x.Pcms {
+                       if err := v.toC(&cPcms[i]); err != nil {
+                               return err
+                       }
+               }
+       }
 
        return nil
 }
@@ -2915,6 +3218,14 @@ func (x *Numainfo) toC(xc *C.libxl_numainfo) (err error) 
{
 
        xc.size = C.uint64_t(x.Size)
        xc.free = C.uint64_t(x.Free)
+       if numDists := len(x.Dists); numDists > 0 {
+               xc.dists = (*C.uint32_t)(C.malloc(C.size_t(numDists * 
numDists)))
+               xc.num_dists = C.int(numDists)
+               cDists := (*[1 << 
28]C.uint32_t)(unsafe.Pointer(xc.dists))[:numDists:numDists]
+               for i, v := range x.Dists {
+                       cDists[i] = C.uint32_t(v)
+               }
+       }
 
        return nil
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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