[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] golang/xenlight: generate structs from the IDL
commit 42e71a4d1b544fc5e4073ad7e9f56cdf0bd93afe Author: Nick Rosbrook <rosbrookn@xxxxxxxxxxxx> AuthorDate: Mon Dec 16 18:08:08 2019 +0000 Commit: George Dunlap <george.dunlap@xxxxxxxxxx> CommitDate: Mon Dec 16 18:08:08 2019 +0000 golang/xenlight: generate structs from the IDL 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 <rosbrookn@xxxxxxxxxxxx> Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- tools/golang/xenlight/gengotypes.py | 119 ++++- tools/golang/xenlight/types.gen.go | 836 ++++++++++++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 123 +----- 3 files changed, 966 insertions(+), 112 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index 2211541547..8963b14eee 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -32,18 +32,32 @@ def xenlight_golang_generate_types(path = None, types = None, comment = None): f.write('package xenlight\n') for ty in types: - f.write(xenlight_golang_type_define(ty)) + (tdef, extras) = xenlight_golang_type_define(ty) + + f.write(tdef) f.write('\n') + # Append extra types + for extra in extras: + f.write(extra) + f.write('\n') + go_fmt(path) def xenlight_golang_type_define(ty = None): - s = '' + """ + Generate the Go type definition of ty. + Return a tuple that contains a string with the + type definition, and a (potentially empty) list + of extra definitions that are associated with + this type. + """ if isinstance(ty, idl.Enumeration): - s += xenlight_golang_define_enum(ty) + return (xenlight_golang_define_enum(ty), []) - return s + elif isinstance(ty, idl.Aggregate): + return xenlight_golang_define_struct(ty) def xenlight_golang_define_enum(ty = None): s = '' @@ -65,6 +79,103 @@ def xenlight_golang_define_enum(ty = None): return s +def xenlight_golang_define_struct(ty = None, typename = None, nested = False): + s = '' + extras = [] + 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): + r = xenlight_golang_define_struct(f.type, typename=f.name, nested=True) + + s += r[0] + extras.extend(r[1]) + + elif isinstance(f.type, idl.KeyedUnion): + r = xenlight_golang_define_union(f.type, ty.typename) + + s += r[0] + extras.extend(r[1]) + + else: + raise Exception('type {} not supported'.format(f.type)) + + # End struct definition + s += '}\n' + + return (s,extras) + +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 = '' + extras = [] + + 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' + + 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) + r = xenlight_golang_define_struct(f.type, typename=name) + extras.append(r[0]) + extras.extend(r[1]) + + # Define function to implement 'union' interface + name = xenlight_golang_fmt_name(name) + s = 'func (x {}) is{}(){{}}\n'.format(name, interface_name) + extras.append(s) + + 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,extras) + def xenlight_golang_fmt_name(name, exported = True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go index 4a52eab048..ede49b4886 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -275,6 +275,183 @@ const ( PassthroughSharePt Passthrough = 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 + Uuid Uuid + Xsdata KeyValueList + Platformdata KeyValueList + Poolid uint32 + PoolName string + RunHotplugScripts Defbool + DriverDomain Defbool + Passthrough Passthrough +} + +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 ( @@ -290,6 +467,11 @@ const ( TeeTypeOptee TeeType = 1 ) +type RdmReserve struct { + Strategy RdmReserveStrategy + Policy RdmReservePolicy +} + type Altp2MMode int const ( @@ -299,6 +481,278 @@ 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 + 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 ( @@ -314,6 +768,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 ( @@ -344,6 +884,14 @@ const ( VsndPcmFormatGsm VsndPcmFormat = 25 ) +type VsndParams struct { + SampleRates []uint32 + SampleFormats []VsndPcmFormat + ChannelsMin uint32 + ChannelsMax uint32 + BufferSize uint32 +} + type VsndStreamType int const ( @@ -351,6 +899,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 ( @@ -361,6 +1132,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 ( @@ -380,9 +1183,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() {} diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index b395963512..8f41047726 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -33,7 +33,6 @@ import "C" import ( "fmt" - "time" "unsafe" ) @@ -408,30 +407,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{} @@ -454,22 +429,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) @@ -503,31 +462,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{} @@ -541,17 +475,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 } @@ -587,27 +521,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 @@ -615,7 +533,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 @@ -642,7 +560,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 @@ -872,7 +790,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 { @@ -1275,24 +1193,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) -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |