From patchwork Mon Oct 7 15:13:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11177801 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3502139A for ; Mon, 7 Oct 2019 15:15:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 961CE2053B for ; Mon, 7 Oct 2019 15:15:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q4W1yxec" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 961CE2053B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUiS-0007GU-K2; Mon, 07 Oct 2019 15:14:28 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUiQ-0007FA-Og for xen-devel@lists.xenproject.org; Mon, 07 Oct 2019 15:14:26 +0000 X-Inumbo-ID: 06a3ea4a-e915-11e9-80e3-bc764e2007e4 Received: from mail-qt1-x82b.google.com (unknown [2607:f8b0:4864:20::82b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 06a3ea4a-e915-11e9-80e3-bc764e2007e4; Mon, 07 Oct 2019 15:13:32 +0000 (UTC) Received: by mail-qt1-x82b.google.com with SMTP id o12so19675056qtf.3 for ; Mon, 07 Oct 2019 08:13:32 -0700 (PDT) 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:content-transfer-encoding; bh=cKsDZtrssBpcweVVwaKyi4QvfbtI/LxHgAmAPdIpSYI=; b=Q4W1yxecJJCdwRtrWtwRyuHmEfgECPXwzg6eXJcByiv/OXGP+ocqBqAnrS4QduW/KL npaHCpKAmmeg4B7iuxBjJWx+0hGb/Q7VJ2anYu00lZFVxrvnzw5L+p1NDqIONTo6MsyX elnaba0fXFTH2NhVX/j8cm/oGoA2ywBR2/QdA/aX3B+79Yh9tEQ3CPXrby3+8MOYepNT sFm+leYbmHu/aEENVRuDkOFE3ynaamCGiXTWDUIqYKJ4LGRZslCz6Ch0AsXbos9trz8w jF5xUejhdbhkJtsfLmg+fP9zBh1ntm7A+M6yB1b5d9utBdXHhQThA3UNBYASjxUW6wfW +Msw== 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:content-transfer-encoding; bh=cKsDZtrssBpcweVVwaKyi4QvfbtI/LxHgAmAPdIpSYI=; b=Hm0SZ7OWVLEcIqtUf9ZWXoEEkIUotAP9E0SnpObl23d6oP6B4hB4JQUebFQ5O2InnM 9oqnumhw5f0ii16VVVjmFq4DAaHXFkIR7Lr0+Mif5a6uzUsWrQ+DO/2XheCJcQ+Tga2J pH695epniOazGM2g/IAdwgrDcOkt1wCLPYAmRsxMjFJ/JiVxHwD2RzMb6ITpiEH/hGu+ T+iOhC7e8lT2Y6RVijxRAeyoMP9CsdSVJCCbXPJvrIW12WgmAGjOvjfIKfYI80QCqnGh gUk8vrLO3PLhYIlh/a0jBTkhj2NOQvKEAmBdw34kIIi0xg/mXUefWpq4FLVtHQF/tlK0 YeOQ== X-Gm-Message-State: APjAAAVJwZLIMyMhwULGJW+nmmLkAnNWLfdDHh8tDbdNv9dt41iWKTYs gBz/Ow8w5XGBnEid/uP85VsBBBDa X-Google-Smtp-Source: APXvYqxhg7+ci7sA0erkuhX4uCl54cjYDfjSR5xt4jpb5hv0DTcWfLhKji159Xi5zni5gy10XLfmaQ== X-Received: by 2002:aed:3576:: with SMTP id b51mr30894758qte.378.1570461211859; Mon, 07 Oct 2019 08:13:31 -0700 (PDT) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id c185sm8354313qkg.74.2019.10.07.08.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:13:31 -0700 (PDT) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Mon, 7 Oct 2019 11:13:01 -0400 Message-Id: <18a733f00beec2b7ec9fc729fd90e2a6c456987b.1570456846.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 14/24] golang/xenlight: generate structs from the IDL X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Nick Rosbrook Add struct and keyed union generation to gengotypes.py. For keyed unions, use a method similar to gRPC's oneof to interpret C unions as Go types. Meaning, for a given struct with a union field, generate a struct for each sub-struct defined in the union. Then, define an interface of one method which is implemented by each of the defined sub-structs. For example: type domainBuildInfoTypeUnion interface { isdomainBuildInfoTypeUnion() } type DomainBuildInfoTypeUnionHvm struct { // HVM-specific fields... } func (x DomainBuildInfoTypeUnionHvm) isdomainBuildInfoTypeUnion() {} type DomainBuildInfoTypeUnionPv struct { // PV-specific fields... } func (x DomainBuildInfoTypeUnionPv) isdomainBuildInfoTypeUnion() {} type DomainBuildInfoTypeUnionPvh struct { // PVH-specific fields... } func (x DomainBuildInfoTypeUnionPvh) isdomainBuildInfoTypeUnion() {} Then, remove existing struct definitions in xenlight.go that conflict with the generated types, and modify existing marshaling functions to align with the new type definitions. Notably, drop "time" package since fields of type time.Duration are now of type uint64. Signed-off-by: Nick Rosbrook --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/gengotypes.py | 103 +++ tools/golang/xenlight/xenlight.go | 123 +--- tools/golang/xenlight/xenlight_types.go | 834 ++++++++++++++++++++++++ 3 files changed, 952 insertions(+), 108 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index 59307492cb..c8513b79e0 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -18,6 +18,10 @@ builtin_type_names = { idl.uint64.typename: 'uint64', } +# List of strings that need to be written to a file +# after a struct definition. +type_extras = [] + def xenlight_golang_generate_types(path = None, types = None, comment = None): """ Generate a .go file (xenlight_types.go by default) @@ -35,6 +39,13 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None): f.write(xenlight_golang_type_define(ty)) f.write('\n') + # Append extra types + for extra in type_extras: + f.write(extra) + f.write('\n') + + del type_extras[:] + go_fmt(path) def xenlight_golang_type_define(ty = None): @@ -43,6 +54,9 @@ def xenlight_golang_type_define(ty = None): if isinstance(ty, idl.Enumeration): s += xenlight_golang_define_enum(ty) + elif isinstance(ty, idl.Aggregate): + s += xenlight_golang_define_struct(ty) + return s def xenlight_golang_define_enum(ty = None): @@ -65,6 +79,95 @@ def xenlight_golang_define_enum(ty = None): return s +def xenlight_golang_define_struct(ty = None, typename = None, nested = False): + s = '' + name = '' + + if typename is not None: + name = xenlight_golang_fmt_name(typename) + else: + name = xenlight_golang_fmt_name(ty.typename) + + # Begin struct definition + if nested: + s += '{} struct {{\n'.format(name) + else: + s += 'type {} struct {{\n'.format(name) + + # Write struct fields + for f in ty.fields: + if f.type.typename is not None: + if isinstance(f.type, idl.Array): + typename = f.type.elem_type.typename + typename = xenlight_golang_fmt_name(typename) + name = xenlight_golang_fmt_name(f.name) + + s += '{} []{}\n'.format(name, typename) + else: + typename = f.type.typename + typename = xenlight_golang_fmt_name(typename) + name = xenlight_golang_fmt_name(f.name) + + s += '{} {}\n'.format(name, typename) + + elif isinstance(f.type, idl.Struct): + s += xenlight_golang_define_struct(f.type, typename=f.name, nested=True) + + elif isinstance(f.type, idl.KeyedUnion): + s += xenlight_golang_define_union(f.type, ty.typename) + + else: + raise Exception('type {} not supported'.format(f.type)) + + # End struct definition + s += '}\n' + + return s + +def xenlight_golang_define_union(ty = None, structname = ''): + """ + Generate the Go translation of a KeyedUnion. + + Define an unexported interface to be used as + the type of the union. Then, define a struct + for each field of the union which implements + that interface. + """ + s = '' + + interface_name = '{}_{}_union'.format(structname, ty.keyvar.name) + interface_name = xenlight_golang_fmt_name(interface_name, exported=False) + + s += 'type {} interface {{\n'.format(interface_name) + s += 'is{}()\n'.format(interface_name) + s += '}\n' + + type_extras.append(s) + + for f in ty.fields: + if f.type is None: + continue + + # Define struct + name = '{}_{}_union_{}'.format(structname, ty.keyvar.name, f.name) + s = xenlight_golang_define_struct(f.type, typename=name) + type_extras.append(s) + + # Define function to implement 'union' interface + name = xenlight_golang_fmt_name(name) + s = 'func (x {}) is{}(){{}}\n'.format(name, interface_name) + type_extras.append(s) + + # Return the field entries, but the associated types are generated later. + fname = xenlight_golang_fmt_name(ty.keyvar.name) + ftype = xenlight_golang_fmt_name(ty.keyvar.type.typename) + s = '{} {}\n'.format(fname, ftype) + + fname = xenlight_golang_fmt_name('{}_union'.format(ty.keyvar.name)) + s += '{} {}\n'.format(fname, interface_name) + + return s + def xenlight_golang_fmt_name(name, exported = True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 8d520bbd98..0adb12d1bf 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -33,7 +33,6 @@ import "C" import ( "fmt" - "time" "unsafe" ) @@ -435,30 +434,6 @@ func (bm *Bitmap) toC() (C.libxl_bitmap, error) { return cbm, nil } -/* - * Types: IDL - * - * FIXME: Generate these automatically from the IDL - */ - -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 - NrNodes uint32 - HwCap Hwcap - CapHvm bool - CapHvmDirectio bool -} - func (cphys *C.libxl_physinfo) toGo() (physinfo *Physinfo) { physinfo = &Physinfo{} @@ -481,22 +456,6 @@ func (cphys *C.libxl_physinfo) toGo() (physinfo *Physinfo) { return } -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 -} - func (cinfo *C.libxl_version_info) toGo() (info *VersionInfo) { info = &VersionInfo{} info.XenVersionMajor = int(cinfo.xen_version_major) @@ -530,31 +489,6 @@ func (dt DomainType) String() (str string) { return } -type Dominfo struct { - Uuid Uuid - Domid Domid - Ssidref uint32 - SsidLabel string - Running bool - Blocked bool - Paused bool - Shutdown bool - Dying bool - NeverStop bool - - ShutdownReason int32 - OutstandingMemkb MemKB - CurrentMemkb MemKB - SharedMemkb MemKB - PagedMemkb MemKB - MaxMemkb MemKB - CpuTime time.Duration - VcpuMaxId uint32 - VcpuOnline uint32 - Cpupool uint32 - DomainType int32 -} - func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { di = &Dominfo{} @@ -568,17 +502,17 @@ func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { di.Shutdown = bool(cdi.shutdown) di.Dying = bool(cdi.dying) di.NeverStop = bool(cdi.never_stop) - di.ShutdownReason = int32(cdi.shutdown_reason) - di.OutstandingMemkb = MemKB(cdi.outstanding_memkb) - di.CurrentMemkb = MemKB(cdi.current_memkb) - di.SharedMemkb = MemKB(cdi.shared_memkb) - di.PagedMemkb = MemKB(cdi.paged_memkb) - di.MaxMemkb = MemKB(cdi.max_memkb) - di.CpuTime = time.Duration(cdi.cpu_time) + di.ShutdownReason = ShutdownReason(cdi.shutdown_reason) + di.OutstandingMemkb = uint64(cdi.outstanding_memkb) + di.CurrentMemkb = uint64(cdi.current_memkb) + di.SharedMemkb = uint64(cdi.shared_memkb) + di.PagedMemkb = uint64(cdi.paged_memkb) + di.MaxMemkb = uint64(cdi.max_memkb) + di.CpuTime = uint64(cdi.cpu_time) di.VcpuMaxId = uint32(cdi.vcpu_max_id) di.VcpuOnline = uint32(cdi.vcpu_online) di.Cpupool = uint32(cdi.cpupool) - di.DomainType = int32(cdi.domain_type) + di.DomainType = DomainType(cdi.domain_type) return } @@ -614,27 +548,11 @@ func SchedulerFromString(name string) (s Scheduler, err error) { return } -// libxl_cpupoolinfo = Struct("cpupoolinfo", [ -// ("poolid", uint32), -// ("pool_name", string), -// ("sched", libxl_scheduler), -// ("n_dom", uint32), -// ("cpumap", libxl_bitmap) -// ], dir=DIR_OUT) - -type CpupoolInfo struct { - Poolid uint32 - PoolName string - Scheduler Scheduler - DomainCount int - Cpumap Bitmap -} - -func (cci C.libxl_cpupoolinfo) toGo() (gci CpupoolInfo) { +func (cci C.libxl_cpupoolinfo) toGo() (gci Cpupoolinfo) { gci.Poolid = uint32(cci.poolid) gci.PoolName = C.GoString(cci.pool_name) - gci.Scheduler = Scheduler(cci.sched) - gci.DomainCount = int(cci.n_dom) + gci.Sched = Scheduler(cci.sched) + gci.NDom = uint32(cci.n_dom) gci.Cpumap.fromC(&cci.cpumap) return @@ -642,7 +560,7 @@ func (cci C.libxl_cpupoolinfo) toGo() (gci CpupoolInfo) { // libxl_cpupoolinfo * libxl_list_cpupool(libxl_ctx*, int *nb_pool_out); // void libxl_cpupoolinfo_list_free(libxl_cpupoolinfo *list, int nb_pool); -func (Ctx *Context) ListCpupool() (list []CpupoolInfo) { +func (Ctx *Context) ListCpupool() (list []Cpupoolinfo) { err := Ctx.CheckOpen() if err != nil { return @@ -669,7 +587,7 @@ func (Ctx *Context) ListCpupool() (list []CpupoolInfo) { } // int libxl_cpupool_info(libxl_ctx *ctx, libxl_cpupoolinfo *info, uint32_t poolid); -func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool CpupoolInfo) { +func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool Cpupoolinfo) { err := Ctx.CheckOpen() if err != nil { return @@ -899,7 +817,7 @@ func (Ctx *Context) CpupoolMovedomain(Poolid uint32, Id Domid) (err error) { // // Utility functions // -func (Ctx *Context) CpupoolFindByName(name string) (info CpupoolInfo, found bool) { +func (Ctx *Context) CpupoolFindByName(name string) (info Cpupoolinfo, found bool) { plist := Ctx.ListCpupool() for i := range plist { @@ -1302,24 +1220,13 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) { return } -type Vcpuinfo struct { - Vcpuid uint32 - Cpu uint32 - Online bool - Blocked bool - Running bool - VCpuTime time.Duration - Cpumap Bitmap - CpumapSoft Bitmap -} - func (cvci C.libxl_vcpuinfo) toGo() (gvci Vcpuinfo) { gvci.Vcpuid = uint32(cvci.vcpuid) gvci.Cpu = uint32(cvci.cpu) gvci.Online = bool(cvci.online) gvci.Blocked = bool(cvci.blocked) gvci.Running = bool(cvci.running) - gvci.VCpuTime = time.Duration(cvci.vcpu_time) + gvci.VcpuTime = uint64(cvci.vcpu_time) gvci.Cpumap.fromC(&cvci.cpumap) gvci.CpumapSoft.fromC(&cvci.cpumap_soft) diff --git a/tools/golang/xenlight/xenlight_types.go b/tools/golang/xenlight/xenlight_types.go index 05f62182b7..8dd435c0dd 100644 --- a/tools/golang/xenlight/xenlight_types.go +++ b/tools/golang/xenlight/xenlight_types.go @@ -265,6 +265,182 @@ const ( VkbBackendLinux VkbBackend = 2 ) +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 + Uuid Uuid + Xsdata KeyValueList + Platformdata KeyValueList + Poolid uint32 + PoolName string + RunHotplugScripts Defbool + DriverDomain 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 ( @@ -280,6 +456,11 @@ const ( TeeTypeOptee TeeType = 1 ) +type RdmReserve struct { + Strategy RdmReserveStrategy + Policy RdmReservePolicy +} + type Altp2MMode int const ( @@ -289,6 +470,277 @@ const ( Altp2MModeLimited Altp2MMode = 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 + 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 ( @@ -304,6 +756,92 @@ const ( UsbdevTypeHostdev UsbdevType = 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 ( @@ -334,6 +872,14 @@ const ( VsndPcmFormatGsm VsndPcmFormat = 25 ) +type VsndParams struct { + SampleRates []uint32 + SampleFormats []VsndPcmFormat + ChannelsMin uint32 + ChannelsMax uint32 + BufferSize uint32 +} + type VsndStreamType int const ( @@ -341,6 +887,229 @@ const ( VsndStreamTypeC VsndStreamType = 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 ( @@ -351,6 +1120,38 @@ const ( EventTypeDomainCreateConsoleAvailable EventType = 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 ( @@ -370,9 +1171,42 @@ const ( PsrCbmTypeMbaThrtl PsrCbmType = 5 ) +type PsrCatInfo struct { + Id uint32 + CosMax uint32 + CbmLen uint32 + CdpEnabled bool +} + type PsrFeatType int const ( PsrFeatTypeCat PsrFeatType = 1 PsrFeatTypeMba PsrFeatType = 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() {}