From nobody Sun May 5 15:03:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=1589331541; cv=none; d=zohomail.com; s=zohoarc; b=k7ulZDgDwNgiumxZV4Sd5p9JAvAomnLQT8v47mhOXo2rBts4KmrI+kSw5o2LwQ4163wmwfNVLQmVz3wWk1p77R7EoY7rJ6iakAdkOkUJ5feQoExO321mC7UmCH7xpb0L6GIQRNhxpBiKHmznoRPZ2bbMgTHqg3YrP7HPtdDY5pY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589331541; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=an676N/D+6nftjkOiiWzF86EZ8yFV1/mcajsNXVTAmI=; b=RZoAf+i9G5iYIQqgV0AP3V73JBTDyaO4Wd+nsIfO8YKryfZBeLIxg6WeWJ3blNaaiWVvA0dWCBBPGczWpB5I7stMeQaajkYoEjzwu/HVG4RXIt4SaZfGwJ90Ird4Qyc41MRJrJiX34ett9mY948Z7CpZScB0gE67kn+LrpS6ehg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1589331541855381.7598620707761; Tue, 12 May 2020 17:59:01 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfj9-0006IY-Es; Wed, 13 May 2020 00:58:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfj7-0006ID-Os for xen-devel@lists.xenproject.org; Wed, 13 May 2020 00:58:25 +0000 Received: from mail-qt1-x832.google.com (unknown [2607:f8b0:4864:20::832]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d401cb60-94b4-11ea-ae69-bc764e2007e4; Wed, 13 May 2020 00:58:16 +0000 (UTC) Received: by mail-qt1-x832.google.com with SMTP id j2so12576205qtr.12 for ; Tue, 12 May 2020 17:58:16 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id 62sm12400828qkh.113.2020.05.12.17.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 17:58:11 -0700 (PDT) X-Inumbo-ID: d401cb60-94b4-11ea-ae69-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=an676N/D+6nftjkOiiWzF86EZ8yFV1/mcajsNXVTAmI=; b=R2Jq28ufrtUpeo73Gfl85WUUCqcfn03eArSLipGmiED+RyNZfH9cGlkIKo9OFUP8kj wfVHIrJJDZrCahXMeylg8DUrXLd0GCe3DXmGyp6q+CFyk9AywRFZW7qLe5NL1IsFLvAy CXzbIx6826Ze12tmQlYc2mnSWmGPXL4/RKhz6mqhCnXR8WQWVgRMbw/IOpRQL7LMhAxI t3aHyVRg/h0oBErSc62/kO8V3QZ80w3cEsOVVLihMSLXpX4e9YWH60OXsO2dFAidg0HP A59wvLyaaTaXo46cxFxd86omzbiu3IIGz4DnCtnpHU4vx+m0FiYzI956WaTyBIYn61F0 zFaQ== 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=an676N/D+6nftjkOiiWzF86EZ8yFV1/mcajsNXVTAmI=; b=V8tqrPvkbV2GShutnb/OIGa926102GuRxpTurRY7rdtVntUKcuMNIlC24T1VaO5aMj GCqmPL5XreXbuP8PGzTSKTqX7XDQuE0Uyxnv9oUiPwEmY2H0kTYRqDcmbc+NHJPo6O0C K4BvMS0plMJjaBy9+HUV6CI9MYdumHZkUCAZfM9oqfuUPvQWr4MDqcbQkH8tD5inlrsA yfT0Nv3sXV8pxin9u9kxzIPsL70Xos61ED4wSQ2G2dDJPqUR1eFa6t7SCjxGR5ftEvug caTd7+Ftbh4hKafkWYrieWB3896Ov/qbRbed7TpVTWhDrEY/q+DmSlHwN/KXYblv3IHN VSig== X-Gm-Message-State: AGi0Pub7i5DrnTlnzykSmjqpbyU/LfUBvWdAUJB5X1SkYOGBD00hoVM0 erayYrxxNJAEkvUHHShcdfw9Ph+VlXI= X-Google-Smtp-Source: APiQypJCdl2pWRGcso/VFc3FfD3oRe6SBMHeT/w/R4xwHJ+UrHmdIAZo1uCIyJ2NtVPK+f1f35mVpg== X-Received: by 2002:aed:37ca:: with SMTP id j68mr25132598qtb.276.1589331492390; Tue, 12 May 2020 17:58:12 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH v2 1/3] golang/xenlight: re-track generated go code Date: Tue, 12 May 2020 20:58:05 -0400 Message-Id: <0b40edc65dfd44a9cad8533163f571e169982d0f.1589330383.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Nick Rosbrook , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit df669de074c395a3b2eeb975fddd3da4c148da13 un-tracked the generated Go code, but it was decided that we actually keep the generated code in-tree. Undo the changes to ignore the generated code, and re-generate it. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- .gitignore | 3 - .hgignore | 2 - tools/golang/xenlight/Makefile | 1 - tools/golang/xenlight/helpers.gen.go | 4728 ++++++++++++++++++++++++++ tools/golang/xenlight/types.gen.go | 1226 +++++++ 5 files changed, 5954 insertions(+), 6 deletions(-) create mode 100644 tools/golang/xenlight/helpers.gen.go create mode 100644 tools/golang/xenlight/types.gen.go diff --git a/.gitignore b/.gitignore index 9c8a31f896..bfa53723b3 100644 --- a/.gitignore +++ b/.gitignore @@ -406,9 +406,6 @@ tools/xenstore/xenstore-watch tools/xl/_paths.h tools/xl/xl =20 -tools/golang/src -tools/golang/*/*.gen.go - docs/txt/misc/*.txt docs/txt/man/*.txt docs/figs/*.png diff --git a/.hgignore b/.hgignore index 2ec52982e1..2d41670632 100644 --- a/.hgignore +++ b/.hgignore @@ -282,8 +282,6 @@ ^tools/ocaml/test/xtl$ ^tools/ocaml/test/send_debug_keys$ ^tools/ocaml/test/list_domains$ -^tools/golang/src$ -^tools/golang/.*/.*\.gen\.go$ ^tools/autom4te\.cache$ ^tools/config\.h$ ^tools/config\.log$ diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile index 144c133ced..753132306a 100644 --- a/tools/golang/xenlight/Makefile +++ b/tools/golang/xenlight/Makefile @@ -49,7 +49,6 @@ install: build clean: $(RM) -r $(XEN_GOPATH)$(GOXL_PKG_DIR) $(RM) $(XEN_GOPATH)/pkg/*/$(XEN_GOCODE_URL)/xenlight.a - $(RM) *.gen.go =20 .PHONY: distclean distclean: clean diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go new file mode 100644 index 0000000000..109e9515a2 --- /dev/null +++ b/tools/golang/xenlight/helpers.gen.go @@ -0,0 +1,4728 @@ +// DO NOT EDIT. +// +// This file is generated by: +// gengotypes.py ../../libxl/libxl_types.idl +// +package xenlight + +import ( + "errors" + "fmt" + "unsafe" +) + +/* +#cgo LDFLAGS: -lxenlight +#include +#include + +typedef typeof(((struct libxl_channelinfo *)NULL)->u.pty)libxl_channelinfo= _connection_union_pty; +typedef typeof(((struct libxl_domain_build_info *)NULL)->u.hvm)libxl_domai= n_build_info_type_union_hvm; +typedef typeof(((struct libxl_domain_build_info *)NULL)->u.pv)libxl_domain= _build_info_type_union_pv; +typedef typeof(((struct libxl_domain_build_info *)NULL)->u.pvh)libxl_domai= n_build_info_type_union_pvh; +typedef typeof(((struct libxl_device_usbdev *)NULL)->u.hostdev)libxl_devic= e_usbdev_type_union_hostdev; +typedef typeof(((struct libxl_device_channel *)NULL)->u.socket)libxl_devic= e_channel_connection_union_socket; +typedef typeof(((struct libxl_event *)NULL)->u.domain_shutdown)libxl_event= _type_union_domain_shutdown; +typedef typeof(((struct libxl_event *)NULL)->u.disk_eject)libxl_event_type= _union_disk_eject; +typedef typeof(((struct libxl_event *)NULL)->u.operation_complete)libxl_ev= ent_type_union_operation_complete; +typedef typeof(((struct libxl_psr_hw_info *)NULL)->u.cat)libxl_psr_hw_info= _type_union_cat; +typedef typeof(((struct libxl_psr_hw_info *)NULL)->u.mba)libxl_psr_hw_info= _type_union_mba; +*/ +import "C" + +// NewIoportRange returns an instance of IoportRange initialized with defa= ults. +func NewIoportRange() (*IoportRange, error) { + var ( + x IoportRange + xc C.libxl_ioport_range + ) + + C.libxl_ioport_range_init(&xc) + defer C.libxl_ioport_range_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *IoportRange) fromC(xc *C.libxl_ioport_range) error { + x.First =3D uint32(xc.first) + x.Number =3D uint32(xc.number) + + return nil +} + +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 +} + +// NewIomemRange returns an instance of IomemRange initialized with defaul= ts. +func NewIomemRange() (*IomemRange, error) { + var ( + x IomemRange + xc C.libxl_iomem_range + ) + + C.libxl_iomem_range_init(&xc) + defer C.libxl_iomem_range_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *IomemRange) fromC(xc *C.libxl_iomem_range) error { + x.Start =3D uint64(xc.start) + x.Number =3D uint64(xc.number) + x.Gfn =3D uint64(xc.gfn) + + return nil +} + +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 +} + +// NewVgaInterfaceInfo returns an instance of VgaInterfaceInfo initialized= with defaults. +func NewVgaInterfaceInfo() (*VgaInterfaceInfo, error) { + var ( + x VgaInterfaceInfo + xc C.libxl_vga_interface_info + ) + + C.libxl_vga_interface_info_init(&xc) + defer C.libxl_vga_interface_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error { + x.Kind =3D VgaInterfaceType(xc.kind) + + return nil +} + +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 +} + +// NewVncInfo returns an instance of VncInfo initialized with defaults. +func NewVncInfo() (*VncInfo, error) { + var ( + x VncInfo + xc C.libxl_vnc_info + ) + + C.libxl_vnc_info_init(&xc) + defer C.libxl_vnc_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return fmt.Errorf("converting field Enable: %v", err) + } + x.Listen =3D C.GoString(xc.listen) + x.Passwd =3D C.GoString(xc.passwd) + x.Display =3D int(xc.display) + if err :=3D x.Findunused.fromC(&xc.findunused); err !=3D nil { + return fmt.Errorf("converting field Findunused: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Enable: %v", 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 fmt.Errorf("converting field Findunused: %v", err) + } + + return nil +} + +// NewSpiceInfo returns an instance of SpiceInfo initialized with defaults. +func NewSpiceInfo() (*SpiceInfo, error) { + var ( + x SpiceInfo + xc C.libxl_spice_info + ) + + C.libxl_spice_info_init(&xc) + defer C.libxl_spice_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return fmt.Errorf("converting field Enable: %v", err) + } + x.Port =3D int(xc.port) + x.TlsPort =3D int(xc.tls_port) + x.Host =3D C.GoString(xc.host) + if err :=3D x.DisableTicketing.fromC(&xc.disable_ticketing); err !=3D nil= { + return fmt.Errorf("converting field DisableTicketing: %v", err) + } + x.Passwd =3D C.GoString(xc.passwd) + if err :=3D x.AgentMouse.fromC(&xc.agent_mouse); err !=3D nil { + return fmt.Errorf("converting field AgentMouse: %v", err) + } + if err :=3D x.Vdagent.fromC(&xc.vdagent); err !=3D nil { + return fmt.Errorf("converting field Vdagent: %v", err) + } + if err :=3D x.ClipboardSharing.fromC(&xc.clipboard_sharing); err !=3D nil= { + return fmt.Errorf("converting field ClipboardSharing: %v", err) + } + x.Usbredirection =3D int(xc.usbredirection) + x.ImageCompression =3D C.GoString(xc.image_compression) + x.StreamingVideo =3D C.GoString(xc.streaming_video) + + return nil +} + +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 fmt.Errorf("converting field Enable: %v", 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 fmt.Errorf("converting field DisableTicketing: %v", 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 fmt.Errorf("converting field AgentMouse: %v", err) + } + if err :=3D x.Vdagent.toC(&xc.vdagent); err !=3D nil { + return fmt.Errorf("converting field Vdagent: %v", err) + } + if err :=3D x.ClipboardSharing.toC(&xc.clipboard_sharing); err !=3D nil { + return fmt.Errorf("converting field ClipboardSharing: %v", 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 +} + +// NewSdlInfo returns an instance of SdlInfo initialized with defaults. +func NewSdlInfo() (*SdlInfo, error) { + var ( + x SdlInfo + xc C.libxl_sdl_info + ) + + C.libxl_sdl_info_init(&xc) + defer C.libxl_sdl_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return fmt.Errorf("converting field Enable: %v", err) + } + if err :=3D x.Opengl.fromC(&xc.opengl); err !=3D nil { + return fmt.Errorf("converting field Opengl: %v", err) + } + x.Display =3D C.GoString(xc.display) + x.Xauthority =3D C.GoString(xc.xauthority) + + return nil +} + +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 fmt.Errorf("converting field Enable: %v", err) + } + if err :=3D x.Opengl.toC(&xc.opengl); err !=3D nil { + return fmt.Errorf("converting field Opengl: %v", 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 +} + +// NewDominfo returns an instance of Dominfo initialized with defaults. +func NewDominfo() (*Dominfo, error) { + var ( + x Dominfo + xc C.libxl_dominfo + ) + + C.libxl_dominfo_init(&xc) + defer C.libxl_dominfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + x.Domid =3D Domid(xc.domid) + x.Ssidref =3D uint32(xc.ssidref) + x.SsidLabel =3D C.GoString(xc.ssid_label) + x.Running =3D bool(xc.running) + x.Blocked =3D bool(xc.blocked) + x.Paused =3D bool(xc.paused) + x.Shutdown =3D bool(xc.shutdown) + x.Dying =3D bool(xc.dying) + x.NeverStop =3D bool(xc.never_stop) + x.ShutdownReason =3D ShutdownReason(xc.shutdown_reason) + x.OutstandingMemkb =3D uint64(xc.outstanding_memkb) + x.CurrentMemkb =3D uint64(xc.current_memkb) + x.SharedMemkb =3D uint64(xc.shared_memkb) + x.PagedMemkb =3D uint64(xc.paged_memkb) + x.MaxMemkb =3D uint64(xc.max_memkb) + x.CpuTime =3D uint64(xc.cpu_time) + x.VcpuMaxId =3D uint32(xc.vcpu_max_id) + x.VcpuOnline =3D uint32(xc.vcpu_online) + x.Cpupool =3D uint32(xc.cpupool) + x.DomainType =3D DomainType(xc.domain_type) + + return nil +} + +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 fmt.Errorf("converting field Uuid: %v", 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 +} + +// NewCpupoolinfo returns an instance of Cpupoolinfo initialized with defa= ults. +func NewCpupoolinfo() (*Cpupoolinfo, error) { + var ( + x Cpupoolinfo + xc C.libxl_cpupoolinfo + ) + + C.libxl_cpupoolinfo_init(&xc) + defer C.libxl_cpupoolinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error { + x.Poolid =3D uint32(xc.poolid) + x.PoolName =3D C.GoString(xc.pool_name) + x.Sched =3D Scheduler(xc.sched) + x.NDom =3D uint32(xc.n_dom) + if err :=3D x.Cpumap.fromC(&xc.cpumap); err !=3D nil { + return fmt.Errorf("converting field Cpumap: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Cpumap: %v", err) + } + + return nil +} + +// NewChannelinfo returns an instance of Channelinfo initialized with defa= ults. +func NewChannelinfo(connection ChannelConnection) (*Channelinfo, error) { + var ( + x Channelinfo + xc C.libxl_channelinfo + ) + + C.libxl_channelinfo_init(&xc) + C.libxl_channelinfo_init_connection(&xc, C.libxl_channel_connection(conne= ction)) + defer C.libxl_channelinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.Rref =3D int(xc.rref) + x.Connection =3D ChannelConnection(xc.connection) + switch x.Connection { + case ChannelConnectionUnknown: + x.ConnectionUnion =3D nil + case ChannelConnectionPty: + var connectionPty ChannelinfoConnectionUnionPty + if err :=3D connectionPty.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field connectionPty: %v", err) + } + x.ConnectionUnion =3D connectionPty + case ChannelConnectionSocket: + x.ConnectionUnion =3D nil + default: + return fmt.Errorf("invalid union key '%v'", x.Connection) + } + + return nil +} + +func (x *ChannelinfoConnectionUnionPty) fromC(xc *C.libxl_channelinfo) err= or { + if ChannelConnection(xc.connection) !=3D ChannelConnectionPty { + return errors.New("expected union key ChannelConnectionPty") + } + + tmp :=3D (*C.libxl_channelinfo_connection_union_pty)(unsafe.Pointer(&xc.u= [0])) + x.Path =3D C.GoString(tmp.path) + return nil +} + +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) + xc.connection =3D C.libxl_channel_connection(x.Connection) + switch x.Connection { + case ChannelConnectionUnknown: + break + case ChannelConnectionPty: + tmp, ok :=3D x.ConnectionUnion.(ChannelinfoConnectionUnionPty) + if !ok { + return errors.New("wrong type for union key connection") + } + var pty C.libxl_channelinfo_connection_union_pty + if tmp.Path !=3D "" { + pty.path =3D C.CString(tmp.Path) + } + ptyBytes :=3D C.GoBytes(unsafe.Pointer(&pty), C.sizeof_libxl_channelinfo= _connection_union_pty) + copy(xc.u[:], ptyBytes) + case ChannelConnectionSocket: + break + default: + return fmt.Errorf("invalid union key '%v'", x.Connection) + } + + return nil +} + +// NewVminfo returns an instance of Vminfo initialized with defaults. +func NewVminfo() (*Vminfo, error) { + var ( + x Vminfo + xc C.libxl_vminfo + ) + + C.libxl_vminfo_init(&xc) + defer C.libxl_vminfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + x.Domid =3D Domid(xc.domid) + + return nil +} + +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 fmt.Errorf("converting field Uuid: %v", err) + } + xc.domid =3D C.libxl_domid(x.Domid) + + return nil +} + +// NewVersionInfo returns an instance of VersionInfo initialized with defa= ults. +func NewVersionInfo() (*VersionInfo, error) { + var ( + x VersionInfo + xc C.libxl_version_info + ) + + C.libxl_version_info_init(&xc) + defer C.libxl_version_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.XenVersionExtra =3D C.GoString(xc.xen_version_extra) + x.Compiler =3D C.GoString(xc.compiler) + x.CompileBy =3D C.GoString(xc.compile_by) + x.CompileDomain =3D C.GoString(xc.compile_domain) + x.CompileDate =3D C.GoString(xc.compile_date) + x.Capabilities =3D C.GoString(xc.capabilities) + x.Changeset =3D C.GoString(xc.changeset) + x.VirtStart =3D uint64(xc.virt_start) + x.Pagesize =3D int(xc.pagesize) + x.Commandline =3D C.GoString(xc.commandline) + x.BuildId =3D C.GoString(xc.build_id) + + return nil +} + +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 +} + +// NewDomainCreateInfo returns an instance of DomainCreateInfo initialized= with defaults. +func NewDomainCreateInfo() (*DomainCreateInfo, error) { + var ( + x DomainCreateInfo + xc C.libxl_domain_create_info + ) + + C.libxl_domain_create_info_init(&xc) + defer C.libxl_domain_create_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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 { + return fmt.Errorf("converting field Hap: %v", err) + } + if err :=3D x.Oos.fromC(&xc.oos); err !=3D nil { + return fmt.Errorf("converting field Oos: %v", err) + } + x.Ssidref =3D uint32(xc.ssidref) + x.SsidLabel =3D C.GoString(xc.ssid_label) + x.Name =3D C.GoString(xc.name) + x.Domid =3D Domid(xc.domid) + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + if err :=3D x.Xsdata.fromC(&xc.xsdata); err !=3D nil { + return fmt.Errorf("converting field Xsdata: %v", err) + } + if err :=3D x.Platformdata.fromC(&xc.platformdata); err !=3D nil { + return fmt.Errorf("converting field Platformdata: %v", err) + } + x.Poolid =3D uint32(xc.poolid) + x.PoolName =3D C.GoString(xc.pool_name) + if err :=3D x.RunHotplugScripts.fromC(&xc.run_hotplug_scripts); err !=3D = nil { + return fmt.Errorf("converting field RunHotplugScripts: %v", err) + } + if err :=3D x.DriverDomain.fromC(&xc.driver_domain); err !=3D nil { + return fmt.Errorf("converting field DriverDomain: %v", err) + } + x.Passthrough =3D Passthrough(xc.passthrough) + if err :=3D x.XendSuspendEvtchnCompat.fromC(&xc.xend_suspend_evtchn_compa= t); err !=3D nil { + return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Hap: %v", err) + } + if err :=3D x.Oos.toC(&xc.oos); err !=3D nil { + return fmt.Errorf("converting field Oos: %v", 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) + } + xc.domid =3D C.libxl_domid(x.Domid) + if err :=3D x.Uuid.toC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + if err :=3D x.Xsdata.toC(&xc.xsdata); err !=3D nil { + return fmt.Errorf("converting field Xsdata: %v", err) + } + if err :=3D x.Platformdata.toC(&xc.platformdata); err !=3D nil { + return fmt.Errorf("converting field Platformdata: %v", 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 fmt.Errorf("converting field RunHotplugScripts: %v", err) + } + if err :=3D x.DriverDomain.toC(&xc.driver_domain); err !=3D nil { + return fmt.Errorf("converting field DriverDomain: %v", err) + } + xc.passthrough =3D C.libxl_passthrough(x.Passthrough) + if err :=3D x.XendSuspendEvtchnCompat.toC(&xc.xend_suspend_evtchn_compat)= ; err !=3D nil { + return fmt.Errorf("converting field XendSuspendEvtchnCompat: %v", err) + } + + return nil +} + +// NewDomainRestoreParams returns an instance of DomainRestoreParams initi= alized with defaults. +func NewDomainRestoreParams() (*DomainRestoreParams, error) { + var ( + x DomainRestoreParams + xc C.libxl_domain_restore_params + ) + + C.libxl_domain_restore_params_init(&xc) + defer C.libxl_domain_restore_params_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.ColoProxyScript =3D C.GoString(xc.colo_proxy_script) + if err :=3D x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != =3D nil { + return fmt.Errorf("converting field UserspaceColoProxy: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field UserspaceColoProxy: %v", err) + } + + return nil +} + +// NewSchedParams returns an instance of SchedParams initialized with defa= ults. +func NewSchedParams() (*SchedParams, error) { + var ( + x SchedParams + xc C.libxl_sched_params + ) + + C.libxl_sched_params_init(&xc) + defer C.libxl_sched_params_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { + x.Vcpuid =3D int(xc.vcpuid) + x.Weight =3D int(xc.weight) + x.Cap =3D int(xc.cap) + x.Period =3D int(xc.period) + x.Extratime =3D int(xc.extratime) + x.Budget =3D int(xc.budget) + + return nil +} + +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 +} + +// NewVcpuSchedParams returns an instance of VcpuSchedParams initialized w= ith defaults. +func NewVcpuSchedParams() (*VcpuSchedParams, error) { + var ( + x VcpuSchedParams + xc C.libxl_vcpu_sched_params + ) + + C.libxl_vcpu_sched_params_init(&xc) + defer C.libxl_vcpu_sched_params_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { + x.Sched =3D Scheduler(xc.sched) + x.Vcpus =3D nil + if n :=3D int(xc.num_vcpus); n > 0 { + cVcpus :=3D (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:= n:n] + x.Vcpus =3D make([]SchedParams, n) + for i, v :=3D range cVcpus { + if err :=3D x.Vcpus[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vcpus: %v", err) + } + } + } + + return nil +} + +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) + if numVcpus :=3D len(x.Vcpus); numVcpus > 0 { + xc.vcpus =3D (*C.libxl_sched_params)(C.malloc(C.ulong(numVcpus) * C.size= of_libxl_sched_params)) + xc.num_vcpus =3D C.int(numVcpus) + cVcpus :=3D (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:= numVcpus:numVcpus] + for i, v :=3D range x.Vcpus { + if err :=3D v.toC(&cVcpus[i]); err !=3D nil { + return fmt.Errorf("converting field Vcpus: %v", err) + } + } + } + + return nil +} + +// NewDomainSchedParams returns an instance of DomainSchedParams initializ= ed with defaults. +func NewDomainSchedParams() (*DomainSchedParams, error) { + var ( + x DomainSchedParams + xc C.libxl_domain_sched_params + ) + + C.libxl_domain_sched_params_init(&xc) + defer C.libxl_domain_sched_params_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { + x.Sched =3D Scheduler(xc.sched) + x.Weight =3D int(xc.weight) + x.Cap =3D int(xc.cap) + x.Period =3D int(xc.period) + x.Budget =3D int(xc.budget) + x.Extratime =3D int(xc.extratime) + x.Slice =3D int(xc.slice) + x.Latency =3D int(xc.latency) + + return nil +} + +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 +} + +// NewVnodeInfo returns an instance of VnodeInfo initialized with defaults. +func NewVnodeInfo() (*VnodeInfo, error) { + var ( + x VnodeInfo + xc C.libxl_vnode_info + ) + + C.libxl_vnode_info_init(&xc) + defer C.libxl_vnode_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { + x.Memkb =3D uint64(xc.memkb) + x.Distances =3D nil + if n :=3D int(xc.num_distances); n > 0 { + cDistances :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:n:= n] + x.Distances =3D make([]uint32, n) + for i, v :=3D range cDistances { + x.Distances[i] =3D uint32(v) + } + } + x.Pnode =3D uint32(xc.pnode) + if err :=3D x.Vcpus.fromC(&xc.vcpus); err !=3D nil { + return fmt.Errorf("converting field Vcpus: %v", err) + } + + return nil +} + +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) + if numDistances :=3D len(x.Distances); numDistances > 0 { + xc.distances =3D (*C.uint32_t)(C.malloc(C.size_t(numDistances * numDista= nces))) + xc.num_distances =3D C.int(numDistances) + cDistances :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:nu= mDistances:numDistances] + for i, v :=3D range x.Distances { + cDistances[i] =3D C.uint32_t(v) + } + } + xc.pnode =3D C.uint32_t(x.Pnode) + if err :=3D x.Vcpus.toC(&xc.vcpus); err !=3D nil { + return fmt.Errorf("converting field Vcpus: %v", err) + } + + return nil +} + +// NewRdmReserve returns an instance of RdmReserve initialized with defaul= ts. +func NewRdmReserve() (*RdmReserve, error) { + var ( + x RdmReserve + xc C.libxl_rdm_reserve + ) + + C.libxl_rdm_reserve_init(&xc) + defer C.libxl_rdm_reserve_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error { + x.Strategy =3D RdmReserveStrategy(xc.strategy) + x.Policy =3D RdmReservePolicy(xc.policy) + + return nil +} + +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 +} + +// NewDomainBuildInfo returns an instance of DomainBuildInfo initialized w= ith defaults. +func NewDomainBuildInfo(dtype DomainType) (*DomainBuildInfo, error) { + var ( + x DomainBuildInfo + xc C.libxl_domain_build_info + ) + + C.libxl_domain_build_info_init(&xc) + C.libxl_domain_build_info_init_type(&xc, C.libxl_domain_type(dtype)) + defer C.libxl_domain_build_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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 { + return fmt.Errorf("converting field AvailVcpus: %v", err) + } + if err :=3D x.Cpumap.fromC(&xc.cpumap); err !=3D nil { + return fmt.Errorf("converting field Cpumap: %v", err) + } + if err :=3D x.Nodemap.fromC(&xc.nodemap); err !=3D nil { + return fmt.Errorf("converting field Nodemap: %v", err) + } + x.VcpuHardAffinity =3D nil + if n :=3D int(xc.num_vcpu_hard_affinity); n > 0 { + cVcpuHardAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu= _hard_affinity))[:n:n] + x.VcpuHardAffinity =3D make([]Bitmap, n) + for i, v :=3D range cVcpuHardAffinity { + if err :=3D x.VcpuHardAffinity[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field VcpuHardAffinity: %v", err) + } + } + } + x.VcpuSoftAffinity =3D nil + if n :=3D int(xc.num_vcpu_soft_affinity); n > 0 { + cVcpuSoftAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu= _soft_affinity))[:n:n] + x.VcpuSoftAffinity =3D make([]Bitmap, n) + for i, v :=3D range cVcpuSoftAffinity { + if err :=3D x.VcpuSoftAffinity[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) + } + } + } + if err :=3D x.NumaPlacement.fromC(&xc.numa_placement); err !=3D nil { + return fmt.Errorf("converting field NumaPlacement: %v", err) + } + x.TscMode =3D TscMode(xc.tsc_mode) + x.MaxMemkb =3D uint64(xc.max_memkb) + x.TargetMemkb =3D uint64(xc.target_memkb) + x.VideoMemkb =3D uint64(xc.video_memkb) + x.ShadowMemkb =3D uint64(xc.shadow_memkb) + x.IommuMemkb =3D uint64(xc.iommu_memkb) + x.RtcTimeoffset =3D uint32(xc.rtc_timeoffset) + x.ExecSsidref =3D uint32(xc.exec_ssidref) + x.ExecSsidLabel =3D C.GoString(xc.exec_ssid_label) + if err :=3D x.Localtime.fromC(&xc.localtime); err !=3D nil { + return fmt.Errorf("converting field Localtime: %v", err) + } + if err :=3D x.DisableMigrate.fromC(&xc.disable_migrate); err !=3D nil { + return fmt.Errorf("converting field DisableMigrate: %v", err) + } + if err :=3D x.Cpuid.fromC(&xc.cpuid); err !=3D nil { + return fmt.Errorf("converting field Cpuid: %v", err) + } + x.BlkdevStart =3D C.GoString(xc.blkdev_start) + x.VnumaNodes =3D nil + if n :=3D int(xc.num_vnuma_nodes); n > 0 { + cVnumaNodes :=3D (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_= nodes))[:n:n] + x.VnumaNodes =3D make([]VnodeInfo, n) + for i, v :=3D range cVnumaNodes { + if err :=3D x.VnumaNodes[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field VnumaNodes: %v", err) + } + } + } + x.MaxGrantFrames =3D uint32(xc.max_grant_frames) + x.MaxMaptrackFrames =3D uint32(xc.max_maptrack_frames) + x.DeviceModelVersion =3D DeviceModelVersion(xc.device_model_version) + if err :=3D x.DeviceModelStubdomain.fromC(&xc.device_model_stubdomain); e= rr !=3D nil { + return fmt.Errorf("converting field DeviceModelStubdomain: %v", err) + } + x.DeviceModel =3D C.GoString(xc.device_model) + x.DeviceModelSsidref =3D uint32(xc.device_model_ssidref) + x.DeviceModelSsidLabel =3D C.GoString(xc.device_model_ssid_label) + x.DeviceModelUser =3D C.GoString(xc.device_model_user) + if err :=3D x.Extra.fromC(&xc.extra); err !=3D nil { + return fmt.Errorf("converting field Extra: %v", err) + } + if err :=3D x.ExtraPv.fromC(&xc.extra_pv); err !=3D nil { + return fmt.Errorf("converting field ExtraPv: %v", err) + } + if err :=3D x.ExtraHvm.fromC(&xc.extra_hvm); err !=3D nil { + return fmt.Errorf("converting field ExtraHvm: %v", err) + } + if err :=3D x.SchedParams.fromC(&xc.sched_params); err !=3D nil { + return fmt.Errorf("converting field SchedParams: %v", err) + } + x.Ioports =3D nil + if n :=3D int(xc.num_ioports); n > 0 { + cIoports :=3D (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports= ))[:n:n] + x.Ioports =3D make([]IoportRange, n) + for i, v :=3D range cIoports { + if err :=3D x.Ioports[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Ioports: %v", err) + } + } + } + x.Irqs =3D nil + if n :=3D int(xc.num_irqs); n > 0 { + cIrqs :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:n:n] + x.Irqs =3D make([]uint32, n) + for i, v :=3D range cIrqs { + x.Irqs[i] =3D uint32(v) + } + } + x.Iomem =3D nil + if n :=3D int(xc.num_iomem); n > 0 { + cIomem :=3D (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:n= :n] + x.Iomem =3D make([]IomemRange, n) + for i, v :=3D range cIomem { + if err :=3D x.Iomem[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Iomem: %v", err) + } + } + } + if err :=3D x.ClaimMode.fromC(&xc.claim_mode); err !=3D nil { + return fmt.Errorf("converting field ClaimMode: %v", err) + } + x.EventChannels =3D uint32(xc.event_channels) + x.Kernel =3D C.GoString(xc.kernel) + x.Cmdline =3D C.GoString(xc.cmdline) + x.Ramdisk =3D C.GoString(xc.ramdisk) + x.DeviceTree =3D C.GoString(xc.device_tree) + if err :=3D x.Acpi.fromC(&xc.acpi); err !=3D nil { + return fmt.Errorf("converting field Acpi: %v", err) + } + x.Bootloader =3D C.GoString(xc.bootloader) + if err :=3D x.BootloaderArgs.fromC(&xc.bootloader_args); err !=3D nil { + return fmt.Errorf("converting field BootloaderArgs: %v", err) + } + x.TimerMode =3D TimerMode(xc.timer_mode) + if err :=3D x.NestedHvm.fromC(&xc.nested_hvm); err !=3D nil { + return fmt.Errorf("converting field NestedHvm: %v", err) + } + if err :=3D x.Apic.fromC(&xc.apic); err !=3D nil { + return fmt.Errorf("converting field Apic: %v", err) + } + if err :=3D x.DmRestrict.fromC(&xc.dm_restrict); err !=3D nil { + return fmt.Errorf("converting field DmRestrict: %v", err) + } + x.Tee =3D TeeType(xc.tee) + x.Type =3D DomainType(xc._type) + switch x.Type { + case DomainTypeHvm: + var typeHvm DomainBuildInfoTypeUnionHvm + if err :=3D typeHvm.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeHvm: %v", err) + } + x.TypeUnion =3D typeHvm + case DomainTypePv: + var typePv DomainBuildInfoTypeUnionPv + if err :=3D typePv.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typePv: %v", err) + } + x.TypeUnion =3D typePv + case DomainTypePvh: + var typePvh DomainBuildInfoTypeUnionPvh + if err :=3D typePvh.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typePvh: %v", err) + } + x.TypeUnion =3D typePvh + case DomainTypeInvalid: + x.TypeUnion =3D nil + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + x.ArchArm.GicVersion =3D GicVersion(xc.arch_arm.gic_version) + x.ArchArm.Vuart =3D VuartType(xc.arch_arm.vuart) + x.Altp2M =3D Altp2MMode(xc.altp2m) + + return nil +} + +func (x *DomainBuildInfoTypeUnionHvm) fromC(xc *C.libxl_domain_build_info)= error { + if DomainType(xc._type) !=3D DomainTypeHvm { + return errors.New("expected union key DomainTypeHvm") + } + + tmp :=3D (*C.libxl_domain_build_info_type_union_hvm)(unsafe.Pointer(&xc.u= [0])) + x.Firmware =3D C.GoString(tmp.firmware) + x.Bios =3D BiosType(tmp.bios) + if err :=3D x.Pae.fromC(&tmp.pae); err !=3D nil { + return fmt.Errorf("converting field Pae: %v", err) + } + if err :=3D x.Apic.fromC(&tmp.apic); err !=3D nil { + return fmt.Errorf("converting field Apic: %v", err) + } + if err :=3D x.Acpi.fromC(&tmp.acpi); err !=3D nil { + return fmt.Errorf("converting field Acpi: %v", err) + } + if err :=3D x.AcpiS3.fromC(&tmp.acpi_s3); err !=3D nil { + return fmt.Errorf("converting field AcpiS3: %v", err) + } + if err :=3D x.AcpiS4.fromC(&tmp.acpi_s4); err !=3D nil { + return fmt.Errorf("converting field AcpiS4: %v", err) + } + if err :=3D x.AcpiLaptopSlate.fromC(&tmp.acpi_laptop_slate); err !=3D nil= { + return fmt.Errorf("converting field AcpiLaptopSlate: %v", err) + } + if err :=3D x.Nx.fromC(&tmp.nx); err !=3D nil { + return fmt.Errorf("converting field Nx: %v", err) + } + if err :=3D x.Viridian.fromC(&tmp.viridian); err !=3D nil { + return fmt.Errorf("converting field Viridian: %v", err) + } + if err :=3D x.ViridianEnable.fromC(&tmp.viridian_enable); err !=3D nil { + return fmt.Errorf("converting field ViridianEnable: %v", err) + } + if err :=3D x.ViridianDisable.fromC(&tmp.viridian_disable); err !=3D nil { + return fmt.Errorf("converting field ViridianDisable: %v", err) + } + x.Timeoffset =3D C.GoString(tmp.timeoffset) + if err :=3D x.Hpet.fromC(&tmp.hpet); err !=3D nil { + return fmt.Errorf("converting field Hpet: %v", err) + } + if err :=3D x.VptAlign.fromC(&tmp.vpt_align); err !=3D nil { + return fmt.Errorf("converting field VptAlign: %v", err) + } + x.MmioHoleMemkb =3D uint64(tmp.mmio_hole_memkb) + x.TimerMode =3D TimerMode(tmp.timer_mode) + if err :=3D x.NestedHvm.fromC(&tmp.nested_hvm); err !=3D nil { + return fmt.Errorf("converting field NestedHvm: %v", err) + } + if err :=3D x.Altp2M.fromC(&tmp.altp2m); err !=3D nil { + return fmt.Errorf("converting field Altp2M: %v", err) + } + x.SystemFirmware =3D C.GoString(tmp.system_firmware) + x.SmbiosFirmware =3D C.GoString(tmp.smbios_firmware) + x.AcpiFirmware =3D C.GoString(tmp.acpi_firmware) + x.Hdtype =3D Hdtype(tmp.hdtype) + if err :=3D x.Nographic.fromC(&tmp.nographic); err !=3D nil { + return fmt.Errorf("converting field Nographic: %v", err) + } + if err :=3D x.Vga.fromC(&tmp.vga); err !=3D nil { + return fmt.Errorf("converting field Vga: %v", err) + } + if err :=3D x.Vnc.fromC(&tmp.vnc); err !=3D nil { + return fmt.Errorf("converting field Vnc: %v", err) + } + x.Keymap =3D C.GoString(tmp.keymap) + if err :=3D x.Sdl.fromC(&tmp.sdl); err !=3D nil { + return fmt.Errorf("converting field Sdl: %v", err) + } + if err :=3D x.Spice.fromC(&tmp.spice); err !=3D nil { + return fmt.Errorf("converting field Spice: %v", err) + } + if err :=3D x.GfxPassthru.fromC(&tmp.gfx_passthru); err !=3D nil { + return fmt.Errorf("converting field GfxPassthru: %v", err) + } + x.GfxPassthruKind =3D GfxPassthruKind(tmp.gfx_passthru_kind) + x.Serial =3D C.GoString(tmp.serial) + x.Boot =3D C.GoString(tmp.boot) + if err :=3D x.Usb.fromC(&tmp.usb); err !=3D nil { + return fmt.Errorf("converting field Usb: %v", err) + } + x.Usbversion =3D int(tmp.usbversion) + x.Usbdevice =3D C.GoString(tmp.usbdevice) + if err :=3D x.VkbDevice.fromC(&tmp.vkb_device); err !=3D nil { + return fmt.Errorf("converting field VkbDevice: %v", err) + } + x.Soundhw =3D C.GoString(tmp.soundhw) + if err :=3D x.XenPlatformPci.fromC(&tmp.xen_platform_pci); err !=3D nil { + return fmt.Errorf("converting field XenPlatformPci: %v", err) + } + if err :=3D x.UsbdeviceList.fromC(&tmp.usbdevice_list); err !=3D nil { + return fmt.Errorf("converting field UsbdeviceList: %v", err) + } + x.VendorDevice =3D VendorDevice(tmp.vendor_device) + if err :=3D x.MsVmGenid.fromC(&tmp.ms_vm_genid); err !=3D nil { + return fmt.Errorf("converting field MsVmGenid: %v", err) + } + if err :=3D x.SerialList.fromC(&tmp.serial_list); err !=3D nil { + return fmt.Errorf("converting field SerialList: %v", err) + } + if err :=3D x.Rdm.fromC(&tmp.rdm); err !=3D nil { + return fmt.Errorf("converting field Rdm: %v", err) + } + x.RdmMemBoundaryMemkb =3D uint64(tmp.rdm_mem_boundary_memkb) + x.McaCaps =3D uint64(tmp.mca_caps) + return nil +} + +func (x *DomainBuildInfoTypeUnionPv) fromC(xc *C.libxl_domain_build_info) = error { + if DomainType(xc._type) !=3D DomainTypePv { + return errors.New("expected union key DomainTypePv") + } + + tmp :=3D (*C.libxl_domain_build_info_type_union_pv)(unsafe.Pointer(&xc.u[= 0])) + x.Kernel =3D C.GoString(tmp.kernel) + x.SlackMemkb =3D uint64(tmp.slack_memkb) + x.Bootloader =3D C.GoString(tmp.bootloader) + if err :=3D x.BootloaderArgs.fromC(&tmp.bootloader_args); err !=3D nil { + return fmt.Errorf("converting field BootloaderArgs: %v", err) + } + x.Cmdline =3D C.GoString(tmp.cmdline) + x.Ramdisk =3D C.GoString(tmp.ramdisk) + x.Features =3D C.GoString(tmp.features) + if err :=3D x.E820Host.fromC(&tmp.e820_host); err !=3D nil { + return fmt.Errorf("converting field E820Host: %v", err) + } + return nil +} + +func (x *DomainBuildInfoTypeUnionPvh) fromC(xc *C.libxl_domain_build_info)= error { + if DomainType(xc._type) !=3D DomainTypePvh { + return errors.New("expected union key DomainTypePvh") + } + + tmp :=3D (*C.libxl_domain_build_info_type_union_pvh)(unsafe.Pointer(&xc.u= [0])) + if err :=3D x.Pvshim.fromC(&tmp.pvshim); err !=3D nil { + return fmt.Errorf("converting field Pvshim: %v", err) + } + x.PvshimPath =3D C.GoString(tmp.pvshim_path) + x.PvshimCmdline =3D C.GoString(tmp.pvshim_cmdline) + x.PvshimExtra =3D C.GoString(tmp.pvshim_extra) + return nil +} + +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 fmt.Errorf("converting field AvailVcpus: %v", err) + } + if err :=3D x.Cpumap.toC(&xc.cpumap); err !=3D nil { + return fmt.Errorf("converting field Cpumap: %v", err) + } + if err :=3D x.Nodemap.toC(&xc.nodemap); err !=3D nil { + return fmt.Errorf("converting field Nodemap: %v", err) + } + if numVcpuHardAffinity :=3D len(x.VcpuHardAffinity); numVcpuHardAffinity = > 0 { + xc.vcpu_hard_affinity =3D (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuHard= Affinity) * C.sizeof_libxl_bitmap)) + xc.num_vcpu_hard_affinity =3D C.int(numVcpuHardAffinity) + cVcpuHardAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu= _hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity] + for i, v :=3D range x.VcpuHardAffinity { + if err :=3D v.toC(&cVcpuHardAffinity[i]); err !=3D nil { + return fmt.Errorf("converting field VcpuHardAffinity: %v", err) + } + } + } + if numVcpuSoftAffinity :=3D len(x.VcpuSoftAffinity); numVcpuSoftAffinity = > 0 { + xc.vcpu_soft_affinity =3D (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuSoft= Affinity) * C.sizeof_libxl_bitmap)) + xc.num_vcpu_soft_affinity =3D C.int(numVcpuSoftAffinity) + cVcpuSoftAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu= _soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity] + for i, v :=3D range x.VcpuSoftAffinity { + if err :=3D v.toC(&cVcpuSoftAffinity[i]); err !=3D nil { + return fmt.Errorf("converting field VcpuSoftAffinity: %v", err) + } + } + } + if err :=3D x.NumaPlacement.toC(&xc.numa_placement); err !=3D nil { + return fmt.Errorf("converting field NumaPlacement: %v", 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 fmt.Errorf("converting field Localtime: %v", err) + } + if err :=3D x.DisableMigrate.toC(&xc.disable_migrate); err !=3D nil { + return fmt.Errorf("converting field DisableMigrate: %v", err) + } + if err :=3D x.Cpuid.toC(&xc.cpuid); err !=3D nil { + return fmt.Errorf("converting field Cpuid: %v", err) + } + if x.BlkdevStart !=3D "" { + xc.blkdev_start =3D C.CString(x.BlkdevStart) + } + if numVnumaNodes :=3D len(x.VnumaNodes); numVnumaNodes > 0 { + xc.vnuma_nodes =3D (*C.libxl_vnode_info)(C.malloc(C.ulong(numVnumaNodes)= * C.sizeof_libxl_vnode_info)) + xc.num_vnuma_nodes =3D C.int(numVnumaNodes) + cVnumaNodes :=3D (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_= nodes))[:numVnumaNodes:numVnumaNodes] + for i, v :=3D range x.VnumaNodes { + if err :=3D v.toC(&cVnumaNodes[i]); err !=3D nil { + return fmt.Errorf("converting field VnumaNodes: %v", err) + } + } + } + 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 fmt.Errorf("converting field DeviceModelStubdomain: %v", 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 fmt.Errorf("converting field Extra: %v", err) + } + if err :=3D x.ExtraPv.toC(&xc.extra_pv); err !=3D nil { + return fmt.Errorf("converting field ExtraPv: %v", err) + } + if err :=3D x.ExtraHvm.toC(&xc.extra_hvm); err !=3D nil { + return fmt.Errorf("converting field ExtraHvm: %v", err) + } + if err :=3D x.SchedParams.toC(&xc.sched_params); err !=3D nil { + return fmt.Errorf("converting field SchedParams: %v", err) + } + if numIoports :=3D len(x.Ioports); numIoports > 0 { + xc.ioports =3D (*C.libxl_ioport_range)(C.malloc(C.ulong(numIoports) * C.= sizeof_libxl_ioport_range)) + xc.num_ioports =3D C.int(numIoports) + cIoports :=3D (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports= ))[:numIoports:numIoports] + for i, v :=3D range x.Ioports { + if err :=3D v.toC(&cIoports[i]); err !=3D nil { + return fmt.Errorf("converting field Ioports: %v", err) + } + } + } + if numIrqs :=3D len(x.Irqs); numIrqs > 0 { + xc.irqs =3D (*C.uint32_t)(C.malloc(C.size_t(numIrqs * numIrqs))) + xc.num_irqs =3D C.int(numIrqs) + cIrqs :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:numIrqs:numI= rqs] + for i, v :=3D range x.Irqs { + cIrqs[i] =3D C.uint32_t(v) + } + } + if numIomem :=3D len(x.Iomem); numIomem > 0 { + xc.iomem =3D (*C.libxl_iomem_range)(C.malloc(C.ulong(numIomem) * C.sizeo= f_libxl_iomem_range)) + xc.num_iomem =3D C.int(numIomem) + cIomem :=3D (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:n= umIomem:numIomem] + for i, v :=3D range x.Iomem { + if err :=3D v.toC(&cIomem[i]); err !=3D nil { + return fmt.Errorf("converting field Iomem: %v", err) + } + } + } + if err :=3D x.ClaimMode.toC(&xc.claim_mode); err !=3D nil { + return fmt.Errorf("converting field ClaimMode: %v", 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 fmt.Errorf("converting field Acpi: %v", 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 fmt.Errorf("converting field BootloaderArgs: %v", err) + } + xc.timer_mode =3D C.libxl_timer_mode(x.TimerMode) + if err :=3D x.NestedHvm.toC(&xc.nested_hvm); err !=3D nil { + return fmt.Errorf("converting field NestedHvm: %v", err) + } + if err :=3D x.Apic.toC(&xc.apic); err !=3D nil { + return fmt.Errorf("converting field Apic: %v", err) + } + if err :=3D x.DmRestrict.toC(&xc.dm_restrict); err !=3D nil { + return fmt.Errorf("converting field DmRestrict: %v", err) + } + xc.tee =3D C.libxl_tee_type(x.Tee) + xc._type =3D C.libxl_domain_type(x.Type) + switch x.Type { + case DomainTypeHvm: + tmp, ok :=3D x.TypeUnion.(DomainBuildInfoTypeUnionHvm) + if !ok { + return errors.New("wrong type for union key type") + } + var hvm C.libxl_domain_build_info_type_union_hvm + if tmp.Firmware !=3D "" { + hvm.firmware =3D C.CString(tmp.Firmware) + } + hvm.bios =3D C.libxl_bios_type(tmp.Bios) + if err :=3D tmp.Pae.toC(&hvm.pae); err !=3D nil { + return fmt.Errorf("converting field Pae: %v", err) + } + if err :=3D tmp.Apic.toC(&hvm.apic); err !=3D nil { + return fmt.Errorf("converting field Apic: %v", err) + } + if err :=3D tmp.Acpi.toC(&hvm.acpi); err !=3D nil { + return fmt.Errorf("converting field Acpi: %v", err) + } + if err :=3D tmp.AcpiS3.toC(&hvm.acpi_s3); err !=3D nil { + return fmt.Errorf("converting field AcpiS3: %v", err) + } + if err :=3D tmp.AcpiS4.toC(&hvm.acpi_s4); err !=3D nil { + return fmt.Errorf("converting field AcpiS4: %v", err) + } + if err :=3D tmp.AcpiLaptopSlate.toC(&hvm.acpi_laptop_slate); err !=3D ni= l { + return fmt.Errorf("converting field AcpiLaptopSlate: %v", err) + } + if err :=3D tmp.Nx.toC(&hvm.nx); err !=3D nil { + return fmt.Errorf("converting field Nx: %v", err) + } + if err :=3D tmp.Viridian.toC(&hvm.viridian); err !=3D nil { + return fmt.Errorf("converting field Viridian: %v", err) + } + if err :=3D tmp.ViridianEnable.toC(&hvm.viridian_enable); err !=3D nil { + return fmt.Errorf("converting field ViridianEnable: %v", err) + } + if err :=3D tmp.ViridianDisable.toC(&hvm.viridian_disable); err !=3D nil= { + return fmt.Errorf("converting field ViridianDisable: %v", err) + } + if tmp.Timeoffset !=3D "" { + hvm.timeoffset =3D C.CString(tmp.Timeoffset) + } + if err :=3D tmp.Hpet.toC(&hvm.hpet); err !=3D nil { + return fmt.Errorf("converting field Hpet: %v", err) + } + if err :=3D tmp.VptAlign.toC(&hvm.vpt_align); err !=3D nil { + return fmt.Errorf("converting field VptAlign: %v", err) + } + hvm.mmio_hole_memkb =3D C.uint64_t(tmp.MmioHoleMemkb) + hvm.timer_mode =3D C.libxl_timer_mode(tmp.TimerMode) + if err :=3D tmp.NestedHvm.toC(&hvm.nested_hvm); err !=3D nil { + return fmt.Errorf("converting field NestedHvm: %v", err) + } + if err :=3D tmp.Altp2M.toC(&hvm.altp2m); err !=3D nil { + return fmt.Errorf("converting field Altp2M: %v", err) + } + if tmp.SystemFirmware !=3D "" { + hvm.system_firmware =3D C.CString(tmp.SystemFirmware) + } + if tmp.SmbiosFirmware !=3D "" { + hvm.smbios_firmware =3D C.CString(tmp.SmbiosFirmware) + } + if tmp.AcpiFirmware !=3D "" { + hvm.acpi_firmware =3D C.CString(tmp.AcpiFirmware) + } + hvm.hdtype =3D C.libxl_hdtype(tmp.Hdtype) + if err :=3D tmp.Nographic.toC(&hvm.nographic); err !=3D nil { + return fmt.Errorf("converting field Nographic: %v", err) + } + if err :=3D tmp.Vga.toC(&hvm.vga); err !=3D nil { + return fmt.Errorf("converting field Vga: %v", err) + } + if err :=3D tmp.Vnc.toC(&hvm.vnc); err !=3D nil { + return fmt.Errorf("converting field Vnc: %v", err) + } + if tmp.Keymap !=3D "" { + hvm.keymap =3D C.CString(tmp.Keymap) + } + if err :=3D tmp.Sdl.toC(&hvm.sdl); err !=3D nil { + return fmt.Errorf("converting field Sdl: %v", err) + } + if err :=3D tmp.Spice.toC(&hvm.spice); err !=3D nil { + return fmt.Errorf("converting field Spice: %v", err) + } + if err :=3D tmp.GfxPassthru.toC(&hvm.gfx_passthru); err !=3D nil { + return fmt.Errorf("converting field GfxPassthru: %v", err) + } + hvm.gfx_passthru_kind =3D C.libxl_gfx_passthru_kind(tmp.GfxPassthruKind) + if tmp.Serial !=3D "" { + hvm.serial =3D C.CString(tmp.Serial) + } + if tmp.Boot !=3D "" { + hvm.boot =3D C.CString(tmp.Boot) + } + if err :=3D tmp.Usb.toC(&hvm.usb); err !=3D nil { + return fmt.Errorf("converting field Usb: %v", err) + } + hvm.usbversion =3D C.int(tmp.Usbversion) + if tmp.Usbdevice !=3D "" { + hvm.usbdevice =3D C.CString(tmp.Usbdevice) + } + if err :=3D tmp.VkbDevice.toC(&hvm.vkb_device); err !=3D nil { + return fmt.Errorf("converting field VkbDevice: %v", err) + } + if tmp.Soundhw !=3D "" { + hvm.soundhw =3D C.CString(tmp.Soundhw) + } + if err :=3D tmp.XenPlatformPci.toC(&hvm.xen_platform_pci); err !=3D nil { + return fmt.Errorf("converting field XenPlatformPci: %v", err) + } + if err :=3D tmp.UsbdeviceList.toC(&hvm.usbdevice_list); err !=3D nil { + return fmt.Errorf("converting field UsbdeviceList: %v", err) + } + hvm.vendor_device =3D C.libxl_vendor_device(tmp.VendorDevice) + if err :=3D tmp.MsVmGenid.toC(&hvm.ms_vm_genid); err !=3D nil { + return fmt.Errorf("converting field MsVmGenid: %v", err) + } + if err :=3D tmp.SerialList.toC(&hvm.serial_list); err !=3D nil { + return fmt.Errorf("converting field SerialList: %v", err) + } + if err :=3D tmp.Rdm.toC(&hvm.rdm); err !=3D nil { + return fmt.Errorf("converting field Rdm: %v", err) + } + hvm.rdm_mem_boundary_memkb =3D C.uint64_t(tmp.RdmMemBoundaryMemkb) + hvm.mca_caps =3D C.uint64_t(tmp.McaCaps) + hvmBytes :=3D C.GoBytes(unsafe.Pointer(&hvm), C.sizeof_libxl_domain_buil= d_info_type_union_hvm) + copy(xc.u[:], hvmBytes) + case DomainTypePv: + tmp, ok :=3D x.TypeUnion.(DomainBuildInfoTypeUnionPv) + if !ok { + return errors.New("wrong type for union key type") + } + var pv C.libxl_domain_build_info_type_union_pv + if tmp.Kernel !=3D "" { + pv.kernel =3D C.CString(tmp.Kernel) + } + pv.slack_memkb =3D C.uint64_t(tmp.SlackMemkb) + if tmp.Bootloader !=3D "" { + pv.bootloader =3D C.CString(tmp.Bootloader) + } + if err :=3D tmp.BootloaderArgs.toC(&pv.bootloader_args); err !=3D nil { + return fmt.Errorf("converting field BootloaderArgs: %v", err) + } + if tmp.Cmdline !=3D "" { + pv.cmdline =3D C.CString(tmp.Cmdline) + } + if tmp.Ramdisk !=3D "" { + pv.ramdisk =3D C.CString(tmp.Ramdisk) + } + if tmp.Features !=3D "" { + pv.features =3D C.CString(tmp.Features) + } + if err :=3D tmp.E820Host.toC(&pv.e820_host); err !=3D nil { + return fmt.Errorf("converting field E820Host: %v", err) + } + pvBytes :=3D C.GoBytes(unsafe.Pointer(&pv), C.sizeof_libxl_domain_build_= info_type_union_pv) + copy(xc.u[:], pvBytes) + case DomainTypePvh: + tmp, ok :=3D x.TypeUnion.(DomainBuildInfoTypeUnionPvh) + if !ok { + return errors.New("wrong type for union key type") + } + var pvh C.libxl_domain_build_info_type_union_pvh + if err :=3D tmp.Pvshim.toC(&pvh.pvshim); err !=3D nil { + return fmt.Errorf("converting field Pvshim: %v", err) + } + if tmp.PvshimPath !=3D "" { + pvh.pvshim_path =3D C.CString(tmp.PvshimPath) + } + if tmp.PvshimCmdline !=3D "" { + pvh.pvshim_cmdline =3D C.CString(tmp.PvshimCmdline) + } + if tmp.PvshimExtra !=3D "" { + pvh.pvshim_extra =3D C.CString(tmp.PvshimExtra) + } + pvhBytes :=3D C.GoBytes(unsafe.Pointer(&pvh), C.sizeof_libxl_domain_buil= d_info_type_union_pvh) + copy(xc.u[:], pvhBytes) + case DomainTypeInvalid: + break + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + 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 +} + +// NewDeviceVfb returns an instance of DeviceVfb initialized with defaults. +func NewDeviceVfb() (*DeviceVfb, error) { + var ( + x DeviceVfb + xc C.libxl_device_vfb + ) + + C.libxl_device_vfb_init(&xc) + defer C.libxl_device_vfb_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + if err :=3D x.Vnc.fromC(&xc.vnc); err !=3D nil { + return fmt.Errorf("converting field Vnc: %v", err) + } + if err :=3D x.Sdl.fromC(&xc.sdl); err !=3D nil { + return fmt.Errorf("converting field Sdl: %v", err) + } + x.Keymap =3D C.GoString(xc.keymap) + + return nil +} + +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 fmt.Errorf("converting field Vnc: %v", err) + } + if err :=3D x.Sdl.toC(&xc.sdl); err !=3D nil { + return fmt.Errorf("converting field Sdl: %v", err) + } + if x.Keymap !=3D "" { + xc.keymap =3D C.CString(x.Keymap) + } + + return nil +} + +// NewDeviceVkb returns an instance of DeviceVkb initialized with defaults. +func NewDeviceVkb() (*DeviceVkb, error) { + var ( + x DeviceVkb + xc C.libxl_device_vkb + ) + + C.libxl_device_vkb_init(&xc) + defer C.libxl_device_vkb_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + x.BackendType =3D VkbBackend(xc.backend_type) + x.UniqueId =3D C.GoString(xc.unique_id) + x.FeatureDisableKeyboard =3D bool(xc.feature_disable_keyboard) + x.FeatureDisablePointer =3D bool(xc.feature_disable_pointer) + x.FeatureAbsPointer =3D bool(xc.feature_abs_pointer) + x.FeatureRawPointer =3D bool(xc.feature_raw_pointer) + x.FeatureMultiTouch =3D bool(xc.feature_multi_touch) + x.Width =3D uint32(xc.width) + x.Height =3D uint32(xc.height) + x.MultiTouchWidth =3D uint32(xc.multi_touch_width) + x.MultiTouchHeight =3D uint32(xc.multi_touch_height) + x.MultiTouchNumContacts =3D uint32(xc.multi_touch_num_contacts) + + return nil +} + +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 +} + +// NewDeviceDisk returns an instance of DeviceDisk initialized with defaul= ts. +func NewDeviceDisk() (*DeviceDisk, error) { + var ( + x DeviceDisk + xc C.libxl_device_disk + ) + + C.libxl_device_disk_init(&xc) + defer C.libxl_device_disk_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.PdevPath =3D C.GoString(xc.pdev_path) + x.Vdev =3D C.GoString(xc.vdev) + x.Backend =3D DiskBackend(xc.backend) + x.Format =3D DiskFormat(xc.format) + x.Script =3D C.GoString(xc.script) + x.Removable =3D int(xc.removable) + x.Readwrite =3D int(xc.readwrite) + x.IsCdrom =3D int(xc.is_cdrom) + x.DirectIoSafe =3D bool(xc.direct_io_safe) + if err :=3D x.DiscardEnable.fromC(&xc.discard_enable); err !=3D nil { + return fmt.Errorf("converting field DiscardEnable: %v", err) + } + if err :=3D x.ColoEnable.fromC(&xc.colo_enable); err !=3D nil { + return fmt.Errorf("converting field ColoEnable: %v", err) + } + if err :=3D x.ColoRestoreEnable.fromC(&xc.colo_restore_enable); err !=3D = nil { + return fmt.Errorf("converting field ColoRestoreEnable: %v", err) + } + x.ColoHost =3D C.GoString(xc.colo_host) + x.ColoPort =3D int(xc.colo_port) + x.ColoExport =3D C.GoString(xc.colo_export) + x.ActiveDisk =3D C.GoString(xc.active_disk) + x.HiddenDisk =3D C.GoString(xc.hidden_disk) + + return nil +} + +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 fmt.Errorf("converting field DiscardEnable: %v", err) + } + if err :=3D x.ColoEnable.toC(&xc.colo_enable); err !=3D nil { + return fmt.Errorf("converting field ColoEnable: %v", err) + } + if err :=3D x.ColoRestoreEnable.toC(&xc.colo_restore_enable); err !=3D ni= l { + return fmt.Errorf("converting field ColoRestoreEnable: %v", 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 +} + +// NewDeviceNic returns an instance of DeviceNic initialized with defaults. +func NewDeviceNic() (*DeviceNic, error) { + var ( + x DeviceNic + xc C.libxl_device_nic + ) + + C.libxl_device_nic_init(&xc) + defer C.libxl_device_nic_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + x.Mtu =3D int(xc.mtu) + x.Model =3D C.GoString(xc.model) + if err :=3D x.Mac.fromC(&xc.mac); err !=3D nil { + return fmt.Errorf("converting field Mac: %v", err) + } + x.Ip =3D C.GoString(xc.ip) + x.Bridge =3D C.GoString(xc.bridge) + x.Ifname =3D C.GoString(xc.ifname) + x.Script =3D C.GoString(xc.script) + x.Nictype =3D NicType(xc.nictype) + x.RateBytesPerInterval =3D uint64(xc.rate_bytes_per_interval) + x.RateIntervalUsecs =3D uint32(xc.rate_interval_usecs) + x.Gatewaydev =3D C.GoString(xc.gatewaydev) + x.ColoftForwarddev =3D C.GoString(xc.coloft_forwarddev) + x.ColoSockMirrorId =3D C.GoString(xc.colo_sock_mirror_id) + x.ColoSockMirrorIp =3D C.GoString(xc.colo_sock_mirror_ip) + x.ColoSockMirrorPort =3D C.GoString(xc.colo_sock_mirror_port) + x.ColoSockComparePriInId =3D C.GoString(xc.colo_sock_compare_pri_in_id) + x.ColoSockComparePriInIp =3D C.GoString(xc.colo_sock_compare_pri_in_ip) + x.ColoSockComparePriInPort =3D C.GoString(xc.colo_sock_compare_pri_in_por= t) + x.ColoSockCompareSecInId =3D C.GoString(xc.colo_sock_compare_sec_in_id) + x.ColoSockCompareSecInIp =3D C.GoString(xc.colo_sock_compare_sec_in_ip) + x.ColoSockCompareSecInPort =3D C.GoString(xc.colo_sock_compare_sec_in_por= t) + x.ColoSockCompareNotifyId =3D C.GoString(xc.colo_sock_compare_notify_id) + x.ColoSockCompareNotifyIp =3D C.GoString(xc.colo_sock_compare_notify_ip) + x.ColoSockCompareNotifyPort =3D C.GoString(xc.colo_sock_compare_notify_po= rt) + x.ColoSockRedirector0Id =3D C.GoString(xc.colo_sock_redirector0_id) + x.ColoSockRedirector0Ip =3D C.GoString(xc.colo_sock_redirector0_ip) + x.ColoSockRedirector0Port =3D C.GoString(xc.colo_sock_redirector0_port) + x.ColoSockRedirector1Id =3D C.GoString(xc.colo_sock_redirector1_id) + x.ColoSockRedirector1Ip =3D C.GoString(xc.colo_sock_redirector1_ip) + x.ColoSockRedirector1Port =3D C.GoString(xc.colo_sock_redirector1_port) + x.ColoSockRedirector2Id =3D C.GoString(xc.colo_sock_redirector2_id) + x.ColoSockRedirector2Ip =3D C.GoString(xc.colo_sock_redirector2_ip) + x.ColoSockRedirector2Port =3D C.GoString(xc.colo_sock_redirector2_port) + x.ColoFilterMirrorQueue =3D C.GoString(xc.colo_filter_mirror_queue) + x.ColoFilterMirrorOutdev =3D C.GoString(xc.colo_filter_mirror_outdev) + x.ColoFilterRedirector0Queue =3D C.GoString(xc.colo_filter_redirector0_qu= eue) + x.ColoFilterRedirector0Indev =3D C.GoString(xc.colo_filter_redirector0_in= dev) + x.ColoFilterRedirector0Outdev =3D C.GoString(xc.colo_filter_redirector0_o= utdev) + x.ColoFilterRedirector1Queue =3D C.GoString(xc.colo_filter_redirector1_qu= eue) + x.ColoFilterRedirector1Indev =3D C.GoString(xc.colo_filter_redirector1_in= dev) + x.ColoFilterRedirector1Outdev =3D C.GoString(xc.colo_filter_redirector1_o= utdev) + x.ColoComparePriIn =3D C.GoString(xc.colo_compare_pri_in) + x.ColoCompareSecIn =3D C.GoString(xc.colo_compare_sec_in) + x.ColoCompareOut =3D C.GoString(xc.colo_compare_out) + x.ColoCompareNotifyDev =3D C.GoString(xc.colo_compare_notify_dev) + x.ColoSockSecRedirector0Id =3D C.GoString(xc.colo_sock_sec_redirector0_id) + x.ColoSockSecRedirector0Ip =3D C.GoString(xc.colo_sock_sec_redirector0_ip) + x.ColoSockSecRedirector0Port =3D C.GoString(xc.colo_sock_sec_redirector0_= port) + x.ColoSockSecRedirector1Id =3D C.GoString(xc.colo_sock_sec_redirector1_id) + x.ColoSockSecRedirector1Ip =3D C.GoString(xc.colo_sock_sec_redirector1_ip) + x.ColoSockSecRedirector1Port =3D C.GoString(xc.colo_sock_sec_redirector1_= port) + x.ColoFilterSecRedirector0Queue =3D C.GoString(xc.colo_filter_sec_redirec= tor0_queue) + x.ColoFilterSecRedirector0Indev =3D C.GoString(xc.colo_filter_sec_redirec= tor0_indev) + x.ColoFilterSecRedirector0Outdev =3D C.GoString(xc.colo_filter_sec_redire= ctor0_outdev) + x.ColoFilterSecRedirector1Queue =3D C.GoString(xc.colo_filter_sec_redirec= tor1_queue) + x.ColoFilterSecRedirector1Indev =3D C.GoString(xc.colo_filter_sec_redirec= tor1_indev) + x.ColoFilterSecRedirector1Outdev =3D C.GoString(xc.colo_filter_sec_redire= ctor1_outdev) + x.ColoFilterSecRewriter0Queue =3D C.GoString(xc.colo_filter_sec_rewriter0= _queue) + x.ColoCheckpointHost =3D C.GoString(xc.colo_checkpoint_host) + x.ColoCheckpointPort =3D C.GoString(xc.colo_checkpoint_port) + + return nil +} + +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 fmt.Errorf("converting field Mac: %v", 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 +} + +// NewDevicePci returns an instance of DevicePci initialized with defaults. +func NewDevicePci() (*DevicePci, error) { + var ( + x DevicePci + xc C.libxl_device_pci + ) + + C.libxl_device_pci_init(&xc) + defer C.libxl_device_pci_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DevicePci) fromC(xc *C.libxl_device_pci) error { + x.Func =3D byte(xc._func) + x.Dev =3D byte(xc.dev) + x.Bus =3D byte(xc.bus) + x.Domain =3D int(xc.domain) + x.Vdevfn =3D uint32(xc.vdevfn) + x.VfuncMask =3D uint32(xc.vfunc_mask) + x.Msitranslate =3D bool(xc.msitranslate) + x.PowerMgmt =3D bool(xc.power_mgmt) + x.Permissive =3D bool(xc.permissive) + x.Seize =3D bool(xc.seize) + x.RdmPolicy =3D RdmReservePolicy(xc.rdm_policy) + + return nil +} + +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 +} + +// NewDeviceRdm returns an instance of DeviceRdm initialized with defaults. +func NewDeviceRdm() (*DeviceRdm, error) { + var ( + x DeviceRdm + xc C.libxl_device_rdm + ) + + C.libxl_device_rdm_init(&xc) + defer C.libxl_device_rdm_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) error { + x.Start =3D uint64(xc.start) + x.Size =3D uint64(xc.size) + x.Policy =3D RdmReservePolicy(xc.policy) + + return nil +} + +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 +} + +// NewDeviceUsbctrl returns an instance of DeviceUsbctrl initialized with = defaults. +func NewDeviceUsbctrl() (*DeviceUsbctrl, error) { + var ( + x DeviceUsbctrl + xc C.libxl_device_usbctrl + ) + + C.libxl_device_usbctrl_init(&xc) + defer C.libxl_device_usbctrl_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbctrl) error { + x.Type =3D UsbctrlType(xc._type) + x.Devid =3D Devid(xc.devid) + x.Version =3D int(xc.version) + x.Ports =3D int(xc.ports) + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + + return nil +} + +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 +} + +// NewDeviceUsbdev returns an instance of DeviceUsbdev initialized with de= faults. +func NewDeviceUsbdev(utype UsbdevType) (*DeviceUsbdev, error) { + var ( + x DeviceUsbdev + xc C.libxl_device_usbdev + ) + + C.libxl_device_usbdev_init(&xc) + C.libxl_device_usbdev_init_type(&xc, C.libxl_usbdev_type(utype)) + defer C.libxl_device_usbdev_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error { + x.Ctrl =3D Devid(xc.ctrl) + x.Port =3D int(xc.port) + x.Type =3D UsbdevType(xc._type) + switch x.Type { + case UsbdevTypeHostdev: + var typeHostdev DeviceUsbdevTypeUnionHostdev + if err :=3D typeHostdev.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeHostdev: %v", err) + } + x.TypeUnion =3D typeHostdev + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} + +func (x *DeviceUsbdevTypeUnionHostdev) fromC(xc *C.libxl_device_usbdev) er= ror { + if UsbdevType(xc._type) !=3D UsbdevTypeHostdev { + return errors.New("expected union key UsbdevTypeHostdev") + } + + tmp :=3D (*C.libxl_device_usbdev_type_union_hostdev)(unsafe.Pointer(&xc.u= [0])) + x.Hostbus =3D byte(tmp.hostbus) + x.Hostaddr =3D byte(tmp.hostaddr) + return nil +} + +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) + xc._type =3D C.libxl_usbdev_type(x.Type) + switch x.Type { + case UsbdevTypeHostdev: + tmp, ok :=3D x.TypeUnion.(DeviceUsbdevTypeUnionHostdev) + if !ok { + return errors.New("wrong type for union key type") + } + var hostdev C.libxl_device_usbdev_type_union_hostdev + hostdev.hostbus =3D C.uint8_t(tmp.Hostbus) + hostdev.hostaddr =3D C.uint8_t(tmp.Hostaddr) + hostdevBytes :=3D C.GoBytes(unsafe.Pointer(&hostdev), C.sizeof_libxl_dev= ice_usbdev_type_union_hostdev) + copy(xc.u[:], hostdevBytes) + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} + +// NewDeviceDtdev returns an instance of DeviceDtdev initialized with defa= ults. +func NewDeviceDtdev() (*DeviceDtdev, error) { + var ( + x DeviceDtdev + xc C.libxl_device_dtdev + ) + + C.libxl_device_dtdev_init(&xc) + defer C.libxl_device_dtdev_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error { + x.Path =3D C.GoString(xc.path) + + return nil +} + +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 +} + +// NewDeviceVtpm returns an instance of DeviceVtpm initialized with defaul= ts. +func NewDeviceVtpm() (*DeviceVtpm, error) { + var ( + x DeviceVtpm + xc C.libxl_device_vtpm + ) + + C.libxl_device_vtpm_init(&xc) + defer C.libxl_device_vtpm_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Uuid: %v", err) + } + + return nil +} + +// NewDeviceP9 returns an instance of DeviceP9 initialized with defaults. +func NewDeviceP9() (*DeviceP9, error) { + var ( + x DeviceP9 + xc C.libxl_device_p9 + ) + + C.libxl_device_p9_init(&xc) + defer C.libxl_device_p9_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Tag =3D C.GoString(xc.tag) + x.Path =3D C.GoString(xc.path) + x.SecurityModel =3D C.GoString(xc.security_model) + x.Devid =3D Devid(xc.devid) + + return nil +} + +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 +} + +// NewDevicePvcallsif returns an instance of DevicePvcallsif initialized w= ith defaults. +func NewDevicePvcallsif() (*DevicePvcallsif, error) { + var ( + x DevicePvcallsif + xc C.libxl_device_pvcallsif + ) + + C.libxl_device_pvcallsif_init(&xc) + defer C.libxl_device_pvcallsif_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + + return nil +} + +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 +} + +// NewDeviceChannel returns an instance of DeviceChannel initialized with = defaults. +func NewDeviceChannel(connection ChannelConnection) (*DeviceChannel, error= ) { + var ( + x DeviceChannel + xc C.libxl_device_channel + ) + + C.libxl_device_channel_init(&xc) + C.libxl_device_channel_init_connection(&xc, C.libxl_channel_connection(co= nnection)) + defer C.libxl_device_channel_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + x.Name =3D C.GoString(xc.name) + x.Connection =3D ChannelConnection(xc.connection) + switch x.Connection { + case ChannelConnectionUnknown: + x.ConnectionUnion =3D nil + case ChannelConnectionPty: + x.ConnectionUnion =3D nil + case ChannelConnectionSocket: + var connectionSocket DeviceChannelConnectionUnionSocket + if err :=3D connectionSocket.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field connectionSocket: %v", err) + } + x.ConnectionUnion =3D connectionSocket + default: + return fmt.Errorf("invalid union key '%v'", x.Connection) + } + + return nil +} + +func (x *DeviceChannelConnectionUnionSocket) fromC(xc *C.libxl_device_chan= nel) error { + if ChannelConnection(xc.connection) !=3D ChannelConnectionSocket { + return errors.New("expected union key ChannelConnectionSocket") + } + + tmp :=3D (*C.libxl_device_channel_connection_union_socket)(unsafe.Pointer= (&xc.u[0])) + x.Path =3D C.GoString(tmp.path) + return nil +} + +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) + } + xc.connection =3D C.libxl_channel_connection(x.Connection) + switch x.Connection { + case ChannelConnectionUnknown: + break + case ChannelConnectionPty: + break + case ChannelConnectionSocket: + tmp, ok :=3D x.ConnectionUnion.(DeviceChannelConnectionUnionSocket) + if !ok { + return errors.New("wrong type for union key connection") + } + var socket C.libxl_device_channel_connection_union_socket + if tmp.Path !=3D "" { + socket.path =3D C.CString(tmp.Path) + } + socketBytes :=3D C.GoBytes(unsafe.Pointer(&socket), C.sizeof_libxl_devic= e_channel_connection_union_socket) + copy(xc.u[:], socketBytes) + default: + return fmt.Errorf("invalid union key '%v'", x.Connection) + } + + return nil +} + +// NewConnectorParam returns an instance of ConnectorParam initialized wit= h defaults. +func NewConnectorParam() (*ConnectorParam, error) { + var ( + x ConnectorParam + xc C.libxl_connector_param + ) + + C.libxl_connector_param_init(&xc) + defer C.libxl_connector_param_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Height =3D uint32(xc.height) + + return nil +} + +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 +} + +// NewDeviceVdispl returns an instance of DeviceVdispl initialized with de= faults. +func NewDeviceVdispl() (*DeviceVdispl, error) { + var ( + x DeviceVdispl + xc C.libxl_device_vdispl + ) + + C.libxl_device_vdispl_init(&xc) + defer C.libxl_device_vdispl_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + x.BeAlloc =3D bool(xc.be_alloc) + x.Connectors =3D nil + if n :=3D int(xc.num_connectors); n > 0 { + cConnectors :=3D (*[1 << 28]C.libxl_connector_param)(unsafe.Pointer(xc.c= onnectors))[:n:n] + x.Connectors =3D make([]ConnectorParam, n) + for i, v :=3D range cConnectors { + if err :=3D x.Connectors[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Connectors: %v", err) + } + } + } + + return nil +} + +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) + if numConnectors :=3D len(x.Connectors); numConnectors > 0 { + xc.connectors =3D (*C.libxl_connector_param)(C.malloc(C.ulong(numConnect= ors) * C.sizeof_libxl_connector_param)) + xc.num_connectors =3D C.int(numConnectors) + cConnectors :=3D (*[1 << 28]C.libxl_connector_param)(unsafe.Pointer(xc.c= onnectors))[:numConnectors:numConnectors] + for i, v :=3D range x.Connectors { + if err :=3D v.toC(&cConnectors[i]); err !=3D nil { + return fmt.Errorf("converting field Connectors: %v", err) + } + } + } + + return nil +} + +// NewVsndParams returns an instance of VsndParams initialized with defaul= ts. +func NewVsndParams() (*VsndParams, error) { + var ( + x VsndParams + xc C.libxl_vsnd_params + ) + + C.libxl_vsnd_params_init(&xc) + defer C.libxl_vsnd_params_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { + x.SampleRates =3D nil + if n :=3D int(xc.num_sample_rates); n > 0 { + cSampleRates :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates)= )[:n:n] + x.SampleRates =3D make([]uint32, n) + for i, v :=3D range cSampleRates { + x.SampleRates[i] =3D uint32(v) + } + } + x.SampleFormats =3D nil + if n :=3D int(xc.num_sample_formats); n > 0 { + cSampleFormats :=3D (*[1 << 28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(x= c.sample_formats))[:n:n] + x.SampleFormats =3D make([]VsndPcmFormat, n) + for i, v :=3D range cSampleFormats { + x.SampleFormats[i] =3D VsndPcmFormat(v) + } + } + x.ChannelsMin =3D uint32(xc.channels_min) + x.ChannelsMax =3D uint32(xc.channels_max) + x.BufferSize =3D uint32(xc.buffer_size) + + return nil +} + +func (x *VsndParams) toC(xc *C.libxl_vsnd_params) (err error) { + defer func() { + if err !=3D nil { + C.libxl_vsnd_params_dispose(xc) + } + }() + + if numSampleRates :=3D len(x.SampleRates); numSampleRates > 0 { + xc.sample_rates =3D (*C.uint32_t)(C.malloc(C.size_t(numSampleRates * num= SampleRates))) + xc.num_sample_rates =3D C.int(numSampleRates) + cSampleRates :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates)= )[:numSampleRates:numSampleRates] + for i, v :=3D range x.SampleRates { + cSampleRates[i] =3D C.uint32_t(v) + } + } + if numSampleFormats :=3D len(x.SampleFormats); numSampleFormats > 0 { + xc.sample_formats =3D (*C.libxl_vsnd_pcm_format)(C.malloc(C.size_t(numSa= mpleFormats * numSampleFormats))) + xc.num_sample_formats =3D C.int(numSampleFormats) + cSampleFormats :=3D (*[1 << 28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(x= c.sample_formats))[:numSampleFormats:numSampleFormats] + for i, v :=3D range x.SampleFormats { + cSampleFormats[i] =3D C.libxl_vsnd_pcm_format(v) + } + } + 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 +} + +// NewVsndStream returns an instance of VsndStream initialized with defaul= ts. +func NewVsndStream() (*VsndStream, error) { + var ( + x VsndStream + xc C.libxl_vsnd_stream + ) + + C.libxl_vsnd_stream_init(&xc) + defer C.libxl_vsnd_stream_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + if err :=3D x.Params.fromC(&xc.params); err !=3D nil { + return fmt.Errorf("converting field Params: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Params: %v", err) + } + + return nil +} + +// NewVsndPcm returns an instance of VsndPcm initialized with defaults. +func NewVsndPcm() (*VsndPcm, error) { + var ( + x VsndPcm + xc C.libxl_vsnd_pcm + ) + + C.libxl_vsnd_pcm_init(&xc) + defer C.libxl_vsnd_pcm_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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 { + return fmt.Errorf("converting field Params: %v", err) + } + x.Streams =3D nil + if n :=3D int(xc.num_vsnd_streams); n > 0 { + cStreams :=3D (*[1 << 28]C.libxl_vsnd_stream)(unsafe.Pointer(xc.streams)= )[:n:n] + x.Streams =3D make([]VsndStream, n) + for i, v :=3D range cStreams { + if err :=3D x.Streams[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Streams: %v", err) + } + } + } + + return nil +} + +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 fmt.Errorf("converting field Params: %v", err) + } + if numVsndStreams :=3D len(x.Streams); numVsndStreams > 0 { + xc.streams =3D (*C.libxl_vsnd_stream)(C.malloc(C.ulong(numVsndStreams) *= C.sizeof_libxl_vsnd_stream)) + xc.num_vsnd_streams =3D C.int(numVsndStreams) + cStreams :=3D (*[1 << 28]C.libxl_vsnd_stream)(unsafe.Pointer(xc.streams)= )[:numVsndStreams:numVsndStreams] + for i, v :=3D range x.Streams { + if err :=3D v.toC(&cStreams[i]); err !=3D nil { + return fmt.Errorf("converting field Streams: %v", err) + } + } + } + + return nil +} + +// NewDeviceVsnd returns an instance of DeviceVsnd initialized with defaul= ts. +func NewDeviceVsnd() (*DeviceVsnd, error) { + var ( + x DeviceVsnd + xc C.libxl_device_vsnd + ) + + C.libxl_device_vsnd_init(&xc) + defer C.libxl_device_vsnd_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.Devid =3D Devid(xc.devid) + x.ShortName =3D C.GoString(xc.short_name) + x.LongName =3D C.GoString(xc.long_name) + if err :=3D x.Params.fromC(&xc.params); err !=3D nil { + return fmt.Errorf("converting field Params: %v", err) + } + x.Pcms =3D nil + if n :=3D int(xc.num_vsnd_pcms); n > 0 { + cPcms :=3D (*[1 << 28]C.libxl_vsnd_pcm)(unsafe.Pointer(xc.pcms))[:n:n] + x.Pcms =3D make([]VsndPcm, n) + for i, v :=3D range cPcms { + if err :=3D x.Pcms[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Pcms: %v", err) + } + } + } + + return nil +} + +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 fmt.Errorf("converting field Params: %v", err) + } + if numVsndPcms :=3D len(x.Pcms); numVsndPcms > 0 { + xc.pcms =3D (*C.libxl_vsnd_pcm)(C.malloc(C.ulong(numVsndPcms) * C.sizeof= _libxl_vsnd_pcm)) + xc.num_vsnd_pcms =3D C.int(numVsndPcms) + cPcms :=3D (*[1 << 28]C.libxl_vsnd_pcm)(unsafe.Pointer(xc.pcms))[:numVsn= dPcms:numVsndPcms] + for i, v :=3D range x.Pcms { + if err :=3D v.toC(&cPcms[i]); err !=3D nil { + return fmt.Errorf("converting field Pcms: %v", err) + } + } + } + + return nil +} + +// NewDomainConfig returns an instance of DomainConfig initialized with de= faults. +func NewDomainConfig() (*DomainConfig, error) { + var ( + x DomainConfig + xc C.libxl_domain_config + ) + + C.libxl_domain_config_init(&xc) + defer C.libxl_domain_config_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error { + if err :=3D x.CInfo.fromC(&xc.c_info); err !=3D nil { + return fmt.Errorf("converting field CInfo: %v", err) + } + if err :=3D x.BInfo.fromC(&xc.b_info); err !=3D nil { + return fmt.Errorf("converting field BInfo: %v", err) + } + x.Disks =3D nil + if n :=3D int(xc.num_disks); n > 0 { + cDisks :=3D (*[1 << 28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:n= :n] + x.Disks =3D make([]DeviceDisk, n) + for i, v :=3D range cDisks { + if err :=3D x.Disks[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Disks: %v", err) + } + } + } + x.Nics =3D nil + if n :=3D int(xc.num_nics); n > 0 { + cNics :=3D (*[1 << 28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:n:n] + x.Nics =3D make([]DeviceNic, n) + for i, v :=3D range cNics { + if err :=3D x.Nics[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Nics: %v", err) + } + } + } + x.Pcidevs =3D nil + if n :=3D int(xc.num_pcidevs); n > 0 { + cPcidevs :=3D (*[1 << 28]C.libxl_device_pci)(unsafe.Pointer(xc.pcidevs))= [:n:n] + x.Pcidevs =3D make([]DevicePci, n) + for i, v :=3D range cPcidevs { + if err :=3D x.Pcidevs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Pcidevs: %v", err) + } + } + } + x.Rdms =3D nil + if n :=3D int(xc.num_rdms); n > 0 { + cRdms :=3D (*[1 << 28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:n:n] + x.Rdms =3D make([]DeviceRdm, n) + for i, v :=3D range cRdms { + if err :=3D x.Rdms[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Rdms: %v", err) + } + } + } + x.Dtdevs =3D nil + if n :=3D int(xc.num_dtdevs); n > 0 { + cDtdevs :=3D (*[1 << 28]C.libxl_device_dtdev)(unsafe.Pointer(xc.dtdevs))= [:n:n] + x.Dtdevs =3D make([]DeviceDtdev, n) + for i, v :=3D range cDtdevs { + if err :=3D x.Dtdevs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Dtdevs: %v", err) + } + } + } + x.Vfbs =3D nil + if n :=3D int(xc.num_vfbs); n > 0 { + cVfbs :=3D (*[1 << 28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:n:n] + x.Vfbs =3D make([]DeviceVfb, n) + for i, v :=3D range cVfbs { + if err :=3D x.Vfbs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vfbs: %v", err) + } + } + } + x.Vkbs =3D nil + if n :=3D int(xc.num_vkbs); n > 0 { + cVkbs :=3D (*[1 << 28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:n:n] + x.Vkbs =3D make([]DeviceVkb, n) + for i, v :=3D range cVkbs { + if err :=3D x.Vkbs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vkbs: %v", err) + } + } + } + x.Vtpms =3D nil + if n :=3D int(xc.num_vtpms); n > 0 { + cVtpms :=3D (*[1 << 28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:n= :n] + x.Vtpms =3D make([]DeviceVtpm, n) + for i, v :=3D range cVtpms { + if err :=3D x.Vtpms[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vtpms: %v", err) + } + } + } + x.P9S =3D nil + if n :=3D int(xc.num_p9s); n > 0 { + cP9S :=3D (*[1 << 28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:n:n] + x.P9S =3D make([]DeviceP9, n) + for i, v :=3D range cP9S { + if err :=3D x.P9S[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field P9S: %v", err) + } + } + } + x.Pvcallsifs =3D nil + if n :=3D int(xc.num_pvcallsifs); n > 0 { + cPvcallsifs :=3D (*[1 << 28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.= pvcallsifs))[:n:n] + x.Pvcallsifs =3D make([]DevicePvcallsif, n) + for i, v :=3D range cPvcallsifs { + if err :=3D x.Pvcallsifs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Pvcallsifs: %v", err) + } + } + } + x.Vdispls =3D nil + if n :=3D int(xc.num_vdispls); n > 0 { + cVdispls :=3D (*[1 << 28]C.libxl_device_vdispl)(unsafe.Pointer(xc.vdispl= s))[:n:n] + x.Vdispls =3D make([]DeviceVdispl, n) + for i, v :=3D range cVdispls { + if err :=3D x.Vdispls[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vdispls: %v", err) + } + } + } + x.Vsnds =3D nil + if n :=3D int(xc.num_vsnds); n > 0 { + cVsnds :=3D (*[1 << 28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:n= :n] + x.Vsnds =3D make([]DeviceVsnd, n) + for i, v :=3D range cVsnds { + if err :=3D x.Vsnds[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Vsnds: %v", err) + } + } + } + x.Channels =3D nil + if n :=3D int(xc.num_channels); n > 0 { + cChannels :=3D (*[1 << 28]C.libxl_device_channel)(unsafe.Pointer(xc.chan= nels))[:n:n] + x.Channels =3D make([]DeviceChannel, n) + for i, v :=3D range cChannels { + if err :=3D x.Channels[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Channels: %v", err) + } + } + } + x.Usbctrls =3D nil + if n :=3D int(xc.num_usbctrls); n > 0 { + cUsbctrls :=3D (*[1 << 28]C.libxl_device_usbctrl)(unsafe.Pointer(xc.usbc= trls))[:n:n] + x.Usbctrls =3D make([]DeviceUsbctrl, n) + for i, v :=3D range cUsbctrls { + if err :=3D x.Usbctrls[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Usbctrls: %v", err) + } + } + } + x.Usbdevs =3D nil + if n :=3D int(xc.num_usbdevs); n > 0 { + cUsbdevs :=3D (*[1 << 28]C.libxl_device_usbdev)(unsafe.Pointer(xc.usbdev= s))[:n:n] + x.Usbdevs =3D make([]DeviceUsbdev, n) + for i, v :=3D range cUsbdevs { + if err :=3D x.Usbdevs[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Usbdevs: %v", err) + } + } + } + x.OnPoweroff =3D ActionOnShutdown(xc.on_poweroff) + x.OnReboot =3D ActionOnShutdown(xc.on_reboot) + x.OnWatchdog =3D ActionOnShutdown(xc.on_watchdog) + x.OnCrash =3D ActionOnShutdown(xc.on_crash) + x.OnSoftReset =3D ActionOnShutdown(xc.on_soft_reset) + + return nil +} + +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 fmt.Errorf("converting field CInfo: %v", err) + } + if err :=3D x.BInfo.toC(&xc.b_info); err !=3D nil { + return fmt.Errorf("converting field BInfo: %v", err) + } + if numDisks :=3D len(x.Disks); numDisks > 0 { + xc.disks =3D (*C.libxl_device_disk)(C.malloc(C.ulong(numDisks) * C.sizeo= f_libxl_device_disk)) + xc.num_disks =3D C.int(numDisks) + cDisks :=3D (*[1 << 28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:n= umDisks:numDisks] + for i, v :=3D range x.Disks { + if err :=3D v.toC(&cDisks[i]); err !=3D nil { + return fmt.Errorf("converting field Disks: %v", err) + } + } + } + if numNics :=3D len(x.Nics); numNics > 0 { + xc.nics =3D (*C.libxl_device_nic)(C.malloc(C.ulong(numNics) * C.sizeof_l= ibxl_device_nic)) + xc.num_nics =3D C.int(numNics) + cNics :=3D (*[1 << 28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:numN= ics:numNics] + for i, v :=3D range x.Nics { + if err :=3D v.toC(&cNics[i]); err !=3D nil { + return fmt.Errorf("converting field Nics: %v", err) + } + } + } + if numPcidevs :=3D len(x.Pcidevs); numPcidevs > 0 { + xc.pcidevs =3D (*C.libxl_device_pci)(C.malloc(C.ulong(numPcidevs) * C.si= zeof_libxl_device_pci)) + xc.num_pcidevs =3D C.int(numPcidevs) + cPcidevs :=3D (*[1 << 28]C.libxl_device_pci)(unsafe.Pointer(xc.pcidevs))= [:numPcidevs:numPcidevs] + for i, v :=3D range x.Pcidevs { + if err :=3D v.toC(&cPcidevs[i]); err !=3D nil { + return fmt.Errorf("converting field Pcidevs: %v", err) + } + } + } + if numRdms :=3D len(x.Rdms); numRdms > 0 { + xc.rdms =3D (*C.libxl_device_rdm)(C.malloc(C.ulong(numRdms) * C.sizeof_l= ibxl_device_rdm)) + xc.num_rdms =3D C.int(numRdms) + cRdms :=3D (*[1 << 28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:numR= dms:numRdms] + for i, v :=3D range x.Rdms { + if err :=3D v.toC(&cRdms[i]); err !=3D nil { + return fmt.Errorf("converting field Rdms: %v", err) + } + } + } + if numDtdevs :=3D len(x.Dtdevs); numDtdevs > 0 { + xc.dtdevs =3D (*C.libxl_device_dtdev)(C.malloc(C.ulong(numDtdevs) * C.si= zeof_libxl_device_dtdev)) + xc.num_dtdevs =3D C.int(numDtdevs) + cDtdevs :=3D (*[1 << 28]C.libxl_device_dtdev)(unsafe.Pointer(xc.dtdevs))= [:numDtdevs:numDtdevs] + for i, v :=3D range x.Dtdevs { + if err :=3D v.toC(&cDtdevs[i]); err !=3D nil { + return fmt.Errorf("converting field Dtdevs: %v", err) + } + } + } + if numVfbs :=3D len(x.Vfbs); numVfbs > 0 { + xc.vfbs =3D (*C.libxl_device_vfb)(C.malloc(C.ulong(numVfbs) * C.sizeof_l= ibxl_device_vfb)) + xc.num_vfbs =3D C.int(numVfbs) + cVfbs :=3D (*[1 << 28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:numV= fbs:numVfbs] + for i, v :=3D range x.Vfbs { + if err :=3D v.toC(&cVfbs[i]); err !=3D nil { + return fmt.Errorf("converting field Vfbs: %v", err) + } + } + } + if numVkbs :=3D len(x.Vkbs); numVkbs > 0 { + xc.vkbs =3D (*C.libxl_device_vkb)(C.malloc(C.ulong(numVkbs) * C.sizeof_l= ibxl_device_vkb)) + xc.num_vkbs =3D C.int(numVkbs) + cVkbs :=3D (*[1 << 28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:numV= kbs:numVkbs] + for i, v :=3D range x.Vkbs { + if err :=3D v.toC(&cVkbs[i]); err !=3D nil { + return fmt.Errorf("converting field Vkbs: %v", err) + } + } + } + if numVtpms :=3D len(x.Vtpms); numVtpms > 0 { + xc.vtpms =3D (*C.libxl_device_vtpm)(C.malloc(C.ulong(numVtpms) * C.sizeo= f_libxl_device_vtpm)) + xc.num_vtpms =3D C.int(numVtpms) + cVtpms :=3D (*[1 << 28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:n= umVtpms:numVtpms] + for i, v :=3D range x.Vtpms { + if err :=3D v.toC(&cVtpms[i]); err !=3D nil { + return fmt.Errorf("converting field Vtpms: %v", err) + } + } + } + if numP9S :=3D len(x.P9S); numP9S > 0 { + xc.p9s =3D (*C.libxl_device_p9)(C.malloc(C.ulong(numP9S) * C.sizeof_libx= l_device_p9)) + xc.num_p9s =3D C.int(numP9S) + cP9S :=3D (*[1 << 28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:numP9S:= numP9S] + for i, v :=3D range x.P9S { + if err :=3D v.toC(&cP9S[i]); err !=3D nil { + return fmt.Errorf("converting field P9S: %v", err) + } + } + } + if numPvcallsifs :=3D len(x.Pvcallsifs); numPvcallsifs > 0 { + xc.pvcallsifs =3D (*C.libxl_device_pvcallsif)(C.malloc(C.ulong(numPvcall= sifs) * C.sizeof_libxl_device_pvcallsif)) + xc.num_pvcallsifs =3D C.int(numPvcallsifs) + cPvcallsifs :=3D (*[1 << 28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.= pvcallsifs))[:numPvcallsifs:numPvcallsifs] + for i, v :=3D range x.Pvcallsifs { + if err :=3D v.toC(&cPvcallsifs[i]); err !=3D nil { + return fmt.Errorf("converting field Pvcallsifs: %v", err) + } + } + } + if numVdispls :=3D len(x.Vdispls); numVdispls > 0 { + xc.vdispls =3D (*C.libxl_device_vdispl)(C.malloc(C.ulong(numVdispls) * C= .sizeof_libxl_device_vdispl)) + xc.num_vdispls =3D C.int(numVdispls) + cVdispls :=3D (*[1 << 28]C.libxl_device_vdispl)(unsafe.Pointer(xc.vdispl= s))[:numVdispls:numVdispls] + for i, v :=3D range x.Vdispls { + if err :=3D v.toC(&cVdispls[i]); err !=3D nil { + return fmt.Errorf("converting field Vdispls: %v", err) + } + } + } + if numVsnds :=3D len(x.Vsnds); numVsnds > 0 { + xc.vsnds =3D (*C.libxl_device_vsnd)(C.malloc(C.ulong(numVsnds) * C.sizeo= f_libxl_device_vsnd)) + xc.num_vsnds =3D C.int(numVsnds) + cVsnds :=3D (*[1 << 28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:n= umVsnds:numVsnds] + for i, v :=3D range x.Vsnds { + if err :=3D v.toC(&cVsnds[i]); err !=3D nil { + return fmt.Errorf("converting field Vsnds: %v", err) + } + } + } + if numChannels :=3D len(x.Channels); numChannels > 0 { + xc.channels =3D (*C.libxl_device_channel)(C.malloc(C.ulong(numChannels) = * C.sizeof_libxl_device_channel)) + xc.num_channels =3D C.int(numChannels) + cChannels :=3D (*[1 << 28]C.libxl_device_channel)(unsafe.Pointer(xc.chan= nels))[:numChannels:numChannels] + for i, v :=3D range x.Channels { + if err :=3D v.toC(&cChannels[i]); err !=3D nil { + return fmt.Errorf("converting field Channels: %v", err) + } + } + } + if numUsbctrls :=3D len(x.Usbctrls); numUsbctrls > 0 { + xc.usbctrls =3D (*C.libxl_device_usbctrl)(C.malloc(C.ulong(numUsbctrls) = * C.sizeof_libxl_device_usbctrl)) + xc.num_usbctrls =3D C.int(numUsbctrls) + cUsbctrls :=3D (*[1 << 28]C.libxl_device_usbctrl)(unsafe.Pointer(xc.usbc= trls))[:numUsbctrls:numUsbctrls] + for i, v :=3D range x.Usbctrls { + if err :=3D v.toC(&cUsbctrls[i]); err !=3D nil { + return fmt.Errorf("converting field Usbctrls: %v", err) + } + } + } + if numUsbdevs :=3D len(x.Usbdevs); numUsbdevs > 0 { + xc.usbdevs =3D (*C.libxl_device_usbdev)(C.malloc(C.ulong(numUsbdevs) * C= .sizeof_libxl_device_usbdev)) + xc.num_usbdevs =3D C.int(numUsbdevs) + cUsbdevs :=3D (*[1 << 28]C.libxl_device_usbdev)(unsafe.Pointer(xc.usbdev= s))[:numUsbdevs:numUsbdevs] + for i, v :=3D range x.Usbdevs { + if err :=3D v.toC(&cUsbdevs[i]); err !=3D nil { + return fmt.Errorf("converting field Usbdevs: %v", 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 +} + +// NewDiskinfo returns an instance of Diskinfo initialized with defaults. +func NewDiskinfo() (*Diskinfo, error) { + var ( + x Diskinfo + xc C.libxl_diskinfo + ) + + C.libxl_diskinfo_init(&xc) + defer C.libxl_diskinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.Rref =3D int(xc.rref) + + return nil +} + +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 +} + +// NewNicinfo returns an instance of Nicinfo initialized with defaults. +func NewNicinfo() (*Nicinfo, error) { + var ( + x Nicinfo + xc C.libxl_nicinfo + ) + + C.libxl_nicinfo_init(&xc) + defer C.libxl_nicinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.RrefTx =3D int(xc.rref_tx) + x.RrefRx =3D int(xc.rref_rx) + + return nil +} + +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 +} + +// NewVtpminfo returns an instance of Vtpminfo initialized with defaults. +func NewVtpminfo() (*Vtpminfo, error) { + var ( + x Vtpminfo + xc C.libxl_vtpminfo + ) + + C.libxl_vtpminfo_init(&xc) + defer C.libxl_vtpminfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.Rref =3D int(xc.rref) + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return fmt.Errorf("converting field Uuid: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Uuid: %v", err) + } + + return nil +} + +// NewUsbctrlinfo returns an instance of Usbctrlinfo initialized with defa= ults. +func NewUsbctrlinfo() (*Usbctrlinfo, error) { + var ( + x Usbctrlinfo + xc C.libxl_usbctrlinfo + ) + + C.libxl_usbctrlinfo_init(&xc) + defer C.libxl_usbctrlinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo) error { + x.Type =3D UsbctrlType(xc._type) + x.Devid =3D Devid(xc.devid) + x.Version =3D int(xc.version) + x.Ports =3D int(xc.ports) + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.RefUrb =3D int(xc.ref_urb) + x.RefConn =3D int(xc.ref_conn) + + return nil +} + +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 +} + +// NewVcpuinfo returns an instance of Vcpuinfo initialized with defaults. +func NewVcpuinfo() (*Vcpuinfo, error) { + var ( + x Vcpuinfo + xc C.libxl_vcpuinfo + ) + + C.libxl_vcpuinfo_init(&xc) + defer C.libxl_vcpuinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error { + x.Vcpuid =3D uint32(xc.vcpuid) + x.Cpu =3D uint32(xc.cpu) + x.Online =3D bool(xc.online) + x.Blocked =3D bool(xc.blocked) + x.Running =3D bool(xc.running) + x.VcpuTime =3D uint64(xc.vcpu_time) + if err :=3D x.Cpumap.fromC(&xc.cpumap); err !=3D nil { + return fmt.Errorf("converting field Cpumap: %v", err) + } + if err :=3D x.CpumapSoft.fromC(&xc.cpumap_soft); err !=3D nil { + return fmt.Errorf("converting field CpumapSoft: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field Cpumap: %v", err) + } + if err :=3D x.CpumapSoft.toC(&xc.cpumap_soft); err !=3D nil { + return fmt.Errorf("converting field CpumapSoft: %v", err) + } + + return nil +} + +// NewPhysinfo returns an instance of Physinfo initialized with defaults. +func NewPhysinfo() (*Physinfo, error) { + var ( + x Physinfo + xc C.libxl_physinfo + ) + + C.libxl_physinfo_init(&xc) + defer C.libxl_physinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.MaxCpuId =3D uint32(xc.max_cpu_id) + x.NrCpus =3D uint32(xc.nr_cpus) + x.CpuKhz =3D uint32(xc.cpu_khz) + x.TotalPages =3D uint64(xc.total_pages) + x.FreePages =3D uint64(xc.free_pages) + x.ScrubPages =3D uint64(xc.scrub_pages) + x.OutstandingPages =3D uint64(xc.outstanding_pages) + x.SharingFreedPages =3D uint64(xc.sharing_freed_pages) + x.SharingUsedFrames =3D uint64(xc.sharing_used_frames) + x.MaxPossibleMfn =3D uint64(xc.max_possible_mfn) + x.NrNodes =3D uint32(xc.nr_nodes) + if err :=3D x.HwCap.fromC(&xc.hw_cap); err !=3D nil { + return fmt.Errorf("converting field HwCap: %v", err) + } + x.CapHvm =3D bool(xc.cap_hvm) + x.CapPv =3D bool(xc.cap_pv) + x.CapHvmDirectio =3D bool(xc.cap_hvm_directio) + x.CapHap =3D bool(xc.cap_hap) + x.CapShadow =3D bool(xc.cap_shadow) + x.CapIommuHapPtShare =3D bool(xc.cap_iommu_hap_pt_share) + + return nil +} + +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 fmt.Errorf("converting field HwCap: %v", 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 +} + +// NewConnectorinfo returns an instance of Connectorinfo initialized with = defaults. +func NewConnectorinfo() (*Connectorinfo, error) { + var ( + x Connectorinfo + xc C.libxl_connectorinfo + ) + + C.libxl_connectorinfo_init(&xc) + defer C.libxl_connectorinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Connectorinfo) fromC(xc *C.libxl_connectorinfo) error { + x.UniqueId =3D C.GoString(xc.unique_id) + x.Width =3D uint32(xc.width) + x.Height =3D uint32(xc.height) + x.ReqEvtch =3D int(xc.req_evtch) + x.ReqRref =3D int(xc.req_rref) + x.EvtEvtch =3D int(xc.evt_evtch) + x.EvtRref =3D int(xc.evt_rref) + + return nil +} + +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 +} + +// NewVdisplinfo returns an instance of Vdisplinfo initialized with defaul= ts. +func NewVdisplinfo() (*Vdisplinfo, error) { + var ( + x Vdisplinfo + xc C.libxl_vdisplinfo + ) + + C.libxl_vdisplinfo_init(&xc) + defer C.libxl_vdisplinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.BeAlloc =3D bool(xc.be_alloc) + x.Connectors =3D nil + if n :=3D int(xc.num_connectors); n > 0 { + cConnectors :=3D (*[1 << 28]C.libxl_connectorinfo)(unsafe.Pointer(xc.con= nectors))[:n:n] + x.Connectors =3D make([]Connectorinfo, n) + for i, v :=3D range cConnectors { + if err :=3D x.Connectors[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Connectors: %v", err) + } + } + } + + return nil +} + +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) + if numConnectors :=3D len(x.Connectors); numConnectors > 0 { + xc.connectors =3D (*C.libxl_connectorinfo)(C.malloc(C.ulong(numConnector= s) * C.sizeof_libxl_connectorinfo)) + xc.num_connectors =3D C.int(numConnectors) + cConnectors :=3D (*[1 << 28]C.libxl_connectorinfo)(unsafe.Pointer(xc.con= nectors))[:numConnectors:numConnectors] + for i, v :=3D range x.Connectors { + if err :=3D v.toC(&cConnectors[i]); err !=3D nil { + return fmt.Errorf("converting field Connectors: %v", err) + } + } + } + + return nil +} + +// NewStreaminfo returns an instance of Streaminfo initialized with defaul= ts. +func NewStreaminfo() (*Streaminfo, error) { + var ( + x Streaminfo + xc C.libxl_streaminfo + ) + + C.libxl_streaminfo_init(&xc) + defer C.libxl_streaminfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error { + x.ReqEvtch =3D int(xc.req_evtch) + x.ReqRref =3D int(xc.req_rref) + + return nil +} + +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 +} + +// NewPcminfo returns an instance of Pcminfo initialized with defaults. +func NewPcminfo() (*Pcminfo, error) { + var ( + x Pcminfo + xc C.libxl_pcminfo + ) + + C.libxl_pcminfo_init(&xc) + defer C.libxl_pcminfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { + x.Streams =3D nil + if n :=3D int(xc.num_vsnd_streams); n > 0 { + cStreams :=3D (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))= [:n:n] + x.Streams =3D make([]Streaminfo, n) + for i, v :=3D range cStreams { + if err :=3D x.Streams[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Streams: %v", err) + } + } + } + + return nil +} + +func (x *Pcminfo) toC(xc *C.libxl_pcminfo) (err error) { + defer func() { + if err !=3D nil { + C.libxl_pcminfo_dispose(xc) + } + }() + + if numVsndStreams :=3D len(x.Streams); numVsndStreams > 0 { + xc.streams =3D (*C.libxl_streaminfo)(C.malloc(C.ulong(numVsndStreams) * = C.sizeof_libxl_streaminfo)) + xc.num_vsnd_streams =3D C.int(numVsndStreams) + cStreams :=3D (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))= [:numVsndStreams:numVsndStreams] + for i, v :=3D range x.Streams { + if err :=3D v.toC(&cStreams[i]); err !=3D nil { + return fmt.Errorf("converting field Streams: %v", err) + } + } + } + + return nil +} + +// NewVsndinfo returns an instance of Vsndinfo initialized with defaults. +func NewVsndinfo() (*Vsndinfo, error) { + var ( + x Vsndinfo + xc C.libxl_vsndinfo + ) + + C.libxl_vsndinfo_init(&xc) + defer C.libxl_vsndinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Pcms =3D nil + if n :=3D int(xc.num_vsnd_pcms); n > 0 { + cPcms :=3D (*[1 << 28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:n:n] + x.Pcms =3D make([]Pcminfo, n) + for i, v :=3D range cPcms { + if err :=3D x.Pcms[i].fromC(&v); err !=3D nil { + return fmt.Errorf("converting field Pcms: %v", err) + } + } + } + + return nil +} + +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) + if numVsndPcms :=3D len(x.Pcms); numVsndPcms > 0 { + xc.pcms =3D (*C.libxl_pcminfo)(C.malloc(C.ulong(numVsndPcms) * C.sizeof_= libxl_pcminfo)) + xc.num_vsnd_pcms =3D C.int(numVsndPcms) + cPcms :=3D (*[1 << 28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:numVsnd= Pcms:numVsndPcms] + for i, v :=3D range x.Pcms { + if err :=3D v.toC(&cPcms[i]); err !=3D nil { + return fmt.Errorf("converting field Pcms: %v", err) + } + } + } + + return nil +} + +// NewVkbinfo returns an instance of Vkbinfo initialized with defaults. +func NewVkbinfo() (*Vkbinfo, error) { + var ( + x Vkbinfo + xc C.libxl_vkbinfo + ) + + C.libxl_vkbinfo_init(&xc) + defer C.libxl_vkbinfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + x.Frontend =3D C.GoString(xc.frontend) + x.FrontendId =3D uint32(xc.frontend_id) + x.Devid =3D Devid(xc.devid) + x.State =3D int(xc.state) + x.Evtch =3D int(xc.evtch) + x.Rref =3D int(xc.rref) + + return nil +} + +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 +} + +// NewNumainfo returns an instance of Numainfo initialized with defaults. +func NewNumainfo() (*Numainfo, error) { + var ( + x Numainfo + xc C.libxl_numainfo + ) + + C.libxl_numainfo_init(&xc) + defer C.libxl_numainfo_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Numainfo) fromC(xc *C.libxl_numainfo) error { + x.Size =3D uint64(xc.size) + x.Free =3D uint64(xc.free) + x.Dists =3D nil + if n :=3D int(xc.num_dists); n > 0 { + cDists :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.dists))[:n:n] + x.Dists =3D make([]uint32, n) + for i, v :=3D range cDists { + x.Dists[i] =3D uint32(v) + } + } + + return nil +} + +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) + if numDists :=3D len(x.Dists); numDists > 0 { + xc.dists =3D (*C.uint32_t)(C.malloc(C.size_t(numDists * numDists))) + xc.num_dists =3D C.int(numDists) + cDists :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.dists))[:numDists:n= umDists] + for i, v :=3D range x.Dists { + cDists[i] =3D C.uint32_t(v) + } + } + + return nil +} + +// NewCputopology returns an instance of Cputopology initialized with defa= ults. +func NewCputopology() (*Cputopology, error) { + var ( + x Cputopology + xc C.libxl_cputopology + ) + + C.libxl_cputopology_init(&xc) + defer C.libxl_cputopology_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Cputopology) fromC(xc *C.libxl_cputopology) error { + x.Core =3D uint32(xc.core) + x.Socket =3D uint32(xc.socket) + x.Node =3D uint32(xc.node) + + return nil +} + +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 +} + +// NewPcitopology returns an instance of Pcitopology initialized with defa= ults. +func NewPcitopology() (*Pcitopology, error) { + var ( + x Pcitopology + xc C.libxl_pcitopology + ) + + C.libxl_pcitopology_init(&xc) + defer C.libxl_pcitopology_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Pcitopology) fromC(xc *C.libxl_pcitopology) error { + x.Seg =3D uint16(xc.seg) + x.Bus =3D byte(xc.bus) + x.Devfn =3D byte(xc.devfn) + x.Node =3D uint32(xc.node) + + return nil +} + +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 +} + +// NewSchedCreditParams returns an instance of SchedCreditParams initializ= ed with defaults. +func NewSchedCreditParams() (*SchedCreditParams, error) { + var ( + x SchedCreditParams + xc C.libxl_sched_credit_params + ) + + C.libxl_sched_credit_params_init(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.VcpuMigrDelayUs =3D int(xc.vcpu_migr_delay_us) + + return nil +} + +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 +} + +// NewSchedCredit2Params returns an instance of SchedCredit2Params initial= ized with defaults. +func NewSchedCredit2Params() (*SchedCredit2Params, error) { + var ( + x SchedCredit2Params + xc C.libxl_sched_credit2_params + ) + + C.libxl_sched_credit2_params_init(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *SchedCredit2Params) fromC(xc *C.libxl_sched_credit2_params) error= { + x.RatelimitUs =3D int(xc.ratelimit_us) + + return nil +} + +func (x *SchedCredit2Params) toC(xc *C.libxl_sched_credit2_params) (err er= ror) { + xc.ratelimit_us =3D C.int(x.RatelimitUs) + + return nil +} + +// NewDomainRemusInfo returns an instance of DomainRemusInfo initialized w= ith defaults. +func NewDomainRemusInfo() (*DomainRemusInfo, error) { + var ( + x DomainRemusInfo + xc C.libxl_domain_remus_info + ) + + C.libxl_domain_remus_info_init(&xc) + defer C.libxl_domain_remus_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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 { + return fmt.Errorf("converting field AllowUnsafe: %v", err) + } + if err :=3D x.Blackhole.fromC(&xc.blackhole); err !=3D nil { + return fmt.Errorf("converting field Blackhole: %v", err) + } + if err :=3D x.Compression.fromC(&xc.compression); err !=3D nil { + return fmt.Errorf("converting field Compression: %v", err) + } + if err :=3D x.Netbuf.fromC(&xc.netbuf); err !=3D nil { + return fmt.Errorf("converting field Netbuf: %v", err) + } + x.Netbufscript =3D C.GoString(xc.netbufscript) + if err :=3D x.Diskbuf.fromC(&xc.diskbuf); err !=3D nil { + return fmt.Errorf("converting field Diskbuf: %v", err) + } + if err :=3D x.Colo.fromC(&xc.colo); err !=3D nil { + return fmt.Errorf("converting field Colo: %v", err) + } + if err :=3D x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != =3D nil { + return fmt.Errorf("converting field UserspaceColoProxy: %v", err) + } + + return nil +} + +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 fmt.Errorf("converting field AllowUnsafe: %v", err) + } + if err :=3D x.Blackhole.toC(&xc.blackhole); err !=3D nil { + return fmt.Errorf("converting field Blackhole: %v", err) + } + if err :=3D x.Compression.toC(&xc.compression); err !=3D nil { + return fmt.Errorf("converting field Compression: %v", err) + } + if err :=3D x.Netbuf.toC(&xc.netbuf); err !=3D nil { + return fmt.Errorf("converting field Netbuf: %v", err) + } + if x.Netbufscript !=3D "" { + xc.netbufscript =3D C.CString(x.Netbufscript) + } + if err :=3D x.Diskbuf.toC(&xc.diskbuf); err !=3D nil { + return fmt.Errorf("converting field Diskbuf: %v", err) + } + if err :=3D x.Colo.toC(&xc.colo); err !=3D nil { + return fmt.Errorf("converting field Colo: %v", err) + } + if err :=3D x.UserspaceColoProxy.toC(&xc.userspace_colo_proxy); err !=3D = nil { + return fmt.Errorf("converting field UserspaceColoProxy: %v", err) + } + + return nil +} + +// NewEvent returns an instance of Event initialized with defaults. +func NewEvent(etype EventType) (*Event, error) { + var ( + x Event + xc C.libxl_event + ) + + C.libxl_event_init(&xc) + C.libxl_event_init_type(&xc, C.libxl_event_type(etype)) + defer C.libxl_event_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *Event) fromC(xc *C.libxl_event) error { + if err :=3D x.Link.fromC(&xc.link); err !=3D nil { + return fmt.Errorf("converting field Link: %v", err) + } + x.Domid =3D Domid(xc.domid) + if err :=3D x.Domuuid.fromC(&xc.domuuid); err !=3D nil { + return fmt.Errorf("converting field Domuuid: %v", err) + } + x.ForUser =3D uint64(xc.for_user) + x.Type =3D EventType(xc._type) + switch x.Type { + case EventTypeDomainShutdown: + var typeDomainShutdown EventTypeUnionDomainShutdown + if err :=3D typeDomainShutdown.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeDomainShutdown: %v", err) + } + x.TypeUnion =3D typeDomainShutdown + case EventTypeDomainDeath: + x.TypeUnion =3D nil + case EventTypeDiskEject: + var typeDiskEject EventTypeUnionDiskEject + if err :=3D typeDiskEject.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeDiskEject: %v", err) + } + x.TypeUnion =3D typeDiskEject + case EventTypeOperationComplete: + var typeOperationComplete EventTypeUnionOperationComplete + if err :=3D typeOperationComplete.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeOperationComplete: %v", err) + } + x.TypeUnion =3D typeOperationComplete + case EventTypeDomainCreateConsoleAvailable: + x.TypeUnion =3D nil + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} + +func (x *EventTypeUnionDomainShutdown) fromC(xc *C.libxl_event) error { + if EventType(xc._type) !=3D EventTypeDomainShutdown { + return errors.New("expected union key EventTypeDomainShutdown") + } + + tmp :=3D (*C.libxl_event_type_union_domain_shutdown)(unsafe.Pointer(&xc.u= [0])) + x.ShutdownReason =3D byte(tmp.shutdown_reason) + return nil +} + +func (x *EventTypeUnionDiskEject) fromC(xc *C.libxl_event) error { + if EventType(xc._type) !=3D EventTypeDiskEject { + return errors.New("expected union key EventTypeDiskEject") + } + + tmp :=3D (*C.libxl_event_type_union_disk_eject)(unsafe.Pointer(&xc.u[0])) + x.Vdev =3D C.GoString(tmp.vdev) + if err :=3D x.Disk.fromC(&tmp.disk); err !=3D nil { + return fmt.Errorf("converting field Disk: %v", err) + } + return nil +} + +func (x *EventTypeUnionOperationComplete) fromC(xc *C.libxl_event) error { + if EventType(xc._type) !=3D EventTypeOperationComplete { + return errors.New("expected union key EventTypeOperationComplete") + } + + tmp :=3D (*C.libxl_event_type_union_operation_complete)(unsafe.Pointer(&x= c.u[0])) + x.Rc =3D int(tmp.rc) + return nil +} + +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 fmt.Errorf("converting field Link: %v", err) + } + xc.domid =3D C.libxl_domid(x.Domid) + if err :=3D x.Domuuid.toC(&xc.domuuid); err !=3D nil { + return fmt.Errorf("converting field Domuuid: %v", err) + } + xc.for_user =3D C.uint64_t(x.ForUser) + xc._type =3D C.libxl_event_type(x.Type) + switch x.Type { + case EventTypeDomainShutdown: + tmp, ok :=3D x.TypeUnion.(EventTypeUnionDomainShutdown) + if !ok { + return errors.New("wrong type for union key type") + } + var domain_shutdown C.libxl_event_type_union_domain_shutdown + domain_shutdown.shutdown_reason =3D C.uint8_t(tmp.ShutdownReason) + domain_shutdownBytes :=3D C.GoBytes(unsafe.Pointer(&domain_shutdown), C.= sizeof_libxl_event_type_union_domain_shutdown) + copy(xc.u[:], domain_shutdownBytes) + case EventTypeDomainDeath: + break + case EventTypeDiskEject: + tmp, ok :=3D x.TypeUnion.(EventTypeUnionDiskEject) + if !ok { + return errors.New("wrong type for union key type") + } + var disk_eject C.libxl_event_type_union_disk_eject + if tmp.Vdev !=3D "" { + disk_eject.vdev =3D C.CString(tmp.Vdev) + } + if err :=3D tmp.Disk.toC(&disk_eject.disk); err !=3D nil { + return fmt.Errorf("converting field Disk: %v", err) + } + disk_ejectBytes :=3D C.GoBytes(unsafe.Pointer(&disk_eject), C.sizeof_lib= xl_event_type_union_disk_eject) + copy(xc.u[:], disk_ejectBytes) + case EventTypeOperationComplete: + tmp, ok :=3D x.TypeUnion.(EventTypeUnionOperationComplete) + if !ok { + return errors.New("wrong type for union key type") + } + var operation_complete C.libxl_event_type_union_operation_complete + operation_complete.rc =3D C.int(tmp.Rc) + operation_completeBytes :=3D C.GoBytes(unsafe.Pointer(&operation_complet= e), C.sizeof_libxl_event_type_union_operation_complete) + copy(xc.u[:], operation_completeBytes) + case EventTypeDomainCreateConsoleAvailable: + break + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} + +// NewPsrCatInfo returns an instance of PsrCatInfo initialized with defaul= ts. +func NewPsrCatInfo() (*PsrCatInfo, error) { + var ( + x PsrCatInfo + xc C.libxl_psr_cat_info + ) + + C.libxl_psr_cat_info_init(&xc) + defer C.libxl_psr_cat_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, 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) + x.CbmLen =3D uint32(xc.cbm_len) + x.CdpEnabled =3D bool(xc.cdp_enabled) + + return nil +} + +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 +} + +// NewPsrHwInfo returns an instance of PsrHwInfo initialized with defaults. +func NewPsrHwInfo(ptype PsrFeatType) (*PsrHwInfo, error) { + var ( + x PsrHwInfo + xc C.libxl_psr_hw_info + ) + + C.libxl_psr_hw_info_init(&xc) + C.libxl_psr_hw_info_init_type(&xc, C.libxl_psr_feat_type(ptype)) + defer C.libxl_psr_hw_info_dispose(&xc) + + if err :=3D x.fromC(&xc); err !=3D nil { + return nil, err + } + + return &x, nil +} + +func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error { + x.Id =3D uint32(xc.id) + x.Type =3D PsrFeatType(xc._type) + switch x.Type { + case PsrFeatTypeCat: + var typeCat PsrHwInfoTypeUnionCat + if err :=3D typeCat.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeCat: %v", err) + } + x.TypeUnion =3D typeCat + case PsrFeatTypeMba: + var typeMba PsrHwInfoTypeUnionMba + if err :=3D typeMba.fromC(xc); err !=3D nil { + return fmt.Errorf("converting field typeMba: %v", err) + } + x.TypeUnion =3D typeMba + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} + +func (x *PsrHwInfoTypeUnionCat) fromC(xc *C.libxl_psr_hw_info) error { + if PsrFeatType(xc._type) !=3D PsrFeatTypeCat { + return errors.New("expected union key PsrFeatTypeCat") + } + + tmp :=3D (*C.libxl_psr_hw_info_type_union_cat)(unsafe.Pointer(&xc.u[0])) + x.CosMax =3D uint32(tmp.cos_max) + x.CbmLen =3D uint32(tmp.cbm_len) + x.CdpEnabled =3D bool(tmp.cdp_enabled) + return nil +} + +func (x *PsrHwInfoTypeUnionMba) fromC(xc *C.libxl_psr_hw_info) error { + if PsrFeatType(xc._type) !=3D PsrFeatTypeMba { + return errors.New("expected union key PsrFeatTypeMba") + } + + tmp :=3D (*C.libxl_psr_hw_info_type_union_mba)(unsafe.Pointer(&xc.u[0])) + x.CosMax =3D uint32(tmp.cos_max) + x.ThrtlMax =3D uint32(tmp.thrtl_max) + 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) + xc._type =3D C.libxl_psr_feat_type(x.Type) + switch x.Type { + case PsrFeatTypeCat: + tmp, ok :=3D x.TypeUnion.(PsrHwInfoTypeUnionCat) + if !ok { + return errors.New("wrong type for union key type") + } + var cat C.libxl_psr_hw_info_type_union_cat + cat.cos_max =3D C.uint32_t(tmp.CosMax) + cat.cbm_len =3D C.uint32_t(tmp.CbmLen) + cat.cdp_enabled =3D C.bool(tmp.CdpEnabled) + catBytes :=3D C.GoBytes(unsafe.Pointer(&cat), C.sizeof_libxl_psr_hw_info= _type_union_cat) + copy(xc.u[:], catBytes) + case PsrFeatTypeMba: + tmp, ok :=3D x.TypeUnion.(PsrHwInfoTypeUnionMba) + if !ok { + return errors.New("wrong type for union key type") + } + var mba C.libxl_psr_hw_info_type_union_mba + mba.cos_max =3D C.uint32_t(tmp.CosMax) + mba.thrtl_max =3D C.uint32_t(tmp.ThrtlMax) + mba.linear =3D C.bool(tmp.Linear) + mbaBytes :=3D C.GoBytes(unsafe.Pointer(&mba), C.sizeof_libxl_psr_hw_info= _type_union_mba) + copy(xc.u[:], mbaBytes) + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } + + return nil +} diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go new file mode 100644 index 0000000000..df68fd0e88 --- /dev/null +++ b/tools/golang/xenlight/types.gen.go @@ -0,0 +1,1226 @@ +// DO NOT EDIT. +// +// This file is generated by: +// gengotypes.py ../../libxl/libxl_types.idl +// +package xenlight + +type Error int + +const ( + ErrorNonspecific Error =3D -1 + ErrorVersion Error =3D -2 + ErrorFail Error =3D -3 + ErrorNi Error =3D -4 + ErrorNomem Error =3D -5 + ErrorInval Error =3D -6 + ErrorBadfail Error =3D -7 + ErrorGuestTimedout Error =3D -8 + ErrorTimedout Error =3D -9 + ErrorNoparavirt Error =3D -10 + ErrorNotReady Error =3D -11 + ErrorOseventRegFail Error =3D -12 + ErrorBufferfull Error =3D -13 + ErrorUnknownChild Error =3D -14 + ErrorLockFail Error =3D -15 + ErrorJsonConfigEmpty Error =3D -16 + ErrorDeviceExists Error =3D -17 + ErrorCheckpointDevopsDoesNotMatch Error =3D -18 + ErrorCheckpointDeviceNotSupported Error =3D -19 + ErrorVnumaConfigInvalid Error =3D -20 + ErrorDomainNotfound Error =3D -21 + ErrorAborted Error =3D -22 + ErrorNotfound Error =3D -23 + ErrorDomainDestroyed Error =3D -24 + ErrorFeatureRemoved Error =3D -25 + ErrorProtocolErrorQmp Error =3D -26 + ErrorUnknownQmpError Error =3D -27 + ErrorQmpGenericError Error =3D -28 + ErrorQmpCommandNotFound Error =3D -29 + ErrorQmpDeviceNotActive Error =3D -30 + ErrorQmpDeviceNotFound Error =3D -31 + ErrorQemuApi Error =3D -32 +) + +type DomainType int + +const ( + DomainTypeInvalid DomainType =3D -1 + DomainTypeHvm DomainType =3D 1 + DomainTypePv DomainType =3D 2 + DomainTypePvh DomainType =3D 3 +) + +type RdmReserveStrategy int + +const ( + RdmReserveStrategyIgnore RdmReserveStrategy =3D 0 + RdmReserveStrategyHost RdmReserveStrategy =3D 1 +) + +type RdmReservePolicy int + +const ( + RdmReservePolicyInvalid RdmReservePolicy =3D -1 + RdmReservePolicyStrict RdmReservePolicy =3D 0 + RdmReservePolicyRelaxed RdmReservePolicy =3D 1 +) + +type ChannelConnection int + +const ( + ChannelConnectionUnknown ChannelConnection =3D 0 + ChannelConnectionPty ChannelConnection =3D 1 + ChannelConnectionSocket ChannelConnection =3D 2 +) + +type DeviceModelVersion int + +const ( + DeviceModelVersionUnknown DeviceModelVersion =3D 0 + DeviceModelVersionQemuXenTraditional DeviceModelVersion =3D 1 + DeviceModelVersionQemuXen DeviceModelVersion =3D 2 +) + +type ConsoleType int + +const ( + ConsoleTypeUnknown ConsoleType =3D 0 + ConsoleTypeSerial ConsoleType =3D 1 + ConsoleTypePv ConsoleType =3D 2 + ConsoleTypeVuart ConsoleType =3D 3 +) + +type DiskFormat int + +const ( + DiskFormatUnknown DiskFormat =3D 0 + DiskFormatQcow DiskFormat =3D 1 + DiskFormatQcow2 DiskFormat =3D 2 + DiskFormatVhd DiskFormat =3D 3 + DiskFormatRaw DiskFormat =3D 4 + DiskFormatEmpty DiskFormat =3D 5 + DiskFormatQed DiskFormat =3D 6 +) + +type DiskBackend int + +const ( + DiskBackendUnknown DiskBackend =3D 0 + DiskBackendPhy DiskBackend =3D 1 + DiskBackendTap DiskBackend =3D 2 + DiskBackendQdisk DiskBackend =3D 3 +) + +type NicType int + +const ( + NicTypeUnknown NicType =3D 0 + NicTypeVifIoemu NicType =3D 1 + NicTypeVif NicType =3D 2 +) + +type ActionOnShutdown int + +const ( + ActionOnShutdownDestroy ActionOnShutdown =3D 1 + ActionOnShutdownRestart ActionOnShutdown =3D 2 + ActionOnShutdownRestartRename ActionOnShutdown =3D 3 + ActionOnShutdownPreserve ActionOnShutdown =3D 4 + ActionOnShutdownCoredumpDestroy ActionOnShutdown =3D 5 + ActionOnShutdownCoredumpRestart ActionOnShutdown =3D 6 + ActionOnShutdownSoftReset ActionOnShutdown =3D 7 +) + +type Trigger int + +const ( + TriggerUnknown Trigger =3D 0 + TriggerPower Trigger =3D 1 + TriggerSleep Trigger =3D 2 + TriggerNmi Trigger =3D 3 + TriggerInit Trigger =3D 4 + TriggerReset Trigger =3D 5 + TriggerS3Resume Trigger =3D 6 +) + +type TscMode int + +const ( + TscModeDefault TscMode =3D 0 + TscModeAlwaysEmulate TscMode =3D 1 + TscModeNative TscMode =3D 2 + TscModeNativeParavirt TscMode =3D 3 +) + +type GfxPassthruKind int + +const ( + GfxPassthruKindDefault GfxPassthruKind =3D 0 + GfxPassthruKindIgd GfxPassthruKind =3D 1 +) + +type TimerMode int + +const ( + TimerModeUnknown TimerMode =3D -1 + TimerModeDelayForMissedTicks TimerMode =3D 0 + TimerModeNoDelayForMissedTicks TimerMode =3D 1 + TimerModeNoMissedTicksPending TimerMode =3D 2 + TimerModeOneMissedTickPending TimerMode =3D 3 +) + +type BiosType int + +const ( + BiosTypeUnknown BiosType =3D 0 + BiosTypeRombios BiosType =3D 1 + BiosTypeSeabios BiosType =3D 2 + BiosTypeOvmf BiosType =3D 3 +) + +type Scheduler int + +const ( + SchedulerUnknown Scheduler =3D 0 + SchedulerSedf Scheduler =3D 4 + SchedulerCredit Scheduler =3D 5 + SchedulerCredit2 Scheduler =3D 6 + SchedulerArinc653 Scheduler =3D 7 + SchedulerRtds Scheduler =3D 8 + SchedulerNull Scheduler =3D 9 +) + +type ShutdownReason int + +const ( + ShutdownReasonUnknown ShutdownReason =3D -1 + ShutdownReasonPoweroff ShutdownReason =3D 0 + ShutdownReasonReboot ShutdownReason =3D 1 + ShutdownReasonSuspend ShutdownReason =3D 2 + ShutdownReasonCrash ShutdownReason =3D 3 + ShutdownReasonWatchdog ShutdownReason =3D 4 + ShutdownReasonSoftReset ShutdownReason =3D 5 +) + +type VgaInterfaceType int + +const ( + VgaInterfaceTypeUnknown VgaInterfaceType =3D 0 + VgaInterfaceTypeCirrus VgaInterfaceType =3D 1 + VgaInterfaceTypeStd VgaInterfaceType =3D 2 + VgaInterfaceTypeNone VgaInterfaceType =3D 3 + VgaInterfaceTypeQxl VgaInterfaceType =3D 4 +) + +type VendorDevice int + +const ( + VendorDeviceNone VendorDevice =3D 0 + VendorDeviceXenserver VendorDevice =3D 1 +) + +type ViridianEnlightenment int + +const ( + ViridianEnlightenmentBase ViridianEnlightenment =3D 0 + ViridianEnlightenmentFreq ViridianEnlightenment =3D 1 + ViridianEnlightenmentTimeRefCount ViridianEnlightenment =3D 2 + ViridianEnlightenmentReferenceTsc ViridianEnlightenment =3D 3 + ViridianEnlightenmentHcallRemoteTlbFlush ViridianEnlightenment =3D 4 + ViridianEnlightenmentApicAssist ViridianEnlightenment =3D 5 + ViridianEnlightenmentCrashCtl ViridianEnlightenment =3D 6 + ViridianEnlightenmentSynic ViridianEnlightenment =3D 7 + ViridianEnlightenmentStimer ViridianEnlightenment =3D 8 + ViridianEnlightenmentHcallIpi ViridianEnlightenment =3D 9 +) + +type Hdtype int + +const ( + HdtypeIde Hdtype =3D 1 + HdtypeAhci Hdtype =3D 2 +) + +type CheckpointedStream int + +const ( + CheckpointedStreamNone CheckpointedStream =3D 0 + CheckpointedStreamRemus CheckpointedStream =3D 1 + CheckpointedStreamColo CheckpointedStream =3D 2 +) + +type VuartType int + +const ( + VuartTypeUnknown VuartType =3D 0 + VuartTypeSbsaUart VuartType =3D 1 +) + +type VkbBackend int + +const ( + VkbBackendUnknown VkbBackend =3D 0 + VkbBackendQemu VkbBackend =3D 1 + VkbBackendLinux VkbBackend =3D 2 +) + +type Passthrough int + +const ( + PassthroughDefault Passthrough =3D 0 + PassthroughDisabled Passthrough =3D 1 + PassthroughEnabled Passthrough =3D 2 + PassthroughSyncPt Passthrough =3D 3 + PassthroughSharePt Passthrough =3D 4 +) + +type IoportRange struct { + First uint32 + Number uint32 +} + +type IomemRange struct { + Start uint64 + Number uint64 + Gfn uint64 +} + +type VgaInterfaceInfo struct { + Kind VgaInterfaceType +} + +type VncInfo struct { + Enable Defbool + Listen string + Passwd string + Display int + Findunused Defbool +} + +type SpiceInfo struct { + Enable Defbool + Port int + TlsPort int + Host string + DisableTicketing Defbool + Passwd string + AgentMouse Defbool + Vdagent Defbool + ClipboardSharing Defbool + Usbredirection int + ImageCompression string + StreamingVideo string +} + +type SdlInfo struct { + Enable Defbool + Opengl Defbool + Display string + Xauthority string +} + +type Dominfo struct { + Uuid Uuid + Domid Domid + Ssidref uint32 + SsidLabel string + Running bool + Blocked bool + Paused bool + Shutdown bool + Dying bool + NeverStop bool + ShutdownReason ShutdownReason + OutstandingMemkb uint64 + CurrentMemkb uint64 + SharedMemkb uint64 + PagedMemkb uint64 + MaxMemkb uint64 + CpuTime uint64 + VcpuMaxId uint32 + VcpuOnline uint32 + Cpupool uint32 + DomainType DomainType +} + +type Cpupoolinfo struct { + Poolid uint32 + PoolName string + Sched Scheduler + NDom uint32 + Cpumap Bitmap +} + +type Channelinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Evtch int + Rref int + Connection ChannelConnection + ConnectionUnion channelinfoConnectionUnion +} + +type channelinfoConnectionUnion interface { + ischannelinfoConnectionUnion() +} + +type ChannelinfoConnectionUnionPty struct { + Path string +} + +func (x ChannelinfoConnectionUnionPty) ischannelinfoConnectionUnion() {} + +type Vminfo struct { + Uuid Uuid + Domid Domid +} + +type VersionInfo struct { + XenVersionMajor int + XenVersionMinor int + XenVersionExtra string + Compiler string + CompileBy string + CompileDomain string + CompileDate string + Capabilities string + Changeset string + VirtStart uint64 + Pagesize int + Commandline string + BuildId string +} + +type DomainCreateInfo struct { + Type DomainType + Hap Defbool + Oos Defbool + Ssidref uint32 + SsidLabel string + Name string + Domid Domid + Uuid Uuid + Xsdata KeyValueList + Platformdata KeyValueList + Poolid uint32 + PoolName string + RunHotplugScripts Defbool + DriverDomain Defbool + Passthrough Passthrough + XendSuspendEvtchnCompat Defbool +} + +type DomainRestoreParams struct { + CheckpointedStream int + StreamVersion uint32 + ColoProxyScript string + UserspaceColoProxy Defbool +} + +type SchedParams struct { + Vcpuid int + Weight int + Cap int + Period int + Extratime int + Budget int +} + +type VcpuSchedParams struct { + Sched Scheduler + Vcpus []SchedParams +} + +type DomainSchedParams struct { + Sched Scheduler + Weight int + Cap int + Period int + Budget int + Extratime int + Slice int + Latency int +} + +type VnodeInfo struct { + Memkb uint64 + Distances []uint32 + Pnode uint32 + Vcpus Bitmap +} + +type GicVersion int + +const ( + GicVersionDefault GicVersion =3D 0 + GicVersionV2 GicVersion =3D 32 + GicVersionV3 GicVersion =3D 48 +) + +type TeeType int + +const ( + TeeTypeNone TeeType =3D 0 + TeeTypeOptee TeeType =3D 1 +) + +type RdmReserve struct { + Strategy RdmReserveStrategy + Policy RdmReservePolicy +} + +type Altp2MMode int + +const ( + Altp2MModeDisabled Altp2MMode =3D 0 + Altp2MModeMixed Altp2MMode =3D 1 + Altp2MModeExternal Altp2MMode =3D 2 + Altp2MModeLimited Altp2MMode =3D 3 +) + +type DomainBuildInfo struct { + MaxVcpus int + AvailVcpus Bitmap + Cpumap Bitmap + Nodemap Bitmap + VcpuHardAffinity []Bitmap + VcpuSoftAffinity []Bitmap + NumaPlacement Defbool + TscMode TscMode + MaxMemkb uint64 + TargetMemkb uint64 + VideoMemkb uint64 + ShadowMemkb uint64 + IommuMemkb uint64 + RtcTimeoffset uint32 + ExecSsidref uint32 + ExecSsidLabel string + Localtime Defbool + DisableMigrate Defbool + Cpuid CpuidPolicyList + BlkdevStart string + VnumaNodes []VnodeInfo + MaxGrantFrames uint32 + MaxMaptrackFrames uint32 + DeviceModelVersion DeviceModelVersion + DeviceModelStubdomain Defbool + DeviceModel string + DeviceModelSsidref uint32 + DeviceModelSsidLabel string + DeviceModelUser string + Extra StringList + ExtraPv StringList + ExtraHvm StringList + SchedParams DomainSchedParams + Ioports []IoportRange + Irqs []uint32 + Iomem []IomemRange + ClaimMode Defbool + EventChannels uint32 + Kernel string + Cmdline string + Ramdisk string + DeviceTree string + Acpi Defbool + Bootloader string + BootloaderArgs StringList + TimerMode TimerMode + NestedHvm Defbool + Apic Defbool + DmRestrict Defbool + Tee TeeType + Type DomainType + TypeUnion domainBuildInfoTypeUnion + ArchArm struct { + GicVersion GicVersion + Vuart VuartType + } + Altp2M Altp2MMode +} + +type domainBuildInfoTypeUnion interface { + isdomainBuildInfoTypeUnion() +} + +type DomainBuildInfoTypeUnionHvm struct { + Firmware string + Bios BiosType + Pae Defbool + Apic Defbool + Acpi Defbool + AcpiS3 Defbool + AcpiS4 Defbool + AcpiLaptopSlate Defbool + Nx Defbool + Viridian Defbool + ViridianEnable Bitmap + ViridianDisable Bitmap + Timeoffset string + Hpet Defbool + VptAlign Defbool + MmioHoleMemkb uint64 + TimerMode TimerMode + NestedHvm Defbool + Altp2M Defbool + SystemFirmware string + SmbiosFirmware string + AcpiFirmware string + Hdtype Hdtype + Nographic Defbool + Vga VgaInterfaceInfo + Vnc VncInfo + Keymap string + Sdl SdlInfo + Spice SpiceInfo + GfxPassthru Defbool + GfxPassthruKind GfxPassthruKind + Serial string + Boot string + Usb Defbool + Usbversion int + Usbdevice string + VkbDevice Defbool + Soundhw string + XenPlatformPci Defbool + UsbdeviceList StringList + VendorDevice VendorDevice + MsVmGenid MsVmGenid + SerialList StringList + Rdm RdmReserve + RdmMemBoundaryMemkb uint64 + McaCaps uint64 +} + +func (x DomainBuildInfoTypeUnionHvm) isdomainBuildInfoTypeUnion() {} + +type DomainBuildInfoTypeUnionPv struct { + Kernel string + SlackMemkb uint64 + Bootloader string + BootloaderArgs StringList + Cmdline string + Ramdisk string + Features string + E820Host Defbool +} + +func (x DomainBuildInfoTypeUnionPv) isdomainBuildInfoTypeUnion() {} + +type DomainBuildInfoTypeUnionPvh struct { + Pvshim Defbool + PvshimPath string + PvshimCmdline string + PvshimExtra string +} + +func (x DomainBuildInfoTypeUnionPvh) isdomainBuildInfoTypeUnion() {} + +type DeviceVfb struct { + BackendDomid Domid + BackendDomname string + Devid Devid + Vnc VncInfo + Sdl SdlInfo + Keymap string +} + +type DeviceVkb struct { + BackendDomid Domid + BackendDomname string + Devid Devid + BackendType VkbBackend + UniqueId string + FeatureDisableKeyboard bool + FeatureDisablePointer bool + FeatureAbsPointer bool + FeatureRawPointer bool + FeatureMultiTouch bool + Width uint32 + Height uint32 + MultiTouchWidth uint32 + MultiTouchHeight uint32 + MultiTouchNumContacts uint32 +} + +type DeviceDisk struct { + BackendDomid Domid + BackendDomname string + PdevPath string + Vdev string + Backend DiskBackend + Format DiskFormat + Script string + Removable int + Readwrite int + IsCdrom int + DirectIoSafe bool + DiscardEnable Defbool + ColoEnable Defbool + ColoRestoreEnable Defbool + ColoHost string + ColoPort int + ColoExport string + ActiveDisk string + HiddenDisk string +} + +type DeviceNic struct { + BackendDomid Domid + BackendDomname string + Devid Devid + Mtu int + Model string + Mac Mac + Ip string + Bridge string + Ifname string + Script string + Nictype NicType + RateBytesPerInterval uint64 + RateIntervalUsecs uint32 + Gatewaydev string + ColoftForwarddev string + ColoSockMirrorId string + ColoSockMirrorIp string + ColoSockMirrorPort string + ColoSockComparePriInId string + ColoSockComparePriInIp string + ColoSockComparePriInPort string + ColoSockCompareSecInId string + ColoSockCompareSecInIp string + ColoSockCompareSecInPort string + ColoSockCompareNotifyId string + ColoSockCompareNotifyIp string + ColoSockCompareNotifyPort string + ColoSockRedirector0Id string + ColoSockRedirector0Ip string + ColoSockRedirector0Port string + ColoSockRedirector1Id string + ColoSockRedirector1Ip string + ColoSockRedirector1Port string + ColoSockRedirector2Id string + ColoSockRedirector2Ip string + ColoSockRedirector2Port string + ColoFilterMirrorQueue string + ColoFilterMirrorOutdev string + ColoFilterRedirector0Queue string + ColoFilterRedirector0Indev string + ColoFilterRedirector0Outdev string + ColoFilterRedirector1Queue string + ColoFilterRedirector1Indev string + ColoFilterRedirector1Outdev string + ColoComparePriIn string + ColoCompareSecIn string + ColoCompareOut string + ColoCompareNotifyDev string + ColoSockSecRedirector0Id string + ColoSockSecRedirector0Ip string + ColoSockSecRedirector0Port string + ColoSockSecRedirector1Id string + ColoSockSecRedirector1Ip string + ColoSockSecRedirector1Port string + ColoFilterSecRedirector0Queue string + ColoFilterSecRedirector0Indev string + ColoFilterSecRedirector0Outdev string + ColoFilterSecRedirector1Queue string + ColoFilterSecRedirector1Indev string + ColoFilterSecRedirector1Outdev string + ColoFilterSecRewriter0Queue string + ColoCheckpointHost string + ColoCheckpointPort string +} + +type DevicePci struct { + Func byte + Dev byte + Bus byte + Domain int + Vdevfn uint32 + VfuncMask uint32 + Msitranslate bool + PowerMgmt bool + Permissive bool + Seize bool + RdmPolicy RdmReservePolicy +} + +type DeviceRdm struct { + Start uint64 + Size uint64 + Policy RdmReservePolicy +} + +type UsbctrlType int + +const ( + UsbctrlTypeAuto UsbctrlType =3D 0 + UsbctrlTypePv UsbctrlType =3D 1 + UsbctrlTypeDevicemodel UsbctrlType =3D 2 + UsbctrlTypeQusb UsbctrlType =3D 3 +) + +type UsbdevType int + +const ( + UsbdevTypeHostdev UsbdevType =3D 1 +) + +type DeviceUsbctrl struct { + Type UsbctrlType + Devid Devid + Version int + Ports int + BackendDomid Domid + BackendDomname string +} + +type DeviceUsbdev struct { + Ctrl Devid + Port int + Type UsbdevType + TypeUnion deviceUsbdevTypeUnion +} + +type deviceUsbdevTypeUnion interface { + isdeviceUsbdevTypeUnion() +} + +type DeviceUsbdevTypeUnionHostdev struct { + Hostbus byte + Hostaddr byte +} + +func (x DeviceUsbdevTypeUnionHostdev) isdeviceUsbdevTypeUnion() {} + +type DeviceDtdev struct { + Path string +} + +type DeviceVtpm struct { + BackendDomid Domid + BackendDomname string + Devid Devid + Uuid Uuid +} + +type DeviceP9 struct { + BackendDomid Domid + BackendDomname string + Tag string + Path string + SecurityModel string + Devid Devid +} + +type DevicePvcallsif struct { + BackendDomid Domid + BackendDomname string + Devid Devid +} + +type DeviceChannel struct { + BackendDomid Domid + BackendDomname string + Devid Devid + Name string + Connection ChannelConnection + ConnectionUnion deviceChannelConnectionUnion +} + +type deviceChannelConnectionUnion interface { + isdeviceChannelConnectionUnion() +} + +type DeviceChannelConnectionUnionSocket struct { + Path string +} + +func (x DeviceChannelConnectionUnionSocket) isdeviceChannelConnectionUnion= () {} + +type ConnectorParam struct { + UniqueId string + Width uint32 + Height uint32 +} + +type DeviceVdispl struct { + BackendDomid Domid + BackendDomname string + Devid Devid + BeAlloc bool + Connectors []ConnectorParam +} + +type VsndPcmFormat int + +const ( + VsndPcmFormatS8 VsndPcmFormat =3D 1 + VsndPcmFormatU8 VsndPcmFormat =3D 2 + VsndPcmFormatS16Le VsndPcmFormat =3D 3 + VsndPcmFormatS16Be VsndPcmFormat =3D 4 + VsndPcmFormatU16Le VsndPcmFormat =3D 5 + VsndPcmFormatU16Be VsndPcmFormat =3D 6 + VsndPcmFormatS24Le VsndPcmFormat =3D 7 + VsndPcmFormatS24Be VsndPcmFormat =3D 8 + VsndPcmFormatU24Le VsndPcmFormat =3D 9 + VsndPcmFormatU24Be VsndPcmFormat =3D 10 + VsndPcmFormatS32Le VsndPcmFormat =3D 11 + VsndPcmFormatS32Be VsndPcmFormat =3D 12 + VsndPcmFormatU32Le VsndPcmFormat =3D 13 + VsndPcmFormatU32Be VsndPcmFormat =3D 14 + VsndPcmFormatF32Le VsndPcmFormat =3D 15 + VsndPcmFormatF32Be VsndPcmFormat =3D 16 + VsndPcmFormatF64Le VsndPcmFormat =3D 17 + VsndPcmFormatF64Be VsndPcmFormat =3D 18 + VsndPcmFormatIec958SubframeLe VsndPcmFormat =3D 19 + VsndPcmFormatIec958SubframeBe VsndPcmFormat =3D 20 + VsndPcmFormatMuLaw VsndPcmFormat =3D 21 + VsndPcmFormatALaw VsndPcmFormat =3D 22 + VsndPcmFormatImaAdpcm VsndPcmFormat =3D 23 + VsndPcmFormatMpeg VsndPcmFormat =3D 24 + VsndPcmFormatGsm VsndPcmFormat =3D 25 +) + +type VsndParams struct { + SampleRates []uint32 + SampleFormats []VsndPcmFormat + ChannelsMin uint32 + ChannelsMax uint32 + BufferSize uint32 +} + +type VsndStreamType int + +const ( + VsndStreamTypeP VsndStreamType =3D 1 + VsndStreamTypeC VsndStreamType =3D 2 +) + +type VsndStream struct { + UniqueId string + Type VsndStreamType + Params VsndParams +} + +type VsndPcm struct { + Name string + Params VsndParams + Streams []VsndStream +} + +type DeviceVsnd struct { + BackendDomid Domid + BackendDomname string + Devid Devid + ShortName string + LongName string + Params VsndParams + Pcms []VsndPcm +} + +type DomainConfig struct { + CInfo DomainCreateInfo + BInfo DomainBuildInfo + Disks []DeviceDisk + Nics []DeviceNic + Pcidevs []DevicePci + Rdms []DeviceRdm + Dtdevs []DeviceDtdev + Vfbs []DeviceVfb + Vkbs []DeviceVkb + Vtpms []DeviceVtpm + P9S []DeviceP9 + Pvcallsifs []DevicePvcallsif + Vdispls []DeviceVdispl + Vsnds []DeviceVsnd + Channels []DeviceChannel + Usbctrls []DeviceUsbctrl + Usbdevs []DeviceUsbdev + OnPoweroff ActionOnShutdown + OnReboot ActionOnShutdown + OnWatchdog ActionOnShutdown + OnCrash ActionOnShutdown + OnSoftReset ActionOnShutdown +} + +type Diskinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Evtch int + Rref int +} + +type Nicinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Evtch int + RrefTx int + RrefRx int +} + +type Vtpminfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Evtch int + Rref int + Uuid Uuid +} + +type Usbctrlinfo struct { + Type UsbctrlType + Devid Devid + Version int + Ports int + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + State int + Evtch int + RefUrb int + RefConn int +} + +type Vcpuinfo struct { + Vcpuid uint32 + Cpu uint32 + Online bool + Blocked bool + Running bool + VcpuTime uint64 + Cpumap Bitmap + CpumapSoft Bitmap +} + +type Physinfo struct { + ThreadsPerCore uint32 + CoresPerSocket uint32 + MaxCpuId uint32 + NrCpus uint32 + CpuKhz uint32 + TotalPages uint64 + FreePages uint64 + ScrubPages uint64 + OutstandingPages uint64 + SharingFreedPages uint64 + SharingUsedFrames uint64 + MaxPossibleMfn uint64 + NrNodes uint32 + HwCap Hwcap + CapHvm bool + CapPv bool + CapHvmDirectio bool + CapHap bool + CapShadow bool + CapIommuHapPtShare bool +} + +type Connectorinfo struct { + UniqueId string + Width uint32 + Height uint32 + ReqEvtch int + ReqRref int + EvtEvtch int + EvtRref int +} + +type Vdisplinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + BeAlloc bool + Connectors []Connectorinfo +} + +type Streaminfo struct { + ReqEvtch int + ReqRref int +} + +type Pcminfo struct { + Streams []Streaminfo +} + +type Vsndinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Pcms []Pcminfo +} + +type Vkbinfo struct { + Backend string + BackendId uint32 + Frontend string + FrontendId uint32 + Devid Devid + State int + Evtch int + Rref int +} + +type Numainfo struct { + Size uint64 + Free uint64 + Dists []uint32 +} + +type Cputopology struct { + Core uint32 + Socket uint32 + Node uint32 +} + +type Pcitopology struct { + Seg uint16 + Bus byte + Devfn byte + Node uint32 +} + +type SchedCreditParams struct { + TsliceMs int + RatelimitUs int + VcpuMigrDelayUs int +} + +type SchedCredit2Params struct { + RatelimitUs int +} + +type DomainRemusInfo struct { + Interval int + AllowUnsafe Defbool + Blackhole Defbool + Compression Defbool + Netbuf Defbool + Netbufscript string + Diskbuf Defbool + Colo Defbool + UserspaceColoProxy Defbool +} + +type EventType int + +const ( + EventTypeDomainShutdown EventType =3D 1 + EventTypeDomainDeath EventType =3D 2 + EventTypeDiskEject EventType =3D 3 + EventTypeOperationComplete EventType =3D 4 + EventTypeDomainCreateConsoleAvailable EventType =3D 5 +) + +type Event struct { + Link EvLink + Domid Domid + Domuuid Uuid + ForUser uint64 + Type EventType + TypeUnion eventTypeUnion +} + +type eventTypeUnion interface { + iseventTypeUnion() +} + +type EventTypeUnionDomainShutdown struct { + ShutdownReason byte +} + +func (x EventTypeUnionDomainShutdown) iseventTypeUnion() {} + +type EventTypeUnionDiskEject struct { + Vdev string + Disk DeviceDisk +} + +func (x EventTypeUnionDiskEject) iseventTypeUnion() {} + +type EventTypeUnionOperationComplete struct { + Rc int +} + +func (x EventTypeUnionOperationComplete) iseventTypeUnion() {} + +type PsrCmtType int + +const ( + PsrCmtTypeCacheOccupancy PsrCmtType =3D 1 + PsrCmtTypeTotalMemCount PsrCmtType =3D 2 + PsrCmtTypeLocalMemCount PsrCmtType =3D 3 +) + +type PsrCbmType int + +const ( + PsrCbmTypeUnknown PsrCbmType =3D 0 + PsrCbmTypeL3Cbm PsrCbmType =3D 1 + PsrCbmTypeL3CbmCode PsrCbmType =3D 2 + PsrCbmTypeL3CbmData PsrCbmType =3D 3 + PsrCbmTypeL2Cbm PsrCbmType =3D 4 + PsrCbmTypeMbaThrtl PsrCbmType =3D 5 +) + +type PsrCatInfo struct { + Id uint32 + CosMax uint32 + CbmLen uint32 + CdpEnabled bool +} + +type PsrFeatType int + +const ( + PsrFeatTypeCat PsrFeatType =3D 1 + PsrFeatTypeMba PsrFeatType =3D 2 +) + +type PsrHwInfo struct { + Id uint32 + Type PsrFeatType + TypeUnion psrHwInfoTypeUnion +} + +type psrHwInfoTypeUnion interface { + ispsrHwInfoTypeUnion() +} + +type PsrHwInfoTypeUnionCat struct { + CosMax uint32 + CbmLen uint32 + CdpEnabled bool +} + +func (x PsrHwInfoTypeUnionCat) ispsrHwInfoTypeUnion() {} + +type PsrHwInfoTypeUnionMba struct { + CosMax uint32 + ThrtlMax uint32 + Linear bool +} + +func (x PsrHwInfoTypeUnionMba) ispsrHwInfoTypeUnion() {} --=20 2.17.1 From nobody Sun May 5 15:03:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=1589331519; cv=none; d=zohomail.com; s=zohoarc; b=C+xXunyAaOcEFbO55lr8ncns0yxeIXoXIkcWyvya7rZozJ7IMq7Pquym4sxwN1AEk683VCaYLSkEgKBRxDejVCY9XBlluHTOXJhGKixIrCjDK62E4xBVNPWE2t9czTjmn9lUgVO0MVtWjnSiJJXVy+FhrRn1gbVBv0q0itsUv4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589331519; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=9QmGMkOR+A+pcuReg/osmrOg0hnPPVtYzNJ/7f6YaNg=; b=QcjZxqdQ2G3mgjG3tw70v28YW/EqS5+pw1jcsSpCeHm0pdziv1wHkUTrz4miFIocsTmW4gUgP+QZIg6UO+H7i6HjI11D5vg2XutSnTLvV/YXx6H6cF7pj4NCmlr4GochXAaXVnuJWi+hdG5WzMjl7djbYaD1swlMdhRmh1NnfhY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1589331519291596.8403784523903; Tue, 12 May 2020 17:58:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfiz-0006GG-5j; Wed, 13 May 2020 00:58:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfiy-0006GA-K6 for xen-devel@lists.xenproject.org; Wed, 13 May 2020 00:58:16 +0000 Received: from mail-qt1-x841.google.com (unknown [2607:f8b0:4864:20::841]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d30b8bb0-94b4-11ea-b07b-bc764e2007e4; Wed, 13 May 2020 00:58:14 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id v4so11939803qte.3 for ; Tue, 12 May 2020 17:58:14 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id 62sm12400828qkh.113.2020.05.12.17.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 17:58:13 -0700 (PDT) X-Inumbo-ID: d30b8bb0-94b4-11ea-b07b-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=9QmGMkOR+A+pcuReg/osmrOg0hnPPVtYzNJ/7f6YaNg=; b=vbptMo/eBHuIG3SRRrDxBqD1zDbRCFmHucEVmXcE07e1JIMsrNjlAvtlsdrBv+BIrs BY3ynre2rZ2nKgSLktlZQH4n7gNfmcn/uKwe86v4sXkacMQuVpVMPnua9f+60d7up7PW nUjIOFBc/ZHdAUfyyT68ReP8SYRDbQiPxa189wMYX5j+L8P6XzTD5e89BQRRmhdJ9ApW pgI1qefmWNHuETb5XDcqG4qWtJr95nHQmdH58qH5hP2Fm/HT1Nq2Y9qSzLW23ilCGssU v1/M1m8bpmEmE2yHtnz/mqEOsVGEvlxVd9MZxcJK0W8avzpYDhvLbjcto/JRTqPCWwd5 wHgA== 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=9QmGMkOR+A+pcuReg/osmrOg0hnPPVtYzNJ/7f6YaNg=; b=Ti6eJxBH6UTo8xGDbUlXeMn2piPZqqeOFnC6I9RvCj3xzB7zKkPkxpFiF50y4Z581N GjbfwElve7fDjAdHA7+C8VBKUS7mVWwj/oGpn1mwqdfR+2vuaa758yn6LOCpvid6vKFL A7Y38ILSD4OKALilRns3F5g3DzHEjiRszfnKxgL6CoBQGHJHzWvZAEBemA7kkKb/+HjL mqT3pD5+z1w57Cqt045sZj/nIYJie5O0XVp2XLI1tnB8GNv9xrwbP1WMJbPcU6PwL0sX 9eiFMK8UaD2D5yuKc0lNtT1fhTZpU/CfS+X8wGdJyYS2ljJsg+3ARNFLchZI0BTWJt/U FQwg== X-Gm-Message-State: AOAM531tUsDeXCoEyWtknDIgN+VvAQSd5cj26lvNVnO4HnmlqdCmd44q j2DFWEOrPgSONatoCWwfBKjxjzZifsc= X-Google-Smtp-Source: ABdhPJyRR0JQaQPyfA0v3+R8gVZAK0qYjKH35eNV0aKR0mDANKcXzAIRb4B32yUg//m2MRiLdpJI7w== X-Received: by 2002:ac8:6651:: with SMTP id j17mr4960597qtp.35.1589331493712; Tue, 12 May 2020 17:58:13 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH v2 2/3] golang/xenlight: init xenlight go module Date: Tue, 12 May 2020 20:58:06 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Initialize the xenlight Go module using the xenbits git-http URL, xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight. Also simplify the build Make target by using `go build` instead of `go install`, and do not set GOPATH here because it is now unnecessary. Signed-off-by: Nick Rosbrook --- Changes in v2: - Use xenproject.org instead of xen.org in module path. - Undo change to XEN_GOCODE_URL; just use `go build`. --- tools/golang/xenlight/Makefile | 2 +- tools/golang/xenlight/go.mod | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tools/golang/xenlight/go.mod diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile index 753132306a..37ed1358c4 100644 --- a/tools/golang/xenlight/Makefile +++ b/tools/golang/xenlight/Makefile @@ -33,7 +33,7 @@ $(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/: xenlight.g= o types.gen.go helpers. # so that it can find the actual library. .PHONY: build build: package - CGO_CFLAGS=3D"$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS= =3D"$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_XENLIGHT) -L$(XEN= _LIBXENTOOLLOG)" GOPATH=3D$(XEN_GOPATH) $(GO) install -x $(XEN_GOCODE_URL)/= xenlight + CGO_CFLAGS=3D"$(CFLAGS_libxenlight) $(CFLAGS_libxentoollog)" CGO_LDFLAGS= =3D"$(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -L$(XEN_XENLIGHT) -L$(XEN= _LIBXENTOOLLOG)" $(GO) build -x =20 .PHONY: install install: build diff --git a/tools/golang/xenlight/go.mod b/tools/golang/xenlight/go.mod new file mode 100644 index 0000000000..926474d929 --- /dev/null +++ b/tools/golang/xenlight/go.mod @@ -0,0 +1 @@ +module xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight --=20 2.17.1 From nobody Sun May 5 15:03:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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=1589331535; cv=none; d=zohomail.com; s=zohoarc; b=ZV59gPKjrpUL67Z0sfJ8lqz3+6NgGbJDPybivTg/J9dxF0j5EAojj6gyp29XLP3WSUDws9Fm9eoxAK/FSkuSw9vLsmOo+JLkLFVAnycVI11ZivLPrs8PJ5V68siRGbS2RqaE5KYTUGnPUoXnLIQuThePa22E+8AGVhapcU3sZbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589331535; 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=1brDpjdUwGMbVSq6tuF5O7Jze20hQbuXMTaGnOz/sxI=; b=FgvgEKj/fj1syAiSVSD/MeYycV4Y4d2QDU0NjkaXbEsJxTyU/HKSPs/AWaEQ8TWm+nk9q3tlKEG4gqT6v3kZyJTsQfdZEKzDMS9O5fslcPweeWlm7e4smk6LjEoekQqmXxC/VOn9shdmJ7uzxV0mIzv3NDGPaEtvgRye2DTSUiw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) 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 1589331535383971.8196753544133; Tue, 12 May 2020 17:58:55 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfjB-0006JR-1i; Wed, 13 May 2020 00:58:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jYfj9-0006Id-NO for xen-devel@lists.xenproject.org; Wed, 13 May 2020 00:58:27 +0000 Received: from mail-qt1-x832.google.com (unknown [2607:f8b0:4864:20::832]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d4c1b0ba-94b4-11ea-b07b-bc764e2007e4; Wed, 13 May 2020 00:58:17 +0000 (UTC) Received: by mail-qt1-x832.google.com with SMTP id x8so12777647qtr.2 for ; Tue, 12 May 2020 17:58:17 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id 62sm12400828qkh.113.2020.05.12.17.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2020 17:58:14 -0700 (PDT) X-Inumbo-ID: d4c1b0ba-94b4-11ea-b07b-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 :mime-version:in-reply-to:references:content-transfer-encoding; bh=1brDpjdUwGMbVSq6tuF5O7Jze20hQbuXMTaGnOz/sxI=; b=XD+Hf7/zflbEuxrNjcGjwwix11KTscuVE9nkRfu+8VCzg6CutgOmkc9Zhr+Z8erA70 6yiizRJwQSdJ5wiziDMYz21cylPU1OUg9bmvdG573SqyfJLJlivULyUVF56CXbDwQvI/ xh2bFZGlYf3lmqDVWwvjFJ++lSaIr3ocks2CG8DLtFfZ8USxh+Fqp+YU18qIqQettKP+ n/vvHQPOdLCmswDwCBQ5SyVSuwunbdWlqG392bvWk1RYsc9rT6lTK7T7tosAgVy4qDs9 wn6XyYzcTS6VnYYptEzaoF0vKV0nsjvyVgTZFOi6ex4XYls36ji/JDgmc8UGAsr60i2p /g/A== 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:mime-version:in-reply-to:references :content-transfer-encoding; bh=1brDpjdUwGMbVSq6tuF5O7Jze20hQbuXMTaGnOz/sxI=; b=idr/KFTybXg1tkFv6tYtqWuDK4jTEZI8LDjT3/KOSw6FTRdsQxHoa9OGbTCs/F+0PJ rfjiPM17Sz8ayMI1Z7UxjTJLPXQI9HkoUnf6xWYK0/tFuxRHC3suHhN1Z1DdIUEyV/oB HeKtpBNXaAC8O5sc4zK0mQpQ9M/nUi7GAHLuhgY/wMIHkjooDpvwlNVoJEycOAizn7oT 3JVbK7wTZaEG12I1luyDdJmfGURmUpuRhlgrqGb/YYFQeG72yavd9YkuVFD8VX5eE98Y OSBM3ArbQ3Z6B881hsWcoB3b1o/TNu18jc90DFFmb3KF8KPB6FOnc24ZYu7Q+CEzTTkJ lryQ== X-Gm-Message-State: AGi0PuYt29qA2ElsJNomh5DnSRCrInddGRmlzizu0gydcc1dgwl4Dn7l 117aW5Nlc4mHWnteU7BEfguIv8aaczM= X-Google-Smtp-Source: APiQypLmY2UikkTHR9+BQw2L5vEGBMeA6STde8Z5tyapQpQljpKFtb9u/T8A0nngKy1Ge2qV36mz2Q== X-Received: by 2002:ac8:6b44:: with SMTP id x4mr14047305qts.353.1589331495390; Tue, 12 May 2020 17:58:15 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH v2 3/3] golang/xenlight: add necessary module/package documentation Date: Tue, 12 May 2020 20:58:07 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , George Dunlap , Nick Rosbrook , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add a README and package comment giving a brief overview of the package. These also help pkg.go.dev generate better documentation. Also, add a copy of the LGPL (the same license used by libxl) to tools/golang/xenlight. This is required for the package to be shown on pkg.go.dev and added to the default module proxy, proxy.golang.org. Finally, add an entry for the xenlight package to SUPPORT.md. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Use LGPL instead of GPL for license. - Change some wording in README for clarity. - Add entry to SUPPORT.md for xenlight package. --- SUPPORT.md | 6 + tools/golang/xenlight/LICENSE | 198 ++++++++++++++++++++++++++++++ tools/golang/xenlight/README.md | 17 +++ tools/golang/xenlight/xenlight.go | 2 + 4 files changed, 223 insertions(+) create mode 100644 tools/golang/xenlight/LICENSE create mode 100644 tools/golang/xenlight/README.md diff --git a/SUPPORT.md b/SUPPORT.md index 7270c9b021..e3a366fd56 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -147,6 +147,12 @@ Output of information in machine-parseable JSON format =20 Status: Supported =20 +### xenlight Go package + +Go (golang) bindings for libxl + + Status: Experimental + ## Toolstack/3rd party =20 ### libvirt driver for xl diff --git a/tools/golang/xenlight/LICENSE b/tools/golang/xenlight/LICENSE new file mode 100644 index 0000000000..d4d1f17688 --- /dev/null +++ b/tools/golang/xenlight/LICENSE @@ -0,0 +1,198 @@ +This repository is distributed under the terms of the GNU Lesser General +Public License version 2.1 (included below). + +As a special exception to the GNU Lesser General Public License, you +may link, statically or dynamically, a "work that uses the Library" +with a publicly distributed version of the Library to produce an +executable file containing portions of the Library, and distribute +that executable file under terms of your choice, without any of the +additional requirements listed in clause 6 of the GNU Lesser General +Public License. By "a publicly distributed version of the Library", +we mean either the unmodified Library as distributed, or a +modified version of the Library that is distributed under the +conditions defined in clause 3 of the GNU Library General Public +License. This exception does not however invalidate any other reasons +why the executable file might be covered by the GNU Lesser General +Public License. + +------------ + +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + +Preamble +The licenses for most software are designed to take away your freedom to s= hare and change it. By contrast, the GNU General Public Licenses are intend= ed to guarantee your freedom to share and change free software--to make sur= e the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially= designated software packages--typically libraries--of the Free Software Fo= undation and other authors who decide to use it. You can use it too, but we= suggest you first think carefully about whether this license or the ordina= ry General Public License is the better strategy to use in any particular c= ase, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not pr= ice. Our General Public Licenses are designed to make sure that you have th= e freedom to distribute copies of free software (and charge for this servic= e if you wish); that you receive source code or can get it if you want it; = that you can change the software and use pieces of it in new free programs;= and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distribut= ors to deny you these rights or to ask you to surrender these rights. These= restrictions translate to certain responsibilities for you if you distribu= te copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or fo= r a fee, you must give the recipients all the rights that we gave you. You = must make sure that they, too, receive or can get the source code. If you l= ink other code with the library, you must provide complete object files to = the recipients, so that they can relink them with the library after making = changes to the library and recompiling it. And you must show them these ter= ms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the librar= y, and (2) we offer you this license, which gives you legal permission to c= opy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is n= o warranty for the free library. Also, if the library is modified by someon= e else and passed on, the recipients should know that what they have is not= the original version, so that the original author's reputation will not be= affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any f= ree program. We wish to make sure that a company cannot effectively restric= t the users of a free program by obtaining a restrictive license from a pat= ent holder. Therefore, we insist that any patent license obtained for a ver= sion of the library must be consistent with the full freedom of use specifi= ed in this license. + +Most GNU software, including some libraries, is covered by the ordinary GN= U General Public License. This license, the GNU Lesser General Public Licen= se, applies to certain designated libraries, and is quite different from th= e ordinary General Public License. We use this license for certain librarie= s in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a sha= red library, the combination of the two is legally speaking a combined work= , a derivative of the original library. The ordinary General Public License= therefore permits such linking only if the entire combination fits its cri= teria of freedom. The Lesser General Public License permits more lax criter= ia for linking other code with the library. + +We call this license the "Lesser" General Public License because it does L= ess to protect the user's freedom than the ordinary General Public License.= It also provides other free software developers Less of an advantage over = competing non-free programs. These disadvantages are the reason we use the = ordinary General Public License for many libraries. However, the Lesser lic= ense provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage t= he widest possible use of a certain library, so that it becomes a de-facto = standard. To achieve this, non-free programs must be allowed to use the lib= rary. A more frequent case is that a free library does the same job as wide= ly used non-free libraries. In this case, there is little to gain by limiti= ng the free library to free software only, so we use the Lesser General Pub= lic License. + +In other cases, permission to use a particular library in non-free program= s enables a greater number of people to use a large body of free software. = For example, permission to use the GNU C Library in non-free programs enabl= es many more people to use the whole GNU operating system, as well as its v= ariant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users= ' freedom, it does ensure that the user of a program that is linked with th= e Library has the freedom and the wherewithal to run that program using a m= odified version of the Library. + +The precise terms and conditions for copying, distribution and modificatio= n follow. Pay close attention to the difference between a "work based on th= e library" and a "work that uses the library". The former contains code der= ived from the library, whereas the latter must be combined with the library= in order to run. + + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License Agreement applies to any software library or other program= which contains a notice placed by the copyright holder or other authorized= party saying it may be distributed under the terms of this Lesser General = Public License (also called "this License"). Each licensee is addressed as = "you". + +A "library" means a collection of software functions and/or data prepared = so as to be conveniently linked with application programs (which use some o= f those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which ha= s been distributed under these terms. A "work based on the Library" means e= ither the Library or any derivative work under copyright law: that is to sa= y, a work containing the Library or a portion of it, either verbatim or wit= h modifications and/or translated straightforwardly into another language. = (Hereinafter, translation is included without limitation in the term "modif= ication".) + +"Source code" for a work means the preferred form of the work for making m= odifications to it. For a library, complete source code means all the sourc= e code for all modules it contains, plus any associated interface definitio= n files, plus the scripts used to control compilation and installation of t= he library. + +Activities other than copying, distribution and modification are not cover= ed by this License; they are outside its scope. The act of running a progra= m using the Library is not restricted, and output from such a program is co= vered only if its contents constitute a work based on the Library (independ= ent of the use of the Library in a tool for writing it). Whether that is tr= ue depends on what the Library does and what the program that uses the Libr= ary does. + +1. You may copy and distribute verbatim copies of the Library's complete s= ource code as you receive it, in any medium, provided that you conspicuousl= y and appropriately publish on each copy an appropriate copyright notice an= d disclaimer of warranty; keep intact all the notices that refer to this Li= cense and to the absence of any warranty; and distribute a copy of this Lic= ense along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you = may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it,= thus forming a work based on the Library, and copy and distribute such mod= ifications or work under the terms of Section 1 above, provided that you al= so meet all of these conditions: + + +a) The modified work must itself be a software library. +b) You must cause the files modified to carry prominent notices stating th= at you changed the files and the date of any change. +c) You must cause the whole of the work to be licensed at no charge to all= third parties under the terms of this License. +d) If a facility in the modified Library refers to a function or a table o= f data to be supplied by an application program that uses the facility, oth= er than as an argument passed when the facility is invoked, then you must m= ake a good faith effort to ensure that, in the event an application does no= t supply such function or table, the facility still operates, and performs = whatever part of its purpose remains meaningful. +(For example, a function in a library to compute square roots has a purpos= e that is entirely well-defined independent of the application. Therefore, = Subsection 2d requires that any application-supplied function or table used= by this function must be optional: if the application does not supply it, = the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable = sections of that work are not derived from the Library, and can be reasonab= ly considered independent and separate works in themselves, then this Licen= se, and its terms, do not apply to those sections when you distribute them = as separate works. But when you distribute the same sections as part of a w= hole which is a work based on the Library, the distribution of the whole mu= st be on the terms of this License, whose permissions for other licensees e= xtend to the entire whole, and thus to each and every part regardless of wh= o wrote it. + +Thus, it is not the intent of this section to claim rights or contest your= rights to work written entirely by you; rather, the intent is to exercise = the right to control the distribution of derivative or collective works bas= ed on the Library. + +In addition, mere aggregation of another work not based on the Library wit= h the Library (or with a work based on the Library) on a volume of a storag= e or distribution medium does not bring the other work under the scope of t= his License. + +3. You may opt to apply the terms of the ordinary GNU General Public Licen= se instead of this License to a given copy of the Library. To do this, you = must alter all the notices that refer to this License, so that they refer t= o the ordinary GNU General Public License, version 2, instead of to this Li= cense. (If a newer version than version 2 of the ordinary GNU General Publi= c License has appeared, then you can specify that version instead if you wi= sh.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy= , so the ordinary GNU General Public License applies to all subsequent copi= es and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Librar= y into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of = it, under Section 2) in object code or executable form under the terms of S= ections 1 and 2 above provided that you accompany it with the complete corr= esponding machine-readable source code, which must be distributed under the= terms of Sections 1 and 2 above on a medium customarily used for software = interchange. + +If distribution of object code is made by offering access to copy from a d= esignated place, then offering equivalent access to copy the source code fr= om the same place satisfies the requirement to distribute the source code, = even though third parties are not compelled to copy the source along with t= he object code. + +5. A program that contains no derivative of any portion of the Library, bu= t is designed to work with the Library by being compiled or linked with it,= is called a "work that uses the Library". Such a work, in isolation, is no= t a derivative work of the Library, and therefore falls outside the scope o= f this License. + +However, linking a "work that uses the Library" with the Library creates a= n executable that is a derivative of the Library (because it contains porti= ons of the Library), rather than a "work that uses the library". The execut= able is therefore covered by this License. Section 6 states terms for distr= ibution of such executables. + +When a "work that uses the Library" uses material from a header file that = is part of the Library, the object code for the work may be a derivative wo= rk of the Library even though the source code is not. Whether this is true = is especially significant if the work can be linked without the Library, or= if the work is itself a library. The threshold for this to be true is not = precisely defined by law. + +If such an object file uses only numerical parameters, data structure layo= uts and accessors, and small macros and small inline functions (ten lines o= r less in length), then the use of the object file is unrestricted, regardl= ess of whether it is legally a derivative work. (Executables containing thi= s object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute = the object code for the work under the terms of Section 6. Any executables = containing that work also fall under Section 6, whether or not they are lin= ked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "= work that uses the Library" with the Library to produce a work containing p= ortions of the Library, and distribute that work under terms of your choice= , provided that the terms permit modification of the work for the customer'= s own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library= is used in it and that the Library and its use are covered by this License= . You must supply a copy of this License. If the work during execution disp= lays copyright notices, you must include the copyright notice for the Libra= ry among them, as well as a reference directing the user to the copy of thi= s License. Also, you must do one of these things: + + +a) Accompany the work with the complete corresponding machine-readable sou= rce code for the Library including whatever changes were used in the work (= which must be distributed under Sections 1 and 2 above); and, if the work i= s an executable linked with the Library, with the complete machine-readable= "work that uses the Library", as object code and/or source code, so that t= he user can modify the Library and then relink to produce a modified execut= able containing the modified Library. (It is understood that the user who c= hanges the contents of definitions files in the Library will not necessaril= y be able to recompile the application to use the modified definitions.) +b) Use a suitable shared library mechanism for linking with the Library. A= suitable mechanism is one that (1) uses at run time a copy of the library = already present on the user's computer system, rather than copying library = functions into the executable, and (2) will operate properly with a modifie= d version of the library, if the user installs one, as long as the modified= version is interface-compatible with the version that the work was made wi= th. +c) Accompany the work with a written offer, valid for at least three years= , to give the same user the materials specified in Subsection 6a, above, fo= r a charge no more than the cost of performing this distribution. +d) If distribution of the work is made by offering access to copy from a d= esignated place, offer equivalent access to copy the above specified materi= als from the same place. +e) Verify that the user has already received a copy of these materials or = that you have already sent this user a copy. +For an executable, the required form of the "work that uses the Library" m= ust include any data and utility programs needed for reproducing the execut= able from it. However, as a special exception, the materials to be distribu= ted need not include anything that is normally distributed (in either sourc= e or binary form) with the major components (compiler, kernel, and so on) o= f the operating system on which the executable runs, unless that component = itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions o= f other proprietary libraries that do not normally accompany the operating = system. Such a contradiction means you cannot use both them and the Library= together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library s= ide-by-side in a single library together with other library facilities not = covered by this License, and distribute such a combined library, provided t= hat the separate distribution of the work based on the Library and of the o= ther library facilities is otherwise permitted, and provided that you do th= ese two things: + + +a) Accompany the combined library with a copy of the same work based on th= e Library, uncombined with any other library facilities. This must be distr= ibuted under the terms of the Sections above. +b) Give prominent notice with the combined library of the fact that part o= f it is a work based on the Library, and explaining where to find the accom= panying uncombined form of the same work. +8. You may not copy, modify, sublicense, link with, or distribute the Libr= ary except as expressly provided under this License. Any attempt otherwise = to copy, modify, sublicense, link with, or distribute the Library is void, = and will automatically terminate your rights under this License. However, p= arties who have received copies, or rights, from you under this License wil= l not have their licenses terminated so long as such parties remain in full= compliance. + +9. You are not required to accept this License, since you have not signed = it. However, nothing else grants you permission to modify or distribute the= Library or its derivative works. These actions are prohibited by law if yo= u do not accept this License. Therefore, by modifying or distributing the L= ibrary (or any work based on the Library), you indicate your acceptance of = this License to do so, and all its terms and conditions for copying, distri= buting or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Libra= ry), the recipient automatically receives a license from the original licen= sor to copy, distribute, link with or modify the Library subject to these t= erms and conditions. You may not impose any further restrictions on the rec= ipients' exercise of the rights granted herein. You are not responsible for= enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infri= ngement or for any other reason (not limited to patent issues), conditions = are imposed on you (whether by court order, agreement or otherwise) that co= ntradict the conditions of this License, they do not excuse you from the co= nditions of this License. If you cannot distribute so as to satisfy simulta= neously your obligations under this License and any other pertinent obligat= ions, then as a consequence you may not distribute the Library at all. For = example, if a patent license would not permit royalty-free redistribution o= f the Library by all those who receive copies directly or indirectly throug= h you, then the only way you could satisfy both it and this License would b= e to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any = particular circumstance, the balance of the section is intended to apply, a= nd the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patent= s or other property right claims or to contest validity of any such claims;= this section has the sole purpose of protecting the integrity of the free = software distribution system which is implemented by public license practic= es. Many people have made generous contributions to the wide range of softw= are distributed through that system in reliance on consistent application o= f that system; it is up to the author/donor to decide if he or she is willi= ng to distribute software through any other system and a licensee cannot im= pose that choice. + +This section is intended to make thoroughly clear what is believed to be a= consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain= countries either by patents or by copyrighted interfaces, the original cop= yright holder who places the Library under this License may add an explicit= geographical distribution limitation excluding those countries, so that di= stribution is permitted only in or among countries not thus excluded. In su= ch case, this License incorporates the limitation as if written in the body= of this License. + +13. The Free Software Foundation may publish revised and/or new versions o= f the Lesser General Public License from time to time. Such new versions wi= ll be similar in spirit to the present version, but may differ in detail to= address new problems or concerns. + +Each version is given a distinguishing version number. If the Library spec= ifies a version number of this License which applies to it and "any later v= ersion", you have the option of following the terms and conditions either o= f that version or of any later version published by the Free Software Found= ation. If the Library does not specify a license version number, you may ch= oose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free progra= ms whose distribution conditions are incompatible with these, write to the = author to ask for permission. For software which is copyrighted by the Free= Software Foundation, write to the Free Software Foundation; we sometimes m= ake exceptions for this. Our decision will be guided by the two goals of pr= eserving the free status of all derivatives of our free software and of pro= moting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY F= OR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHE= RWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE = THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLI= ED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILIT= Y AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY A= ND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTI= VE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING = WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTR= IBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDI= NG ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF= THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS= OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR TH= IRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE)= , EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF= SUCH DAMAGES. + + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Libraries +If you develop a new library, and you want it to be of the greatest possib= le use to the public, we recommend making it free software that everyone ca= n redistribute and change. You can do so by permitting redistribution under= these terms (or, alternatively, under the terms of the ordinary General Pu= blic License). + +To apply these terms, attach the following notices to the library. It is s= afest to attach them to the start of each source file to most effectively c= onvey the exclusion of warranty; and each file should have at least the "co= pyright" line and a pointer to where the full notice is found. + + +one line to give the library's name and an idea of what it does. +Copyright (C) year name of author + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; If not, see . + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your sc= hool, if any, to sign a "copyright disclaimer" for the library, if necessar= y. Here is a sample; alter the names: + + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice + +That's all there is to it! diff --git a/tools/golang/xenlight/README.md b/tools/golang/xenlight/README= .md new file mode 100644 index 0000000000..046f86ab3e --- /dev/null +++ b/tools/golang/xenlight/README.md @@ -0,0 +1,17 @@ +# xenlight + +## About + +The xenlight package provides Go bindings to Xen's libxl C library via cgo= . The package is currently in an unstable "experimental" state. This means = the package is ready for initial use and evaluation, but is not yet fully f= unctional. Namely, only a subset of libxl's API is implemented, and breakin= g changes may occur in future package versions. + +Much of the package is generated using the libxl IDL. Changes to the gener= ated code can be made by modifying `tools/golang/xenlight/gengotypes.py` in= the xen.git tree. + +## Getting Started + +```go +import ( + "xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight" +) +``` + +The module is not yet tagged independently of xen.git; if you don=E2=80=99= t specify the version, you=E2=80=99ll get the most recent development versi= on, which is probably not what you want. A better option would be to speci= fy a Xen release tag; for instance: `go get xenbits.xenproject.org/git-http= /xen.git/tools/golang/xenlight@RELEASE-4.14.0`. diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 6b4f492550..3eaa5a3d63 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -14,6 +14,8 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; If not, see . */ + +// Package xenlight provides bindings to Xen's libxl C library. package xenlight =20 /* --=20 2.17.1