From nobody Mon Feb 9 06:49:37 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1578171748; cv=none; d=zohomail.com; s=zohoarc; b=bkBWE7DYkHKFmo3WfrS8Hnd+VbGv7touVSzA0o9ZYwDH58rhz77s3YFldP6C/8H2hX6RRaYwcreEytD//2plx0BRVKqrjRERzW13PGatWxNrCMZFdlBTOQb10pCj3GJuPkw0bSftEZoLRD0j5I4whvqQuBLr5U0/HBKWeWiGG6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578171748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7rrRS/82t38erLAGVqr7a3C0eUC5EAXLsBAsZKnYptk=; b=VdbYZ5GtuyewyhGNCzZJIqQeGxuzVBD7q3Clu3mhIyYwRYfqhQwxHq8KKbS9Hqjd8kJ8ODvxd9zh3ChAMSo8vCbdIAKNcbdCkoz25/zjX8l0ynBkP3t14V3lpBL9gDs3O6gDIoCXvdMmni/iFrT7mKAS/n5ZA4LHmmGo56u9uQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1578171748606533.4577185632863; Sat, 4 Jan 2020 13:02:28 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inqY2-0003F4-Ds; Sat, 04 Jan 2020 21:01:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inqY1-0003Ey-G2 for xen-devel@lists.xenproject.org; Sat, 04 Jan 2020 21:01:25 +0000 Received: from mail-yb1-xb31.google.com (unknown [2607:f8b0:4864:20::b31]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5bb30b72-2f35-11ea-a914-bc764e2007e4; Sat, 04 Jan 2020 21:01:20 +0000 (UTC) Received: by mail-yb1-xb31.google.com with SMTP id l7so12425796ybp.1 for ; Sat, 04 Jan 2020 13:01:20 -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 r10sm26366714ywr.97.2020.01.04.13.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2020 13:01:18 -0800 (PST) X-Inumbo-ID: 5bb30b72-2f35-11ea-a914-bc764e2007e4 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=CZfl/dl9ScYmQdwwhWaZQUW3IxIbwMKFNGj7gBDf/k0=; b=qjApG186HqrCzSJMFkTaUaSZXClronMbCiuRo6t+S08acncmHiu/+W8IFa+sMgasJ7 KsyL4E7fN1Kh048d/HFiMdK4nJ5SczUMuaqcoiOi5xR2TFYvIWwN4hfE9f237pD6f6Rf CvGy1LVZuIr9/8I9xyvtN3IX/HMlKDwKlvkq9NeGQnvxNiMMP6vKWAPUumWwKOKazsiS +qtQN97VGFCH7cUNObA53wYBGavoYvuDUjxw0QFbpTtL52LkHqp9nQkfST+Ymca1gXj+ bgOZGoV/OohL8rBebgEw3wEGMLczGxzwensvR+fdAVp9WetvLdyg8/AJ+nlNSdkBzoDg P5sw== 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=CZfl/dl9ScYmQdwwhWaZQUW3IxIbwMKFNGj7gBDf/k0=; b=PspsDvGLzQHMw1Eb31Yf4bRvAL+sSURnSnZTAT7Kdy6QB/HtifZOfSlgg1rVRj1+6L c/WQvityWTcaZDEOeBY9ho9M4U01Bc44I7uuWCZFd4PKvcp77mJhcYY5ySJ+aGk64zXH C3GdmzJ8aETukNuGmPBeFzryWoIDJ1oIgG13aq2o2Espkj04LUWt8HZxok1rsV1GOjFY VbJNmSB2p7yNjmMTPx/ObwOdcuHGUPSXlMHEwtOOgSZTVfS9YCFddBL3vLG1ct2ZzqYX gVTqkuZiIffwY7rGl29HTgZg4hGmSV+vPNAzFPb9EomiWoUS/RqEj2qkdQGAdlwzrdUq i5ow== X-Gm-Message-State: APjAAAX/+H4MVYayIVnGzSckPJRVoSqlLOnYVuKIvY0m2L55fan4s2UO iRa6pF+N7QkYE1Db5nKjslDYaYl7 X-Google-Smtp-Source: APXvYqw3pa4Wf4hoaKb/ZTXnm0EcQQHQqTul/7ruoKrfyloW4+0l3QcOel1MiD0gTuFrp3pR36R/fg== X-Received: by 2002:a25:d2d3:: with SMTP id j202mr67110040ybg.278.1578171678767; Sat, 04 Jan 2020 13:01:18 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Sat, 4 Jan 2020 16:00:51 -0500 Message-Id: <3a36857aeebe9a8ec3c4bc64f8ee77cdab035d6e.1578170151.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH v5 1/3] golang/xenlight: begin Go to C type 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 , George Dunlap , Wei Liu MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Implement conversions for basic types such as strings and integer types in toC functions. Modify function signatures of toC implementations for builtin types to be consistent with the signature of the generated toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v5: - Define xenlight_golang_convert_to_C so that field conversion code can be easily re-used. - Check for err in defer'd func within toC to determine if the dispose function needs to be called. - Pass a reference to the C type in toC, rather than returning a copy of the C variable. - Update the existing toC functions for builtin types to be consistent with the generated functions. - Only call CString if the Go string is non-empty. --- tools/golang/xenlight/gengotypes.py | 81 ++ tools/golang/xenlight/helpers.gen.go | 1506 ++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 82 +- 3 files changed, 1621 insertions(+), 48 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 8857e2e8fd..15aa4be220 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -234,6 +234,9 @@ def xenlight_golang_generate_helpers(path =3D None, typ= es =3D None, comment =3D None): f.write(extra) f.write('\n') =20 + f.write(xenlight_golang_define_to_C(ty)) + f.write('\n') + go_fmt(path) =20 def xenlight_golang_define_from_C(ty =3D None): @@ -434,6 +437,84 @@ def xenlight_golang_array_from_C(ty =3D None): =20 return s =20 +def xenlight_golang_define_to_C(ty =3D None, typename =3D None, nested =3D= False): + """ + Define the toC marshaling function for the type + represented by ty. + """ + func =3D 'func (x *{}) toC(xc *C.{}) (err error){{{}\n return nil \n }= }\n' + body =3D '' + + if ty.dispose_fn is not None: + body +=3D 'defer func(){{\nif err !=3D nil{{\nC.{}(xc)}}\n}}()\n\n= '.format(ty.dispose_fn) + + goname =3D xenlight_golang_fmt_name(ty.typename) + cname =3D ty.typename + + for f in ty.fields: + if f.type.typename is not None: + if isinstance(f.type, idl.Array): + # TODO + continue + + body +=3D xenlight_golang_convert_to_C(f) + + elif isinstance(f.type, idl.Struct): + for nf in f.type.fields: + body +=3D xenlight_golang_convert_to_C(nf, outer_name=3Df.= name) + + elif isinstance(f.type, idl.KeyedUnion): + # TODO + pass + + else: + raise Exception('type {} not supported'.format(f.type)) + + return func.format(goname, cname, body) + +def xenlight_golang_convert_to_C(ty =3D None, outer_name =3D None): + """ + Returns a line of Go code that converts the Go type represented + by ty to its corresponding Go type. + + If outer_name is set, the type is treated as nested within another fie= ld + named outer_name. + """ + s =3D '' + + gotypename =3D xenlight_golang_fmt_name(ty.type.typename) + ctypename =3D ty.type.typename + goname =3D xenlight_golang_fmt_name(ty.name) + cname =3D ty.name + + # In cgo, C names that conflict with Go keywords can be + # accessed by prepending an underscore to the name. + if cname in go_keywords: + cname =3D '_' + cname + + # If outer_name is set, treat this as nested. + if outer_name is not None: + goname =3D '{}.{}'.format(xenlight_golang_fmt_name(outer_name), go= name) + cname =3D '{}.{}'.format(outer_name, cname) + + is_castable =3D (ty.type.json_parse_type =3D=3D 'JSON_INTEGER' or + isinstance(ty.type, idl.Enumeration) or + gotypename in go_builtin_types) + + if not is_castable: + s +=3D 'if err :=3D x.{}.toC(&xc.{}); err !=3D nil {{\n'.format(go= name,cname) + s +=3D 'return err\n}\n' + + elif gotypename =3D=3D 'string': + # Use the cgo helper for converting C strings. + s +=3D 'if x.{} !=3D "" {{\n'.format(goname) + s +=3D 'xc.{} =3D C.CString(x.{})}}\n'.format(cname,goname) + + else: + s +=3D 'xc.{} =3D C.{}(x.{})\n'.format(cname,ctypename,goname) + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 25294ba292..30cd1a9b3f 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -37,6 +37,19 @@ func (x *IoportRange) fromC(xc *C.libxl_ioport_range) er= ror { return nil } =20 +func (x *IoportRange) toC(xc *C.libxl_ioport_range) (err error) { + defer func() { + if err !=3D nil { + C.libxl_ioport_range_dispose(xc) + } + }() + + xc.first =3D C.uint32_t(x.First) + xc.number =3D C.uint32_t(x.Number) + + return nil +} + func (x *IomemRange) fromC(xc *C.libxl_iomem_range) error { x.Start =3D uint64(xc.start) x.Number =3D uint64(xc.number) @@ -45,12 +58,38 @@ func (x *IomemRange) fromC(xc *C.libxl_iomem_range) err= or { return nil } =20 +func (x *IomemRange) toC(xc *C.libxl_iomem_range) (err error) { + defer func() { + if err !=3D nil { + C.libxl_iomem_range_dispose(xc) + } + }() + + xc.start =3D C.uint64_t(x.Start) + xc.number =3D C.uint64_t(x.Number) + xc.gfn =3D C.uint64_t(x.Gfn) + + return nil +} + func (x *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error { x.Kind =3D VgaInterfaceType(xc.kind) =20 return nil } =20 +func (x *VgaInterfaceInfo) toC(xc *C.libxl_vga_interface_info) (err error)= { + defer func() { + if err !=3D nil { + C.libxl_vga_interface_info_dispose(xc) + } + }() + + xc.kind =3D C.libxl_vga_interface_type(x.Kind) + + return nil +} + func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -65,6 +104,30 @@ func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { return nil } =20 +func (x *VncInfo) toC(xc *C.libxl_vnc_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vnc_info_dispose(xc) + } + }() + + if err :=3D x.Enable.toC(&xc.enable); err !=3D nil { + return err + } + if x.Listen !=3D "" { + xc.listen =3D C.CString(x.Listen) + } + if x.Passwd !=3D "" { + xc.passwd =3D C.CString(x.Passwd) + } + xc.display =3D C.int(x.Display) + if err :=3D x.Findunused.toC(&xc.findunused); err !=3D nil { + return err + } + + return nil +} + func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -92,6 +155,47 @@ func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error= { return nil } =20 +func (x *SpiceInfo) toC(xc *C.libxl_spice_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_spice_info_dispose(xc) + } + }() + + if err :=3D x.Enable.toC(&xc.enable); err !=3D nil { + return err + } + xc.port =3D C.int(x.Port) + xc.tls_port =3D C.int(x.TlsPort) + if x.Host !=3D "" { + xc.host =3D C.CString(x.Host) + } + if err :=3D x.DisableTicketing.toC(&xc.disable_ticketing); err !=3D nil { + return err + } + if x.Passwd !=3D "" { + xc.passwd =3D C.CString(x.Passwd) + } + if err :=3D x.AgentMouse.toC(&xc.agent_mouse); err !=3D nil { + return err + } + if err :=3D x.Vdagent.toC(&xc.vdagent); err !=3D nil { + return err + } + if err :=3D x.ClipboardSharing.toC(&xc.clipboard_sharing); err !=3D nil { + return err + } + xc.usbredirection =3D C.int(x.Usbredirection) + if x.ImageCompression !=3D "" { + xc.image_compression =3D C.CString(x.ImageCompression) + } + if x.StreamingVideo !=3D "" { + xc.streaming_video =3D C.CString(x.StreamingVideo) + } + + return nil +} + func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -105,6 +209,29 @@ func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { return nil } =20 +func (x *SdlInfo) toC(xc *C.libxl_sdl_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_sdl_info_dispose(xc) + } + }() + + if err :=3D x.Enable.toC(&xc.enable); err !=3D nil { + return err + } + if err :=3D x.Opengl.toC(&xc.opengl); err !=3D nil { + return err + } + if x.Display !=3D "" { + xc.display =3D C.CString(x.Display) + } + if x.Xauthority !=3D "" { + xc.xauthority =3D C.CString(x.Xauthority) + } + + return nil +} + func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { return err @@ -133,6 +260,42 @@ func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { return nil } =20 +func (x *Dominfo) toC(xc *C.libxl_dominfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_dominfo_dispose(xc) + } + }() + + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return err + } + xc.domid =3D C.libxl_domid(x.Domid) + xc.ssidref =3D C.uint32_t(x.Ssidref) + if x.SsidLabel !=3D "" { + xc.ssid_label =3D C.CString(x.SsidLabel) + } + xc.running =3D C.bool(x.Running) + xc.blocked =3D C.bool(x.Blocked) + xc.paused =3D C.bool(x.Paused) + xc.shutdown =3D C.bool(x.Shutdown) + xc.dying =3D C.bool(x.Dying) + xc.never_stop =3D C.bool(x.NeverStop) + xc.shutdown_reason =3D C.libxl_shutdown_reason(x.ShutdownReason) + xc.outstanding_memkb =3D C.uint64_t(x.OutstandingMemkb) + xc.current_memkb =3D C.uint64_t(x.CurrentMemkb) + xc.shared_memkb =3D C.uint64_t(x.SharedMemkb) + xc.paged_memkb =3D C.uint64_t(x.PagedMemkb) + xc.max_memkb =3D C.uint64_t(x.MaxMemkb) + xc.cpu_time =3D C.uint64_t(x.CpuTime) + xc.vcpu_max_id =3D C.uint32_t(x.VcpuMaxId) + xc.vcpu_online =3D C.uint32_t(x.VcpuOnline) + xc.cpupool =3D C.uint32_t(x.Cpupool) + xc.domain_type =3D C.libxl_domain_type(x.DomainType) + + return nil +} + func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error { x.Poolid =3D uint32(xc.poolid) x.PoolName =3D C.GoString(xc.pool_name) @@ -145,6 +308,26 @@ func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) e= rror { return nil } =20 +func (x *Cpupoolinfo) toC(xc *C.libxl_cpupoolinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_cpupoolinfo_dispose(xc) + } + }() + + xc.poolid =3D C.uint32_t(x.Poolid) + if x.PoolName !=3D "" { + xc.pool_name =3D C.CString(x.PoolName) + } + xc.sched =3D C.libxl_scheduler(x.Sched) + xc.n_dom =3D C.uint32_t(x.NDom) + if err :=3D x.Cpumap.toC(&xc.cpumap); err !=3D nil { + return err + } + + return nil +} + func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -179,6 +362,29 @@ func (x *ChannelinfoConnectionUnionPty) fromC(xc *C.li= bxl_channelinfo) error { return nil } =20 +func (x *Channelinfo) toC(xc *C.libxl_channelinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_channelinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.rref =3D C.int(x.Rref) + + return nil +} + func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { return err @@ -188,6 +394,21 @@ func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { return nil } =20 +func (x *Vminfo) toC(xc *C.libxl_vminfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vminfo_dispose(xc) + } + }() + + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return err + } + xc.domid =3D C.libxl_domid(x.Domid) + + return nil +} + func (x *VersionInfo) fromC(xc *C.libxl_version_info) error { x.XenVersionMajor =3D int(xc.xen_version_major) x.XenVersionMinor =3D int(xc.xen_version_minor) @@ -206,6 +427,48 @@ func (x *VersionInfo) fromC(xc *C.libxl_version_info) = error { return nil } =20 +func (x *VersionInfo) toC(xc *C.libxl_version_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_version_info_dispose(xc) + } + }() + + xc.xen_version_major =3D C.int(x.XenVersionMajor) + xc.xen_version_minor =3D C.int(x.XenVersionMinor) + if x.XenVersionExtra !=3D "" { + xc.xen_version_extra =3D C.CString(x.XenVersionExtra) + } + if x.Compiler !=3D "" { + xc.compiler =3D C.CString(x.Compiler) + } + if x.CompileBy !=3D "" { + xc.compile_by =3D C.CString(x.CompileBy) + } + if x.CompileDomain !=3D "" { + xc.compile_domain =3D C.CString(x.CompileDomain) + } + if x.CompileDate !=3D "" { + xc.compile_date =3D C.CString(x.CompileDate) + } + if x.Capabilities !=3D "" { + xc.capabilities =3D C.CString(x.Capabilities) + } + if x.Changeset !=3D "" { + xc.changeset =3D C.CString(x.Changeset) + } + xc.virt_start =3D C.uint64_t(x.VirtStart) + xc.pagesize =3D C.int(x.Pagesize) + if x.Commandline !=3D "" { + xc.commandline =3D C.CString(x.Commandline) + } + if x.BuildId !=3D "" { + xc.build_id =3D C.CString(x.BuildId) + } + + return nil +} + func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_create_info) error { x.Type =3D DomainType(xc._type) if err :=3D x.Hap.fromC(&xc.hap); err !=3D nil { @@ -239,6 +502,51 @@ func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_cr= eate_info) error { return nil } =20 +func (x *DomainCreateInfo) toC(xc *C.libxl_domain_create_info) (err error)= { + defer func() { + if err !=3D nil { + C.libxl_domain_create_info_dispose(xc) + } + }() + + xc._type =3D C.libxl_domain_type(x.Type) + if err :=3D x.Hap.toC(&xc.hap); err !=3D nil { + return err + } + if err :=3D x.Oos.toC(&xc.oos); err !=3D nil { + return err + } + xc.ssidref =3D C.uint32_t(x.Ssidref) + if x.SsidLabel !=3D "" { + xc.ssid_label =3D C.CString(x.SsidLabel) + } + if x.Name !=3D "" { + xc.name =3D C.CString(x.Name) + } + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return err + } + if err :=3D x.Xsdata.toC(&xc.xsdata); err !=3D nil { + return err + } + if err :=3D x.Platformdata.toC(&xc.platformdata); err !=3D nil { + return err + } + xc.poolid =3D C.uint32_t(x.Poolid) + if x.PoolName !=3D "" { + xc.pool_name =3D C.CString(x.PoolName) + } + if err :=3D x.RunHotplugScripts.toC(&xc.run_hotplug_scripts); err !=3D ni= l { + return err + } + if err :=3D x.DriverDomain.toC(&xc.driver_domain); err !=3D nil { + return err + } + xc.passthrough =3D C.libxl_passthrough(x.Passthrough) + + return nil +} + func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) err= or { x.CheckpointedStream =3D int(xc.checkpointed_stream) x.StreamVersion =3D uint32(xc.stream_version) @@ -250,6 +558,25 @@ func (x *DomainRestoreParams) fromC(xc *C.libxl_domain= _restore_params) error { return nil } =20 +func (x *DomainRestoreParams) toC(xc *C.libxl_domain_restore_params) (err = error) { + defer func() { + if err !=3D nil { + C.libxl_domain_restore_params_dispose(xc) + } + }() + + xc.checkpointed_stream =3D C.int(x.CheckpointedStream) + xc.stream_version =3D C.uint32_t(x.StreamVersion) + if x.ColoProxyScript !=3D "" { + xc.colo_proxy_script =3D C.CString(x.ColoProxyScript) + } + if err :=3D x.UserspaceColoProxy.toC(&xc.userspace_colo_proxy); err !=3D = nil { + return err + } + + return nil +} + func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { x.Vcpuid =3D int(xc.vcpuid) x.Weight =3D int(xc.weight) @@ -261,6 +588,23 @@ func (x *SchedParams) fromC(xc *C.libxl_sched_params) = error { return nil } =20 +func (x *SchedParams) toC(xc *C.libxl_sched_params) (err error) { + defer func() { + if err !=3D nil { + C.libxl_sched_params_dispose(xc) + } + }() + + xc.vcpuid =3D C.int(x.Vcpuid) + xc.weight =3D C.int(x.Weight) + xc.cap =3D C.int(x.Cap) + xc.period =3D C.int(x.Period) + xc.extratime =3D C.int(x.Extratime) + xc.budget =3D C.int(x.Budget) + + return nil +} + func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { x.Sched =3D Scheduler(xc.sched) numVcpus :=3D int(xc.num_vcpus) @@ -275,6 +619,18 @@ func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched= _params) error { return nil } =20 +func (x *VcpuSchedParams) toC(xc *C.libxl_vcpu_sched_params) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vcpu_sched_params_dispose(xc) + } + }() + + xc.sched =3D C.libxl_scheduler(x.Sched) + + return nil +} + func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { x.Sched =3D Scheduler(xc.sched) x.Weight =3D int(xc.weight) @@ -288,6 +644,25 @@ func (x *DomainSchedParams) fromC(xc *C.libxl_domain_s= ched_params) error { return nil } =20 +func (x *DomainSchedParams) toC(xc *C.libxl_domain_sched_params) (err erro= r) { + defer func() { + if err !=3D nil { + C.libxl_domain_sched_params_dispose(xc) + } + }() + + xc.sched =3D C.libxl_scheduler(x.Sched) + xc.weight =3D C.int(x.Weight) + xc.cap =3D C.int(x.Cap) + xc.period =3D C.int(x.Period) + xc.budget =3D C.int(x.Budget) + xc.extratime =3D C.int(x.Extratime) + xc.slice =3D C.int(x.Slice) + xc.latency =3D C.int(x.Latency) + + return nil +} + func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { x.Memkb =3D uint64(xc.memkb) numDistances :=3D int(xc.num_distances) @@ -304,6 +679,22 @@ func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) erro= r { return nil } =20 +func (x *VnodeInfo) toC(xc *C.libxl_vnode_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vnode_info_dispose(xc) + } + }() + + xc.memkb =3D C.uint64_t(x.Memkb) + xc.pnode =3D C.uint32_t(x.Pnode) + if err :=3D x.Vcpus.toC(&xc.vcpus); err !=3D nil { + return err + } + + return nil +} + func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error { x.Strategy =3D RdmReserveStrategy(xc.strategy) x.Policy =3D RdmReservePolicy(xc.policy) @@ -311,6 +702,19 @@ func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) er= ror { return nil } =20 +func (x *RdmReserve) toC(xc *C.libxl_rdm_reserve) (err error) { + defer func() { + if err !=3D nil { + C.libxl_rdm_reserve_dispose(xc) + } + }() + + xc.strategy =3D C.libxl_rdm_reserve_strategy(x.Strategy) + xc.policy =3D C.libxl_rdm_reserve_policy(x.Policy) + + return nil +} + func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error { x.MaxVcpus =3D int(xc.max_vcpus) if err :=3D x.AvailVcpus.fromC(&xc.avail_vcpus); err !=3D nil { @@ -613,6 +1017,120 @@ func (x *DomainBuildInfoTypeUnionPvh) fromC(xc *C.li= bxl_domain_build_info) error return nil } =20 +func (x *DomainBuildInfo) toC(xc *C.libxl_domain_build_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_domain_build_info_dispose(xc) + } + }() + + xc.max_vcpus =3D C.int(x.MaxVcpus) + if err :=3D x.AvailVcpus.toC(&xc.avail_vcpus); err !=3D nil { + return err + } + if err :=3D x.Cpumap.toC(&xc.cpumap); err !=3D nil { + return err + } + if err :=3D x.Nodemap.toC(&xc.nodemap); err !=3D nil { + return err + } + if err :=3D x.NumaPlacement.toC(&xc.numa_placement); err !=3D nil { + return err + } + xc.tsc_mode =3D C.libxl_tsc_mode(x.TscMode) + xc.max_memkb =3D C.uint64_t(x.MaxMemkb) + xc.target_memkb =3D C.uint64_t(x.TargetMemkb) + xc.video_memkb =3D C.uint64_t(x.VideoMemkb) + xc.shadow_memkb =3D C.uint64_t(x.ShadowMemkb) + xc.iommu_memkb =3D C.uint64_t(x.IommuMemkb) + xc.rtc_timeoffset =3D C.uint32_t(x.RtcTimeoffset) + xc.exec_ssidref =3D C.uint32_t(x.ExecSsidref) + if x.ExecSsidLabel !=3D "" { + xc.exec_ssid_label =3D C.CString(x.ExecSsidLabel) + } + if err :=3D x.Localtime.toC(&xc.localtime); err !=3D nil { + return err + } + if err :=3D x.DisableMigrate.toC(&xc.disable_migrate); err !=3D nil { + return err + } + if err :=3D x.Cpuid.toC(&xc.cpuid); err !=3D nil { + return err + } + if x.BlkdevStart !=3D "" { + xc.blkdev_start =3D C.CString(x.BlkdevStart) + } + xc.max_grant_frames =3D C.uint32_t(x.MaxGrantFrames) + xc.max_maptrack_frames =3D C.uint32_t(x.MaxMaptrackFrames) + xc.device_model_version =3D C.libxl_device_model_version(x.DeviceModelVer= sion) + if err :=3D x.DeviceModelStubdomain.toC(&xc.device_model_stubdomain); err= !=3D nil { + return err + } + if x.DeviceModel !=3D "" { + xc.device_model =3D C.CString(x.DeviceModel) + } + xc.device_model_ssidref =3D C.uint32_t(x.DeviceModelSsidref) + if x.DeviceModelSsidLabel !=3D "" { + xc.device_model_ssid_label =3D C.CString(x.DeviceModelSsidLabel) + } + if x.DeviceModelUser !=3D "" { + xc.device_model_user =3D C.CString(x.DeviceModelUser) + } + if err :=3D x.Extra.toC(&xc.extra); err !=3D nil { + return err + } + if err :=3D x.ExtraPv.toC(&xc.extra_pv); err !=3D nil { + return err + } + if err :=3D x.ExtraHvm.toC(&xc.extra_hvm); err !=3D nil { + return err + } + if err :=3D x.SchedParams.toC(&xc.sched_params); err !=3D nil { + return err + } + if err :=3D x.ClaimMode.toC(&xc.claim_mode); err !=3D nil { + return err + } + xc.event_channels =3D C.uint32_t(x.EventChannels) + if x.Kernel !=3D "" { + xc.kernel =3D C.CString(x.Kernel) + } + if x.Cmdline !=3D "" { + xc.cmdline =3D C.CString(x.Cmdline) + } + if x.Ramdisk !=3D "" { + xc.ramdisk =3D C.CString(x.Ramdisk) + } + if x.DeviceTree !=3D "" { + xc.device_tree =3D C.CString(x.DeviceTree) + } + if err :=3D x.Acpi.toC(&xc.acpi); err !=3D nil { + return err + } + if x.Bootloader !=3D "" { + xc.bootloader =3D C.CString(x.Bootloader) + } + if err :=3D x.BootloaderArgs.toC(&xc.bootloader_args); err !=3D nil { + return err + } + xc.timer_mode =3D C.libxl_timer_mode(x.TimerMode) + if err :=3D x.NestedHvm.toC(&xc.nested_hvm); err !=3D nil { + return err + } + if err :=3D x.Apic.toC(&xc.apic); err !=3D nil { + return err + } + if err :=3D x.DmRestrict.toC(&xc.dm_restrict); err !=3D nil { + return err + } + xc.tee =3D C.libxl_tee_type(x.Tee) + xc.arch_arm.gic_version =3D C.libxl_gic_version(x.ArchArm.GicVersion) + xc.arch_arm.vuart =3D C.libxl_vuart_type(x.ArchArm.Vuart) + xc.altp2m =3D C.libxl_altp2m_mode(x.Altp2M) + + return nil +} + func (x *DeviceVfb) fromC(xc *C.libxl_device_vfb) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -628,6 +1146,31 @@ func (x *DeviceVfb) fromC(xc *C.libxl_device_vfb) err= or { return nil } =20 +func (x *DeviceVfb) toC(xc *C.libxl_device_vfb) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_vfb_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + if err :=3D x.Vnc.toC(&xc.vnc); err !=3D nil { + return err + } + if err :=3D x.Sdl.toC(&xc.sdl); err !=3D nil { + return err + } + if x.Keymap !=3D "" { + xc.keymap =3D C.CString(x.Keymap) + } + + return nil +} + func (x *DeviceVkb) fromC(xc *C.libxl_device_vkb) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -648,6 +1191,36 @@ func (x *DeviceVkb) fromC(xc *C.libxl_device_vkb) err= or { return nil } =20 +func (x *DeviceVkb) toC(xc *C.libxl_device_vkb) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_vkb_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + xc.backend_type =3D C.libxl_vkb_backend(x.BackendType) + if x.UniqueId !=3D "" { + xc.unique_id =3D C.CString(x.UniqueId) + } + xc.feature_disable_keyboard =3D C.bool(x.FeatureDisableKeyboard) + xc.feature_disable_pointer =3D C.bool(x.FeatureDisablePointer) + xc.feature_abs_pointer =3D C.bool(x.FeatureAbsPointer) + xc.feature_raw_pointer =3D C.bool(x.FeatureRawPointer) + xc.feature_multi_touch =3D C.bool(x.FeatureMultiTouch) + xc.width =3D C.uint32_t(x.Width) + xc.height =3D C.uint32_t(x.Height) + xc.multi_touch_width =3D C.uint32_t(x.MultiTouchWidth) + xc.multi_touch_height =3D C.uint32_t(x.MultiTouchHeight) + xc.multi_touch_num_contacts =3D C.uint32_t(x.MultiTouchNumContacts) + + return nil +} + func (x *DeviceDisk) fromC(xc *C.libxl_device_disk) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -678,6 +1251,58 @@ func (x *DeviceDisk) fromC(xc *C.libxl_device_disk) e= rror { return nil } =20 +func (x *DeviceDisk) toC(xc *C.libxl_device_disk) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_disk_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + if x.PdevPath !=3D "" { + xc.pdev_path =3D C.CString(x.PdevPath) + } + if x.Vdev !=3D "" { + xc.vdev =3D C.CString(x.Vdev) + } + xc.backend =3D C.libxl_disk_backend(x.Backend) + xc.format =3D C.libxl_disk_format(x.Format) + if x.Script !=3D "" { + xc.script =3D C.CString(x.Script) + } + xc.removable =3D C.int(x.Removable) + xc.readwrite =3D C.int(x.Readwrite) + xc.is_cdrom =3D C.int(x.IsCdrom) + xc.direct_io_safe =3D C.bool(x.DirectIoSafe) + if err :=3D x.DiscardEnable.toC(&xc.discard_enable); err !=3D nil { + return err + } + if err :=3D x.ColoEnable.toC(&xc.colo_enable); err !=3D nil { + return err + } + if err :=3D x.ColoRestoreEnable.toC(&xc.colo_restore_enable); err !=3D ni= l { + return err + } + if x.ColoHost !=3D "" { + xc.colo_host =3D C.CString(x.ColoHost) + } + xc.colo_port =3D C.int(x.ColoPort) + if x.ColoExport !=3D "" { + xc.colo_export =3D C.CString(x.ColoExport) + } + if x.ActiveDisk !=3D "" { + xc.active_disk =3D C.CString(x.ActiveDisk) + } + if x.HiddenDisk !=3D "" { + xc.hidden_disk =3D C.CString(x.HiddenDisk) + } + + return nil +} + func (x *DeviceNic) fromC(xc *C.libxl_device_nic) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -748,6 +1373,194 @@ func (x *DeviceNic) fromC(xc *C.libxl_device_nic) er= ror { return nil } =20 +func (x *DeviceNic) toC(xc *C.libxl_device_nic) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_nic_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + xc.mtu =3D C.int(x.Mtu) + if x.Model !=3D "" { + xc.model =3D C.CString(x.Model) + } + if err :=3D x.Mac.toC(&xc.mac); err !=3D nil { + return err + } + if x.Ip !=3D "" { + xc.ip =3D C.CString(x.Ip) + } + if x.Bridge !=3D "" { + xc.bridge =3D C.CString(x.Bridge) + } + if x.Ifname !=3D "" { + xc.ifname =3D C.CString(x.Ifname) + } + if x.Script !=3D "" { + xc.script =3D C.CString(x.Script) + } + xc.nictype =3D C.libxl_nic_type(x.Nictype) + xc.rate_bytes_per_interval =3D C.uint64_t(x.RateBytesPerInterval) + xc.rate_interval_usecs =3D C.uint32_t(x.RateIntervalUsecs) + if x.Gatewaydev !=3D "" { + xc.gatewaydev =3D C.CString(x.Gatewaydev) + } + if x.ColoftForwarddev !=3D "" { + xc.coloft_forwarddev =3D C.CString(x.ColoftForwarddev) + } + if x.ColoSockMirrorId !=3D "" { + xc.colo_sock_mirror_id =3D C.CString(x.ColoSockMirrorId) + } + if x.ColoSockMirrorIp !=3D "" { + xc.colo_sock_mirror_ip =3D C.CString(x.ColoSockMirrorIp) + } + if x.ColoSockMirrorPort !=3D "" { + xc.colo_sock_mirror_port =3D C.CString(x.ColoSockMirrorPort) + } + if x.ColoSockComparePriInId !=3D "" { + xc.colo_sock_compare_pri_in_id =3D C.CString(x.ColoSockComparePriInId) + } + if x.ColoSockComparePriInIp !=3D "" { + xc.colo_sock_compare_pri_in_ip =3D C.CString(x.ColoSockComparePriInIp) + } + if x.ColoSockComparePriInPort !=3D "" { + xc.colo_sock_compare_pri_in_port =3D C.CString(x.ColoSockComparePriInPor= t) + } + if x.ColoSockCompareSecInId !=3D "" { + xc.colo_sock_compare_sec_in_id =3D C.CString(x.ColoSockCompareSecInId) + } + if x.ColoSockCompareSecInIp !=3D "" { + xc.colo_sock_compare_sec_in_ip =3D C.CString(x.ColoSockCompareSecInIp) + } + if x.ColoSockCompareSecInPort !=3D "" { + xc.colo_sock_compare_sec_in_port =3D C.CString(x.ColoSockCompareSecInPor= t) + } + if x.ColoSockCompareNotifyId !=3D "" { + xc.colo_sock_compare_notify_id =3D C.CString(x.ColoSockCompareNotifyId) + } + if x.ColoSockCompareNotifyIp !=3D "" { + xc.colo_sock_compare_notify_ip =3D C.CString(x.ColoSockCompareNotifyIp) + } + if x.ColoSockCompareNotifyPort !=3D "" { + xc.colo_sock_compare_notify_port =3D C.CString(x.ColoSockCompareNotifyPo= rt) + } + if x.ColoSockRedirector0Id !=3D "" { + xc.colo_sock_redirector0_id =3D C.CString(x.ColoSockRedirector0Id) + } + if x.ColoSockRedirector0Ip !=3D "" { + xc.colo_sock_redirector0_ip =3D C.CString(x.ColoSockRedirector0Ip) + } + if x.ColoSockRedirector0Port !=3D "" { + xc.colo_sock_redirector0_port =3D C.CString(x.ColoSockRedirector0Port) + } + if x.ColoSockRedirector1Id !=3D "" { + xc.colo_sock_redirector1_id =3D C.CString(x.ColoSockRedirector1Id) + } + if x.ColoSockRedirector1Ip !=3D "" { + xc.colo_sock_redirector1_ip =3D C.CString(x.ColoSockRedirector1Ip) + } + if x.ColoSockRedirector1Port !=3D "" { + xc.colo_sock_redirector1_port =3D C.CString(x.ColoSockRedirector1Port) + } + if x.ColoSockRedirector2Id !=3D "" { + xc.colo_sock_redirector2_id =3D C.CString(x.ColoSockRedirector2Id) + } + if x.ColoSockRedirector2Ip !=3D "" { + xc.colo_sock_redirector2_ip =3D C.CString(x.ColoSockRedirector2Ip) + } + if x.ColoSockRedirector2Port !=3D "" { + xc.colo_sock_redirector2_port =3D C.CString(x.ColoSockRedirector2Port) + } + if x.ColoFilterMirrorQueue !=3D "" { + xc.colo_filter_mirror_queue =3D C.CString(x.ColoFilterMirrorQueue) + } + if x.ColoFilterMirrorOutdev !=3D "" { + xc.colo_filter_mirror_outdev =3D C.CString(x.ColoFilterMirrorOutdev) + } + if x.ColoFilterRedirector0Queue !=3D "" { + xc.colo_filter_redirector0_queue =3D C.CString(x.ColoFilterRedirector0Qu= eue) + } + if x.ColoFilterRedirector0Indev !=3D "" { + xc.colo_filter_redirector0_indev =3D C.CString(x.ColoFilterRedirector0In= dev) + } + if x.ColoFilterRedirector0Outdev !=3D "" { + xc.colo_filter_redirector0_outdev =3D C.CString(x.ColoFilterRedirector0O= utdev) + } + if x.ColoFilterRedirector1Queue !=3D "" { + xc.colo_filter_redirector1_queue =3D C.CString(x.ColoFilterRedirector1Qu= eue) + } + if x.ColoFilterRedirector1Indev !=3D "" { + xc.colo_filter_redirector1_indev =3D C.CString(x.ColoFilterRedirector1In= dev) + } + if x.ColoFilterRedirector1Outdev !=3D "" { + xc.colo_filter_redirector1_outdev =3D C.CString(x.ColoFilterRedirector1O= utdev) + } + if x.ColoComparePriIn !=3D "" { + xc.colo_compare_pri_in =3D C.CString(x.ColoComparePriIn) + } + if x.ColoCompareSecIn !=3D "" { + xc.colo_compare_sec_in =3D C.CString(x.ColoCompareSecIn) + } + if x.ColoCompareOut !=3D "" { + xc.colo_compare_out =3D C.CString(x.ColoCompareOut) + } + if x.ColoCompareNotifyDev !=3D "" { + xc.colo_compare_notify_dev =3D C.CString(x.ColoCompareNotifyDev) + } + if x.ColoSockSecRedirector0Id !=3D "" { + xc.colo_sock_sec_redirector0_id =3D C.CString(x.ColoSockSecRedirector0Id) + } + if x.ColoSockSecRedirector0Ip !=3D "" { + xc.colo_sock_sec_redirector0_ip =3D C.CString(x.ColoSockSecRedirector0Ip) + } + if x.ColoSockSecRedirector0Port !=3D "" { + xc.colo_sock_sec_redirector0_port =3D C.CString(x.ColoSockSecRedirector0= Port) + } + if x.ColoSockSecRedirector1Id !=3D "" { + xc.colo_sock_sec_redirector1_id =3D C.CString(x.ColoSockSecRedirector1Id) + } + if x.ColoSockSecRedirector1Ip !=3D "" { + xc.colo_sock_sec_redirector1_ip =3D C.CString(x.ColoSockSecRedirector1Ip) + } + if x.ColoSockSecRedirector1Port !=3D "" { + xc.colo_sock_sec_redirector1_port =3D C.CString(x.ColoSockSecRedirector1= Port) + } + if x.ColoFilterSecRedirector0Queue !=3D "" { + xc.colo_filter_sec_redirector0_queue =3D C.CString(x.ColoFilterSecRedire= ctor0Queue) + } + if x.ColoFilterSecRedirector0Indev !=3D "" { + xc.colo_filter_sec_redirector0_indev =3D C.CString(x.ColoFilterSecRedire= ctor0Indev) + } + if x.ColoFilterSecRedirector0Outdev !=3D "" { + xc.colo_filter_sec_redirector0_outdev =3D C.CString(x.ColoFilterSecRedir= ector0Outdev) + } + if x.ColoFilterSecRedirector1Queue !=3D "" { + xc.colo_filter_sec_redirector1_queue =3D C.CString(x.ColoFilterSecRedire= ctor1Queue) + } + if x.ColoFilterSecRedirector1Indev !=3D "" { + xc.colo_filter_sec_redirector1_indev =3D C.CString(x.ColoFilterSecRedire= ctor1Indev) + } + if x.ColoFilterSecRedirector1Outdev !=3D "" { + xc.colo_filter_sec_redirector1_outdev =3D C.CString(x.ColoFilterSecRedir= ector1Outdev) + } + if x.ColoFilterSecRewriter0Queue !=3D "" { + xc.colo_filter_sec_rewriter0_queue =3D C.CString(x.ColoFilterSecRewriter= 0Queue) + } + if x.ColoCheckpointHost !=3D "" { + xc.colo_checkpoint_host =3D C.CString(x.ColoCheckpointHost) + } + if x.ColoCheckpointPort !=3D "" { + xc.colo_checkpoint_port =3D C.CString(x.ColoCheckpointPort) + } + + return nil +} + func (x *DevicePci) fromC(xc *C.libxl_device_pci) error { x.Func =3D byte(xc._func) x.Dev =3D byte(xc.dev) @@ -764,6 +1577,28 @@ func (x *DevicePci) fromC(xc *C.libxl_device_pci) err= or { return nil } =20 +func (x *DevicePci) toC(xc *C.libxl_device_pci) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_pci_dispose(xc) + } + }() + + xc._func =3D C.uint8_t(x.Func) + xc.dev =3D C.uint8_t(x.Dev) + xc.bus =3D C.uint8_t(x.Bus) + xc.domain =3D C.int(x.Domain) + xc.vdevfn =3D C.uint32_t(x.Vdevfn) + xc.vfunc_mask =3D C.uint32_t(x.VfuncMask) + xc.msitranslate =3D C.bool(x.Msitranslate) + xc.power_mgmt =3D C.bool(x.PowerMgmt) + xc.permissive =3D C.bool(x.Permissive) + xc.seize =3D C.bool(x.Seize) + xc.rdm_policy =3D C.libxl_rdm_reserve_policy(x.RdmPolicy) + + return nil +} + func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) error { x.Start =3D uint64(xc.start) x.Size =3D uint64(xc.size) @@ -772,6 +1607,20 @@ func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) err= or { return nil } =20 +func (x *DeviceRdm) toC(xc *C.libxl_device_rdm) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_rdm_dispose(xc) + } + }() + + xc.start =3D C.uint64_t(x.Start) + xc.size =3D C.uint64_t(x.Size) + xc.policy =3D C.libxl_rdm_reserve_policy(x.Policy) + + return nil +} + func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbctrl) error { x.Type =3D UsbctrlType(xc._type) x.Devid =3D Devid(xc.devid) @@ -783,6 +1632,25 @@ func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbc= trl) error { return nil } =20 +func (x *DeviceUsbctrl) toC(xc *C.libxl_device_usbctrl) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_usbctrl_dispose(xc) + } + }() + + xc._type =3D C.libxl_usbctrl_type(x.Type) + xc.devid =3D C.libxl_devid(x.Devid) + xc.version =3D C.int(x.Version) + xc.ports =3D C.int(x.Ports) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + + return nil +} + func (x *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error { x.Ctrl =3D Devid(xc.ctrl) x.Port =3D int(xc.port) @@ -812,12 +1680,39 @@ func (x *DeviceUsbdevTypeUnionHostdev) fromC(xc *C.l= ibxl_device_usbdev) error { return nil } =20 +func (x *DeviceUsbdev) toC(xc *C.libxl_device_usbdev) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_usbdev_dispose(xc) + } + }() + + xc.ctrl =3D C.libxl_devid(x.Ctrl) + xc.port =3D C.int(x.Port) + + return nil +} + func (x *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error { x.Path =3D C.GoString(xc.path) =20 return nil } =20 +func (x *DeviceDtdev) toC(xc *C.libxl_device_dtdev) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_dtdev_dispose(xc) + } + }() + + if x.Path !=3D "" { + xc.path =3D C.CString(x.Path) + } + + return nil +} + func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -829,6 +1724,25 @@ func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) e= rror { return nil } =20 +func (x *DeviceVtpm) toC(xc *C.libxl_device_vtpm) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_vtpm_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return err + } + + return nil +} + func (x *DeviceP9) fromC(xc *C.libxl_device_p9) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -840,6 +1754,31 @@ func (x *DeviceP9) fromC(xc *C.libxl_device_p9) error= { return nil } =20 +func (x *DeviceP9) toC(xc *C.libxl_device_p9) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_p9_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + if x.Tag !=3D "" { + xc.tag =3D C.CString(x.Tag) + } + if x.Path !=3D "" { + xc.path =3D C.CString(x.Path) + } + if x.SecurityModel !=3D "" { + xc.security_model =3D C.CString(x.SecurityModel) + } + xc.devid =3D C.libxl_devid(x.Devid) + + return nil +} + func (x *DevicePvcallsif) fromC(xc *C.libxl_device_pvcallsif) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -848,6 +1787,22 @@ func (x *DevicePvcallsif) fromC(xc *C.libxl_device_pv= callsif) error { return nil } =20 +func (x *DevicePvcallsif) toC(xc *C.libxl_device_pvcallsif) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_pvcallsif_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + + return nil +} + func (x *DeviceChannel) fromC(xc *C.libxl_device_channel) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -878,6 +1833,25 @@ func (x *DeviceChannelConnectionUnionSocket) fromC(xc= *C.libxl_device_channel) e return nil } =20 +func (x *DeviceChannel) toC(xc *C.libxl_device_channel) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_channel_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + if x.Name !=3D "" { + xc.name =3D C.CString(x.Name) + } + + return nil +} + func (x *ConnectorParam) fromC(xc *C.libxl_connector_param) error { x.UniqueId =3D C.GoString(xc.unique_id) x.Width =3D uint32(xc.width) @@ -886,6 +1860,22 @@ func (x *ConnectorParam) fromC(xc *C.libxl_connector_= param) error { return nil } =20 +func (x *ConnectorParam) toC(xc *C.libxl_connector_param) (err error) { + defer func() { + if err !=3D nil { + C.libxl_connector_param_dispose(xc) + } + }() + + if x.UniqueId !=3D "" { + xc.unique_id =3D C.CString(x.UniqueId) + } + xc.width =3D C.uint32_t(x.Width) + xc.height =3D C.uint32_t(x.Height) + + return nil +} + func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdispl) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -903,6 +1893,23 @@ func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdisp= l) error { return nil } =20 +func (x *DeviceVdispl) toC(xc *C.libxl_device_vdispl) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_vdispl_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + xc.be_alloc =3D C.bool(x.BeAlloc) + + return nil +} + func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { numSampleRates :=3D int(xc.num_sample_rates) cSampleRates :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates))= [:numSampleRates:numSampleRates] @@ -923,6 +1930,20 @@ func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) e= rror { return nil } =20 +func (x *VsndParams) toC(xc *C.libxl_vsnd_params) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vsnd_params_dispose(xc) + } + }() + + xc.channels_min =3D C.uint32_t(x.ChannelsMin) + xc.channels_max =3D C.uint32_t(x.ChannelsMax) + xc.buffer_size =3D C.uint32_t(x.BufferSize) + + return nil +} + func (x *VsndStream) fromC(xc *C.libxl_vsnd_stream) error { x.UniqueId =3D C.GoString(xc.unique_id) x.Type =3D VsndStreamType(xc._type) @@ -933,6 +1954,24 @@ func (x *VsndStream) fromC(xc *C.libxl_vsnd_stream) e= rror { return nil } =20 +func (x *VsndStream) toC(xc *C.libxl_vsnd_stream) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vsnd_stream_dispose(xc) + } + }() + + if x.UniqueId !=3D "" { + xc.unique_id =3D C.CString(x.UniqueId) + } + xc._type =3D C.libxl_vsnd_stream_type(x.Type) + if err :=3D x.Params.toC(&xc.params); err !=3D nil { + return err + } + + return nil +} + func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { x.Name =3D C.GoString(xc.name) if err :=3D x.Params.fromC(&xc.params); err !=3D nil { @@ -950,6 +1989,23 @@ func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { return nil } =20 +func (x *VsndPcm) toC(xc *C.libxl_vsnd_pcm) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vsnd_pcm_dispose(xc) + } + }() + + if x.Name !=3D "" { + xc.name =3D C.CString(x.Name) + } + if err :=3D x.Params.toC(&xc.params); err !=3D nil { + return err + } + + return nil +} + func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -971,6 +2027,31 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) e= rror { return nil } =20 +func (x *DeviceVsnd) toC(xc *C.libxl_device_vsnd) (err error) { + defer func() { + if err !=3D nil { + C.libxl_device_vsnd_dispose(xc) + } + }() + + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + if x.BackendDomname !=3D "" { + xc.backend_domname =3D C.CString(x.BackendDomname) + } + xc.devid =3D C.libxl_devid(x.Devid) + if x.ShortName !=3D "" { + xc.short_name =3D C.CString(x.ShortName) + } + if x.LongName !=3D "" { + xc.long_name =3D C.CString(x.LongName) + } + if err :=3D x.Params.toC(&xc.params); err !=3D nil { + return err + } + + return nil +} + func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error { if err :=3D x.CInfo.fromC(&xc.c_info); err !=3D nil { return err @@ -1107,6 +2188,28 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_conf= ig) error { return nil } =20 +func (x *DomainConfig) toC(xc *C.libxl_domain_config) (err error) { + defer func() { + if err !=3D nil { + C.libxl_domain_config_dispose(xc) + } + }() + + if err :=3D x.CInfo.toC(&xc.c_info); err !=3D nil { + return err + } + if err :=3D x.BInfo.toC(&xc.b_info); err !=3D nil { + return err + } + xc.on_poweroff =3D C.libxl_action_on_shutdown(x.OnPoweroff) + xc.on_reboot =3D C.libxl_action_on_shutdown(x.OnReboot) + xc.on_watchdog =3D C.libxl_action_on_shutdown(x.OnWatchdog) + xc.on_crash =3D C.libxl_action_on_shutdown(x.OnCrash) + xc.on_soft_reset =3D C.libxl_action_on_shutdown(x.OnSoftReset) + + return nil +} + func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1120,6 +2223,29 @@ func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error= { return nil } =20 +func (x *Diskinfo) toC(xc *C.libxl_diskinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_diskinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.rref =3D C.int(x.Rref) + + return nil +} + func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1134,6 +2260,30 @@ func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error { return nil } =20 +func (x *Nicinfo) toC(xc *C.libxl_nicinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_nicinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.rref_tx =3D C.int(x.RrefTx) + xc.rref_rx =3D C.int(x.RrefRx) + + return nil +} + func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1150,6 +2300,32 @@ func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error= { return nil } =20 +func (x *Vtpminfo) toC(xc *C.libxl_vtpminfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vtpminfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.rref =3D C.int(x.Rref) + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return err + } + + return nil +} + func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo) error { x.Type =3D UsbctrlType(xc._type) x.Devid =3D Devid(xc.devid) @@ -1167,6 +2343,33 @@ func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo)= error { return nil } =20 +func (x *Usbctrlinfo) toC(xc *C.libxl_usbctrlinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_usbctrlinfo_dispose(xc) + } + }() + + xc._type =3D C.libxl_usbctrl_type(x.Type) + xc.devid =3D C.libxl_devid(x.Devid) + xc.version =3D C.int(x.Version) + xc.ports =3D C.int(x.Ports) + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.ref_urb =3D C.int(x.RefUrb) + xc.ref_conn =3D C.int(x.RefConn) + + return nil +} + func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error { x.Vcpuid =3D uint32(xc.vcpuid) x.Cpu =3D uint32(xc.cpu) @@ -1184,6 +2387,29 @@ func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error= { return nil } =20 +func (x *Vcpuinfo) toC(xc *C.libxl_vcpuinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vcpuinfo_dispose(xc) + } + }() + + xc.vcpuid =3D C.uint32_t(x.Vcpuid) + xc.cpu =3D C.uint32_t(x.Cpu) + xc.online =3D C.bool(x.Online) + xc.blocked =3D C.bool(x.Blocked) + xc.running =3D C.bool(x.Running) + xc.vcpu_time =3D C.uint64_t(x.VcpuTime) + if err :=3D x.Cpumap.toC(&xc.cpumap); err !=3D nil { + return err + } + if err :=3D x.CpumapSoft.toC(&xc.cpumap_soft); err !=3D nil { + return err + } + + return nil +} + func (x *Physinfo) fromC(xc *C.libxl_physinfo) error { x.ThreadsPerCore =3D uint32(xc.threads_per_core) x.CoresPerSocket =3D uint32(xc.cores_per_socket) @@ -1211,6 +2437,39 @@ func (x *Physinfo) fromC(xc *C.libxl_physinfo) error= { return nil } =20 +func (x *Physinfo) toC(xc *C.libxl_physinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_physinfo_dispose(xc) + } + }() + + xc.threads_per_core =3D C.uint32_t(x.ThreadsPerCore) + xc.cores_per_socket =3D C.uint32_t(x.CoresPerSocket) + xc.max_cpu_id =3D C.uint32_t(x.MaxCpuId) + xc.nr_cpus =3D C.uint32_t(x.NrCpus) + xc.cpu_khz =3D C.uint32_t(x.CpuKhz) + xc.total_pages =3D C.uint64_t(x.TotalPages) + xc.free_pages =3D C.uint64_t(x.FreePages) + xc.scrub_pages =3D C.uint64_t(x.ScrubPages) + xc.outstanding_pages =3D C.uint64_t(x.OutstandingPages) + xc.sharing_freed_pages =3D C.uint64_t(x.SharingFreedPages) + xc.sharing_used_frames =3D C.uint64_t(x.SharingUsedFrames) + xc.max_possible_mfn =3D C.uint64_t(x.MaxPossibleMfn) + xc.nr_nodes =3D C.uint32_t(x.NrNodes) + if err :=3D x.HwCap.toC(&xc.hw_cap); err !=3D nil { + return err + } + xc.cap_hvm =3D C.bool(x.CapHvm) + xc.cap_pv =3D C.bool(x.CapPv) + xc.cap_hvm_directio =3D C.bool(x.CapHvmDirectio) + xc.cap_hap =3D C.bool(x.CapHap) + xc.cap_shadow =3D C.bool(x.CapShadow) + xc.cap_iommu_hap_pt_share =3D C.bool(x.CapIommuHapPtShare) + + return nil +} + func (x *Connectorinfo) fromC(xc *C.libxl_connectorinfo) error { x.UniqueId =3D C.GoString(xc.unique_id) x.Width =3D uint32(xc.width) @@ -1223,6 +2482,26 @@ func (x *Connectorinfo) fromC(xc *C.libxl_connectori= nfo) error { return nil } =20 +func (x *Connectorinfo) toC(xc *C.libxl_connectorinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_connectorinfo_dispose(xc) + } + }() + + if x.UniqueId !=3D "" { + xc.unique_id =3D C.CString(x.UniqueId) + } + xc.width =3D C.uint32_t(x.Width) + xc.height =3D C.uint32_t(x.Height) + xc.req_evtch =3D C.int(x.ReqEvtch) + xc.req_rref =3D C.int(x.ReqRref) + xc.evt_evtch =3D C.int(x.EvtEvtch) + xc.evt_rref =3D C.int(x.EvtRref) + + return nil +} + func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1243,6 +2522,28 @@ func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) e= rror { return nil } =20 +func (x *Vdisplinfo) toC(xc *C.libxl_vdisplinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vdisplinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.be_alloc =3D C.bool(x.BeAlloc) + + return nil +} + func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error { x.ReqEvtch =3D int(xc.req_evtch) x.ReqRref =3D int(xc.req_rref) @@ -1250,6 +2551,19 @@ func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) e= rror { return nil } =20 +func (x *Streaminfo) toC(xc *C.libxl_streaminfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_streaminfo_dispose(xc) + } + }() + + xc.req_evtch =3D C.int(x.ReqEvtch) + xc.req_rref =3D C.int(x.ReqRref) + + return nil +} + func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { numVsndStreams :=3D int(xc.num_vsnd_streams) cStreams :=3D (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))[= :numVsndStreams:numVsndStreams] @@ -1263,6 +2577,16 @@ func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { return nil } =20 +func (x *Pcminfo) toC(xc *C.libxl_pcminfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_pcminfo_dispose(xc) + } + }() + + return nil +} + func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1282,6 +2606,27 @@ func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error= { return nil } =20 +func (x *Vsndinfo) toC(xc *C.libxl_vsndinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vsndinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + + return nil +} + func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1295,6 +2640,29 @@ func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { return nil } =20 +func (x *Vkbinfo) toC(xc *C.libxl_vkbinfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vkbinfo_dispose(xc) + } + }() + + if x.Backend !=3D "" { + xc.backend =3D C.CString(x.Backend) + } + xc.backend_id =3D C.uint32_t(x.BackendId) + if x.Frontend !=3D "" { + xc.frontend =3D C.CString(x.Frontend) + } + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.evtch =3D C.int(x.Evtch) + xc.rref =3D C.int(x.Rref) + + return nil +} + func (x *Numainfo) fromC(xc *C.libxl_numainfo) error { x.Size =3D uint64(xc.size) x.Free =3D uint64(xc.free) @@ -1308,6 +2676,19 @@ func (x *Numainfo) fromC(xc *C.libxl_numainfo) error= { return nil } =20 +func (x *Numainfo) toC(xc *C.libxl_numainfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_numainfo_dispose(xc) + } + }() + + xc.size =3D C.uint64_t(x.Size) + xc.free =3D C.uint64_t(x.Free) + + return nil +} + func (x *Cputopology) fromC(xc *C.libxl_cputopology) error { x.Core =3D uint32(xc.core) x.Socket =3D uint32(xc.socket) @@ -1316,6 +2697,20 @@ func (x *Cputopology) fromC(xc *C.libxl_cputopology)= error { return nil } =20 +func (x *Cputopology) toC(xc *C.libxl_cputopology) (err error) { + defer func() { + if err !=3D nil { + C.libxl_cputopology_dispose(xc) + } + }() + + xc.core =3D C.uint32_t(x.Core) + xc.socket =3D C.uint32_t(x.Socket) + xc.node =3D C.uint32_t(x.Node) + + return nil +} + func (x *Pcitopology) fromC(xc *C.libxl_pcitopology) error { x.Seg =3D uint16(xc.seg) x.Bus =3D byte(xc.bus) @@ -1325,6 +2720,21 @@ func (x *Pcitopology) fromC(xc *C.libxl_pcitopology)= error { return nil } =20 +func (x *Pcitopology) toC(xc *C.libxl_pcitopology) (err error) { + defer func() { + if err !=3D nil { + C.libxl_pcitopology_dispose(xc) + } + }() + + xc.seg =3D C.uint16_t(x.Seg) + xc.bus =3D C.uint8_t(x.Bus) + xc.devfn =3D C.uint8_t(x.Devfn) + xc.node =3D C.uint32_t(x.Node) + + return nil +} + func (x *SchedCreditParams) fromC(xc *C.libxl_sched_credit_params) error { x.TsliceMs =3D int(xc.tslice_ms) x.RatelimitUs =3D int(xc.ratelimit_us) @@ -1333,12 +2743,26 @@ func (x *SchedCreditParams) fromC(xc *C.libxl_sched= _credit_params) error { return nil } =20 +func (x *SchedCreditParams) toC(xc *C.libxl_sched_credit_params) (err erro= r) { + xc.tslice_ms =3D C.int(x.TsliceMs) + xc.ratelimit_us =3D C.int(x.RatelimitUs) + xc.vcpu_migr_delay_us =3D C.int(x.VcpuMigrDelayUs) + + return nil +} + func (x *SchedCredit2Params) fromC(xc *C.libxl_sched_credit2_params) error= { x.RatelimitUs =3D int(xc.ratelimit_us) =20 return nil } =20 +func (x *SchedCredit2Params) toC(xc *C.libxl_sched_credit2_params) (err er= ror) { + xc.ratelimit_us =3D C.int(x.RatelimitUs) + + return nil +} + func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_remus_info) error { x.Interval =3D int(xc.interval) if err :=3D x.AllowUnsafe.fromC(&xc.allow_unsafe); err !=3D nil { @@ -1367,6 +2791,42 @@ func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_r= emus_info) error { return nil } =20 +func (x *DomainRemusInfo) toC(xc *C.libxl_domain_remus_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_domain_remus_info_dispose(xc) + } + }() + + xc.interval =3D C.int(x.Interval) + if err :=3D x.AllowUnsafe.toC(&xc.allow_unsafe); err !=3D nil { + return err + } + if err :=3D x.Blackhole.toC(&xc.blackhole); err !=3D nil { + return err + } + if err :=3D x.Compression.toC(&xc.compression); err !=3D nil { + return err + } + if err :=3D x.Netbuf.toC(&xc.netbuf); err !=3D nil { + return err + } + if x.Netbufscript !=3D "" { + xc.netbufscript =3D C.CString(x.Netbufscript) + } + if err :=3D x.Diskbuf.toC(&xc.diskbuf); err !=3D nil { + return err + } + if err :=3D x.Colo.toC(&xc.colo); err !=3D nil { + return err + } + if err :=3D x.UserspaceColoProxy.toC(&xc.userspace_colo_proxy); err !=3D = nil { + return err + } + + return nil +} + func (x *Event) fromC(xc *C.libxl_event) error { if err :=3D x.Link.fromC(&xc.link); err !=3D nil { return err @@ -1436,6 +2896,25 @@ func (x *EventTypeUnionOperationComplete) fromC(xc *= C.libxl_event) error { return nil } =20 +func (x *Event) toC(xc *C.libxl_event) (err error) { + defer func() { + if err !=3D nil { + C.libxl_event_dispose(xc) + } + }() + + if err :=3D x.Link.toC(&xc.link); err !=3D nil { + return err + } + xc.domid =3D C.libxl_domid(x.Domid) + if err :=3D x.Domuuid.toC(&xc.domuuid); err !=3D nil { + return err + } + xc.for_user =3D C.uint64_t(x.ForUser) + + return nil +} + func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info) error { x.Id =3D uint32(xc.id) x.CosMax =3D uint32(xc.cos_max) @@ -1445,6 +2924,21 @@ func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info)= error { return nil } =20 +func (x *PsrCatInfo) toC(xc *C.libxl_psr_cat_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_psr_cat_info_dispose(xc) + } + }() + + xc.id =3D C.uint32_t(x.Id) + xc.cos_max =3D C.uint32_t(x.CosMax) + xc.cbm_len =3D C.uint32_t(x.CbmLen) + xc.cdp_enabled =3D C.bool(x.CdpEnabled) + + return nil +} + func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error { x.Id =3D uint32(xc.id) x.Type =3D PsrFeatType(xc._type) @@ -1491,3 +2985,15 @@ func (x *PsrHwInfoTypeUnionMba) fromC(xc *C.libxl_ps= r_hw_info) error { x.Linear =3D bool(tmp.linear) return nil } + +func (x *PsrHwInfo) toC(xc *C.libxl_psr_hw_info) (err error) { + defer func() { + if err !=3D nil { + C.libxl_psr_hw_info_dispose(xc) + } + }() + + xc.id =3D C.uint32_t(x.Id) + + return nil +} diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 237f26bce9..24b1e022ff 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -140,14 +140,12 @@ func (u *Uuid) fromC(c *C.libxl_uuid) error { return nil } =20 -func (u *Uuid) toC() (C.libxl_uuid, error) { - var c C.libxl_uuid - +func (u *Uuid) toC(cu *C.libxl_uuid) error { for i, v :=3D range u { - c.uuid[i] =3D C.uint8_t(v) + cu.uuid[i] =3D C.uint8_t(v) } =20 - return c, nil + return nil } =20 // defboolVal represents a defbool value. @@ -232,15 +230,13 @@ func (d *Defbool) fromC(c *C.libxl_defbool) error { return nil } =20 -func (d *Defbool) toC() (C.libxl_defbool, error) { - var c C.libxl_defbool - +func (d *Defbool) toC(cd *C.libxl_defbool) error { if !d.IsDefault() { val, _ :=3D d.Val() - C.libxl_defbool_set(&c, C.bool(val)) + C.libxl_defbool_set(cd, C.bool(val)) } =20 - return c, nil + return nil } =20 // Mac represents a libxl_mac, or simply a MAC address. @@ -266,14 +262,12 @@ func (mac *Mac) fromC(cmac *C.libxl_mac) error { return nil } =20 -func (mac Mac) toC() (C.libxl_mac, error) { - var cmac C.libxl_mac - +func (mac Mac) toC(cm *C.libxl_mac) error { for i, v :=3D range mac { - cmac[i] =3D C.uint8_t(v) + (*cm)[i] =3D C.uint8_t(v) } =20 - return cmac, nil + return nil } =20 // MsVmGenid represents a libxl_ms_vm_genid. @@ -287,14 +281,12 @@ func (mvg *MsVmGenid) fromC(cmvg *C.libxl_ms_vm_genid= ) error { return nil } =20 -func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, error) { - var cmvg C.libxl_ms_vm_genid - +func (mvg *MsVmGenid) toC(cmvg *C.libxl_ms_vm_genid) error { for i, v :=3D range mvg { cmvg.bytes[i] =3D C.uint8_t(v) } =20 - return cmvg, nil + return nil } =20 // EvLink represents a libxl_ev_link. @@ -304,8 +296,8 @@ func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, error= ) { // through the Go package. type EvLink struct{} =20 -func (el *EvLink) fromC(cel *C.libxl_ev_link) error { return nil } -func (el *EvLink) toC() (cel C.libxl_ev_link, err error) { return } +func (el *EvLink) fromC(cel *C.libxl_ev_link) error { return nil } +func (el *EvLink) toC(cel *C.libxl_ev_link) (err error) { return } =20 // CpuidPolicyList represents a libxl_cpuid_policy_list. // @@ -316,20 +308,18 @@ type CpuidPolicyList string =20 func (cpl CpuidPolicyList) fromC(ccpl *C.libxl_cpuid_policy_list) error { = return nil } =20 -func (cpl CpuidPolicyList) toC() (C.libxl_cpuid_policy_list, error) { - var ccpl C.libxl_cpuid_policy_list - +func (cpl CpuidPolicyList) toC(ccpl *C.libxl_cpuid_policy_list) error { s :=3D C.CString(string(cpl)) defer C.free(unsafe.Pointer(s)) =20 - ret :=3D C.libxl_cpuid_parse_config(&ccpl, s) + ret :=3D C.libxl_cpuid_parse_config(ccpl, s) if ret !=3D 0 { - C.libxl_cpuid_dispose(&ccpl) + C.libxl_cpuid_dispose(ccpl) =20 - return ccpl, Error(-ret) + return Error(-ret) } =20 - return ccpl, nil + return nil } =20 // Hwcap represents a libxl_hwcap. @@ -343,14 +333,12 @@ func (hwcap *Hwcap) fromC(chwcap *C.libxl_hwcap) erro= r { return nil } =20 -func (hwcap *Hwcap) toC() (C.libxl_hwcap, error) { - var chwcap C.libxl_hwcap - +func (hwcap *Hwcap) toC(chwcap *C.libxl_hwcap) error { for i, v :=3D range hwcap { - chwcap[i] =3D C.uint32_t(v) + (*chwcap)[i] =3D C.uint32_t(v) } =20 - return chwcap, nil + return nil } =20 // KeyValueList represents a libxl_key_value_list. @@ -360,8 +348,8 @@ func (hwcap *Hwcap) toC() (C.libxl_hwcap, error) { // Go package. type KeyValueList struct{} =20 -func (kvl KeyValueList) fromC(ckvl *C.libxl_key_value_list) error { r= eturn nil } -func (kvl KeyValueList) toC() (ckvl C.libxl_key_value_list, err error) { r= eturn } +func (kvl KeyValueList) fromC(ckvl *C.libxl_key_value_list) error { re= turn nil } +func (kvl KeyValueList) toC(ckvl *C.libxl_key_value_list) (err error) { re= turn } =20 // StringList represents a libxl_string_list. type StringList []string @@ -379,17 +367,17 @@ func (sl *StringList) fromC(csl *C.libxl_string_list)= error { return nil } =20 -func (sl StringList) toC() (C.libxl_string_list, error) { +func (sl StringList) toC(csl *C.libxl_string_list) error { var char *C.char size :=3D len(sl) - csl :=3D (C.libxl_string_list)(C.malloc(C.ulong(size) * C.ulong(unsafe.Si= zeof(char)))) + *csl =3D (C.libxl_string_list)(C.malloc(C.ulong(size) * C.ulong(unsafe.Si= zeof(char)))) clist :=3D (*[1 << 30]*C.char)(unsafe.Pointer(csl))[:size:size] =20 for i, v :=3D range sl { clist[i] =3D C.CString(v) } =20 - return csl, nil + return nil } =20 // Bitmap represents a libxl_bitmap. @@ -421,9 +409,7 @@ func (bm *Bitmap) fromC(cbm *C.libxl_bitmap) error { return nil } =20 -func (bm *Bitmap) toC() (C.libxl_bitmap, error) { - var cbm C.libxl_bitmap - +func (bm *Bitmap) toC(cbm *C.libxl_bitmap) error { size :=3D len(bm.bitmap) cbm.size =3D C.uint32_t(size) cbm._map =3D (*C.uint8_t)(C.malloc(C.ulong(cbm.size) * C.sizeof_uint8_t)) @@ -431,7 +417,7 @@ func (bm *Bitmap) toC() (C.libxl_bitmap, error) { =20 copy(cs, bm.bitmap) =20 - return cbm, nil + return nil } =20 func (sr ShutdownReason) String() (str string) { @@ -534,8 +520,8 @@ func (Ctx *Context) CpupoolCreate(Name string, Schedule= r Scheduler, Cpumap Bitma var uuid C.libxl_uuid C.libxl_uuid_generate(&uuid) =20 - cbm, err :=3D Cpumap.toC() - if err !=3D nil { + var cbm C.libxl_bitmap + if err =3D Cpumap.toC(&cbm); err !=3D nil { return } defer C.libxl_bitmap_dispose(&cbm) @@ -577,8 +563,8 @@ func (Ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu in= t) (err error) { // int libxl_cpupool_cpuadd_cpumap(libxl_ctx *ctx, uint32_t poolid, // const libxl_bitmap *cpumap); func (Ctx *Context) CpupoolCpuaddCpumap(Poolid uint32, Cpumap Bitmap) (err= error) { - cbm, err :=3D Cpumap.toC() - if err !=3D nil { + var cbm C.libxl_bitmap + if err =3D Cpumap.toC(&cbm); err !=3D nil { return } defer C.libxl_bitmap_dispose(&cbm) @@ -606,8 +592,8 @@ func (Ctx *Context) CpupoolCpuremove(Poolid uint32, Cpu= int) (err error) { // int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid, // const libxl_bitmap *cpumap); func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint32, Cpumap Bitmap) (= err error) { - cbm, err :=3D Cpumap.toC() - if err !=3D nil { + var cbm C.libxl_bitmap + if err =3D Cpumap.toC(&cbm); err !=3D nil { return } defer C.libxl_bitmap_dispose(&cbm) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel