From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992919; cv=none; d=zohomail.com; s=zohoarc; b=PFAjIMBZNn97pKexFLcye1N5NW3k8RjQZhEI52imiMm5dHtFr9ZExLTrJvYcgkPcJ3T8E01n+OzIogVAKUuFSHqq3GXmjSVpYFWfjhd86272N+XCF717YXEr7f/2yZS0PqFV7YGSX1QaGylnRftamVfsb+qwieqUGlHrrFkL3y8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992919; 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=4eBYz9QITeuhVUDLHxA2Pyu/S/F06e1X/fUdV8XqNzg=; b=lNH6qMg+yjzyPHwcJOxGfnsAghibIKph+gN+3gO7F6hG33bGNjLU8/FOZOshMfGE3HD00g+EEuPCeLAbNrnZppkwdN19xq2hwLkdqlPms4wgp+A6XA3gzvPUY56LC+8sKVWC+uNukcqb5xEpGqqAWjd+t4KjZDJxGWQFNV2grxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992919902995.5702779324196; Tue, 10 Dec 2019 07:48:39 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehjx-0002re-6X; Tue, 10 Dec 2019 15:47:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehjv-0002rO-Px for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:47:55 +0000 Received: from mail-qt1-x833.google.com (unknown [2607:f8b0:4864:20::833]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6c421576-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:47:51 +0000 (UTC) Received: by mail-qt1-x833.google.com with SMTP id i12so2006253qtp.6 for ; Tue, 10 Dec 2019 07:47:51 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:49 -0800 (PST) X-Inumbo-ID: 6c421576-1b64-11ea-b6f1-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:content-transfer-encoding; bh=xJQbH0Nm/8lI641knvIgk1T9SXkoB93ydbAB30piTN8=; b=hiMwiCLMyfeEdX9fUWXhlKLG4wWBMC653+9gb9H6XMe6giXrIZ2yARUteHJM/IZVtU ME6Il1oWjHzACgj5KGNwW1TTWBVHpgQ0wxVquxu39LNecFxcExVYLQKY7DlNvFRQkAXG ApCHF0XeO80Vm3Dld7bG4ev44RzTAi90uY/ZRVrMCBg9Av6Bkl3/pONg/Kd2WFtDsmaW Z4Q97rG1TPZZHb/HQHmGxN8jtyyI4tY441d9nB1SIcl5djK/03Y2/rvf/ZPWhkEC977M F//zPyb9UM3HioDBGWNXfL9l82C/fgQAZeVGQwiHMEw9BhE+LwRGkOFezaD+O1n58mrk wvZw== 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=xJQbH0Nm/8lI641knvIgk1T9SXkoB93ydbAB30piTN8=; b=h/8ELqkEuC1oypg7QH4H/acM/f81PlNF9dToA0qhaLAQmEdkf1n5o8T3MaHQdJNlbL Ham5VbPl1badKo+bSu9WTzRCEcGgjdUYewokmTz5jlqvDZ6mBUs8YPB9K4GJ7laWeW0R cWgeNSgfJWWERBlClgGhzs3lEDSgACINtJ7YfXMWDximEPm3xTv5rxgKQNhcAuaUzgQc LqHt2u35eEaIfCeM15JQ4YIbI+gMsplsbOOHdKJfYu7eaWlPqSend5TSJ3TypHRAVCr4 R68Or5Lwh6kdiFPVVTIs495jguU4rbYVQ8dPietKBJWO04md1x9QC18e8koZNPC+9M6T Wk1g== X-Gm-Message-State: APjAAAUai4MwW8Xbtt7SMYGS4rvXX/EEo8ffDHFDMi9TFNDMxLQgx5yd Xs+9ypsUJtF+mzhqk2lXme++OXmE X-Google-Smtp-Source: APXvYqzkLQcGFFCj8WCuPc0UK1vZo/OqNYKunDz74jMsaH7RdBCkNP2yTQdv8EbnLzUFjmdvwndpxQ== X-Received: by 2002:aed:36e3:: with SMTP id f90mr10017101qtb.86.1575992870522; Tue, 10 Dec 2019 07:47:50 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:16 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 01/22] golang/xenlight: generate enum types from 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Introduce gengotypes.py to generate Go code the from IDL. As a first step, implement 'enum' type generation. As a result of the newly-generated code, remove the existing, and now conflicting definitions in xenlight.go. In the case of the Error type, rename the slice 'errors' to 'libxlErrors' so that it does not conflict with the standard library package 'errors.' And, negate the values used in 'libxlErrors' since the generated error values are negative. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Introduce Makefile targets for code generation - Re-generate Go code (includes new libxl_passtrhough enum). - Use *.gen.go naming convention for generated Go files. --- tools/golang/xenlight/Makefile | 18 +- tools/golang/xenlight/gengotypes.py | 109 ++++++++ tools/golang/xenlight/types.gen.go | 388 ++++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 140 ++-------- 4 files changed, 535 insertions(+), 120 deletions(-) create mode 100644 tools/golang/xenlight/gengotypes.py create mode 100644 tools/golang/xenlight/types.gen.go diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile index 0987305224..681f32c234 100644 --- a/tools/golang/xenlight/Makefile +++ b/tools/golang/xenlight/Makefile @@ -7,20 +7,21 @@ GOCODE_DIR ?=3D $(prefix)/share/gocode/ GOXL_PKG_DIR =3D /src/$(XEN_GOCODE_URL)/xenlight/ GOXL_INSTALL_DIR =3D $(GOCODE_DIR)$(GOXL_PKG_DIR) =20 -# PKGSOURCES: Files which comprise the distributed source package -PKGSOURCES =3D xenlight.go - GO ?=3D go =20 .PHONY: all all: build =20 .PHONY: package -package: $(XEN_GOPATH)$(GOXL_PKG_DIR)$(PKGSOURCES) +package: $(XEN_GOPATH)$(GOXL_PKG_DIR) =20 -$(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/$(PKGSOURCES): $(PKGSOURCES) +$(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/: %.gen.go $(INSTALL_DIR) $(XEN_GOPATH)$(GOXL_PKG_DIR) - $(INSTALL_DATA) $(PKGSOURCES) $(XEN_GOPATH)$(GOXL_PKG_DIR) + $(INSTALL_DATA) xenlight.go $(XEN_GOPATH)$(GOXL_PKG_DIR) + $(INSTALL_DATA) types.gen.go $(XEN_GOPATH)$(GOXL_PKG_DIR) + +%.gen.go: gengotypes.py $(XEN_ROOT)/tools/libxl/libxl_types.idl $(XEN_ROOT= )/tools/libxl/idl.py + XEN_ROOT=3D$(XEN_ROOT) $(PYTHON) gengotypes.py ../../libxl/libxl_types.idl =20 # Go will do its own dependency checking, and not actuall go through # with the build if none of the input files have changed. @@ -36,10 +37,11 @@ build: package .PHONY: install install: build $(INSTALL_DIR) $(DESTDIR)$(GOXL_INSTALL_DIR) - $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)$(PKGSOURCES) $(DESTDIR)$(GOX= L_INSTALL_DIR) + $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)xenlight.go $(DESTDIR)$(GOXL_= INSTALL_DIR) + $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)types.gen.go $(DESTDIR)$(GOXL= _INSTALL_DIR) =20 .PHONY: uninstall - rm -f $(addprefix $(DESTDIR)$(GOXL_INSTALL_DIR)/, $(PKGSOURCES)) + rm -rf $(DESTDIR)$(GOXL_INSTALL_DIR) =20 .PHONY: clean clean: diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py new file mode 100644 index 0000000000..2211541547 --- /dev/null +++ b/tools/golang/xenlight/gengotypes.py @@ -0,0 +1,109 @@ +#!/usr/bin/python + +import os +import sys + +sys.path.append('{}/tools/libxl'.format(os.environ['XEN_ROOT'])) +import idl + +# Go versions of some builtin types. +# Append the libxl-defined builtins after IDL parsing. +builtin_type_names =3D { + idl.bool.typename: 'bool', + idl.string.typename: 'string', + idl.integer.typename: 'int', + idl.uint8.typename: 'byte', + idl.uint16.typename: 'uint16', + idl.uint32.typename: 'uint32', + idl.uint64.typename: 'uint64', +} + +def xenlight_golang_generate_types(path =3D None, types =3D None, comment = =3D None): + """ + Generate a .go file (types.gen.go by default) + that contains a Go type for each type in types. + """ + if path is None: + path =3D 'types.gen.go' + + with open(path, 'w') as f: + if comment is not None: + f.write(comment) + f.write('package xenlight\n') + + for ty in types: + f.write(xenlight_golang_type_define(ty)) + f.write('\n') + + go_fmt(path) + +def xenlight_golang_type_define(ty =3D None): + s =3D '' + + if isinstance(ty, idl.Enumeration): + s +=3D xenlight_golang_define_enum(ty) + + return s + +def xenlight_golang_define_enum(ty =3D None): + s =3D '' + typename =3D '' + + if ty.typename is not None: + typename =3D xenlight_golang_fmt_name(ty.typename) + s +=3D 'type {} int\n'.format(typename) + + # Start const block + s +=3D 'const(\n' + + for v in ty.values: + name =3D xenlight_golang_fmt_name(v.name) + s +=3D '{} {} =3D {}\n'.format(name, typename, v.value) + + # End const block + s +=3D ')\n' + + return s + +def xenlight_golang_fmt_name(name, exported =3D True): + """ + Take a given type name and return an + appropriate Go type name. + """ + if name in builtin_type_names.keys(): + return builtin_type_names[name] + + # Name is not a builtin, format it for Go. + words =3D name.split('_') + + # Remove 'libxl' prefix + if words[0].lower() =3D=3D 'libxl': + words.remove(words[0]) + + if exported: + return ''.join(x.title() for x in words) + + return words[0] + ''.join(x.title() for x in words[1:]) + +def go_fmt(path): + """ Call go fmt on the given path. """ + os.system('go fmt {}'.format(path)) + +if __name__ =3D=3D '__main__': + idlname =3D sys.argv[1] + + (builtins, types) =3D idl.parse(idlname) + + for b in builtins: + name =3D b.typename + builtin_type_names[name] =3D xenlight_golang_fmt_name(name) + + header_comment=3D"""// DO NOT EDIT. + // + // This file is generated by: + // {} + // + """.format(' '.join(sys.argv)) + + xenlight_golang_generate_types(types=3Dtypes, + comment=3Dheader_comment) diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go new file mode 100644 index 0000000000..4a52eab048 --- /dev/null +++ b/tools/golang/xenlight/types.gen.go @@ -0,0 +1,388 @@ +// 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 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 Altp2MMode int + +const ( + Altp2MModeDisabled Altp2MMode =3D 0 + Altp2MModeMixed Altp2MMode =3D 1 + Altp2MModeExternal Altp2MMode =3D 2 + Altp2MModeLimited Altp2MMode =3D 3 +) + +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 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 VsndStreamType int + +const ( + VsndStreamTypeP VsndStreamType =3D 1 + VsndStreamTypeC VsndStreamType =3D 2 +) + +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 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 PsrFeatType int + +const ( + PsrFeatTypeCat PsrFeatType =3D 1 + PsrFeatTypeMba PsrFeatType =3D 2 +) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 902cbb839e..89ed439fd0 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -37,77 +37,42 @@ import ( "unsafe" ) =20 -/* - * Errors - */ - -type Error int - -const ( - ErrorNonspecific =3D Error(-C.ERROR_NONSPECIFIC) - ErrorVersion =3D Error(-C.ERROR_VERSION) - ErrorFail =3D Error(-C.ERROR_FAIL) - ErrorNi =3D Error(-C.ERROR_NI) - ErrorNomem =3D Error(-C.ERROR_NOMEM) - ErrorInval =3D Error(-C.ERROR_INVAL) - ErrorBadfail =3D Error(-C.ERROR_BADFAIL) - ErrorGuestTimedout =3D Error(-C.ERROR_GUEST_TIMEDOUT) - ErrorTimedout =3D Error(-C.ERROR_TIMEDOUT) - ErrorNoparavirt =3D Error(-C.ERROR_NOPARAVIRT) - ErrorNotReady =3D Error(-C.ERROR_NOT_READY) - ErrorOseventRegFail =3D Error(-C.ERROR_OSEVENT_REG_FAIL) - ErrorBufferfull =3D Error(-C.ERROR_BUFFERFULL) - ErrorUnknownChild =3D Error(-C.ERROR_UNKNOWN_CHILD) - ErrorLockFail =3D Error(-C.ERROR_LOCK_FAIL) - ErrorJsonConfigEmpty =3D Error(-C.ERROR_JSON_CONFIG_EMPTY) - ErrorDeviceExists =3D Error(-C.ERROR_DEVICE_EXISTS) - ErrorCheckpointDevopsDoesNotMatch =3D Error(-C.ERROR_CHECKPOINT_DEVOPS_DO= ES_NOT_MATCH) - ErrorCheckpointDeviceNotSupported =3D Error(-C.ERROR_CHECKPOINT_DEVICE_NO= T_SUPPORTED) - ErrorVnumaConfigInvalid =3D Error(-C.ERROR_VNUMA_CONFIG_INVALID) - ErrorDomainNotfound =3D Error(-C.ERROR_DOMAIN_NOTFOUND) - ErrorAborted =3D Error(-C.ERROR_ABORTED) - ErrorNotfound =3D Error(-C.ERROR_NOTFOUND) - ErrorDomainDestroyed =3D Error(-C.ERROR_DOMAIN_DESTROYED) - ErrorFeatureRemoved =3D Error(-C.ERROR_FEATURE_REMOVED) -) - -var errors =3D [...]string{ - ErrorNonspecific: "Non-specific error", - ErrorVersion: "Wrong version", - ErrorFail: "Failed", - ErrorNi: "Not Implemented", - ErrorNomem: "No memory", - ErrorInval: "Invalid argument", - ErrorBadfail: "Bad Fail", - ErrorGuestTimedout: "Guest timed out", - ErrorTimedout: "Timed out", - ErrorNoparavirt: "No Paravirtualization", - ErrorNotReady: "Not ready", - ErrorOseventRegFail: "OS event registration failed", - ErrorBufferfull: "Buffer full", - ErrorUnknownChild: "Unknown child", - ErrorLockFail: "Lock failed", - ErrorJsonConfigEmpty: "JSON config empty", - ErrorDeviceExists: "Device exists", - ErrorCheckpointDevopsDoesNotMatch: "Checkpoint devops does not match", - ErrorCheckpointDeviceNotSupported: "Checkpoint device not supported", - ErrorVnumaConfigInvalid: "VNUMA config invalid", - ErrorDomainNotfound: "Domain not found", - ErrorAborted: "Aborted", - ErrorNotfound: "Not found", - ErrorDomainDestroyed: "Domain destroyed", - ErrorFeatureRemoved: "Feature removed", +var libxlErrors =3D [...]string{ + -ErrorNonspecific: "Non-specific error", + -ErrorVersion: "Wrong version", + -ErrorFail: "Failed", + -ErrorNi: "Not Implemented", + -ErrorNomem: "No memory", + -ErrorInval: "Invalid argument", + -ErrorBadfail: "Bad Fail", + -ErrorGuestTimedout: "Guest timed out", + -ErrorTimedout: "Timed out", + -ErrorNoparavirt: "No Paravirtualization", + -ErrorNotReady: "Not ready", + -ErrorOseventRegFail: "OS event registration failed", + -ErrorBufferfull: "Buffer full", + -ErrorUnknownChild: "Unknown child", + -ErrorLockFail: "Lock failed", + -ErrorJsonConfigEmpty: "JSON config empty", + -ErrorDeviceExists: "Device exists", + -ErrorCheckpointDevopsDoesNotMatch: "Checkpoint devops does not match", + -ErrorCheckpointDeviceNotSupported: "Checkpoint device not supported", + -ErrorVnumaConfigInvalid: "VNUMA config invalid", + -ErrorDomainNotfound: "Domain not found", + -ErrorAborted: "Aborted", + -ErrorNotfound: "Not found", + -ErrorDomainDestroyed: "Domain destroyed", + -ErrorFeatureRemoved: "Feature removed", } =20 func (e Error) Error() string { - if 0 < int(e) && int(e) < len(errors) { - s :=3D errors[e] + if 0 < int(e) && int(e) < len(libxlErrors) { + s :=3D libxlErrors[e] if s !=3D "" { return s } } return fmt.Sprintf("libxl error: %d", -e) - } =20 /* @@ -236,18 +201,6 @@ func (cinfo *C.libxl_version_info) toGo() (info *Versi= onInfo) { return } =20 -type ShutdownReason int32 - -const ( - ShutdownReasonUnknown =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_UNKNOW= N) - ShutdownReasonPoweroff =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_POWERO= FF) - ShutdownReasonReboot =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_REBOOT) - ShutdownReasonSuspend =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_SUSPEN= D) - ShutdownReasonCrash =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_CRASH) - ShutdownReasonWatchdog =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_WATCHD= OG) - ShutdownReasonSoftReset =3D ShutdownReason(C.LIBXL_SHUTDOWN_REASON_SOFT_R= ESET) -) - func (sr ShutdownReason) String() (str string) { cstr :=3D C.libxl_shutdown_reason_to_string(C.libxl_shutdown_reason(sr)) str =3D C.GoString(cstr) @@ -255,14 +208,6 @@ func (sr ShutdownReason) String() (str string) { return } =20 -type DomainType int32 - -const ( - DomainTypeInvalid =3D DomainType(C.LIBXL_DOMAIN_TYPE_INVALID) - DomainTypeHvm =3D DomainType(C.LIBXL_DOMAIN_TYPE_HVM) - DomainTypePv =3D DomainType(C.LIBXL_DOMAIN_TYPE_PV) -) - func (dt DomainType) String() (str string) { cstr :=3D C.libxl_domain_type_to_string(C.libxl_domain_type(dt)) str =3D C.GoString(cstr) @@ -323,27 +268,6 @@ func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { return } =20 -// # Consistent with values defined in domctl.h -// # Except unknown which we have made up -// libxl_scheduler =3D Enumeration("scheduler", [ -// (0, "unknown"), -// (4, "sedf"), -// (5, "credit"), -// (6, "credit2"), -// (7, "arinc653"), -// (8, "rtds"), -// ]) -type Scheduler int - -var ( - SchedulerUnknown Scheduler =3D C.LIBXL_SCHEDULER_UNKNOWN - SchedulerSedf Scheduler =3D C.LIBXL_SCHEDULER_SEDF - SchedulerCredit Scheduler =3D C.LIBXL_SCHEDULER_CREDIT - SchedulerCredit2 Scheduler =3D C.LIBXL_SCHEDULER_CREDIT2 - SchedulerArinc653 Scheduler =3D C.LIBXL_SCHEDULER_ARINC653 - SchedulerRTDS Scheduler =3D C.LIBXL_SCHEDULER_RTDS -) - // const char *libxl_scheduler_to_string(libxl_scheduler p); func (s Scheduler) String() string { cs :=3D C.libxl_scheduler_to_string(C.libxl_scheduler(s)) @@ -1141,14 +1065,6 @@ func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpu= info) { return } =20 -type ConsoleType int - -const ( - ConsoleTypeUnknown =3D ConsoleType(C.LIBXL_CONSOLE_TYPE_UNKNOWN) - ConsoleTypeSerial =3D ConsoleType(C.LIBXL_CONSOLE_TYPE_SERIAL) - ConsoleTypePV =3D ConsoleType(C.LIBXL_CONSOLE_TYPE_PV) -) - func (ct ConsoleType) String() (str string) { cstr :=3D C.libxl_console_type_to_string(C.libxl_console_type(ct)) str =3D C.GoString(cstr) --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992916; cv=none; d=zohomail.com; s=zohoarc; b=lHwiFYF3uRkckmNNiaKsSeufl6HVqcLQc21BS68Tje3BwAAwyZWqt5sT4z/bDxh28Y1AV6NR1sU0bcsWQ/N1V72CzI98UvqHijG3Tz+WD5d80RdplqOh0402k7euH9qRpjzQ8Ut91NgGoQldEPUwCHWCxk5P1Vt3B2qyvGeOkng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992916; 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=Oi/sb4fLu75ov0fMyb3cCBFERMeS3Ui0J3/yiJ1XdOk=; b=DasIvTtf7FC0udeHP7I5sjR9DMr6WpwamsTlju9Pt0r1aibGHSvC8NxXN/Jey5QVTCkJtIi0C7oYioTLBfr87u1ZLh/F9hqTDn8BaFlvOjMmCklt0Enso8+ALWJuUuxQ9mE/pXKVZc3txnNYB3DP/OuuwmzcRek9DVpurntrp2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992916432877.4332000063528; Tue, 10 Dec 2019 07:48:36 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehk2-0002t6-H5; Tue, 10 Dec 2019 15:48:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehk0-0002sh-QL for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:00 +0000 Received: from mail-qt1-x842.google.com (unknown [2607:f8b0:4864:20::842]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6ce50dd0-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:47:52 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id 38so3130244qtb.13 for ; Tue, 10 Dec 2019 07:47:52 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:50 -0800 (PST) X-Inumbo-ID: 6ce50dd0-1b64-11ea-a1e1-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:content-transfer-encoding; bh=Z2NYMlNEa239ID0p7i58khGBjYrcb8RrDrNqVGHrC6k=; b=sTkcmyd/QE8Ga9ksK7HINz32oVWTxWm1Oz6EGNaTzojblW3hjqInZ6PmX4cd1ng+Y5 9oRhcuErUmHvFXvP1gyo+oq3AC2E1njw5ZDDUxzBnRJv4u9xsZq2QOvzMLaIjJo83kpG hjvUGpC3+TcULSaVXyUCgVI6cKxcyVb56B1jwjHb328B+4XDSVnDGagFP094+FAQzffn I90MQMqjpTdBcmMWfctsVlJEJKHO4M98iT5fHB+BCP8CMFfrKGn4KLDqgtAEBUeqXu2V CdC4FYdXLlN60oZ2Qs/N5GvDA1l/5b/CyXuWjucl0n+a6VfODFooCEPbiAmvAwQDTz74 QN7w== 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=Z2NYMlNEa239ID0p7i58khGBjYrcb8RrDrNqVGHrC6k=; b=Xm2qklwdGOkVvoq0cAbZs6e0bvMMamMfXQXXE1uYUfLmjlXZ5uqudUx823zahKE6nq Ffv8u7NV7P2oPp6l6qB+2FHImm0XyDcw7wirl461q2E2mhofhpCSw45qmKTeqL80MOOT Py0h+RBwgHMjqw12NhVBQo0z1t3CfT5Lh2uIX+UhbFTif+pgWnUJDOg0vEfmgKne5IOp ubqmCPt2oxeQfTBfE9zAOXg8pHRI1XyziBU03MD3U2mBuPMWtsufifZWor4AyB6e1fjT M7qDw4I1JgvS3Bip2KkZ/ng1Gw94K+uHsJ/W8zCh1gnnXXrkGXnGVqAv78FYQ9Hrv08f DPww== X-Gm-Message-State: APjAAAUFd+UTpJpUbP7efQvYMsGL01HzF/DVc2iDd96bPeF/Mzs74nBK OMKsTvUF1wz9b3DJv7cKO/+jlOHQ X-Google-Smtp-Source: APXvYqyQ4WyzJYCN4Qe97lJpPL1oO/AQYKsGsBR++9pRgagf/KT88xX6WmiZPrKygBsCH9qI/7sgzw== X-Received: by 2002:ac8:5513:: with SMTP id j19mr30537125qtq.143.1575992871961; Tue, 10 Dec 2019 07:47:51 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:17 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 02/22] golang/xenlight: define Defbool builtin type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define Defbool as struct analagous to the C type, and define the type 'defboolVal' that represent true, false, and default defbool values. Implement Set, Unset, SetIfDefault, IsDefault, Val, and String functions on Defbool so that the type can be used in Go analagously to how its used in C. Finally, implement fromC and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 93 +++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 89ed439fd0..640d82f35f 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -85,6 +85,99 @@ type MemKB uint64 =20 type Uuid C.libxl_uuid =20 +// defboolVal represents a defbool value. +type defboolVal int + +const ( + defboolDefault defboolVal =3D 0 + defboolFalse defboolVal =3D -1 + defboolTrue defboolVal =3D 1 +) + +// Defbool represents a libxl_defbool. +type Defbool struct { + val defboolVal +} + +func (d Defbool) String() string { + switch d.val { + case defboolDefault: + return "" + case defboolFalse: + return "False" + case defboolTrue: + return "True" + } + + return "" +} + +// Set sets the value of the Defbool. +func (d *Defbool) Set(b bool) { + if b { + d.val =3D defboolTrue + return + } + d.val =3D defboolFalse +} + +// Unset resets the Defbool to default value. +func (d *Defbool) Unset() { + d.val =3D defboolDefault +} + +// SetIfDefault sets the value of Defbool only if +// its current value is default. +func (d *Defbool) SetIfDefault(b bool) { + if d.IsDefault() { + d.Set(b) + } +} + +// IsDefault returns true if the value of Defbool +// is default, returns false otherwise. +func (d *Defbool) IsDefault() bool { + return d.val =3D=3D defboolDefault +} + +// Val returns the boolean value associated with the +// Defbool value. An error is returned if the value +// is default. +func (d *Defbool) Val() (bool, error) { + if d.IsDefault() { + return false, fmt.Errorf("%v: cannot take value of default defbool", Err= orInval) + } + + return (d.val > 0), nil +} + +func (d *Defbool) fromC(c *C.libxl_defbool) error { + if C.libxl_defbool_is_default(*c) { + d.val =3D defboolDefault + return nil + } + + if C.libxl_defbool_val(*c) { + d.val =3D defboolTrue + return nil + } + + d.val =3D defboolFalse + + return nil +} + +func (d *Defbool) toC() (C.libxl_defbool, error) { + var c C.libxl_defbool + + if !d.IsDefault() { + val, _ :=3D d.Val() + C.libxl_defbool_set(&c, C.bool(val)) + } + + return c, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992919; cv=none; d=zohomail.com; s=zohoarc; b=cEfgZzhJg85cC+Nd2f8nNvtPzA2dNZ6wxxV7GRtNcaa/AvL++/x+42IcW1+RB+AHZFoAAyFLLHpUEMP05ibyGmmGhj7K54jjhdv61ZXwf3OPeZu3DXIpGRUz80BH8JWFRMtTjsu4waQsA05vMkgS4rm4CB1TUupL1pahRhPfPLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992919; 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=PTPHOpR6QXIocyYBjja2KHXBgoQV1hmX6ay2Rz3XuPo=; b=S84nptXMdtClAMiRbervQXrG9Eg8hx64rImhDeEVVjuPD+33C9fFYULJYEAEAKPi0aHdDS8KbIMGO+0qauT9K5a+gWeqXaKxBN0j9g04E94qLlwPrHE5F/M//Yo2tdLd1zJZXm0yF+Y/ncK9hXlE0oU5JKWODzbY18d8GrKRYEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992919404747.6067959875293; Tue, 10 Dec 2019 07:48:39 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehk6-0002v1-WD; Tue, 10 Dec 2019 15:48:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehk5-0002uh-RB for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:05 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6d9100c2-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:47:53 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id l124so4839236qkf.8 for ; Tue, 10 Dec 2019 07:47:53 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:52 -0800 (PST) X-Inumbo-ID: 6d9100c2-1b64-11ea-a1e1-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:content-transfer-encoding; bh=Bl4kmcGwcbL0QI9zZzG8ebrx0FfXrmxwyQuh29q0y+o=; b=RaMY1cMQFE0k+UZGVwDW96RQXSH3urkB8MCBkF84GbfIcTDZqLRdlxaw32IYbReM5R +JK0Tea/wxQ9X8SJu6j9coD6kgPdAOez1v5KJvy9FpFeKVse89bohNde0xwoQ7nFLAB8 ppMddtAXCEoyOYh80couUHkIeWruJoy1qrxs01FdH0dgNsU0atJ8/o+agbOas4fzvd52 CD5i7OyMR67ET4OcRmkEbi40VN9zqspLV/X3BTWwuj00JsejJq3DoHsInERa0VupgY+G Kb/HJL8TBaG3OxvIBBVaai9vktREulU06QczcuzcU0Vs8niREOcXmBwnCb9B9VmBe9Y5 zvBA== 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=Bl4kmcGwcbL0QI9zZzG8ebrx0FfXrmxwyQuh29q0y+o=; b=OEBISpZRI5BzDIY+HuDYiX3PS4ipgV9+oXFiCqnYPRLyD7b76aNzsCjMqgdJFAxMfe rI8LyXVKtXfFL2/CWlsg0Q8s6uScguPMiUFOidsqGo9aYzmmvzMIYZz1wl5ya/s5xmOs IGl9f7nbj8L51dxuIGdGaXohirNYfl76vCnA3fvaUxed39mIDBNgIMXDxsSt0HpwX+Tn JKmwWxEjA/GhWWiJ40g+kYEpISK4xQVyt0HQgyw0YJWarUTUL7YNQ3qdSVti625R6yil r8xkCFykyCjsapCdXEOrDAppTXqStojQYKEWTOsIMNxykBpfdq1vEPZw4XH0RZb8Iw+t MpAQ== X-Gm-Message-State: APjAAAXjTntva+KDMrt4GXkqVbEV+OruxeN1/UXTJDXsNpp9jmdR8T6G 3N+tGL9dDByqyzrlt6zODNPPnzBY X-Google-Smtp-Source: APXvYqySvExekk3DuX3qbxD+6Td0TxBmfNa0jzkgdTl46w9PXNAUoSq9sTgtvuNdXiBZrGDZnCa4yw== X-Received: by 2002:a05:620a:13da:: with SMTP id g26mr33985682qkl.410.1575992873138; Tue, 10 Dec 2019 07:47:53 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:18 -0500 Message-Id: <99f726c939543cb538c2f2851ba070ed8ec1176f.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 03/22] golang/xenlight: define Devid type as int 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 640d82f35f..8ac26e63f0 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -81,6 +81,9 @@ func (e Error) Error() string { =20 type Domid uint32 =20 +// Devid is a device ID. +type Devid int + type MemKB uint64 =20 type Uuid C.libxl_uuid --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992924; cv=none; d=zohomail.com; s=zohoarc; b=af1cj2DIWe39rbYON/aCFN6vIoDNxDkpYuNDdMEAMmrlyZyjzitprdo+58b0CSpOGiOCjTKXV3419DaFZcw6SR1XqryH8ftFd9WGWMRZhsiP6DukN3vNwX537lPesHgab5pIvhPjXTecNjzpFyZDpbYbcO1iH+j5t+5/EcxgMis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992924; 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=6gwGOOoDCg/c55Hv0KV0QBjRlwT+uIPhufNp8WAG54k=; b=U92L5VTZ0zABVtYnKeNOApQz3wjdVF/yqeWUk8W7CQvdt2N2UYJoJk56yiYJOM3ti6vguJp6gJ5kNsFEJ4OOaZoLfqzXD+jyUvGSFQKHMJ6sKabhTU6oLithmP37PBucISxCgpMHwDyOdy/TIn0oRYRPPu5rETGx5J9kCU7LvXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992924653545.6002470665343; Tue, 10 Dec 2019 07:48:44 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkC-0002xW-9W; Tue, 10 Dec 2019 15:48:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkA-0002x2-Rm for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:10 +0000 Received: from mail-qv1-xf44.google.com (unknown [2607:f8b0:4864:20::f44]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6e5311f8-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:47:55 +0000 (UTC) Received: by mail-qv1-xf44.google.com with SMTP id o18so4362118qvf.1 for ; Tue, 10 Dec 2019 07:47:55 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:53 -0800 (PST) X-Inumbo-ID: 6e5311f8-1b64-11ea-88e7-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:content-transfer-encoding; bh=xJtsVD7v/eLGT0PYCbUK6OcDbHvosGa2K6bcDN+U4so=; b=O7cyzIDfXsW/cWNr3AOTOBJQFOUwuAHIo6SCquLuU0Ed9Utiebev++ixg6UV2rvbZ1 6mjoRsgSg2vCgm8IXp0/1mu5StUBtqTrABPgJPzrJreOlDVrTR+24iY+aAxV/eF9b1hI 6t7YuJkw4LUp+syVagqW2Vdvi1Z5QrSKNovOPY1fAILp7AmKs7uf3J6Ii89SDtR9sTGw kBeMgTN14aIXGF8+WjrylLX+K5aPXtQ8CLfUHaAvft0K+toAoDWZLAQxbK2YL482jdJK ewEGsOnH3Lj41efkJoZKTQemmEnIC9//aD8sf9RGoobcWcT8TXQY/DPW3QnqoodCw78i UCtQ== 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=xJtsVD7v/eLGT0PYCbUK6OcDbHvosGa2K6bcDN+U4so=; b=KlevWZ6rm2EJ6PGPaTCPacKHPGHk8y7Ig/6kLcx82/r7oUmJw5raM9bbsf2u5znDvB rnD1sF/aKsaj8kjZn+VOkteCFu0JMMFBWabYUoup877iFIMjsjfPIETC+6bgEltxbibG ia7i+7a6WvjQE4mgcJFhlU2PEZiwXmwpOpnWD1Bqfp0+9BDN1e39B4fADYrMhfMlB9Y6 B8DBBWe66w1yDKI+Bz0CMmJVifDbgGSq06AqcLqiPnacTONUXHafREjqhVoOQYWuNZD/ XPnRLjbcaCdhn4T1lD4rW4rffg75la2GbHbVJXtfCD8HGr+PFzYfdmtT0V5cUsD34OT2 h+yg== X-Gm-Message-State: APjAAAUJICtw45dccLXiApfKE8s2ScQZjHI/NU14S2ncGQU8Z4icIzvf t1XhlaWLSRjRNsLecz7ipvF1tR62 X-Google-Smtp-Source: APXvYqwRTEm2d+0xw17v2x9ep5VQowpww71DOu/n7kLiC49CxcatED5XEDSH21LEvvMi/V8cRJ5EVg== X-Received: by 2002:a05:6214:5ce:: with SMTP id t14mr4589643qvz.139.1575992874368; Tue, 10 Dec 2019 07:47:54 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:19 -0500 Message-Id: <3e79f8024a55f673f31c1768df0f3e9676a0ae2f.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 04/22] golang/xenlight: define KeyValueList as empty struct 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define KeyValueList as empty struct as there is currently no reason for this type to be available in the Go package. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Re-define KeyValueList as empty struct, as it was decided this type probably shouldn't be exposed in the Go package. --- tools/golang/xenlight/xenlight.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 8ac26e63f0..3edff18471 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -202,6 +202,16 @@ func (chwcap C.libxl_hwcap) toGo() (ghwcap Hwcap) { return } =20 +// KeyValueList represents a libxl_key_value_list. +// +// Represented as an empty struct for now, as there is no +// apparent need for this type to be exposed through the +// Go package. +type KeyValueList struct{} + +func (kvl KeyValueList) fromC(ckvl *C.libxl_key_value_list) error { r= eturn nil } +func (kvl KeyValueList) toC() (ckvl C.libxl_key_value_list, err error) { r= eturn } + // typedef struct { // uint32_t size; /* number of bytes in map */ // uint8_t *map; --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992936; cv=none; d=zohomail.com; s=zohoarc; b=Emt7dm8wSB1ciOgrQdaBSn3FtJOyT1j1d0j9SYPleccpU94F9MvMcYCR680auwZy2tBZ9RATBKMAdAh0YZJlzXI8/zitBzGYmUmUY7CqUbkG+kjg32+mK1FBF+opZgJaQEMmmTlLiKfG+BQT0qABKzunlZiSf/WGlAdwx4DL/t4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992936; 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=O8FINU4mlZ+ngUHN4dYoTEBdOqLXcb4lAOR+TOcKxaA=; b=fJQtIjtOTRiLS0aJPjXaEMj2qqVfDMw3cEd3PtZpQoaf/QCdXllpkBHnlCCUgG0dxScexnqKMAiOsMYOnPCu89zaIc5n1rx0Uv6N0BNYFmFx6plGUqUlc3WfxmgXsCxFbeliUrRtLsq/GwgZnYDuPWi2oBvacDWLP51FMGDZRfM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992936888285.15332464494645; Tue, 10 Dec 2019 07:48:56 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkH-00030L-JE; Tue, 10 Dec 2019 15:48:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkF-0002zU-RU for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:15 +0000 Received: from mail-qv1-xf41.google.com (unknown [2607:f8b0:4864:20::f41]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6f37b24a-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:47:56 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id b18so4338651qvo.8 for ; Tue, 10 Dec 2019 07:47:56 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:55 -0800 (PST) X-Inumbo-ID: 6f37b24a-1b64-11ea-a1e1-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:content-transfer-encoding; bh=BBGUyrHNGFQPFq/o+TvXylCQY7vgNJpmV7qKIg4M/Cs=; b=Yjx05uyVX0tJ+6VD1idFE4HzfRIdrW2VKoWs/6QhrcLl0clYS8Rq/VSJYMF/GbnEiH 0F+jhy60Hb9mINGYG1IzhB3hUsjuWUC5Z2O3OYz7OvdAFLwatM3L8WzxqYAKsLVmRd6Y 9oRVQ/iUFNwGReYucx3kB57AhH/wQxFWulUEta5+NcjlUKJOeMtrBQCjN8HlJsjtUgId ohEX/8brNUCZl5jQl4EwZFAmfG/23Iq2HKrp97kuyiTtArbEPgwHCldWpgaBIBI7MwhM c4bqdeRckna1bO3cwRIISdlYoHXs7MKoJiPBTgn6cRV9ELS/WwPaH9Ic2NMsj1xgfc3k eeYA== 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=BBGUyrHNGFQPFq/o+TvXylCQY7vgNJpmV7qKIg4M/Cs=; b=YzioM/ZWal3MXa8XUQITagQ4Izw2SiPktXcs6/vQlq+CeFbF3Gpn7FULpb5dai9WdE 4QWzBqm8MuxA4D7BUxUwz1h8OYLGpM/U+9K6avDcqy2IbmbimajzpiAdNjr1Dqjrx4Hr A9SqU2TmdGloIo3fL+TlVc+qFYJzYs3C4PZozc02Tcajwogy2SE0uDLtZxt+k6FcAKy/ c7Al+oghiifJOsEkLoMIi48P8DtTEP6Yh+7H4EmGFXcb3J6zBohMq4mr6dfJAS/5OwRA e6hFLHGOky1FNLp1H1UKBb+y6bziCKfgncVzP51rjjPmunaKhcE+HFjUEgbN5xbyKxGA dBhg== X-Gm-Message-State: APjAAAXtYcbv88ALl81gX4c9t+FNlDYgHZ8yiwlwpYNNxq/M/Xf35tRR bjUjkgFMq9jQ2OJ7WIpaaSutK/Ok X-Google-Smtp-Source: APXvYqyxqDs6L4y/NujGTJemWBuyzz4BTtAgbsJN5j+PS1on0omvebxiKpX9wSMHsodSqFqB8NTnyg== X-Received: by 2002:a0c:f792:: with SMTP id s18mr29619358qvn.118.1575992875684; Tue, 10 Dec 2019 07:47:55 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:20 -0500 Message-Id: <688067dbf85cc8f2487165af21379039dcc30e9a.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 05/22] golang/xenlight: re-name Bitmap marshaling functions 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Re-name and modify signature of toGo function to fromC. The reason for using 'fromC' rather than 'toGo' is that it is not a good idea to define methods on the C types. Also, add error return type to Bitmap's toC functio= n. Finally, as code-cleanup, re-organize the Bitmap type's comments as per Go conventions. Signed-off-by: Nick Rosbrook Acked-by: George Dunlap -- Changes in v2: - Use consistent variable naming for slice created from libxl_bitmap. --- tools/golang/xenlight/xenlight.go | 94 ++++++++++++++++--------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 3edff18471..1c5e3c0cc7 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -212,20 +212,48 @@ type KeyValueList struct{} func (kvl KeyValueList) fromC(ckvl *C.libxl_key_value_list) error { r= eturn nil } func (kvl KeyValueList) toC() (ckvl C.libxl_key_value_list, err error) { r= eturn } =20 -// typedef struct { -// uint32_t size; /* number of bytes in map */ -// uint8_t *map; -// } libxl_bitmap; - +// Bitmap represents a libxl_bitmap. +// // Implement the Go bitmap type such that the underlying data can // easily be copied in and out. NB that we still have to do copies // both directions, because cgo runtime restrictions forbid passing to // a C function a pointer to a Go-allocated structure which contains a // pointer. type Bitmap struct { + // typedef struct { + // uint32_t size; /* number of bytes in map */ + // uint8_t *map; + // } libxl_bitmap; bitmap []C.uint8_t } =20 +func (bm *Bitmap) fromC(cbm *C.libxl_bitmap) error { + // Alloc a Go slice for the bytes + size :=3D int(cbm.size) + bm.bitmap =3D make([]C.uint8_t, size) + + // Make a slice pointing to the C array + cs :=3D (*[1 << 30]C.uint8_t)(unsafe.Pointer(cbm._map))[:size:size] + + // And copy the C array into the Go array + copy(bm.bitmap, cs) + + return nil +} + +func (bm *Bitmap) toC() (C.libxl_bitmap, error) { + var cbm C.libxl_bitmap + + size :=3D len(bm.bitmap) + cbm.size =3D C.uint32_t(size) + cbm._map =3D (*C.uint8_t)(C.malloc(C.ulong(cbm.size) * C.sizeof_uint8_t)) + cs :=3D (*[1 << 31]C.uint8_t)(unsafe.Pointer(cbm._map))[:size:size] + + copy(cs, bm.bitmap) + + return cbm, nil +} + /* * Types: IDL * @@ -426,7 +454,7 @@ func (cci C.libxl_cpupoolinfo) toGo() (gci CpupoolInfo)= { gci.PoolName =3D C.GoString(cci.pool_name) gci.Scheduler =3D Scheduler(cci.sched) gci.DomainCount =3D int(cci.n_dom) - gci.Cpumap =3D cci.cpumap.toGo() + gci.Cpumap.fromC(&cci.cpumap) =20 return } @@ -500,7 +528,10 @@ func (Ctx *Context) CpupoolCreate(Name string, Schedul= er Scheduler, Cpumap Bitma var uuid C.libxl_uuid C.libxl_uuid_generate(&uuid) =20 - cbm :=3D Cpumap.toC() + cbm, err :=3D Cpumap.toC() + if err !=3D nil { + return + } defer C.libxl_bitmap_dispose(&cbm) =20 ret :=3D C.libxl_cpupool_create(Ctx.ctx, name, C.libxl_scheduler(Schedule= r), @@ -555,7 +586,10 @@ func (Ctx *Context) CpupoolCpuaddCpumap(Poolid uint32,= Cpumap Bitmap) (err error return } =20 - cbm :=3D Cpumap.toC() + cbm, err :=3D Cpumap.toC() + if err !=3D nil { + return + } defer C.libxl_bitmap_dispose(&cbm) =20 ret :=3D C.libxl_cpupool_cpuadd_cpumap(Ctx.ctx, C.uint32_t(Poolid), &cbm) @@ -591,7 +625,10 @@ func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint= 32, Cpumap Bitmap) (err er return } =20 - cbm :=3D Cpumap.toC() + cbm, err :=3D Cpumap.toC() + if err !=3D nil { + return + } defer C.libxl_bitmap_dispose(&cbm) =20 ret :=3D C.libxl_cpupool_cpuremove_cpumap(Ctx.ctx, C.uint32_t(Poolid), &c= bm) @@ -714,41 +751,6 @@ func (Ctx *Context) CpupoolMakeFree(Cpumap Bitmap) (er= r error) { * Bitmap operations */ =20 -// Return a Go bitmap which is a copy of the referred C bitmap. -func (cbm C.libxl_bitmap) toGo() (gbm Bitmap) { - // Alloc a Go slice for the bytes - size :=3D int(cbm.size) - gbm.bitmap =3D make([]C.uint8_t, size) - - // Make a slice pointing to the C array - mapslice :=3D (*[1 << 30]C.uint8_t)(unsafe.Pointer(cbm._map))[:size:size] - - // And copy the C array into the Go array - copy(gbm.bitmap, mapslice) - - return -} - -// Must be C.libxl_bitmap_dispose'd of afterwards -func (gbm Bitmap) toC() (cbm C.libxl_bitmap) { - C.libxl_bitmap_init(&cbm) - - size :=3D len(gbm.bitmap) - cbm._map =3D (*C.uint8_t)(C.malloc(C.size_t(size))) - cbm.size =3D C.uint32_t(size) - if cbm._map =3D=3D nil { - panic("C.calloc failed!") - } - - // Make a slice pointing to the C array - mapslice :=3D (*[1 << 30]C.uint8_t)(unsafe.Pointer(cbm._map))[:size:size] - - // And copy the Go array into the C array - copy(mapslice, gbm.bitmap) - - return -} - func (bm *Bitmap) Test(bit int) bool { ubit :=3D uint(bit) if bit > bm.Max() || bm.bitmap =3D=3D nil { @@ -1137,8 +1139,8 @@ func (cvci C.libxl_vcpuinfo) toGo() (gvci Vcpuinfo) { gvci.Blocked =3D bool(cvci.blocked) gvci.Running =3D bool(cvci.running) gvci.VCpuTime =3D time.Duration(cvci.vcpu_time) - gvci.Cpumap =3D cvci.cpumap.toGo() - gvci.CpumapSoft =3D cvci.cpumap_soft.toGo() + gvci.Cpumap.fromC(&cvci.cpumap) + gvci.CpumapSoft.fromC(&cvci.cpumap_soft) =20 return } --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992931; cv=none; d=zohomail.com; s=zohoarc; b=fGJN61WRe+W0Ak8A+9xTsmP1vPpvBzdjfyZ8He+XSmo5ndDuU8PoEE92kM3Igo1IeXyMGa3GvF0rOkL6Up9qR70a0nwj0bcU7JYOVjvmPyicP1P3bRr1gSQ36On4hBzPF1HBYnTCxwZN0Oa+xm1KSpmbTsXcmds1mQ21UrcY2DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992931; 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=HIQHAYavPshzqqplFQjnyLaTnghtYveeP/ov5lcV3pw=; b=ebKiSDI4XDOmYr52Bqjejrdok3hKpQVae13FykP5ZG9MjCJabmb4h4+UbjkwRjcaPVrsWRsqObCbY8PjSm26TsKMHO1Z8aJy84bzCPsFMQpTyBgFcW+KjpX1vanyM+8KzfMFZQSZ7XKu/P9W7/Ew/53oEIgOCodDG/HqQEMRgq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992931707652.1278218799494; Tue, 10 Dec 2019 07:48:51 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkL-00032A-Ty; Tue, 10 Dec 2019 15:48:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkK-00031j-S6 for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:20 +0000 Received: from mail-qv1-xf42.google.com (unknown [2607:f8b0:4864:20::f42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6fe772f2-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:47:57 +0000 (UTC) Received: by mail-qv1-xf42.google.com with SMTP id o18so4362170qvf.1 for ; Tue, 10 Dec 2019 07:47:57 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:56 -0800 (PST) X-Inumbo-ID: 6fe772f2-1b64-11ea-a1e1-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:content-transfer-encoding; bh=LI98nKVqVPVJ264Gwu280nugbkHUVeryCxnErgot7XQ=; b=TtKXJkMEp5aXVuwJn+B49mebLdzJu/zKFtdZYdLXQbgcsk/jiQnURaVor81rxqVTb9 KPwZIlXHa/ofY31DqPMkwuDfGYfrvuNfFJlgKw07FbpJNjz0Xhmf1WBWgy7btudsqac1 oYgMuDOg2JJFjgA8Lb7fwJwoVpLVnYMDa/UQXa+ohE7WIxVxLgvkBUiIvYEuGUYx/u/e HwdgGZYqRqRwQqhwrjChMaskUDRYeNpfAW39fbtMmyTnrbluCHSMlKqE5/pcxR3lD9Xi pVfAmf0jWgMZzW69Lnfu38yFLOQzhC0TLMAxG8K4n5bae0Sg3qRdcsLXqEd4vyZ40oV2 I+iA== 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=LI98nKVqVPVJ264Gwu280nugbkHUVeryCxnErgot7XQ=; b=JLYdbo7TdI01tqpZG2XCcbUEBCmu+MHCyirbcAUS0KQrlxxpPmsgFtZh9MUbmAPnhI Fy9Y/7qkSf/gmeDo1PtB4NDTDxshi5jdZh/xac9ktYOl78fUFjIM13YVz3+yhnUGjmdX hvW2JPtG5MX4N1Mrip1i5jqsjG5d/w9+TKZVRxwU321RrVhc5OlpmvgaeQymg6tyIJv3 9HYaY65ckxi7R/G/Qp2GbzNeVcKpXmYyE3YwTRy71K7qklUrCGRrTTPmVVD4rPI0qhq3 W9BXnVWLeartTFoLfXAezOxQ7C5sfOGbLAx7OnqTm3ClyOd/om1YB7H2VIx0WKbgWYMi ToQw== X-Gm-Message-State: APjAAAWKfwZSpIta/ompBDBbOHNL688Wk0sK6kOjR/p3WwUf6PcVCmF3 t02sBu901vJKy0Pv/eP3jP+D7t/M X-Google-Smtp-Source: APXvYqyhKJwJ4aID2FLPRTM2Ag3jog5KMtO1TPYhCBceOCItIr7Mm6ee7fu+x7PJuTQT04WGE/Muew== X-Received: by 2002:ad4:436d:: with SMTP id u13mr10048515qvt.171.1575992876969; Tue, 10 Dec 2019 07:47:56 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:21 -0500 Message-Id: <68236a9fc20a48988703da4eb0ab19821b59d271.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 06/22] golang/xenlight: define StringList builtin type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define StringList as []string an implement fromC and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Define fromC with a pointer receiver since a newly-allocated slice is being assigned to the StringList. --- tools/golang/xenlight/xenlight.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 1c5e3c0cc7..72afc3cf14 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -212,6 +212,35 @@ type KeyValueList struct{} func (kvl KeyValueList) fromC(ckvl *C.libxl_key_value_list) error { r= eturn nil } func (kvl KeyValueList) toC() (ckvl C.libxl_key_value_list, err error) { r= eturn } =20 +// StringList represents a libxl_string_list. +type StringList []string + +func (sl *StringList) fromC(csl *C.libxl_string_list) error { + size :=3D int(C.libxl_string_list_length(csl)) + list :=3D (*[1 << 30]*C.char)(unsafe.Pointer(csl))[:size:size] + + *sl =3D make([]string, size) + + for i, v :=3D range list { + (*sl)[i] =3D C.GoString(v) + } + + return nil +} + +func (sl StringList) toC() (C.libxl_string_list, error) { + var char *C.char + size :=3D len(sl) + csl :=3D (C.libxl_string_list)(C.malloc(C.ulong(size) * C.ulong(unsafe.Si= zeof(char)))) + clist :=3D (*[1 << 30]*C.char)(unsafe.Pointer(csl))[:size:size] + + for i, v :=3D range sl { + clist[i] =3D C.CString(v) + } + + return csl, nil +} + // Bitmap represents a libxl_bitmap. // // Implement the Go bitmap type such that the underlying data can --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992937; cv=none; d=zohomail.com; s=zohoarc; b=jgGeu8OYqGzd92UVoII0nJ8i8Kvl4XOQXyvEPj/xa7jpyAu+LMyVY0btVs65pJCACs+tOAxDyxEHjd3vRrcIep7spS8sRJpr425e0FoYNa7jC9jrHdwkb9dCYCFq/lfBGkpXS3crhB1Xq9cp7bqYxJk1hOnuNynvFzrj616nrLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992937; 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=mP+vkZ8S5Wk3TevkNOpV35tGXD7sDkj1BOTeZ29QIhs=; b=Z5MNbBG72O1luW5QhuBviq3/ueZaTGP9BG8QFmtIDVno79h13Vu+VXLLDcWgqP8nKxoRKzsOvojmhAMqgKF3GOZP+so7agW65hLxRzXH/VMeXIEV4IuP3gugtyXP6ouzKv921zvfvIZ+VcdH2q1SmbITKiA+ITOA+kqm3T/Em1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992937169307.54617678925183; Tue, 10 Dec 2019 07:48:57 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkR-00035F-7f; Tue, 10 Dec 2019 15:48:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkP-00034X-Ri for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:25 +0000 Received: from mail-qv1-xf42.google.com (unknown [2607:f8b0:4864:20::f42]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 709bb30c-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:47:59 +0000 (UTC) Received: by mail-qv1-xf42.google.com with SMTP id q19so4345845qvy.9 for ; Tue, 10 Dec 2019 07:47:58 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:57 -0800 (PST) X-Inumbo-ID: 709bb30c-1b64-11ea-b6f1-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:content-transfer-encoding; bh=5Sxwv5A++XwWjW3r96jIpvbj5k3Ch0M30fjE7fzumV0=; b=pTUHbIZ/DpbwkzmQMz17B423imTwlhuSwOW23dDrhxWPxxYR7L7y8CMz0pr1I37unf 4DtiW4b9RmcuURRn+hn2Nb5fNQDdCfimhXEdYD9UHYuNObXCfagLPsKH/jzFmEm+8Og8 16vkqTYGnvmP4wJQomXPtVpOsuzMYN/Y3FeiTwRLq5t00OFgiOmz5q+fV8b7w0IU4jz2 REuw7/Z7b2OBPZA5SD1uS3ORmxylxZfOttnou9PEgfrXL8L8V5VbA6YdmOFnUTPN9H/q WWmbyNZBSpRUp/lOBJFx/fAug1DhLX1nWaG0YXkp2HiyzaUF8IWqb/GnVVxtjImN0VXS ycXw== 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=5Sxwv5A++XwWjW3r96jIpvbj5k3Ch0M30fjE7fzumV0=; b=GCPJ7UY3hbct6ZYKOE7arC1+EaD5mmM8sA1CL+ODVojSNIek5uRo3rMGX/Iz5kV3nc bNoCEXUI4CczjNHqJMAcTmS+QMGsaUpZCgpA9HHLRZVoAGbXzy2uvW6x9CSPlyU35Qf3 RACCIudHvLQzUaAZhavz0OHeOPXHuafq9X0pzTzAJRe4i4bo5xWc/MKJqNsiPlLrrx/l f46jDCorfvzsLKw7BsFrEVUUA6cTA0vDsYxUHbsqjjc+dq2+PWzk8ejT2Oi/1OVVRQgL PjBoTfUm3GYbGC9myvHhbhLdWzrXyfbjLfWrFcpQ4otwPBTBhIrjqrAdD8P43yR/7woj sb+w== X-Gm-Message-State: APjAAAWiK5H5vypBOzxdk6Q32LuvN0XBtMdxa3WyCnwbvlyIrgmU9fl+ L61jO3NS1aGsufbN9tn9bkEhNcOJ X-Google-Smtp-Source: APXvYqwK2pN/734YUERX1Hy9tqF2dVHK62qvXujL4uGZLiL2bKMtog0QHdO/rwqqjQaBI47C9hJBnQ== X-Received: by 2002:a05:6214:983:: with SMTP id dt3mr29504946qvb.145.1575992878193; Tue, 10 Dec 2019 07:47:58 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:22 -0500 Message-Id: <7de569cbacb5d9869ee657bd1ae3bc7c6fe49b1a.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 07/22] golang/xenlight: define Mac builtin type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define Mac as [6]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix the format string in String function to use %02x. - Use a value reciever for the toC function. Changes in v3: - Iterate over the indirect of mac instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 72afc3cf14..17d146771e 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -181,6 +181,39 @@ func (d *Defbool) toC() (C.libxl_defbool, error) { return c, nil } =20 +// Mac represents a libxl_mac, or simply a MAC address. +type Mac [6]byte + +// String formats a Mac address to string representation. +func (mac Mac) String() string { + s :=3D "%02x:%02x:%02x:%02x:%02x:%02x" + opts :=3D make([]interface{}, 6) + + for i, v :=3D range mac { + opts[i] =3D v + } + + return fmt.Sprintf(s, opts...) +} + +func (mac *Mac) fromC(cmac *C.libxl_mac) error { + for i :=3D range *mac { + mac[i] =3D byte(cmac[i]) + } + + return nil +} + +func (mac Mac) toC() (C.libxl_mac, error) { + var cmac C.libxl_mac + + for i, v :=3D range mac { + cmac[i] =3D C.uint8_t(v) + } + + return cmac, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992943; cv=none; d=zohomail.com; s=zohoarc; b=FCdunO/E8hkm9IaTiXAiod9p9IL2apKBhM+QL5J8dqNvT1CFFAjxKMbUVAkeABOO7QPvcLleV0G4/jvTf0jaf5g6CFMHToa73xXXzh0UAcLjbPtD5tHJffjXWzTGaO7xqW4tcmd9rDns0t4VHv7jqw01Ntp48raSP0C+IeC3cwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992943; 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=MSrg6YV+L57gDBK9sapKvHFCUpB2rw7vh3zwQEmhfhY=; b=iojmGc/z3w+KaJPt7jGxYSDnC8+gT2CI+JK1ubHoc94ASgUgq/Xmyi6+pxgtN9Ao8BfMfx4CARJFjms0hM4dkL0Qa3P2Euo4WigHL0UBfLlX9aItiGP/Tmcv4Vvfj/O4Kf7icaMVSYYXiioMHo26nwZXhlKvZ9smN2tIfhyX0Po= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157599294368778.99073021666698; Tue, 10 Dec 2019 07:49:03 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkW-00038T-Hu; Tue, 10 Dec 2019 15:48:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkU-00037Q-RH for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:30 +0000 Received: from mail-qt1-x841.google.com (unknown [2607:f8b0:4864:20::841]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 713c9574-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:47:59 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id s8so3207832qte.2 for ; Tue, 10 Dec 2019 07:47:59 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:58 -0800 (PST) X-Inumbo-ID: 713c9574-1b64-11ea-b6f1-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:content-transfer-encoding; bh=FHv28KVI1LuPzWrTOCFa+sts2+d/6qshGJxnHHNJjD4=; b=T4JR5lkMiFThm4g2hlVchv7XpPP1BLqo5e/qNpwseqT25AKe88Lp2Ad8J1mqs0HAw9 Wx+jo35oujweyMcXlSTqZCssCfSXJyqFmED6LNDJIqecJDqWoOTF0Qu56UoNUDnltiGb K61j3xWLYHa+O3hHBXqfwqOZzzQBC4USpddnQYRWFgWDya1Ii1YPsSzNy7F2jJd6Rw14 AyWF2fElS16McXbwOy1FsAZRePjLrcSSWmlFU2RPzvqkfKdvo7mG87vDkap8gJcpI0dA PBxD3JTf5P/E+55d6tCsocUeZPZAeWhnDHvmrXcU9JOGLL2LXCPWNF6NDkMuBIEBh24+ IHAw== 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=FHv28KVI1LuPzWrTOCFa+sts2+d/6qshGJxnHHNJjD4=; b=Zwthfoi4NgpplWjEeOs3EklZ2LvCSJSJaMYq92gwvv/1oum2nyBk/1vYRyWEu7Dg6E Bv18uZSZCm8ll12ZDIO7OfRFOWSY2f7hc2lrmcjdR6XKJ1L4MMDOCxeX6JOY8+RzpIG0 gbRoRIu4HwXiXh1sKZ1QvM8rei/I17b9jWfe/tPC+F6obJd3WrdcAW4eCEMHRVsfPMyQ 2J58WaWtYRXNCMJtW96aPGBCG4IMRQrPgqYmhMR0IDK8vsnD/9wFrRd+f3ZEjFSgruad uRkZ3phfeaysnhYIa+QQycO0oN4YqZkC0hdRyMx0LlwLi4U2zjlpEZM3u3JfQ2+jKOBh 33EA== X-Gm-Message-State: APjAAAUBf7NzWmNKWwhA1BQOXvJEFASJeD8QY4JTNuYWTLPsINxmloNz 0go00ZrOkpAKmEn0hAs5hEBVf19J X-Google-Smtp-Source: APXvYqwFBtgEAx+3xnGXkptZqxPJjk3sldGF7iRNpzN44/XCdc52kc37ApJeJLCuPaT9gxWW8f9lIw== X-Received: by 2002:ac8:6f73:: with SMTP id u19mr30205732qtv.326.1575992879261; Tue, 10 Dec 2019 07:47:59 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:23 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 08/22] golang/xenlight: define MsVmGenid builtin type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define MsVmGenid as [int(C.LIBXL_MS_VM_GENID_LEN)]byte and implement fromC = and toC functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v3: - In fromC, iterate over the indirect of mvg instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 17d146771e..6c3868cd69 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -214,6 +214,27 @@ func (mac Mac) toC() (C.libxl_mac, error) { return cmac, nil } =20 +// MsVmGenid represents a libxl_ms_vm_genid. +type MsVmGenid [int(C.LIBXL_MS_VM_GENID_LEN)]byte + +func (mvg *MsVmGenid) fromC(cmvg *C.libxl_ms_vm_genid) error { + for i :=3D range *mvg { + mvg[i] =3D byte(cmvg.bytes[i]) + } + + return nil +} + +func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, error) { + var cmvg C.libxl_ms_vm_genid + + for i, v :=3D range mvg { + cmvg.bytes[i] =3D C.uint8_t(v) + } + + return cmvg, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992948; cv=none; d=zohomail.com; s=zohoarc; b=h+rwAr7mEklBFhdTPxt7DERb/DqOm7hq2ywy+pEFmzjpPb7lObbDqJxLG7rasARakHmhbS3+mU6ioLuC9rt0f1JqGhiOlWZSr4jzD15rRyTZU/w/fftqmTKq5oSbibafnD5REEjDy3q8TrVtwiHH/Kift74meKJ9ydZIlJZ7B2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992948; 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=QMLSbsguITX6sZFJhSdFz/IRgzELqkNy3XJ03VOR7dQ=; b=HMQuf6O0Gt9bWldddtK78Jd6Zzy1MbufmbCStY47GWRgZ8gFDUgOvP1YeYwBonVqAWkKtkYhgJGgrobwZNSZ40tdJXdrmeu9698vsFqdXEXdsujEBtfJFKD9gxyTov4dVDUDdaJREhCnKv9DSAdMkSOdVHmAENT4YAQZTXSSfFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992948720937.2267323239054; Tue, 10 Dec 2019 07:49:08 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkb-0003C2-2c; Tue, 10 Dec 2019 15:48:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkZ-0003BG-S9 for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:35 +0000 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 72036a14-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:48:01 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id b18so4361473qvy.3 for ; Tue, 10 Dec 2019 07:48:01 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:47:59 -0800 (PST) X-Inumbo-ID: 72036a14-1b64-11ea-b6f1-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:content-transfer-encoding; bh=7XDtT+R+j+Gort2OZw6NF6IRipFP5JGZB9Hq2a/P3nk=; b=Lc5cvUekzkyLziO9fb5pfZnbiBbOH+gLF8yk6gu32Y682jmjszG2KeVLFI01AMs7MW e9zl88qYRoC7dLqHyng3vjm+RARX7T9cp+w8hWbP9kAUIdUytjucIMSiaMHkA/26iM6k vnG1qSMN2bbDIRnXnbURRP0+qR2fpEDCi9zeeQbLZAyvoZKLAOoikMPPu//Hn3gNDOqP WFGmxqHVUtvVy2tfHfT0cgy+nwWGdIIULtYp2jqYUzFrSDS8P5sQjO/gWOGfoPZ3mUkU Yd5LOgGX6Xgu+NqMc6XbUC3Z8WgGLIyc073eRisPVkLH2Xo3LIlul9G7/qMNr0R3T+Kx Ib1Q== 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=7XDtT+R+j+Gort2OZw6NF6IRipFP5JGZB9Hq2a/P3nk=; b=h+PoqQgYDr834UVWFFy5KqE9SN05vYbyUeEbubVXW7qwvkp39cgyg3jWlq2m6CxIHl rpSEbRlmKD2aR6m6nsowXtyI2xFDpkWRqh3kb5vkAw+LmdMsJ1d6gDoDYYH0Bo1Glbus dh7lKI7A7Q2W4UakgYI1m0oYhDqnb+46JSmRKfNEX9OGMc1BTfoSPvjjZjvFFhngbX/G RlNNBgvTaGdVyu7aWsVeL4Wyv30J3NgQCmdONB9kqc2+Y6EQ1uyl4fPgIXC7+RzF8Puz evBkviQWltrjCYQhWPVT6t++dsIg2BY+Mi69bOrxmL2Pj7c8DioLuoodRKJlZwbEMDHF MxYA== X-Gm-Message-State: APjAAAXdPrsg6RXN8NqmO2P8ZcYu3xpAFdQ4uFpkBcn8HTzsnOZKzVqg j+I7Gafg/Ljd0f4bWAqgIg7kOfsv X-Google-Smtp-Source: APXvYqyVSYwvynQbLNatqp0j54rTE7mMPz8nZCukOyzPs1xZO8BdIO9pt0+fZQMlKrTxN9Tw9kyvdw== X-Received: by 2002:a05:6214:5ac:: with SMTP id by12mr28750820qvb.74.1575992880505; Tue, 10 Dec 2019 07:48:00 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:24 -0500 Message-Id: <82d9e6cb433d40ceb490a49d0aaafb6ec00bda06.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 09/22] golang/xenlight: define EvLink builtin as empty struct 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define EvLink as empty struct as there is currently no reason the internal = of this type should be used in Go. Implement fromC and toC functions as no-ops. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 6c3868cd69..c1d9fe85fd 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -235,6 +235,16 @@ func (mvg *MsVmGenid) toC() (C.libxl_ms_vm_genid, erro= r) { return cmvg, nil } =20 +// EvLink represents a libxl_ev_link. +// +// Represented as an empty struct for now, as there is no +// apparent need for the internals of this type to be exposed +// through the Go package. +type EvLink struct{} + +func (el *EvLink) fromC(cel *C.libxl_ev_link) error { return nil } +func (el *EvLink) toC() (cel C.libxl_ev_link, err error) { return } + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992950; cv=none; d=zohomail.com; s=zohoarc; b=G92kl1831f5ALFdfL+Xz9CjdwM54Jxkd1W/BJqnkbYB8AXfdJRG5oEyjdGRwTMZjGGZhoozeX8GiL33oubuayQ9zeXxwbTHo97xdYTt74oxtmTK+uRCd9k/HvfcI3rBZlZIDM5u9xRC9a6VCdCUY+peKO/vlmH5fvlPuekjLqP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992950; 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=8IeViILQA2b04Yt+iHTCFx4kdMEgkQmKRurZfSGluwc=; b=nwxRJdhTHRcd39+UDx+JlUYOJArqgx0Xk/Gfn6UFjvyz9msRSi15HPaQM8mmD2JVd8PEa91Y6UJL5X/OlhhfbsHmkYksSc+0EalBggQn1cZ6SvJqKtAyPiKdDve9onFQ+AdlwP0H+c5O6Se+55aceY8il3cpnT7Ef1c+f+6hrEg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992950527598.7034618302425; Tue, 10 Dec 2019 07:49:10 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkg-0003GR-Db; Tue, 10 Dec 2019 15:48:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehke-0003FW-SL for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:40 +0000 Received: from mail-qk1-x743.google.com (unknown [2607:f8b0:4864:20::743]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 72e21ea8-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:02 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id d71so8822149qkc.0 for ; Tue, 10 Dec 2019 07:48:02 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:00 -0800 (PST) X-Inumbo-ID: 72e21ea8-1b64-11ea-88e7-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:content-transfer-encoding; bh=Zeqavew/vY6f4t63gmA+rSSNtPJ2y+B2UxfgLhzHhUY=; b=EygbGrdkLsTEk84mPqLcTv0ZRFwnCJfn950cmfQS7JbKzUn/9cHW+fppSCNGF7xek0 Bb9gDYey8ithsZAYGYV55EeJQcipgmee+ugZGBP9jZvd3+6wv98oa7FPdS25EKHhi02e Uyeq0Jvt216T8Lsd3RM2XWf/QnI+14Ehu0lDfTndkG1obPM0SBtHQCGtVEIF8NPT/ary AqSVSQMjp5sl7t2fghySRJV++bgtJxyBYA/m6uBWDVt3Uth7+qQVZrw4RdWQG9AHrFrN 5SRlKp2028GvIrso/6mOqCY8CcTMNfkC16t/ZxE3DMxFv76rS51djEY2aFhN2wNw2VUN mHQw== 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=Zeqavew/vY6f4t63gmA+rSSNtPJ2y+B2UxfgLhzHhUY=; b=SjRndx2HH8hHOSJHoAP/LE+b+fBaLthYVfw6ykFYjJMdgGBOpWhrg5CmA2Pm8ZLD9o SOkf+NjQqCH5qd1tSOqIQEgXD0aLuMki5RmU7m92Cgr7yEclpL42UN0hH9YN/nb+Moyq D0KyR8TwMvCHXzHhg1IWX1jUei7y9Dwh0Q5e+hV93P/xXJy47OwCk0GDcKF3vZU1hrHz VwVqV5HGLGp2+dSEBGCkT6gz7GQgzKDMLZjQgjZwxstc8nZLaypBwrb46EU9Z1LFpUw/ 8XPeRodlkbkc6Rb3xAvluOpTtWzCOLSq3++LueBHu0qjPnuBMayYJ2mtDOQ1+lW6KQtj RBgw== X-Gm-Message-State: APjAAAU/wE2M0xg3NtpkYVnFHtrs/Sce6h2WSCFn6CerHu1ndUau7mje hmKVvO1fFqAqfVnvRlbnXjlnH9d8 X-Google-Smtp-Source: APXvYqwh9aTRRUDRv9wyWdtg/YUET9v/Hyw7FI8XTve/UavWp824/kDuEMYqZ+I6Uj7wSJRabYz+TA== X-Received: by 2002:a05:620a:12ab:: with SMTP id x11mr33769828qki.149.1575992881771; Tue, 10 Dec 2019 07:48:01 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:25 -0500 Message-Id: <7e9e0c548291406c980e9496a7f09d081682d3c7.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 10/22] golang/xenlight: define CpuidPolicyList builtin type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Define CpuidPolicyList as a string so that libxl_cpuid_parse_config can be used in the toC function. For now, fromC is a no-op since libxl does not support a way to read a policy, modify it,and then give it back to libxl. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Re-define CpuidPolicyList as string. - Make fromC a no-op. - Use libxl_cpuid_parse_config in toC function. --- tools/golang/xenlight/xenlight.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index c1d9fe85fd..6b87bf857d 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -245,6 +245,31 @@ type EvLink struct{} func (el *EvLink) fromC(cel *C.libxl_ev_link) error { return nil } func (el *EvLink) toC() (cel C.libxl_ev_link, err error) { return } =20 +// CpuidPolicyList represents a libxl_cpuid_policy_list. +// +// The value of CpuidPolicyList is honored when used as input to libxl. If +// a struct contains a field of type CpuidPolicyList, that field will be l= eft +// empty when it is returned from libxl. +type CpuidPolicyList string + +func (cpl CpuidPolicyList) fromC(ccpl *C.libxl_cpuid_policy_list) error { = return nil } + +func (cpl CpuidPolicyList) toC() (C.libxl_cpuid_policy_list, error) { + var ccpl C.libxl_cpuid_policy_list + + s :=3D C.CString(string(cpl)) + defer C.free(unsafe.Pointer(s)) + + ret :=3D C.libxl_cpuid_parse_config(&ccpl, s) + if ret !=3D 0 { + C.libxl_cpuid_dispose(&ccpl) + + return ccpl, Error(-ret) + } + + return ccpl, nil +} + type Context struct { ctx *C.libxl_ctx logger *C.xentoollog_logger_stdiostream --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992958; cv=none; d=zohomail.com; s=zohoarc; b=O/0bmQWiRwrMpVmz2MzL9zJLq7EmN9sC1EsC5gzVJH1mwFEHVfUpTK66LWryZ9WAIryZapbS3ZoAIkxrebPMbRnkhmOfo3MHR8ylzDHv5oGjxIU4xCutEJBcm17zxPBr51EPQSEBYrgNmR/R1bbO6m1bnbM5/S6UpX1OSsxySa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992958; 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=euk8GyTsS6TGmo3kFfawIfRYN2LsUUcu/5v43FJeFzU=; b=HCM5DTbVFVLvX0JaDd38O4KdfBy3nHyQCOCIKc9IJBeLohLLpBDzP/baujtkTY1TxVpz5SDi1x7st2p0BhEkO2LIli+KNaXkPdPAKD6dkMSfRUxKzpjUK5+zcgF4xEloSdn4y+/SVgFtS729sNfTwczcMXXCmf9uM2PtHX30oo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992958117759.4089629613209; Tue, 10 Dec 2019 07:49:18 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkl-0003Ki-O3; Tue, 10 Dec 2019 15:48:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkj-0003J1-S3 for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:45 +0000 Received: from mail-qt1-x844.google.com (unknown [2607:f8b0:4864:20::844]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 73741506-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:48:03 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id 38so3130825qtb.13 for ; Tue, 10 Dec 2019 07:48:03 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:02 -0800 (PST) X-Inumbo-ID: 73741506-1b64-11ea-a1e1-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:content-transfer-encoding; bh=c8eG9nY6uSAld50WZyo55/GW778waof2L41HLOEHCKQ=; b=bGd4ymgkVlVL1phXwcmu5aPmfqdTvLi6u5ExaiW9g829fXig+NFceUzr6jTqtV5gwf eYIuiTYlaXmrTnukn6XCoLjlQlBFSHZTtzP2RcN0w8sV70fqZ0jEnbs4a0e4Dp0UIcFD lT2eE3O1i09NHJ9ORk4nd6QBgdQjXc5o2CJXyQcytZmqOcmnbIfYiuOv7QV5MGCLUd/4 CPWXCR+OdVwWhMtt/+sg+/5+HR1aIikUC+p4Twuo+tFE/QFWus64gOEPlRqi2PhMVwI2 0ikez2OYCUS/T9Z7g96/PKv2GEyDwgFYeVC40PSXp0GCe/49mdokT8SwMlSs/JwDOkyc idzg== 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=c8eG9nY6uSAld50WZyo55/GW778waof2L41HLOEHCKQ=; b=ai1fpvJmD0rhGP46/6x1a3x7wbIuiiKADNJbXpgwAqOvXK7a6wDMa0VS3gZx7PULXm qvX0/14f8Fa4AtFfaba2t7SDWVqBEAv8yMKWmGHctCiIOFoGg4G5Z5oXzdQO0iL2nCy1 DqJa8nzaVeZP8CKbDYFk+S5mKVxh7myG6rsoj21RpzQDCXS+tHEqAQjAp188v+JejWsO lT/pH8o3UtQ2xrGsQsATKHMeTTp7+qP9HMFTzO7O1oqMxXkh4LEes4DYbJ95+j+uRAl9 4fWeX3LGkv8Cv9fOWroWHVK0F7YfS7tgZCiawEkztSa6Juvw9tJDwTEEx3R9nV5CyuSw DAqQ== X-Gm-Message-State: APjAAAUT5iik6+NFWhxJ+rRvurHkMVbyqehXgUE22qSJWXRE/9NoMQJo 6LTOo4b8XCYYt0eQChCbTJbjZbG8 X-Google-Smtp-Source: APXvYqz8TJn17TN6D32LLH5uf7D2c0reXOGZrLTbJ9v2fyFuFDZQHnaIsX4Y0WMjgqTi4SuVUxxP4g== X-Received: by 2002:ac8:5159:: with SMTP id h25mr31205583qtn.101.1575992882974; Tue, 10 Dec 2019 07:48:02 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:26 -0500 Message-Id: <0003ff86099be24d6b5a2131393189da6bf5bab7.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 11/22] golang/xenlight: re-factor Uuid type implementation 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Re-define Uuid as [16]byte and implement fromC, toC, and String functions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v3: - In fromC, iterate over the indirect of u instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 35 +++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 6b87bf857d..f9c2f84c81 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -86,7 +86,38 @@ type Devid int =20 type MemKB uint64 =20 -type Uuid C.libxl_uuid +// Uuid is a domain UUID. +type Uuid [16]byte + +// String formats a Uuid in the form "xxxx-xx-xx-xx-xxxxxx". +func (u Uuid) String() string { + s :=3D "%x%x%x%x-%x%x-%x%x-%x%x-%x%x%x%x%x%x" + opts :=3D make([]interface{}, 16) + + for i, v :=3D range u { + opts[i] =3D v + } + + return fmt.Sprintf(s, opts...) +} + +func (u *Uuid) fromC(c *C.libxl_uuid) error { + for i :=3D range *u { + u[i] =3D byte(c.uuid[i]) + } + + return nil +} + +func (u *Uuid) toC() (C.libxl_uuid, error) { + var c C.libxl_uuid + + for i, v :=3D range u { + c.uuid[i] =3D C.uint8_t(v) + } + + return c, nil +} =20 // defboolVal represents a defbool value. type defboolVal int @@ -495,7 +526,7 @@ type Dominfo struct { func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { =20 di =3D &Dominfo{} - di.Uuid =3D Uuid(cdi.uuid) + di.Uuid.fromC(&cdi.uuid) di.Domid =3D Domid(cdi.domid) di.Ssidref =3D uint32(cdi.ssidref) di.SsidLabel =3D C.GoString(cdi.ssid_label) --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992965; cv=none; d=zohomail.com; s=zohoarc; b=ELEEGKcfIJ35Gv4LaS8HtOedYoejE2iv1WPMFKQ2nHMXxf9jGqgeC1T80G91/qrkBJijQdiKpA5UCmVWCRI8CwyxetuHY7GpS3cMFZqjVtrJEfOByMRF7p/kCxkNDq8FQeKUvjmjyaTR/Uyr5hiSuhRjobMrBTAOvVuPY9Ik7Bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992965; 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=FJukvunWNd+QXlT8BRxIiGGrH3miGX7HaD955+oL0iE=; b=YcW3UUxdFu+wrSjZUGaJqZUigxigD+JOMr4mppUpJEJFyQW9N62dBNpA8HEK1KVrEsnqSBl87vHQJMPwvE8D8DdC7bQ7JX8vy1XxTL+H7KK7RSsSuFlRPHrDZe7+N+EiUh55xOl6he3T+xZ7GkjwLtX8T77UcFGrM7+VzXhOJu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992965398145.58547653033338; Tue, 10 Dec 2019 07:49:25 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkq-0003OR-3h; Tue, 10 Dec 2019 15:48:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehko-0003NL-SF for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:50 +0000 Received: from mail-qv1-xf41.google.com (unknown [2607:f8b0:4864:20::f41]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 74232154-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:04 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id t5so4353960qvs.5 for ; Tue, 10 Dec 2019 07:48:04 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:03 -0800 (PST) X-Inumbo-ID: 74232154-1b64-11ea-88e7-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:content-transfer-encoding; bh=lfSXRpgw3eVeA7YwpoTkHPmcDjBPWceRwH/SOucJAAQ=; b=FBccXHBTUri+KAyO6xTjfajMJ39Yj0OBmAysXJTLpemtmDEzFQQPvYI39haJ4rDoF6 ZYHeB4MglGIXgCgFXyVK7d1l9zLNLmfcaYk2GHvd+YJ9oneLussrUPY1nhHepkIKy4jR ldpTbhMQjxHYfTlaN8WpHMunrb5CQ90SlTYU7RAqPBWqvhRQSX6zvQNpChZTZooyT9mt mXFeD0+ZEQlA1PJdlnYeCa0kG3NOwgkN3XcEQmrcH96PvppAtcygP/Vv5Lqd1T49OHzQ VAPJCc+zgSuo9qSEctUaMYsoj0GgAmc3PpXzVNw0gWCGIH4b3O+r83m2BcbT4M0Nnsoy +Jlg== 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=lfSXRpgw3eVeA7YwpoTkHPmcDjBPWceRwH/SOucJAAQ=; b=oPPgTsrTqyktKRJyAX3fZfSmy+/tc1sZFX8ygKW+wAQKzl8O8ZDvKF29id9J/312S/ pJzyXnPBSxrjYXfXtqHJ6nhbpEzNUUDIcOXMvTFAN9Lg8RFniLaZ2fXBbv3ld2SfayKQ XaYpyafB6oCWkIqd76DTaOi380eTep3BQItBEa6XFawOklpFQgwRuYmNMdnSDztgPpJE ukd7VMFS8P1QcMa16ZbfeDE+Ybje3nnYo4h6RSJVq0tgf0f4vGtb3KQfziRZ8dBL5dLT C1XVPKneR63TakMX0Nwo+pSdFc73/+xkJh/acn6oXc8Eo7gsqdtd4SBW4nKvwVi1QTbC ISqg== X-Gm-Message-State: APjAAAX7glVfjlxVdCri9YOCkq78mu7SksE1l0ygTzLsnHJZTS3QP3/2 PvxmDeztKSoIhreHZknkrVFSKSGA X-Google-Smtp-Source: APXvYqzuBusz/PYk0k4PcYgSBjqOXeyAI1CC2tDIejBw2FAwwmgPdy8r4De3xiCWU4U1V/zORgsnuw== X-Received: by 2002:a0c:ef0f:: with SMTP id t15mr27304967qvr.123.1575992884039; Tue, 10 Dec 2019 07:48:04 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:27 -0500 Message-Id: <7a789af7e2a0595132cf898a80ea6707537d31c2.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 12/22] golang/xenlight: re-factor Hwcap type implementation 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Re-define Hwcap as [8]uint32, and implement toC function. Also, re-name and modify signature of toGo function to fromC. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix comment in fromC since an array is being used now, not a slice. - Use a concise variable name instead of mapslice for the C array. Changes in v3: - In fromC, iterate over the indirect of hwcap instead of creating a slice from the C type. --- tools/golang/xenlight/xenlight.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index f9c2f84c81..b395963512 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -306,20 +306,25 @@ type Context struct { logger *C.xentoollog_logger_stdiostream } =20 -type Hwcap []C.uint32_t +// Hwcap represents a libxl_hwcap. +type Hwcap [8]uint32 =20 -func (chwcap C.libxl_hwcap) toGo() (ghwcap Hwcap) { - // Alloc a Go slice for the bytes - size :=3D 8 - ghwcap =3D make([]C.uint32_t, size) +func (hwcap *Hwcap) fromC(chwcap *C.libxl_hwcap) error { + for i :=3D range *hwcap { + hwcap[i] =3D uint32(chwcap[i]) + } =20 - // Make a slice pointing to the C array - mapslice :=3D (*[1 << 30]C.uint32_t)(unsafe.Pointer(&chwcap[0]))[:size:si= ze] + return nil +} =20 - // And copy the C array into the Go array - copy(ghwcap, mapslice) +func (hwcap *Hwcap) toC() (C.libxl_hwcap, error) { + var chwcap C.libxl_hwcap =20 - return + for i, v :=3D range hwcap { + chwcap[i] =3D C.uint32_t(v) + } + + return chwcap, nil } =20 // KeyValueList represents a libxl_key_value_list. @@ -442,7 +447,7 @@ func (cphys *C.libxl_physinfo) toGo() (physinfo *Physin= fo) { physinfo.SharingFreedPages =3D uint64(cphys.sharing_freed_pages) physinfo.SharingUsedFrames =3D uint64(cphys.sharing_used_frames) physinfo.NrNodes =3D uint32(cphys.nr_nodes) - physinfo.HwCap =3D cphys.hw_cap.toGo() + physinfo.HwCap.fromC(&cphys.hw_cap) physinfo.CapHvm =3D bool(cphys.cap_hvm) physinfo.CapHvmDirectio =3D bool(cphys.cap_hvm_directio) =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992987; cv=none; d=zohomail.com; s=zohoarc; b=W7UgIHVcBgXGDxKPpfnj6Cv8Km5r6spsPRaZHEJLRaynJOCCzntqbZDN2iI+yXAgfNmpAKHmkwFjnV6ulxK31TlioFI2As+Nx4AZEbBoxWUXjaJCTtM9dwsSA+yKBk3hyxYAf85hR5T6gjImWm2wxoUIyBh0MIGFqYxZdCufs9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992987; 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=D6DtEp3OKwkkb6BduG1l6E5Y/hDFKj/Muj/12avecJM=; b=m1qe6nGbpRp208SEOVWVmnO+9xwflxY9X16eCPmqhW7MMG5AHIdwSPwsPyeY0iAdHetnWoDQZZco/tVYd33AF3CBMPbxB3KXufJNBGCkXOlwn3tl4+nFMLF1VSr74jASCNbdTGTlVChqhl93EsnzD/tAyam89q0nCUZ6qDd9e3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992987917367.17648382589937; Tue, 10 Dec 2019 07:49:47 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehl0-0003XO-Oy; Tue, 10 Dec 2019 15:49:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehky-0003W4-TC for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:00 +0000 Received: from mail-qv1-xf2f.google.com (unknown [2607:f8b0:4864:20::f2f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7527e134-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:06 +0000 (UTC) Received: by mail-qv1-xf2f.google.com with SMTP id k10so2747334qve.7 for ; Tue, 10 Dec 2019 07:48:06 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:04 -0800 (PST) X-Inumbo-ID: 7527e134-1b64-11ea-88e7-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:content-transfer-encoding; bh=af5EwPUGi1avVJwjAlPBs3prh+kcXvkBRkwJbMReW60=; b=TLuPaUUXY1rTdtLGgyimIZ2OPedRUMzipdADwJw5GHddbRRyXthMufscVruM7x6FMr l/j/j9xy0mA8p4y8h+r43Ky6qlNSfzyrAFUNMJWoUmzK9jrAl+8EUNexTVTGoamEIAON uwnTJqBsNS5bMz/z2KGjDrE7HuTgpinNxbMvCT9ja40kJ1XtSGxAr72xJMJgwcYE7p76 ZWRQrUgOoFWsWvqqr63hSB8TghJg0+BK97BFqRWcKlBNcCSTdx9SkyybFQo06T28g3Re rX3xr8PY0qHDNzFBmI38KJDPlB/Ytt3uMdQC2hK04sX90KikTGPU3FIRC0SZg87V7vHF jprg== 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=af5EwPUGi1avVJwjAlPBs3prh+kcXvkBRkwJbMReW60=; b=nUOLaZeOALEO2JWXlvRHRprvhyNMzz/rxFaf+oSHRE0H+zD3Lq6a90H8+wuyl3CZW9 1y++7ZgWS9A81BmZGXFpD+01w+8Lceftu5jg2Y+FK4exwkpvYircs/PGhkpdJC9Qa1OA djE7TpzMpflJrjw0x7BpTuwqeqUm2C20D8IlO6XjZbej8lqlEdYJ6JU1hxAb740lSGPB VuLsB89/7wvuFnWfm0nqv7Msa5bkf+8NBpxvHA7fA9XTHlZ4bBlyZOq119r+G3Ti4Tpz 5+TdZHVgBcJ+h+bLiRPFIunIm5ziBLMwYJmdXH4jNvgJeg8jEvWs/aam5yH1fDrbo3Xo 0Efg== X-Gm-Message-State: APjAAAUfLlTSv71ICfVKaTPZS/utOlnLVr5/DURkmFq4W+tK+Vu+uFNr UnsHeHhFo/+SK+Gmo36+e7oqQXm7 X-Google-Smtp-Source: APXvYqwA7XR/atdUpAeLvKl+W2LSlwYQb7wbFc4ERoC7zAIhsUVKFclujwUcbCK7Yxfxgd5F98JDOA== X-Received: by 2002:a05:6214:14ad:: with SMTP id bo13mr16880575qvb.22.1575992885368; Tue, 10 Dec 2019 07:48:05 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:28 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 13/22] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 Reviewed-by: George Dunlap --- Changes in v2: - Do not use global variables for extra type definitions. Instead, return a tuple which includes a list of extra type definitions associated with the original type. - Re-generate types.gen.go to include changes to libxl after rebase. --- 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/ge= ngotypes.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 =3D None, types= =3D None, comment =3D None): f.write('package xenlight\n') =20 for ty in types: - f.write(xenlight_golang_type_define(ty)) + (tdef, extras) =3D xenlight_golang_type_define(ty) + + f.write(tdef) f.write('\n') =20 + # Append extra types + for extra in extras: + f.write(extra) + f.write('\n') + go_fmt(path) =20 def xenlight_golang_type_define(ty =3D None): - s =3D '' + """ + Generate the Go type definition of ty. =20 + 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 +=3D xenlight_golang_define_enum(ty) + return (xenlight_golang_define_enum(ty), []) =20 - return s + elif isinstance(ty, idl.Aggregate): + return xenlight_golang_define_struct(ty) =20 def xenlight_golang_define_enum(ty =3D None): s =3D '' @@ -65,6 +79,103 @@ def xenlight_golang_define_enum(ty =3D None): =20 return s =20 +def xenlight_golang_define_struct(ty =3D None, typename =3D None, nested = =3D False): + s =3D '' + extras =3D [] + name =3D '' + + if typename is not None: + name =3D xenlight_golang_fmt_name(typename) + else: + name =3D xenlight_golang_fmt_name(ty.typename) + + # Begin struct definition + if nested: + s +=3D '{} struct {{\n'.format(name) + else: + s +=3D '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 =3D f.type.elem_type.typename + typename =3D xenlight_golang_fmt_name(typename) + name =3D xenlight_golang_fmt_name(f.name) + + s +=3D '{} []{}\n'.format(name, typename) + else: + typename =3D f.type.typename + typename =3D xenlight_golang_fmt_name(typename) + name =3D xenlight_golang_fmt_name(f.name) + + s +=3D '{} {}\n'.format(name, typename) + + elif isinstance(f.type, idl.Struct): + r =3D xenlight_golang_define_struct(f.type, typename=3Df.name,= nested=3DTrue) + + s +=3D r[0] + extras.extend(r[1]) + + elif isinstance(f.type, idl.KeyedUnion): + r =3D xenlight_golang_define_union(f.type, ty.typename) + + s +=3D r[0] + extras.extend(r[1]) + + else: + raise Exception('type {} not supported'.format(f.type)) + + # End struct definition + s +=3D '}\n' + + return (s,extras) + +def xenlight_golang_define_union(ty =3D None, structname =3D ''): + """ + 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 =3D '' + extras =3D [] + + interface_name =3D '{}_{}_union'.format(structname, ty.keyvar.name) + interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + + s +=3D 'type {} interface {{\n'.format(interface_name) + s +=3D 'is{}()\n'.format(interface_name) + s +=3D '}\n' + + extras.append(s) + + for f in ty.fields: + if f.type is None: + continue + + # Define struct + name =3D '{}_{}_union_{}'.format(structname, ty.keyvar.name, f.nam= e) + r =3D xenlight_golang_define_struct(f.type, typename=3Dname) + extras.append(r[0]) + extras.extend(r[1]) + + # Define function to implement 'union' interface + name =3D xenlight_golang_fmt_name(name) + s =3D 'func (x {}) is{}(){{}}\n'.format(name, interface_name) + extras.append(s) + + fname =3D xenlight_golang_fmt_name(ty.keyvar.name) + ftype =3D xenlight_golang_fmt_name(ty.keyvar.type.typename) + s =3D '{} {}\n'.format(fname, ftype) + + fname =3D xenlight_golang_fmt_name('{}_union'.format(ty.keyvar.name)) + s +=3D '{} {}\n'.format(fname, interface_name) + + return (s,extras) + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.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 =3D 4 ) =20 +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 =20 const ( @@ -290,6 +467,11 @@ const ( TeeTypeOptee TeeType =3D 1 ) =20 +type RdmReserve struct { + Strategy RdmReserveStrategy + Policy RdmReservePolicy +} + type Altp2MMode int =20 const ( @@ -299,6 +481,278 @@ const ( Altp2MModeLimited Altp2MMode =3D 3 ) =20 +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 =20 const ( @@ -314,6 +768,92 @@ const ( UsbdevTypeHostdev UsbdevType =3D 1 ) =20 +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 =20 const ( @@ -344,6 +884,14 @@ const ( VsndPcmFormatGsm VsndPcmFormat =3D 25 ) =20 +type VsndParams struct { + SampleRates []uint32 + SampleFormats []VsndPcmFormat + ChannelsMin uint32 + ChannelsMax uint32 + BufferSize uint32 +} + type VsndStreamType int =20 const ( @@ -351,6 +899,229 @@ const ( VsndStreamTypeC VsndStreamType =3D 2 ) =20 +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 =20 const ( @@ -361,6 +1132,38 @@ const ( EventTypeDomainCreateConsoleAvailable EventType =3D 5 ) =20 +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 =20 const ( @@ -380,9 +1183,42 @@ const ( PsrCbmTypeMbaThrtl PsrCbmType =3D 5 ) =20 +type PsrCatInfo struct { + Id uint32 + CosMax uint32 + CbmLen uint32 + CdpEnabled bool +} + type PsrFeatType int =20 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() {} diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index b395963512..8f41047726 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -33,7 +33,6 @@ import "C" =20 import ( "fmt" - "time" "unsafe" ) =20 @@ -408,30 +407,6 @@ func (bm *Bitmap) toC() (C.libxl_bitmap, error) { return cbm, nil } =20 -/* - * 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) { =20 physinfo =3D &Physinfo{} @@ -454,22 +429,6 @@ func (cphys *C.libxl_physinfo) toGo() (physinfo *Physi= nfo) { return } =20 -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 =3D &VersionInfo{} info.XenVersionMajor =3D int(cinfo.xen_version_major) @@ -503,31 +462,6 @@ func (dt DomainType) String() (str string) { return } =20 -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) { =20 di =3D &Dominfo{} @@ -541,17 +475,17 @@ func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { di.Shutdown =3D bool(cdi.shutdown) di.Dying =3D bool(cdi.dying) di.NeverStop =3D bool(cdi.never_stop) - di.ShutdownReason =3D int32(cdi.shutdown_reason) - di.OutstandingMemkb =3D MemKB(cdi.outstanding_memkb) - di.CurrentMemkb =3D MemKB(cdi.current_memkb) - di.SharedMemkb =3D MemKB(cdi.shared_memkb) - di.PagedMemkb =3D MemKB(cdi.paged_memkb) - di.MaxMemkb =3D MemKB(cdi.max_memkb) - di.CpuTime =3D time.Duration(cdi.cpu_time) + di.ShutdownReason =3D ShutdownReason(cdi.shutdown_reason) + di.OutstandingMemkb =3D uint64(cdi.outstanding_memkb) + di.CurrentMemkb =3D uint64(cdi.current_memkb) + di.SharedMemkb =3D uint64(cdi.shared_memkb) + di.PagedMemkb =3D uint64(cdi.paged_memkb) + di.MaxMemkb =3D uint64(cdi.max_memkb) + di.CpuTime =3D uint64(cdi.cpu_time) di.VcpuMaxId =3D uint32(cdi.vcpu_max_id) di.VcpuOnline =3D uint32(cdi.vcpu_online) di.Cpupool =3D uint32(cdi.cpupool) - di.DomainType =3D int32(cdi.domain_type) + di.DomainType =3D DomainType(cdi.domain_type) =20 return } @@ -587,27 +521,11 @@ func SchedulerFromString(name string) (s Scheduler, e= rr error) { return } =20 -// libxl_cpupoolinfo =3D Struct("cpupoolinfo", [ -// ("poolid", uint32), -// ("pool_name", string), -// ("sched", libxl_scheduler), -// ("n_dom", uint32), -// ("cpumap", libxl_bitmap) -// ], dir=3DDIR_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 =3D uint32(cci.poolid) gci.PoolName =3D C.GoString(cci.pool_name) - gci.Scheduler =3D Scheduler(cci.sched) - gci.DomainCount =3D int(cci.n_dom) + gci.Sched =3D Scheduler(cci.sched) + gci.NDom =3D uint32(cci.n_dom) gci.Cpumap.fromC(&cci.cpumap) =20 return @@ -615,7 +533,7 @@ func (cci C.libxl_cpupoolinfo) toGo() (gci CpupoolInfo)= { =20 // 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 :=3D Ctx.CheckOpen() if err !=3D nil { return @@ -642,7 +560,7 @@ func (Ctx *Context) ListCpupool() (list []CpupoolInfo) { } =20 // 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 :=3D Ctx.CheckOpen() if err !=3D 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, foun= d bool) { +func (Ctx *Context) CpupoolFindByName(name string) (info Cpupoolinfo, foun= d bool) { plist :=3D Ctx.ListCpupool() =20 for i :=3D range plist { @@ -1275,24 +1193,13 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) { return } =20 -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 =3D uint32(cvci.vcpuid) gvci.Cpu =3D uint32(cvci.cpu) gvci.Online =3D bool(cvci.online) gvci.Blocked =3D bool(cvci.blocked) gvci.Running =3D bool(cvci.running) - gvci.VCpuTime =3D time.Duration(cvci.vcpu_time) + gvci.VcpuTime =3D uint64(cvci.vcpu_time) gvci.Cpumap.fromC(&cvci.cpumap) gvci.CpumapSoft.fromC(&cvci.cpumap_soft) =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992965; cv=none; d=zohomail.com; s=zohoarc; b=nlw23KjHnPAK9glix3J4FBarZO2PtLgxNHNZ39NfEJ8pBxJrKeqTKHemOMBv+Hr5g59/RjWmvnQDNCQg8n6HA20IY3S87pQTXI01RgK58JxVdEIQgjP9fB8+h3JFfEmGErjxNWJLYiZrgbq9nr406KTRDVUhOxH1xwQzT0ir74I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992965; 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=qCgDCmrNNuHW0Ad+YGr4c/AI/WEeqxp81w4KyBawlCM=; b=StiZlxJBN4n5VXfz4usu8NzG5l8bJ0gDJq828Rv9biJIjiCRRS7BMESMmtDp4mj5AQE1KyuZkSFvFBhKsWsILCcrpKdBA2r87w0yPiKffSM1MG+vRaLESLa5/v24CELpGl8q4opfQHy+ObLb992Woz3e1BYItduwD8Um4HBXjm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992965658733.602116685375; Tue, 10 Dec 2019 07:49:25 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehku-0003Rz-Dw; Tue, 10 Dec 2019 15:48:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehkt-0003Rb-Rk for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:48:55 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 757fa158-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:48:07 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id l124so4839905qkf.8 for ; Tue, 10 Dec 2019 07:48:07 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:05 -0800 (PST) X-Inumbo-ID: 757fa158-1b64-11ea-a1e1-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:content-transfer-encoding; bh=0TURsPZc+1/SmVXD/EyiheO2ykqzwRquClSd3SbIosQ=; b=h84yTtVmUxwtJaAcNNpoBjVacQCFLHyxF7k36Y0+m8yvhxQtS2Ed3oOPYiQfQUdGMk XWpDkahoYyqgrysVUuJtiyimnGVknkUqjIkZ1tL91hu4Ei3NAbbYWDbxckaYmQvbnT2M 74paNWdgY4vNzFybwMDhHBWHI9vpALEf2VwnBcqyQljSzBtBuIDQfq16O/POqa6U8EQX /XtojjqaKZFJESd7pTKri+nwwC3UvVs9JYJNIzFJ61D2Ier+HifkY9nNoASNO3QtEC6d SPRQdGWrg2JBcpm9CNLhRNOpHzGCKBEY+lIUJZVJto2zdZywYOcaicGBKU4YDq/x6qqL vEuw== 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=0TURsPZc+1/SmVXD/EyiheO2ykqzwRquClSd3SbIosQ=; b=EEWlasJvRKjDqmaidDV/xz7+ZtNyUwDWqgLEWvCE9UhsgldYxlEsmoP2hGN9PBRtmF OW2EAhFHA3aIdsl9n/mY6OBGYKHb8unJh04F5EGzak4WVbQRLaYgpDZU9g2S5z9l56J0 DZhufm1/nlGRSRpcPumfobh6EV9DNIIPs8pyS3/PLV1Nkkw3i2KZ6TrwO3ALESMTN07f 8KJkCFn51Emzs+TyjXdxQGrId/9SMaf5RZM5oXYT5bQ305sKc9MEneWi68Kc87mREorn scBTXjZRdHhha5I7gbDKmI6IA3z0f5WfgAW2/GP8z+Hsl2tT+SDVkrGVWLK+T43kpJxz Tn0Q== X-Gm-Message-State: APjAAAUHoZg0pO2xj7FTXvQlOnK7XQUjozR7/0HnwetNPwKermECf4Nd kvcx98REpB63eNqWwKHJhehcyleD X-Google-Smtp-Source: APXvYqwVONuQ5qQupjSW0e2xsvADiPlWYvyV0/uegvWp7ArPVHnSyZxEOHXh5i6Zmmv78dN0L2u/6Q== X-Received: by 2002:a05:620a:795:: with SMTP id 21mr4965079qka.60.1575992886409; Tue, 10 Dec 2019 07:48:06 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:29 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 14/22] golang/xenlight: remove no-longer used type MemKB 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Signed-off-by: Nick Rosbrook Acked-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 8f41047726..fb1c6d9e51 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -83,8 +83,6 @@ type Domid uint32 // Devid is a device ID. type Devid int =20 -type MemKB uint64 - // Uuid is a domain UUID. type Uuid [16]byte =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992995; cv=none; d=zohomail.com; s=zohoarc; b=CmvNaHIOxtY7xUMeMFEf8ceXoXQbwA+Qwj1mUV7vZu2snGNPysUXkgZUEBoMa3wRkHVmB5sQGGfUFhNss1JiXrh+Z5YyPe9aUxkTbQM+KqkraSQd1XGXccUm1CYyNBs8m1k7uCuF2aU3t1BPEnJ5nHynnecM8MNYIDcUFd/dnFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992995; 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=YzUoVzsUDBadqfVGepWl3m5BFm1nAg4lfDn403oFBmw=; b=KaxRq7lPAjbu5w/+MVxqsUOQlmVVnHS0LgSDbyshs08iNqBehUSsVXBxLmv5crBbvzjfRd4BxmoqYKvsgRZwDaNC1SNz1VR7+xhor/2eXnROf8mTMb1Sr/F7PHzOv4I7aDhcdBhM4PNGjdIrIvL+Xysi/IG1S1DGYBD1siRjtu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992995798906.9975157769869; Tue, 10 Dec 2019 07:49:55 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehl4-0003bi-CC; Tue, 10 Dec 2019 15:49:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehl3-0003b4-TM for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:05 +0000 Received: from mail-qt1-x834.google.com (unknown [2607:f8b0:4864:20::834]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 76eb48f8-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:48:09 +0000 (UTC) Received: by mail-qt1-x834.google.com with SMTP id 38so3131172qtb.13 for ; Tue, 10 Dec 2019 07:48:09 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:07 -0800 (PST) X-Inumbo-ID: 76eb48f8-1b64-11ea-b6f1-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:content-transfer-encoding; bh=IKxnF64WqOtC2gu9kOieP6MMS1r7pR3op50iaDflv5Q=; b=Sd4MjQiozvV4+2KgB1L1BR501ktZauaE0xOZNJRmwgmYFW9hilqPReAxtKj9rB6akb 6utXZ0My7hAwSz7ekmyMEp/hdNJxsUGSYAsQ/PGhVs0R6Yl2VpsjXvNTSzUXJ7/+q72o G2kJLK0uyaz6mtNFJC6tHF2cfdiZBHGrUXX5HB/JIQzLNLJ771f7CcR9D8+PbhoXE4Sj w77mf7gTw1Tp0QVs5zcZzKKabJe/dLHdMuEKcgtCcmljpXsTHzGC++ubCpGwSXpdbhYJ HEmIlEbiiOL0PbUkE6+XHPeJzP4whU0YLCzgCTbQUVNKz17aAUrIYSb5FgZEo2Cj5MZU 4Dhw== 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=IKxnF64WqOtC2gu9kOieP6MMS1r7pR3op50iaDflv5Q=; b=sKUNyEiGvZV99a+IJx3LxfgcWQrrouOCJalV9pHxb7cwGQoytTvW5THpemGqdrVEO4 jA9T6AlKmOWIkBfPneM4KzAqY0Ntj7P2xWeLvMIBJIYOtnocmTfs6NYmS9Av8/wDQ+oR ODDF9Vi7WDyyo1TrCp0KiSUKVaWQ+VwUtj9Ver94A9HZPbsbTSx/I9ELJvKzJ+MFmHRZ lF8zmnq1zdKdccltTkGXLQYWIb+9U5yvvYfCufbCsoqOlZuDVjNbfu3gZDbeTH+FERxa iUvmQMj7NS/Og2tv/fupszjxwXdimT+J0exqyuMVUdS0WAZw+SJgGkvCkVIfbxs5zafb MF5A== X-Gm-Message-State: APjAAAXsIViAnrIKgN3oib9SP2hLuygwbnCYrTQgGF2ejFekVPJS0j7a A0HSKiqfDeRhAhlcZay0EOj70a4c X-Google-Smtp-Source: APXvYqzcKxw3ICT7f6AE6J7dTOUhQlrQl4h3mF85T9AEpcdvnE1KkHDZqCqi5pQ7twlNRqkwgM1kYQ== X-Received: by 2002:ac8:36f5:: with SMTP id b50mr31179907qtc.268.1575992887871; Tue, 10 Dec 2019 07:48:07 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:30 -0500 Message-Id: <3c638e0022455d8c670af7aa0ad5c98305c91221.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 15/22] golang/xenlight: begin C to Go type marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Begin implementation of fromC marshaling functions for generated struct types. This includes support for converting fields that are basic primitive types such as string and integer types, nested anonymous structs, nested libxl structs, and libxl built-in types. This patch does not implement conversion of arrays or keyed unions. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Add Makefile changes for helpers.gen.go. - Re-generate helpers.gen.go to include libxl changes after rebase. Changes in v3: - Break out field copying/type conversion code into its own function called xenlight_golang_convert_from_C to allow that code to be easily re-used. - Use consistent style for calling fromC on struct fields that require it. Namely, do not use a temporary variable - call fromC directly on the struct field. --- tools/golang/xenlight/Makefile | 2 + tools/golang/xenlight/gengotypes.py | 118 ++++ tools/golang/xenlight/helpers.gen.go | 901 +++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 111 +--- 4 files changed, 1032 insertions(+), 100 deletions(-) create mode 100644 tools/golang/xenlight/helpers.gen.go diff --git a/tools/golang/xenlight/Makefile b/tools/golang/xenlight/Makefile index 681f32c234..07b8896e5b 100644 --- a/tools/golang/xenlight/Makefile +++ b/tools/golang/xenlight/Makefile @@ -19,6 +19,7 @@ $(XEN_GOPATH)/src/$(XEN_GOCODE_URL)/xenlight/: %.gen.go $(INSTALL_DIR) $(XEN_GOPATH)$(GOXL_PKG_DIR) $(INSTALL_DATA) xenlight.go $(XEN_GOPATH)$(GOXL_PKG_DIR) $(INSTALL_DATA) types.gen.go $(XEN_GOPATH)$(GOXL_PKG_DIR) + $(INSTALL_DATA) helpers.gen.go $(XEN_GOPATH)$(GOXL_PKG_DIR) =20 %.gen.go: gengotypes.py $(XEN_ROOT)/tools/libxl/libxl_types.idl $(XEN_ROOT= )/tools/libxl/idl.py XEN_ROOT=3D$(XEN_ROOT) $(PYTHON) gengotypes.py ../../libxl/libxl_types.idl @@ -39,6 +40,7 @@ install: build $(INSTALL_DIR) $(DESTDIR)$(GOXL_INSTALL_DIR) $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)xenlight.go $(DESTDIR)$(GOXL_= INSTALL_DIR) $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)types.gen.go $(DESTDIR)$(GOXL= _INSTALL_DIR) + $(INSTALL_DATA) $(XEN_GOPATH)$(GOXL_PKG_DIR)helpers.gen.go $(DESTDIR)$(GO= XL_INSTALL_DIR) =20 .PHONY: uninstall rm -rf $(DESTDIR)$(GOXL_INSTALL_DIR) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 8963b14eee..1fe56179e2 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -18,6 +18,12 @@ builtin_type_names =3D { idl.uint64.typename: 'uint64', } =20 +# Some go keywords that conflict with field names in libxl structs. +go_keywords =3D ['type', 'func'] + +go_builtin_types =3D ['bool', 'string', 'int', 'byte', + 'uint16', 'uint32', 'uint64'] + def xenlight_golang_generate_types(path =3D None, types =3D None, comment = =3D None): """ Generate a .go file (types.gen.go by default) @@ -176,6 +182,116 @@ def xenlight_golang_define_union(ty =3D None, structn= ame =3D ''): =20 return (s,extras) =20 +def xenlight_golang_generate_helpers(path =3D None, types =3D None, commen= t =3D None): + """ + Generate a .go file (helpers.gen.go by default) + that contains helper functions for marshaling between + C and Go types. + """ + if path is None: + path =3D 'helpers.gen.go' + + with open(path, 'w') as f: + if comment is not None: + f.write(comment) + f.write('package xenlight\n') + + # Cgo preamble + f.write('/*\n') + f.write('#cgo LDFLAGS: -lxenlight\n') + f.write('#include \n') + f.write('#include \n') + f.write('\n') + + f.write('*/\nimport "C"\n') + + for ty in types: + if not isinstance(ty, idl.Struct): + continue + + f.write(xenlight_golang_define_from_C(ty)) + f.write('\n') + + go_fmt(path) + +def xenlight_golang_define_from_C(ty =3D None): + """ + Define the fromC marshaling function for the type + represented by ty. + """ + func =3D 'func (x *{}) fromC(xc *C.{}) error {{\n {} \n return nil}}\n' + + goname =3D xenlight_golang_fmt_name(ty.typename) + cname =3D ty.typename + + body =3D '' + + for f in ty.fields: + if f.type.typename is not None: + if isinstance(f.type, idl.Array): + # TODO + continue + + body +=3D xenlight_golang_convert_from_C(f) + + elif isinstance(f.type, idl.Struct): + # Go through the fields of the anonymous nested struct. + for nf in f.type.fields: + body +=3D xenlight_golang_convert_from_C(nf,outer_name=3Df= .name) + + elif isinstance(f.type, idl.KeyedUnion): + pass + + else: + raise Exception('type {} not supported'.format(f.type)) + + return func.format(goname, cname, body) + +def xenlight_golang_convert_from_C(ty =3D None, outer_name =3D None): + """ + Returns a line of Go code that converts the C type represented + by ty to its corresponding Go type. + + If outer_name is set, the type is treated as nested within another fie= ld + named outer_name. + """ + s =3D '' + + gotypename =3D xenlight_golang_fmt_name(ty.type.typename) + goname =3D xenlight_golang_fmt_name(ty.name) + cname =3D ty.name + + # In cgo, C names that conflict with Go keywords can be + # accessed by prepending an underscore to the name. + if cname in go_keywords: + cname =3D '_' + cname + + # If outer_name is set, treat this as nested. + if outer_name is not None: + goname =3D '{}.{}'.format(xenlight_golang_fmt_name(outer_name), go= name) + cname =3D '{}.{}'.format(outer_name, cname) + + # Types that satisfy this condition can be easily casted or + # converted to a Go builtin type. + is_castable =3D (ty.type.json_parse_type =3D=3D 'JSON_INTEGER' or + isinstance(ty.type, idl.Enumeration) or + gotypename in go_builtin_types) + + if not is_castable: + # If the type is not castable, we need to call its fromC + # function. + s +=3D 'if err :=3D x.{}.fromC(&xc.{});'.format(goname,cname) + s +=3D 'err !=3D nil {\n return err \n}\n' + + elif gotypename =3D=3D 'string': + # Use the cgo helper for converting C strings. + s +=3D 'x.{} =3D C.GoString(xc.{})\n'.format(goname, cname) + + else: + s +=3D 'x.{} =3D {}(xc.{})\n'.format(goname, gotypename, cname) + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an @@ -218,3 +334,5 @@ if __name__ =3D=3D '__main__': =20 xenlight_golang_generate_types(types=3Dtypes, comment=3Dheader_comment) + xenlight_golang_generate_helpers(types=3Dtypes, + comment=3Dheader_comment) diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go new file mode 100644 index 0000000000..576aebcf6d --- /dev/null +++ b/tools/golang/xenlight/helpers.gen.go @@ -0,0 +1,901 @@ +// DO NOT EDIT. +// +// This file is generated by: +// gengotypes.py ../../libxl/libxl_types.idl +// +package xenlight + +/* +#cgo LDFLAGS: -lxenlight +#include +#include + +*/ +import "C" + +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 *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 *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error { + x.Kind =3D VgaInterfaceType(xc.kind) + + return nil +} + +func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return err + } + 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 err + } + + return nil +} + +func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return err + } + 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 err + } + x.Passwd =3D C.GoString(xc.passwd) + if err :=3D x.AgentMouse.fromC(&xc.agent_mouse); err !=3D nil { + return err + } + if err :=3D x.Vdagent.fromC(&xc.vdagent); err !=3D nil { + return err + } + if err :=3D x.ClipboardSharing.fromC(&xc.clipboard_sharing); err !=3D nil= { + return 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 *SdlInfo) fromC(xc *C.libxl_sdl_info) error { + if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { + return err + } + if err :=3D x.Opengl.fromC(&xc.opengl); err !=3D nil { + return err + } + x.Display =3D C.GoString(xc.display) + x.Xauthority =3D C.GoString(xc.xauthority) + + return nil +} + +func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return err + } + 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 *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 err + } + + return nil +} + +func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + 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 *Vminfo) fromC(xc *C.libxl_vminfo) error { + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return err + } + x.Domid =3D Domid(xc.domid) + + return nil +} + +func (x *VersionInfo) fromC(xc *C.libxl_version_info) error { + x.XenVersionMajor =3D int(xc.xen_version_major) + x.XenVersionMinor =3D int(xc.xen_version_minor) + 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 *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 err + } + if err :=3D x.Oos.fromC(&xc.oos); err !=3D nil { + return err + } + x.Ssidref =3D uint32(xc.ssidref) + x.SsidLabel =3D C.GoString(xc.ssid_label) + x.Name =3D C.GoString(xc.name) + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return err + } + if err :=3D x.Xsdata.fromC(&xc.xsdata); err !=3D nil { + return err + } + if err :=3D x.Platformdata.fromC(&xc.platformdata); err !=3D nil { + return 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 err + } + if err :=3D x.DriverDomain.fromC(&xc.driver_domain); err !=3D nil { + return err + } + x.Passthrough =3D Passthrough(xc.passthrough) + + return nil +} + +func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) err= or { + x.CheckpointedStream =3D int(xc.checkpointed_stream) + x.StreamVersion =3D uint32(xc.stream_version) + x.ColoProxyScript =3D C.GoString(xc.colo_proxy_script) + if err :=3D x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != =3D nil { + return err + } + + return nil +} + +func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { + x.Vcpuid =3D int(xc.vcpuid) + x.Weight =3D int(xc.weight) + 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 *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { + x.Sched =3D Scheduler(xc.sched) + + return nil +} + +func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { + x.Sched =3D Scheduler(xc.sched) + x.Weight =3D int(xc.weight) + 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 *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { + x.Memkb =3D uint64(xc.memkb) + x.Pnode =3D uint32(xc.pnode) + if err :=3D x.Vcpus.fromC(&xc.vcpus); err !=3D nil { + return err + } + + return nil +} + +func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error { + x.Strategy =3D RdmReserveStrategy(xc.strategy) + x.Policy =3D RdmReservePolicy(xc.policy) + + return nil +} + +func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_build_info) error { + x.MaxVcpus =3D int(xc.max_vcpus) + if err :=3D x.AvailVcpus.fromC(&xc.avail_vcpus); err !=3D nil { + return err + } + if err :=3D x.Cpumap.fromC(&xc.cpumap); err !=3D nil { + return err + } + if err :=3D x.Nodemap.fromC(&xc.nodemap); err !=3D nil { + return err + } + if err :=3D x.NumaPlacement.fromC(&xc.numa_placement); err !=3D nil { + return 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 err + } + if err :=3D x.DisableMigrate.fromC(&xc.disable_migrate); err !=3D nil { + return err + } + if err :=3D x.Cpuid.fromC(&xc.cpuid); err !=3D nil { + return err + } + x.BlkdevStart =3D C.GoString(xc.blkdev_start) + 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 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 err + } + if err :=3D x.ExtraPv.fromC(&xc.extra_pv); err !=3D nil { + return err + } + if err :=3D x.ExtraHvm.fromC(&xc.extra_hvm); err !=3D nil { + return err + } + if err :=3D x.SchedParams.fromC(&xc.sched_params); err !=3D nil { + return err + } + if err :=3D x.ClaimMode.fromC(&xc.claim_mode); err !=3D nil { + return 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 err + } + x.Bootloader =3D C.GoString(xc.bootloader) + if err :=3D x.BootloaderArgs.fromC(&xc.bootloader_args); err !=3D nil { + return err + } + x.TimerMode =3D TimerMode(xc.timer_mode) + if err :=3D x.NestedHvm.fromC(&xc.nested_hvm); err !=3D nil { + return err + } + if err :=3D x.Apic.fromC(&xc.apic); err !=3D nil { + return err + } + if err :=3D x.DmRestrict.fromC(&xc.dm_restrict); err !=3D nil { + return err + } + x.Tee =3D TeeType(xc.tee) + 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 *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 err + } + if err :=3D x.Sdl.fromC(&xc.sdl); err !=3D nil { + return err + } + x.Keymap =3D C.GoString(xc.keymap) + + return nil +} + +func (x *DeviceVkb) fromC(xc *C.libxl_device_vkb) error { + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + 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 *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 err + } + if err :=3D x.ColoEnable.fromC(&xc.colo_enable); err !=3D nil { + return err + } + if err :=3D x.ColoRestoreEnable.fromC(&xc.colo_restore_enable); err !=3D = nil { + return 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 *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 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 *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 *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 *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 *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error { + x.Ctrl =3D Devid(xc.ctrl) + x.Port =3D int(xc.port) + + return nil +} + +func (x *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error { + x.Path =3D C.GoString(xc.path) + + return nil +} + +func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) error { + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + x.Devid =3D Devid(xc.devid) + if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { + return err + } + + return nil +} + +func (x *DeviceP9) fromC(xc *C.libxl_device_p9) error { + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + 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 *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 *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) + + return nil +} + +func (x *ConnectorParam) fromC(xc *C.libxl_connector_param) error { + x.UniqueId =3D C.GoString(xc.unique_id) + x.Width =3D uint32(xc.width) + x.Height =3D uint32(xc.height) + + return nil +} + +func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdispl) error { + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + x.Devid =3D Devid(xc.devid) + x.BeAlloc =3D bool(xc.be_alloc) + + return nil +} + +func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { + 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 *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 err + } + + return nil +} + +func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { + x.Name =3D C.GoString(xc.name) + if err :=3D x.Params.fromC(&xc.params); err !=3D nil { + return err + } + + return nil +} + +func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) error { + x.BackendDomid =3D Domid(xc.backend_domid) + x.BackendDomname =3D C.GoString(xc.backend_domname) + 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 err + } + + return nil +} + +func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error { + if err :=3D x.CInfo.fromC(&xc.c_info); err !=3D nil { + return err + } + if err :=3D x.BInfo.fromC(&xc.b_info); err !=3D nil { + return 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 *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 *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 *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 err + } + + return 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 *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 err + } + if err :=3D x.CpumapSoft.fromC(&xc.cpumap_soft); err !=3D nil { + return err + } + + return nil +} + +func (x *Physinfo) fromC(xc *C.libxl_physinfo) error { + x.ThreadsPerCore =3D uint32(xc.threads_per_core) + x.CoresPerSocket =3D uint32(xc.cores_per_socket) + 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 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 *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 *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) + + return nil +} + +func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error { + x.ReqEvtch =3D int(xc.req_evtch) + x.ReqRref =3D int(xc.req_rref) + + return nil +} + +func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { + + return nil +} + +func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + 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) + + return nil +} + +func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { + x.Backend =3D C.GoString(xc.backend) + x.BackendId =3D uint32(xc.backend_id) + 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 *Numainfo) fromC(xc *C.libxl_numainfo) error { + x.Size =3D uint64(xc.size) + x.Free =3D uint64(xc.free) + + return 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 *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 *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 *SchedCredit2Params) fromC(xc *C.libxl_sched_credit2_params) error= { + x.RatelimitUs =3D int(xc.ratelimit_us) + + return nil +} + +func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_remus_info) error { + x.Interval =3D int(xc.interval) + if err :=3D x.AllowUnsafe.fromC(&xc.allow_unsafe); err !=3D nil { + return err + } + if err :=3D x.Blackhole.fromC(&xc.blackhole); err !=3D nil { + return err + } + if err :=3D x.Compression.fromC(&xc.compression); err !=3D nil { + return err + } + if err :=3D x.Netbuf.fromC(&xc.netbuf); err !=3D nil { + return err + } + x.Netbufscript =3D C.GoString(xc.netbufscript) + if err :=3D x.Diskbuf.fromC(&xc.diskbuf); err !=3D nil { + return err + } + if err :=3D x.Colo.fromC(&xc.colo); err !=3D nil { + return err + } + if err :=3D x.UserspaceColoProxy.fromC(&xc.userspace_colo_proxy); err != =3D nil { + return err + } + + return nil +} + +func (x *Event) fromC(xc *C.libxl_event) error { + if err :=3D x.Link.fromC(&xc.link); err !=3D nil { + return err + } + x.Domid =3D Domid(xc.domid) + if err :=3D x.Domuuid.fromC(&xc.domuuid); err !=3D nil { + return err + } + x.ForUser =3D uint64(xc.for_user) + + return nil +} + +func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info) error { + x.Id =3D uint32(xc.id) + x.CosMax =3D uint32(xc.cos_max) + x.CbmLen =3D uint32(xc.cbm_len) + x.CdpEnabled =3D bool(xc.cdp_enabled) + + return nil +} + +func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error { + x.Id =3D uint32(xc.id) + + return nil +} diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index fb1c6d9e51..f32eb11384 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -405,47 +405,6 @@ func (bm *Bitmap) toC() (C.libxl_bitmap, error) { return cbm, nil } =20 -func (cphys *C.libxl_physinfo) toGo() (physinfo *Physinfo) { - - physinfo =3D &Physinfo{} - physinfo.ThreadsPerCore =3D uint32(cphys.threads_per_core) - physinfo.CoresPerSocket =3D uint32(cphys.cores_per_socket) - physinfo.MaxCpuId =3D uint32(cphys.max_cpu_id) - physinfo.NrCpus =3D uint32(cphys.nr_cpus) - physinfo.CpuKhz =3D uint32(cphys.cpu_khz) - physinfo.TotalPages =3D uint64(cphys.total_pages) - physinfo.FreePages =3D uint64(cphys.free_pages) - physinfo.ScrubPages =3D uint64(cphys.scrub_pages) - physinfo.ScrubPages =3D uint64(cphys.scrub_pages) - physinfo.SharingFreedPages =3D uint64(cphys.sharing_freed_pages) - physinfo.SharingUsedFrames =3D uint64(cphys.sharing_used_frames) - physinfo.NrNodes =3D uint32(cphys.nr_nodes) - physinfo.HwCap.fromC(&cphys.hw_cap) - physinfo.CapHvm =3D bool(cphys.cap_hvm) - physinfo.CapHvmDirectio =3D bool(cphys.cap_hvm_directio) - - return -} - -func (cinfo *C.libxl_version_info) toGo() (info *VersionInfo) { - info =3D &VersionInfo{} - info.XenVersionMajor =3D int(cinfo.xen_version_major) - info.XenVersionMinor =3D int(cinfo.xen_version_minor) - info.XenVersionExtra =3D C.GoString(cinfo.xen_version_extra) - info.Compiler =3D C.GoString(cinfo.compiler) - info.CompileBy =3D C.GoString(cinfo.compile_by) - info.CompileDomain =3D C.GoString(cinfo.compile_domain) - info.CompileDate =3D C.GoString(cinfo.compile_date) - info.Capabilities =3D C.GoString(cinfo.capabilities) - info.Changeset =3D C.GoString(cinfo.changeset) - info.VirtStart =3D uint64(cinfo.virt_start) - info.Pagesize =3D int(cinfo.pagesize) - info.Commandline =3D C.GoString(cinfo.commandline) - info.BuildId =3D C.GoString(cinfo.build_id) - - return -} - func (sr ShutdownReason) String() (str string) { cstr :=3D C.libxl_shutdown_reason_to_string(C.libxl_shutdown_reason(sr)) str =3D C.GoString(cstr) @@ -460,34 +419,6 @@ func (dt DomainType) String() (str string) { return } =20 -func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) { - - di =3D &Dominfo{} - di.Uuid.fromC(&cdi.uuid) - di.Domid =3D Domid(cdi.domid) - di.Ssidref =3D uint32(cdi.ssidref) - di.SsidLabel =3D C.GoString(cdi.ssid_label) - di.Running =3D bool(cdi.running) - di.Blocked =3D bool(cdi.blocked) - di.Paused =3D bool(cdi.paused) - di.Shutdown =3D bool(cdi.shutdown) - di.Dying =3D bool(cdi.dying) - di.NeverStop =3D bool(cdi.never_stop) - di.ShutdownReason =3D ShutdownReason(cdi.shutdown_reason) - di.OutstandingMemkb =3D uint64(cdi.outstanding_memkb) - di.CurrentMemkb =3D uint64(cdi.current_memkb) - di.SharedMemkb =3D uint64(cdi.shared_memkb) - di.PagedMemkb =3D uint64(cdi.paged_memkb) - di.MaxMemkb =3D uint64(cdi.max_memkb) - di.CpuTime =3D uint64(cdi.cpu_time) - di.VcpuMaxId =3D uint32(cdi.vcpu_max_id) - di.VcpuOnline =3D uint32(cdi.vcpu_online) - di.Cpupool =3D uint32(cdi.cpupool) - di.DomainType =3D DomainType(cdi.domain_type) - - return -} - // const char *libxl_scheduler_to_string(libxl_scheduler p); func (s Scheduler) String() string { cs :=3D C.libxl_scheduler_to_string(C.libxl_scheduler(s)) @@ -519,16 +450,6 @@ func SchedulerFromString(name string) (s Scheduler, er= r error) { return } =20 -func (cci C.libxl_cpupoolinfo) toGo() (gci Cpupoolinfo) { - gci.Poolid =3D uint32(cci.poolid) - gci.PoolName =3D C.GoString(cci.pool_name) - gci.Sched =3D Scheduler(cci.sched) - gci.NDom =3D uint32(cci.n_dom) - gci.Cpumap.fromC(&cci.cpumap) - - return -} - // 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) { @@ -550,7 +471,8 @@ func (Ctx *Context) ListCpupool() (list []Cpupoolinfo) { // Magic cpupoolListSlice :=3D (*[1 << 30]C.libxl_cpupoolinfo)(unsafe.Pointer(c_cp= upool_list))[:nbPool:nbPool] for i :=3D range cpupoolListSlice { - info :=3D cpupoolListSlice[i].toGo() + var info Cpupoolinfo + _ =3D info.fromC(&cpupoolListSlice[i]) list =3D append(list, info) } =20 @@ -573,7 +495,7 @@ func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool Cp= upoolinfo) { } defer C.libxl_cpupoolinfo_dispose(&c_cpupool) =20 - pool =3D c_cpupool.toGo() + _ =3D pool.fromC(&c_cpupool) =20 return } @@ -1064,7 +986,7 @@ func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo,= err error) { err =3D Error(ret) return } - physinfo =3D cphys.toGo() + err =3D physinfo.fromC(&cphys) =20 return } @@ -1080,7 +1002,7 @@ func (Ctx *Context) GetVersionInfo() (info *VersionIn= fo, err error) { =20 cinfo =3D C.libxl_get_version_info(Ctx.ctx) =20 - info =3D cinfo.toGo() + err =3D info.fromC(cinfo) =20 return } @@ -1102,7 +1024,7 @@ func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo= , err error) { return } =20 - di =3D cdi.toGo() + err =3D di.fromC(&cdi) =20 return } @@ -1184,26 +1106,14 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) { =20 gslice :=3D (*[1 << 30]C.libxl_dominfo)(unsafe.Pointer(clist))[:nbDomain:= nbDomain] for i :=3D range gslice { - info :=3D gslice[i].toGo() - glist =3D append(glist, *info) + var info Dominfo + _ =3D info.fromC(&gslice[i]) + glist =3D append(glist, info) } =20 return } =20 -func (cvci C.libxl_vcpuinfo) toGo() (gvci Vcpuinfo) { - gvci.Vcpuid =3D uint32(cvci.vcpuid) - gvci.Cpu =3D uint32(cvci.cpu) - gvci.Online =3D bool(cvci.online) - gvci.Blocked =3D bool(cvci.blocked) - gvci.Running =3D bool(cvci.running) - gvci.VcpuTime =3D uint64(cvci.vcpu_time) - gvci.Cpumap.fromC(&cvci.cpumap) - gvci.CpumapSoft.fromC(&cvci.cpumap_soft) - - return -} - //libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, // int *nb_vcpu, int *nr_cpus_out); //void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus); @@ -1225,7 +1135,8 @@ func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpui= nfo) { =20 gslice :=3D (*[1 << 30]C.libxl_vcpuinfo)(unsafe.Pointer(clist))[:nbVcpu:n= bVcpu] for i :=3D range gslice { - info :=3D gslice[i].toGo() + var info Vcpuinfo + _ =3D info.fromC(&gslice[i]) glist =3D append(glist, info) } =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992998; cv=none; d=zohomail.com; s=zohoarc; b=eW40Chb9a1UMiNbKvQAHIMmd7+suy8jgS7LrlHIsvT4ivMbNROmUFexnqwR2XbU70/cbA1eBzP1Hpc1y/wDsBH6K+GDus+/ra1o7uVly2Ik9hjwUvqEzPpi3ig5GAU1jSFkQPttv8c0mCa2tNuiSCKatvmAC5/VuiKtM6BpCa60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992998; 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=HpOds0NW5+NE4bJa8JDXebaHJiGWjg2aIBbGFImIA64=; b=l0HQ4H9u7ZcfUwVmcuorkMR63SDlKiF8GZfcyAOgG9TxzadDofnf7GSK1mmM5mHPp4AZ1n0MD9ly3EL7C43I7zTl3uZ6ePoQZPEAMP6XYHeeOMC2KCU3/YAez7BYH0qX/ydavljb5ieHGwybS11fPtEOEuHKdR9H31sn0w8WOeE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992998254748.5081285269273; Tue, 10 Dec 2019 07:49:58 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehl9-0003go-Ub; Tue, 10 Dec 2019 15:49:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehl8-0003fz-Td for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:10 +0000 Received: from mail-qk1-x732.google.com (unknown [2607:f8b0:4864:20::732]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 775cd34c-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:48:10 +0000 (UTC) Received: by mail-qk1-x732.google.com with SMTP id d202so16808753qkb.1 for ; Tue, 10 Dec 2019 07:48:10 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:08 -0800 (PST) X-Inumbo-ID: 775cd34c-1b64-11ea-a1e1-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:content-transfer-encoding; bh=6bFttf93Zv7bJw+HhrXFNoNF5zm0+Ns2KTF1xAY7wfU=; b=YSOwNhHOINHafwHrTozijvpCCUTZw4CF4f9Xde08G5lN/lT5x+t50BZoZ/JDp+97bV WdR/vz/OLl6sOrXlwjEXG0zZ88d2fyprVXDlLRNcmaW0yVlFu584yISzdme3/k/aKtmD JoBbjyCtXD5DzoOL+qdTxaanRUrxT9h6IPZUxRBc0FJCTHVmjAxL6N3CX57OjPOnvbto tNkLDMzYb9O8HZ5IIn1kOoxwyZ4/7Synz2jYoIViduXzvLU4BuCqq43vreVvr3BMC7Ci WBg0mQn1TH9G5QjxDPmybFrKHJ6hpO91OxaWvHKxULRApKPwPTY0Bf/4ksrYE6ET37Ay qNnw== 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=6bFttf93Zv7bJw+HhrXFNoNF5zm0+Ns2KTF1xAY7wfU=; b=nycQ7TggWgq8xhqIFUR5JjPlI2aFJ9s0Dj02pwKtvp0PbXYFsYRxLJJ4Ls5xYtVv2S 6VGPRLv5B3wq9ttrffcXg3ukPgfaItbMuZ7eXPqNmvlrRm2U6GIQB7eth1GD3QHCmE6W O4CAUsUuTzT+hHOYtWTBVpnbujf5yhWSx2zOmiOiBPvE+0PqRsaA4xE1FVlLMDTj7G+N Jkfu30Km9cPSX/tJY8mGJljRQ4a6BhHAXyPycqK6hWFZTsFbh6Jt5py0gQ7pxP8FWI6E VOKwSBtBFFIb6IyDn5cdaaLwFiVtdlEHC4TFUK3IX0O4stOTb5PpPP6AjpguSM4rthFN 1LcQ== X-Gm-Message-State: APjAAAXQt4D8J2N9rPgO0WC8OTFauFgM+LoCfQaq7gVY8X2tVlOWGrhc Qb8ivsARdnxq3OPyR0JWQAc/am3P X-Google-Smtp-Source: APXvYqxgVOQgzkzyL9VxP4Yr1fHy7lSCRl5pj/wBz9R+kACeKCs39hebWZq2Rxh27veMx843VeBFtw== X-Received: by 2002:a37:e55:: with SMTP id 82mr33915836qko.370.1575992889007; Tue, 10 Dec 2019 07:48:09 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:31 -0500 Message-Id: <55d5a61e30b20df027a159834f18d777c8e6b0d9.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 16/22] golang/xenlight: implement keyed union C to Go marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Switch over union key to determine how to populate 'union' in Go struct. Since the unions of C types cannot be directly accessed in cgo, use a typeof trick to typedef a struct in the cgo preamble that is analagous to each inner struct of a keyed union. For example, to define a struct for the hvm inner struct of libxl_domain_build_info, do: typedef typeof(((struct libxl_domain_build_info *)NULL)->u.hvm) libxl_dom= ain_build_info_type_union_hvm; Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Do not use global variable for extra helper function definitions. Instead, return a tuple which contains a list of extra helper functions associated with the original. Changes in v3: - Use the new xenlight_golang_convert_from_C function for field copying/ type conversion. - Use a typeof trick in the cgo preamble to define structs for the inner struct of keyed unions, instead of explicitly defining the fields. --- tools/golang/xenlight/gengotypes.py | 129 +++++++++- tools/golang/xenlight/helpers.gen.go | 346 +++++++++++++++++++++++++++ 2 files changed, 464 insertions(+), 11 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 1fe56179e2..b68c1aa66b 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -24,6 +24,10 @@ go_keywords =3D ['type', 'func'] go_builtin_types =3D ['bool', 'string', 'int', 'byte', 'uint16', 'uint32', 'uint64'] =20 +# cgo preamble for xenlight_helpers.go, created during type generation and +# written later. +cgo_helpers_preamble =3D [] + def xenlight_golang_generate_types(path =3D None, types =3D None, comment = =3D None): """ Generate a .go file (types.gen.go by default) @@ -124,7 +128,7 @@ def xenlight_golang_define_struct(ty =3D None, typename= =3D None, nested =3D False): extras.extend(r[1]) =20 elif isinstance(f.type, idl.KeyedUnion): - r =3D xenlight_golang_define_union(f.type, ty.typename) + r =3D xenlight_golang_define_union(f.type, ty.typename, f.name) =20 s +=3D r[0] extras.extend(r[1]) @@ -137,7 +141,7 @@ def xenlight_golang_define_struct(ty =3D None, typename= =3D None, nested =3D False): =20 return (s,extras) =20 -def xenlight_golang_define_union(ty =3D None, structname =3D ''): +def xenlight_golang_define_union(ty =3D None, struct_name =3D '', union_na= me =3D ''): """ Generate the Go translation of a KeyedUnion. =20 @@ -149,7 +153,7 @@ def xenlight_golang_define_union(ty =3D None, structnam= e =3D ''): s =3D '' extras =3D [] =20 - interface_name =3D '{}_{}_union'.format(structname, ty.keyvar.name) + interface_name =3D '{}_{}_union'.format(struct_name, ty.keyvar.name) interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) =20 s +=3D 'type {} interface {{\n'.format(interface_name) @@ -163,11 +167,18 @@ def xenlight_golang_define_union(ty =3D None, structn= ame =3D ''): continue =20 # Define struct - name =3D '{}_{}_union_{}'.format(structname, ty.keyvar.name, f.nam= e) + name =3D '{}_{}_union_{}'.format(struct_name, ty.keyvar.name, f.na= me) r =3D xenlight_golang_define_struct(f.type, typename=3Dname) extras.append(r[0]) extras.extend(r[1]) =20 + # This typeof trick ensures that the fields used in the cgo struct + # used for marshaling are the same as the fields of the union in t= he + # actual C type, and avoids re-defining all of those fields. + s =3D 'typedef typeof(((struct {} *)NULL)->{}.{}){};' + s =3D s.format(struct_name, union_name, f.name, name) + cgo_helpers_preamble.append(s) + # Define function to implement 'union' interface name =3D xenlight_golang_fmt_name(name) s =3D 'func (x {}) is{}(){{}}\n'.format(name, interface_name) @@ -195,6 +206,7 @@ def xenlight_golang_generate_helpers(path =3D None, typ= es =3D None, comment =3D None): if comment is not None: f.write(comment) f.write('package xenlight\n') + f.write('import (\n"unsafe"\n"errors"\n"fmt"\n)\n') =20 # Cgo preamble f.write('/*\n') @@ -203,15 +215,25 @@ def xenlight_golang_generate_helpers(path =3D None, t= ypes =3D None, comment =3D None): f.write('#include \n') f.write('\n') =20 + for s in cgo_helpers_preamble: + f.write(s) + f.write('\n') + f.write('*/\nimport "C"\n') =20 for ty in types: if not isinstance(ty, idl.Struct): continue =20 - f.write(xenlight_golang_define_from_C(ty)) + (fdef, extras) =3D xenlight_golang_define_from_C(ty) + + f.write(fdef) f.write('\n') =20 + for extra in extras: + f.write(extra) + f.write('\n') + go_fmt(path) =20 def xenlight_golang_define_from_C(ty =3D None): @@ -225,6 +247,7 @@ def xenlight_golang_define_from_C(ty =3D None): cname =3D ty.typename =20 body =3D '' + extras =3D [] =20 for f in ty.fields: if f.type.typename is not None: @@ -240,14 +263,17 @@ def xenlight_golang_define_from_C(ty =3D None): body +=3D xenlight_golang_convert_from_C(nf,outer_name=3Df= .name) =20 elif isinstance(f.type, idl.KeyedUnion): - pass + r =3D xenlight_golang_union_from_C(f.type, f.name, ty.typename) + + body +=3D r[0] + extras.extend(r[1]) =20 else: raise Exception('type {} not supported'.format(f.type)) =20 - return func.format(goname, cname, body) + return (func.format(goname, cname, body), extras) =20 -def xenlight_golang_convert_from_C(ty =3D None, outer_name =3D None): +def xenlight_golang_convert_from_C(ty =3D None, outer_name =3D None, cvarn= ame =3D None): """ Returns a line of Go code that converts the C type represented by ty to its corresponding Go type. @@ -257,6 +283,10 @@ def xenlight_golang_convert_from_C(ty =3D None, outer_= name =3D None): """ s =3D '' =20 + # Use 'xc' as the name for the C variable unless otherwise specified + if cvarname is None: + cvarname =3D 'xc' + gotypename =3D xenlight_golang_fmt_name(ty.type.typename) goname =3D xenlight_golang_fmt_name(ty.name) cname =3D ty.name @@ -280,18 +310,95 @@ def xenlight_golang_convert_from_C(ty =3D None, outer= _name =3D None): if not is_castable: # If the type is not castable, we need to call its fromC # function. - s +=3D 'if err :=3D x.{}.fromC(&xc.{});'.format(goname,cname) + s +=3D 'if err :=3D x.{}.fromC(&{}.{});'.format(goname,cvarname,cn= ame) s +=3D 'err !=3D nil {\n return err \n}\n' =20 elif gotypename =3D=3D 'string': # Use the cgo helper for converting C strings. - s +=3D 'x.{} =3D C.GoString(xc.{})\n'.format(goname, cname) + s +=3D 'x.{} =3D C.GoString({}.{})\n'.format(goname,cvarname,cname) =20 else: - s +=3D 'x.{} =3D {}(xc.{})\n'.format(goname, gotypename, cname) + s +=3D 'x.{} =3D {}({}.{})\n'.format(goname,gotypename,cvarname,cn= ame) =20 return s =20 +def xenlight_golang_union_from_C(ty =3D None, union_name =3D '', struct_na= me =3D ''): + extras =3D [] + + keyname =3D ty.keyvar.name + gokeyname =3D xenlight_golang_fmt_name(keyname) + keytype =3D ty.keyvar.type.typename + gokeytype =3D xenlight_golang_fmt_name(keytype) + + interface_name =3D '{}_{}_union'.format(struct_name, keyname) + interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + + cgo_keyname =3D keyname + if cgo_keyname in go_keywords: + cgo_keyname =3D '_' + cgo_keyname + + cases =3D {} + + for f in ty.fields: + val =3D '{}_{}'.format(keytype, f.name) + val =3D xenlight_golang_fmt_name(val) + + # Add to list of cases to make for the switch + # statement below. + if f.type is None: + continue + + cases[f.name] =3D val + + # Define fromC func for 'union' struct. + typename =3D '{}_{}_union_{}'.format(struct_name,keyname,f.name) + gotypename =3D xenlight_golang_fmt_name(typename) + + # Define the function here. The cases for keyed unions are a little + # different. + s =3D 'func (x *{}) fromC(xc *C.{}) error {{\n'.format(gotypename,= struct_name) + s +=3D 'if {}(xc.{}) !=3D {} {{\n'.format(gokeytype,cgo_keyname,va= l) + err_string =3D '"expected union key {}"'.format(val) + s +=3D 'return errors.New({})\n'.format(err_string) + s +=3D '}\n\n' + s +=3D 'tmp :=3D (*C.{})(unsafe.Pointer(&xc.{}[0]))\n'.format(type= name,union_name) + + for nf in f.type.fields: + s +=3D xenlight_golang_convert_from_C(nf,cvarname=3D'tmp') + + s +=3D 'return nil\n' + s +=3D '}\n' + + extras.append(s) + + s =3D 'x.{} =3D {}(xc.{})\n'.format(gokeyname,gokeytype,cgo_keyname) + s +=3D 'switch x.{}{{\n'.format(gokeyname) + + # Create switch statement to determine which 'union element' + # to populate in the Go struct. + for case_name, case_val in cases.items(): + s +=3D 'case {}:\n'.format(case_val) + + gotype =3D '{}_{}_union_{}'.format(struct_name,keyname,case_name) + gotype =3D xenlight_golang_fmt_name(gotype) + goname =3D '{}_{}'.format(keyname,case_name) + goname =3D xenlight_golang_fmt_name(goname,exported=3DFalse) + + s +=3D 'var {} {}\n'.format(goname, gotype) + s +=3D 'if err :=3D {}.fromC(xc);'.format(goname) + s +=3D 'err !=3D nil {\n return err \n}\n' + + field_name =3D xenlight_golang_fmt_name('{}_union'.format(keyname)) + s +=3D 'x.{} =3D {}\n'.format(field_name, goname) + + # End switch statement + s +=3D 'default:\n' + err_string =3D '"invalid union key \'%v\'", x.{}'.format(gokeyname) + s +=3D 'return fmt.Errorf({})'.format(err_string) + s +=3D '}\n' + + return (s,extras) + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 576aebcf6d..e6eee234c0 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -5,11 +5,28 @@ // package xenlight =20 +import ( + "errors" + "fmt" + "unsafe" +) + /* #cgo LDFLAGS: -lxenlight #include #include =20 +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" =20 @@ -137,7 +154,28 @@ func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) e= rror { 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 ChannelConnectionPty: + var connectionPty ChannelinfoConnectionUnionPty + if err :=3D connectionPty.fromC(xc); err !=3D nil { + return err + } + x.ConnectionUnion =3D connectionPty + 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") + } =20 + tmp :=3D (*C.libxl_channelinfo_connection_union_pty)(unsafe.Pointer(&xc.u= [0])) + x.Path =3D C.GoString(tmp.path) return nil } =20 @@ -340,6 +378,29 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_bui= ld_info) error { return err } x.Tee =3D TeeType(xc.tee) + x.Type =3D DomainType(xc._type) + switch x.Type { + case DomainTypePv: + var typePv DomainBuildInfoTypeUnionPv + if err :=3D typePv.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typePv + case DomainTypeHvm: + var typeHvm DomainBuildInfoTypeUnionHvm + if err :=3D typeHvm.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeHvm + case DomainTypePvh: + var typePvh DomainBuildInfoTypeUnionPvh + if err :=3D typePvh.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typePvh + 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) @@ -347,6 +408,151 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_bu= ild_info) error { return nil } =20 +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 err + } + if err :=3D x.Apic.fromC(&tmp.apic); err !=3D nil { + return err + } + if err :=3D x.Acpi.fromC(&tmp.acpi); err !=3D nil { + return err + } + if err :=3D x.AcpiS3.fromC(&tmp.acpi_s3); err !=3D nil { + return err + } + if err :=3D x.AcpiS4.fromC(&tmp.acpi_s4); err !=3D nil { + return err + } + if err :=3D x.AcpiLaptopSlate.fromC(&tmp.acpi_laptop_slate); err !=3D nil= { + return err + } + if err :=3D x.Nx.fromC(&tmp.nx); err !=3D nil { + return err + } + if err :=3D x.Viridian.fromC(&tmp.viridian); err !=3D nil { + return err + } + if err :=3D x.ViridianEnable.fromC(&tmp.viridian_enable); err !=3D nil { + return err + } + if err :=3D x.ViridianDisable.fromC(&tmp.viridian_disable); err !=3D nil { + return err + } + x.Timeoffset =3D C.GoString(tmp.timeoffset) + if err :=3D x.Hpet.fromC(&tmp.hpet); err !=3D nil { + return err + } + if err :=3D x.VptAlign.fromC(&tmp.vpt_align); err !=3D nil { + return 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 err + } + if err :=3D x.Altp2M.fromC(&tmp.altp2m); err !=3D nil { + return 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 err + } + if err :=3D x.Vga.fromC(&tmp.vga); err !=3D nil { + return err + } + if err :=3D x.Vnc.fromC(&tmp.vnc); err !=3D nil { + return err + } + x.Keymap =3D C.GoString(tmp.keymap) + if err :=3D x.Sdl.fromC(&tmp.sdl); err !=3D nil { + return err + } + if err :=3D x.Spice.fromC(&tmp.spice); err !=3D nil { + return err + } + if err :=3D x.GfxPassthru.fromC(&tmp.gfx_passthru); err !=3D nil { + return 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 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 err + } + x.Soundhw =3D C.GoString(tmp.soundhw) + if err :=3D x.XenPlatformPci.fromC(&tmp.xen_platform_pci); err !=3D nil { + return err + } + if err :=3D x.UsbdeviceList.fromC(&tmp.usbdevice_list); err !=3D nil { + return err + } + x.VendorDevice =3D VendorDevice(tmp.vendor_device) + if err :=3D x.MsVmGenid.fromC(&tmp.ms_vm_genid); err !=3D nil { + return err + } + if err :=3D x.SerialList.fromC(&tmp.serial_list); err !=3D nil { + return err + } + if err :=3D x.Rdm.fromC(&tmp.rdm); err !=3D nil { + return 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 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 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 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 *DeviceVfb) fromC(xc *C.libxl_device_vfb) error { x.BackendDomid =3D Domid(xc.backend_domid) x.BackendDomname =3D C.GoString(xc.backend_domname) @@ -520,10 +726,32 @@ func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbc= trl) error { 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 err + } + x.TypeUnion =3D typeHostdev + default: + return fmt.Errorf("invalid union key '%v'", x.Type) + } =20 return nil } =20 +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 *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error { x.Path =3D C.GoString(xc.path) =20 @@ -565,7 +793,28 @@ func (x *DeviceChannel) fromC(xc *C.libxl_device_chann= el) error { 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 ChannelConnectionSocket: + var connectionSocket DeviceChannelConnectionUnionSocket + if err :=3D connectionSocket.fromC(xc); err !=3D nil { + return err + } + x.ConnectionUnion =3D connectionSocket + default: + return fmt.Errorf("invalid union key '%v'", x.Connection) + } + + return nil +} =20 +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 } =20 @@ -881,7 +1130,63 @@ func (x *Event) fromC(xc *C.libxl_event) error { return err } x.ForUser =3D uint64(xc.for_user) + x.Type =3D EventType(xc._type) + switch x.Type { + case EventTypeOperationComplete: + var typeOperationComplete EventTypeUnionOperationComplete + if err :=3D typeOperationComplete.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeOperationComplete + case EventTypeDomainShutdown: + var typeDomainShutdown EventTypeUnionDomainShutdown + if err :=3D typeDomainShutdown.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeDomainShutdown + case EventTypeDiskEject: + var typeDiskEject EventTypeUnionDiskEject + if err :=3D typeDiskEject.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeDiskEject + 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") + } =20 + 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 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 } =20 @@ -896,6 +1201,47 @@ func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info) = error { =20 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 PsrFeatTypeMba: + var typeMba PsrHwInfoTypeUnionMba + if err :=3D typeMba.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeMba + case PsrFeatTypeCat: + var typeCat PsrHwInfoTypeUnionCat + if err :=3D typeCat.fromC(xc); err !=3D nil { + return err + } + x.TypeUnion =3D typeCat + 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") + } =20 + 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 } --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575992996; cv=none; d=zohomail.com; s=zohoarc; b=LoQlFrz/4v7r0lzlE5We5vKAjxTBkXmDSx5ukDcWL9Isfy20mwfA7p04RPvJDtiZultGPe4WFkDwYP5EWuqOND8jjI9+qIz+HtE2kgt7zCBajzs5HWM7XW/UibN2LZvA8uDprB4Xhjb6AcnCkfK8+VkIQRHjUHFACMwrnUs+S00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575992996; 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=qpo5nmTDQSdSnTp5uxzFriHE9hkVKUdyyhFPw6vjeEo=; b=U0CL+dh5HwN90ZsFHaBXJrtari+q75XyiZwoTjv2HWx7KTX6v58qX04jAdssep+7PzBzmQLgJOcjbQf90MJvA7USqYx6ifOL3+19t9YEY2L7+Kcl/oKdGeZj177yW5qGu31Jpg2Qz9lO6rgUOAq2kbg1xTDR3MzeQj0Um0IZV5M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575992996850297.9184367750604; Tue, 10 Dec 2019 07:49:56 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlF-0003lW-A6; Tue, 10 Dec 2019 15:49:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlD-0003k7-TJ for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:15 +0000 Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 782e1cf4-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:48:11 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id d71so8822618qkc.0 for ; Tue, 10 Dec 2019 07:48:11 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:09 -0800 (PST) X-Inumbo-ID: 782e1cf4-1b64-11ea-b6f1-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:content-transfer-encoding; bh=63i23Fqk9zJzsRQoamhJmJqI3J1g9w1MAzTUDB82EsI=; b=OwbYslkS/hyng3+/gu1ow7IOBeO3g5AI0oFF6X5wiULuLq2InVdLdcLblGvJGu1EOU PALr1UvjRJ1mKo5iLPWvDmS6HuzF1obcsJ9Tzekmt6TGzSETmlsoEKzBsjiOlJdcmoGa yUilHGDmqdhRNbHSUxhCcT8h6kOVKWQcDgU24DmUvtkquP9FnmuQTmB0tMXuzj/WJLoi KOqi6jFSaZQWjS7iN5804ZWVY018wr2avEr7EMfOSvNkSRUSAGV1QsOe9tcvfgrru1Bu lVPGnUoTwIADgGurtJg83gt6NXntiNnjG4UsAIxTj7GkEJmtrID+TmIl1TDTlL0tzhaY mcNQ== 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=63i23Fqk9zJzsRQoamhJmJqI3J1g9w1MAzTUDB82EsI=; b=Z3t714Xm9y6YPkRszJKwkBbsMSiP0zAXhsodbNr8ZaDID1X9MoLHQJuaasoQHgqM3J OC38toBtJKDE5+cYrCbATgQRvomv9rlwUnNpwnxPqtmYZAzSk0TyAEHk10CzC2lfo7ws ryvrNHYRgZiv7oTNxHSnrSZOzr8hE/ipu+nQLK9Pj7Jz9PxTAL+/y5kGtAmY0pJuXT1d qL+sfoiJ+kM/mfPcM7uJFi17i8aLyqB+Jxuv2QrDM5rm2/9AZrXnFWCVheBklJJ+h1hO 6ZGypFB6/zSvgphba5vxzK+k7qkrX2rWidQF0jiK9L/C678rDIqXXlUSwQpo9uNvewoA XPpg== X-Gm-Message-State: APjAAAV3K2iuX5XsEc5tEmmjDucFL6ziVg4X+aUWjnu1Kca6AXPjWuNf /L2yUEQozkr9SyBNKVos4lc1uHsl X-Google-Smtp-Source: APXvYqxQT5wDJ3AzP4IjeXru8NEH728v60DDBd6/LkzptpR5VkeI4+KQWQSmwi5lCy3fiNIkeQprBQ== X-Received: by 2002:a37:6e86:: with SMTP id j128mr27504148qkc.265.1575992890591; Tue, 10 Dec 2019 07:48:10 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:32 -0500 Message-Id: <67ce148341ae0823584777d15b0c6c4e6c74bddd.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 17/22] golang/xenlight: implement array C to Go marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 39 +++- tools/golang/xenlight/helpers.gen.go | 300 +++++++++++++++++++++++++++ 2 files changed, 338 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index b68c1aa66b..ee9aaf9eff 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -252,7 +252,7 @@ def xenlight_golang_define_from_C(ty =3D None): for f in ty.fields: if f.type.typename is not None: if isinstance(f.type, idl.Array): - # TODO + body +=3D xenlight_golang_array_from_C(f) continue =20 body +=3D xenlight_golang_convert_from_C(f) @@ -399,6 +399,43 @@ def xenlight_golang_union_from_C(ty =3D None, union_na= me =3D '', struct_name =3D ''): =20 return (s,extras) =20 +def xenlight_golang_array_from_C(ty =3D None): + """ + Convert C array to Go slice using the method + described here: + + https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices + """ + s =3D '' + + gotypename =3D xenlight_golang_fmt_name(ty.type.elem_type.typename) + goname =3D xenlight_golang_fmt_name(ty.name) + ctypename =3D ty.type.elem_type.typename + cname =3D ty.name + cslice =3D 'c{}'.format(goname) + clenvar =3D ty.type.lenvar.name + golenvar =3D xenlight_golang_fmt_name(clenvar,exported=3DFalse) + + s +=3D '{} :=3D int(xc.{})\n'.format(golenvar, clenvar) + s +=3D '{} :=3D '.format(cslice) + s +=3D'(*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.format(ctypena= me, cname, + golenvar, = golenvar) + s +=3D 'x.{} =3D make([]{}, {})\n'.format(goname, gotypename, golenvar) + s +=3D 'for i, v :=3D range {} {{\n'.format(cslice) + + is_enum =3D isinstance(ty.type.elem_type,idl.Enumeration) + if gotypename in go_builtin_types or is_enum: + s +=3D 'x.{}[i] =3D {}(v)\n'.format(goname, gotypename) + else: + s +=3D 'var e {}\n'.format(gotypename) + s +=3D 'if err :=3D e.fromC(&v); err !=3D nil {\n' + s +=3D 'return err }\n' + s +=3D 'x.{}[i] =3D e\n'.format(goname) + + s +=3D '}\n' + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index e6eee234c0..2f917cac58 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -263,6 +263,16 @@ func (x *SchedParams) fromC(xc *C.libxl_sched_params) = error { =20 func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { x.Sched =3D Scheduler(xc.sched) + numVcpus :=3D int(xc.num_vcpus) + cVcpus :=3D (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:n= umVcpus:numVcpus] + x.Vcpus =3D make([]SchedParams, numVcpus) + for i, v :=3D range cVcpus { + var e SchedParams + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vcpus[i] =3D e + } =20 return nil } @@ -282,6 +292,12 @@ func (x *DomainSchedParams) fromC(xc *C.libxl_domain_s= ched_params) error { =20 func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { x.Memkb =3D uint64(xc.memkb) + numDistances :=3D int(xc.num_distances) + cDistances :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:num= Distances:numDistances] + x.Distances =3D make([]uint32, numDistances) + 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 err @@ -308,6 +324,26 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_bui= ld_info) error { if err :=3D x.Nodemap.fromC(&xc.nodemap); err !=3D nil { return err } + numVcpuHardAffinity :=3D int(xc.num_vcpu_hard_affinity) + cVcpuHardAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_= hard_affinity))[:numVcpuHardAffinity:numVcpuHardAffinity] + x.VcpuHardAffinity =3D make([]Bitmap, numVcpuHardAffinity) + for i, v :=3D range cVcpuHardAffinity { + var e Bitmap + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.VcpuHardAffinity[i] =3D e + } + numVcpuSoftAffinity :=3D int(xc.num_vcpu_soft_affinity) + cVcpuSoftAffinity :=3D (*[1 << 28]C.libxl_bitmap)(unsafe.Pointer(xc.vcpu_= soft_affinity))[:numVcpuSoftAffinity:numVcpuSoftAffinity] + x.VcpuSoftAffinity =3D make([]Bitmap, numVcpuSoftAffinity) + for i, v :=3D range cVcpuSoftAffinity { + var e Bitmap + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.VcpuSoftAffinity[i] =3D e + } if err :=3D x.NumaPlacement.fromC(&xc.numa_placement); err !=3D nil { return err } @@ -330,6 +366,16 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_bui= ld_info) error { return err } x.BlkdevStart =3D C.GoString(xc.blkdev_start) + numVnumaNodes :=3D int(xc.num_vnuma_nodes) + cVnumaNodes :=3D (*[1 << 28]C.libxl_vnode_info)(unsafe.Pointer(xc.vnuma_n= odes))[:numVnumaNodes:numVnumaNodes] + x.VnumaNodes =3D make([]VnodeInfo, numVnumaNodes) + for i, v :=3D range cVnumaNodes { + var e VnodeInfo + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.VnumaNodes[i] =3D e + } x.MaxGrantFrames =3D uint32(xc.max_grant_frames) x.MaxMaptrackFrames =3D uint32(xc.max_maptrack_frames) x.DeviceModelVersion =3D DeviceModelVersion(xc.device_model_version) @@ -352,6 +398,32 @@ func (x *DomainBuildInfo) fromC(xc *C.libxl_domain_bui= ld_info) error { if err :=3D x.SchedParams.fromC(&xc.sched_params); err !=3D nil { return err } + numIoports :=3D int(xc.num_ioports) + cIoports :=3D (*[1 << 28]C.libxl_ioport_range)(unsafe.Pointer(xc.ioports)= )[:numIoports:numIoports] + x.Ioports =3D make([]IoportRange, numIoports) + for i, v :=3D range cIoports { + var e IoportRange + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Ioports[i] =3D e + } + numIrqs :=3D int(xc.num_irqs) + cIrqs :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.irqs))[:numIrqs:numIr= qs] + x.Irqs =3D make([]uint32, numIrqs) + for i, v :=3D range cIrqs { + x.Irqs[i] =3D uint32(v) + } + numIomem :=3D int(xc.num_iomem) + cIomem :=3D (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:nu= mIomem:numIomem] + x.Iomem =3D make([]IomemRange, numIomem) + for i, v :=3D range cIomem { + var e IomemRange + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Iomem[i] =3D e + } if err :=3D x.ClaimMode.fromC(&xc.claim_mode); err !=3D nil { return err } @@ -831,11 +903,33 @@ func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdisp= l) error { x.BackendDomname =3D C.GoString(xc.backend_domname) x.Devid =3D Devid(xc.devid) x.BeAlloc =3D bool(xc.be_alloc) + numConnectors :=3D int(xc.num_connectors) + cConnectors :=3D (*[1 << 28]C.libxl_connector_param)(unsafe.Pointer(xc.co= nnectors))[:numConnectors:numConnectors] + x.Connectors =3D make([]ConnectorParam, numConnectors) + for i, v :=3D range cConnectors { + var e ConnectorParam + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Connectors[i] =3D e + } =20 return nil } =20 func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { + numSampleRates :=3D int(xc.num_sample_rates) + cSampleRates :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates))= [:numSampleRates:numSampleRates] + x.SampleRates =3D make([]uint32, numSampleRates) + for i, v :=3D range cSampleRates { + x.SampleRates[i] =3D uint32(v) + } + numSampleFormats :=3D int(xc.num_sample_formats) + cSampleFormats :=3D (*[1 << 28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(xc= .sample_formats))[:numSampleFormats:numSampleFormats] + x.SampleFormats =3D make([]VsndPcmFormat, numSampleFormats) + 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) @@ -858,6 +952,16 @@ func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { if err :=3D x.Params.fromC(&xc.params); err !=3D nil { return err } + numVsndStreams :=3D int(xc.num_vsnd_streams) + cStreams :=3D (*[1 << 28]C.libxl_vsnd_stream)(unsafe.Pointer(xc.streams))= [:numVsndStreams:numVsndStreams] + x.Streams =3D make([]VsndStream, numVsndStreams) + for i, v :=3D range cStreams { + var e VsndStream + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Streams[i] =3D e + } =20 return nil } @@ -871,6 +975,16 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) er= ror { if err :=3D x.Params.fromC(&xc.params); err !=3D nil { return err } + numVsndPcms :=3D int(xc.num_vsnd_pcms) + cPcms :=3D (*[1 << 28]C.libxl_vsnd_pcm)(unsafe.Pointer(xc.pcms))[:numVsnd= Pcms:numVsndPcms] + x.Pcms =3D make([]VsndPcm, numVsndPcms) + for i, v :=3D range cPcms { + var e VsndPcm + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Pcms[i] =3D e + } =20 return nil } @@ -882,6 +996,156 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_confi= g) error { if err :=3D x.BInfo.fromC(&xc.b_info); err !=3D nil { return err } + numDisks :=3D int(xc.num_disks) + cDisks :=3D (*[1 << 28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:nu= mDisks:numDisks] + x.Disks =3D make([]DeviceDisk, numDisks) + for i, v :=3D range cDisks { + var e DeviceDisk + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Disks[i] =3D e + } + numNics :=3D int(xc.num_nics) + cNics :=3D (*[1 << 28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:numNi= cs:numNics] + x.Nics =3D make([]DeviceNic, numNics) + for i, v :=3D range cNics { + var e DeviceNic + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Nics[i] =3D e + } + numPcidevs :=3D int(xc.num_pcidevs) + cPcidevs :=3D (*[1 << 28]C.libxl_device_pci)(unsafe.Pointer(xc.pcidevs))[= :numPcidevs:numPcidevs] + x.Pcidevs =3D make([]DevicePci, numPcidevs) + for i, v :=3D range cPcidevs { + var e DevicePci + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Pcidevs[i] =3D e + } + numRdms :=3D int(xc.num_rdms) + cRdms :=3D (*[1 << 28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:numRd= ms:numRdms] + x.Rdms =3D make([]DeviceRdm, numRdms) + for i, v :=3D range cRdms { + var e DeviceRdm + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Rdms[i] =3D e + } + numDtdevs :=3D int(xc.num_dtdevs) + cDtdevs :=3D (*[1 << 28]C.libxl_device_dtdev)(unsafe.Pointer(xc.dtdevs))[= :numDtdevs:numDtdevs] + x.Dtdevs =3D make([]DeviceDtdev, numDtdevs) + for i, v :=3D range cDtdevs { + var e DeviceDtdev + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Dtdevs[i] =3D e + } + numVfbs :=3D int(xc.num_vfbs) + cVfbs :=3D (*[1 << 28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:numVf= bs:numVfbs] + x.Vfbs =3D make([]DeviceVfb, numVfbs) + for i, v :=3D range cVfbs { + var e DeviceVfb + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vfbs[i] =3D e + } + numVkbs :=3D int(xc.num_vkbs) + cVkbs :=3D (*[1 << 28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:numVk= bs:numVkbs] + x.Vkbs =3D make([]DeviceVkb, numVkbs) + for i, v :=3D range cVkbs { + var e DeviceVkb + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vkbs[i] =3D e + } + numVtpms :=3D int(xc.num_vtpms) + cVtpms :=3D (*[1 << 28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:nu= mVtpms:numVtpms] + x.Vtpms =3D make([]DeviceVtpm, numVtpms) + for i, v :=3D range cVtpms { + var e DeviceVtpm + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vtpms[i] =3D e + } + numP9S :=3D int(xc.num_p9s) + cP9S :=3D (*[1 << 28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:numP9S:n= umP9S] + x.P9S =3D make([]DeviceP9, numP9S) + for i, v :=3D range cP9S { + var e DeviceP9 + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.P9S[i] =3D e + } + numPvcallsifs :=3D int(xc.num_pvcallsifs) + cPvcallsifs :=3D (*[1 << 28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.p= vcallsifs))[:numPvcallsifs:numPvcallsifs] + x.Pvcallsifs =3D make([]DevicePvcallsif, numPvcallsifs) + for i, v :=3D range cPvcallsifs { + var e DevicePvcallsif + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Pvcallsifs[i] =3D e + } + numVdispls :=3D int(xc.num_vdispls) + cVdispls :=3D (*[1 << 28]C.libxl_device_vdispl)(unsafe.Pointer(xc.vdispls= ))[:numVdispls:numVdispls] + x.Vdispls =3D make([]DeviceVdispl, numVdispls) + for i, v :=3D range cVdispls { + var e DeviceVdispl + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vdispls[i] =3D e + } + numVsnds :=3D int(xc.num_vsnds) + cVsnds :=3D (*[1 << 28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:nu= mVsnds:numVsnds] + x.Vsnds =3D make([]DeviceVsnd, numVsnds) + for i, v :=3D range cVsnds { + var e DeviceVsnd + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Vsnds[i] =3D e + } + numChannels :=3D int(xc.num_channels) + cChannels :=3D (*[1 << 28]C.libxl_device_channel)(unsafe.Pointer(xc.chann= els))[:numChannels:numChannels] + x.Channels =3D make([]DeviceChannel, numChannels) + for i, v :=3D range cChannels { + var e DeviceChannel + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Channels[i] =3D e + } + numUsbctrls :=3D int(xc.num_usbctrls) + cUsbctrls :=3D (*[1 << 28]C.libxl_device_usbctrl)(unsafe.Pointer(xc.usbct= rls))[:numUsbctrls:numUsbctrls] + x.Usbctrls =3D make([]DeviceUsbctrl, numUsbctrls) + for i, v :=3D range cUsbctrls { + var e DeviceUsbctrl + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Usbctrls[i] =3D e + } + numUsbdevs :=3D int(xc.num_usbdevs) + cUsbdevs :=3D (*[1 << 28]C.libxl_device_usbdev)(unsafe.Pointer(xc.usbdevs= ))[:numUsbdevs:numUsbdevs] + x.Usbdevs =3D make([]DeviceUsbdev, numUsbdevs) + for i, v :=3D range cUsbdevs { + var e DeviceUsbdev + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Usbdevs[i] =3D e + } x.OnPoweroff =3D ActionOnShutdown(xc.on_poweroff) x.OnReboot =3D ActionOnShutdown(xc.on_reboot) x.OnWatchdog =3D ActionOnShutdown(xc.on_watchdog) @@ -1015,6 +1279,16 @@ func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) e= rror { x.Devid =3D Devid(xc.devid) x.State =3D int(xc.state) x.BeAlloc =3D bool(xc.be_alloc) + numConnectors :=3D int(xc.num_connectors) + cConnectors :=3D (*[1 << 28]C.libxl_connectorinfo)(unsafe.Pointer(xc.conn= ectors))[:numConnectors:numConnectors] + x.Connectors =3D make([]Connectorinfo, numConnectors) + for i, v :=3D range cConnectors { + var e Connectorinfo + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Connectors[i] =3D e + } =20 return nil } @@ -1027,6 +1301,16 @@ func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) e= rror { } =20 func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { + numVsndStreams :=3D int(xc.num_vsnd_streams) + cStreams :=3D (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))[= :numVsndStreams:numVsndStreams] + x.Streams =3D make([]Streaminfo, numVsndStreams) + for i, v :=3D range cStreams { + var e Streaminfo + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Streams[i] =3D e + } =20 return nil } @@ -1038,6 +1322,16 @@ func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error= { x.FrontendId =3D uint32(xc.frontend_id) x.Devid =3D Devid(xc.devid) x.State =3D int(xc.state) + numVsndPcms :=3D int(xc.num_vsnd_pcms) + cPcms :=3D (*[1 << 28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:numVsndP= cms:numVsndPcms] + x.Pcms =3D make([]Pcminfo, numVsndPcms) + for i, v :=3D range cPcms { + var e Pcminfo + if err :=3D e.fromC(&v); err !=3D nil { + return err + } + x.Pcms[i] =3D e + } =20 return nil } @@ -1058,6 +1352,12 @@ func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { func (x *Numainfo) fromC(xc *C.libxl_numainfo) error { x.Size =3D uint64(xc.size) x.Free =3D uint64(xc.free) + numDists :=3D int(xc.num_dists) + cDists :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.dists))[:numDists:nu= mDists] + x.Dists =3D make([]uint32, numDists) + for i, v :=3D range cDists { + x.Dists[i] =3D uint32(v) + } =20 return nil } --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575993013; cv=none; d=zohomail.com; s=zohoarc; b=JHDqusZ+39bYcaVvuTw56/o37LNKVT0tXKL0nI3ImIWZQexHOiz7QSNOLIWuaMepfD5GhGjmiGTmEMI0SdBnJ5G/8QfHKO2FNTPSD29y9wxVELpUsTCEx6qLmBtMB3mnn2H+xvxT9H4A1v2pmD5qnPD/QxLDhSDHGUfg5E4l8Bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575993013; 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=aLbv2MxThy+7arZj3KXSOwFxBVRhPMPt3vZuVV76D94=; b=AZY7xRhGWhjI3Bn4t//v3jrniKmDR8H9R04ENluLw7dbrFz0iov4ZFHQviVuNHlauJMI4+hgiOcF2milT/xPgJU59ZlK7U39nVZj8K7NESDw/InWD03WE78HHyw/UgLKPTW4kodfhqhailUfbb3aeuiYdGSFp4N47q2QbvdPyb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575993013143992.2069393265308; Tue, 10 Dec 2019 07:50:13 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlP-0003v4-A1; Tue, 10 Dec 2019 15:49:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlN-0003tq-UZ for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:26 +0000 Received: from mail-qt1-x82d.google.com (unknown [2607:f8b0:4864:20::82d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 79756568-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:13 +0000 (UTC) Received: by mail-qt1-x82d.google.com with SMTP id 5so3211594qtz.1 for ; Tue, 10 Dec 2019 07:48:13 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:11 -0800 (PST) X-Inumbo-ID: 79756568-1b64-11ea-88e7-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:content-transfer-encoding; bh=OXSNz2MEBIs7JpBT0cL0HMNBR/NYhbhpDmMVqQGDU20=; b=sJJZ7DseMALkXWnzl5Osh9GYuem3Rvsrm/8t8vCn17HASVcEG2rxBL7PyQEGTtNRwy qpyzxnbMrSQXM3RAKL11QFhytYPKbQNA1pSxJTXG1BpSVt+qAdXnJhX6hn8n0gBdvFGW uZ9xSwYI5b9AkFzS6abCYug24rSQRi5lbkNLmxY1qjb+ZBRn6bzZLA4jFBhLsxws49pT OEdYqumfMZ0HT74XfqgMXpJY/9VdVMRSWzkXecmYgKN4/FdRKXNIraQyrqquQkgX2GFH HjQdF59NtZUFTneawOYn0oJbBnMXnAG5usAPnq9lPy1tkcdGrRiFBwO/GqSVcoXmMffn gx+g== 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=OXSNz2MEBIs7JpBT0cL0HMNBR/NYhbhpDmMVqQGDU20=; b=WefK4CJZm/0CUGgoK5wUrZil+zqSn8KKR9r6rqa4z9Wo43ggKVX8+1EtALKLsndnw1 vMNzZekCCUiYMD/6SNAYvDdVc+nQoqTY6jswDqnOIeJJ59y77+91zHr0r/s3BneQvirE auINVKmPjxDv0STSmMjpCPXnft1BuR0L08KvIeAmtqYJZmBe23HmDfNe2h3wQgd+V6QJ CTMK8TiXq7lFdjNr9xtCRk1Y7p+7IV35yho2kQrytD27Ma61IlnPr/WgT/fdhyTx926b KJJt47Gayfy3tvwE57pdXXszbhIEWe1uQkneo4ZnlFA0yE9Nydn3JWoC/W5BTKAuVrMR Knng== X-Gm-Message-State: APjAAAWP2NMD8m0B4YTgECEkfNm16whLj5bUEgwnSnawsP946CVvDQ42 En0ZWxLrY/IojJamR4JbjGH48mcg X-Google-Smtp-Source: APXvYqxT9w59+KU+OqBAkMPyDe8EtY86k/xrwuAePHMpysEFy1RGHdS5ga8TnE0JESxFVWJO9aiS1Q== X-Received: by 2002:aed:3fce:: with SMTP id w14mr32183358qth.0.1575992892079; Tue, 10 Dec 2019 07:48:12 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:33 -0500 Message-Id: <79dbba7b8217f653c55a6e166055be4ab3a31400.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 18/22] golang/xenlight: begin Go to C type marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Implement conversion of basic type conversions such as strings and integer types in toC functions. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 80 ++ tools/golang/xenlight/helpers.gen.go | 1015 ++++++++++++++++++++++++++ 2 files changed, 1095 insertions(+) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index ee9aaf9eff..cb9b18218f 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -234,6 +234,9 @@ def xenlight_golang_generate_helpers(path =3D None, typ= es =3D None, comment =3D None): f.write(extra) f.write('\n') =20 + f.write(xenlight_golang_define_to_C(ty)) + f.write('\n') + go_fmt(path) =20 def xenlight_golang_define_from_C(ty =3D None): @@ -436,6 +439,83 @@ def xenlight_golang_array_from_C(ty =3D None): =20 return s =20 +def xenlight_golang_define_to_C(ty =3D None, typename =3D None, nested =3D= False): + s =3D '' + + gotypename =3D ctypename =3D '' + + if typename is not None: + gotypename =3D xenlight_golang_fmt_name(typename) + ctypename =3D typename + else: + gotypename =3D xenlight_golang_fmt_name(ty.typename) + ctypename =3D ty.typename + + if not nested: + s +=3D 'func (x *{}) toC() (xc C.{},err error) {{\n'.format(gotype= name,ctypename) + s +=3D 'C.{}(&xc)\n'.format(ty.init_fn) + + for f in ty.fields: + if f.type.typename is not None: + if isinstance(f.type, idl.Array): + # TODO + continue + + gotypename =3D xenlight_golang_fmt_name(f.type.typename) + ctypename =3D f.type.typename + gofname =3D xenlight_golang_fmt_name(f.name) + cfname =3D f.name + + # In cgo, C names that conflict with Go keywords can be + # accessed by prepending an underscore to the name. + if cfname in go_keywords: + cfname =3D '_' + cfname + + # If this is nested, we need the outer name too. + if nested and typename is not None: + goname =3D xenlight_golang_fmt_name(typename) + goname =3D '{}.{}'.format(goname, gofname) + cname =3D '{}.{}'.format(typename, cfname) + + else: + goname =3D gofname + cname =3D cfname + + is_castable =3D (f.type.json_parse_type =3D=3D 'JSON_INTEGER' = or + isinstance(f.type, idl.Enumeration) or + gotypename in go_builtin_types) + + if is_castable: + # Use the cgo helper for converting C strings. + if gotypename =3D=3D 'string': + s +=3D 'xc.{} =3D C.CString(x.{})\n'.format(cname,gona= me) + continue + + s +=3D 'xc.{} =3D C.{}(x.{})\n'.format(cname,ctypename,gon= ame) + + else: + s +=3D 'xc.{}, err =3D x.{}.toC()\n'.format(cname,goname) + s +=3D 'if err !=3D nil {\n' + s +=3D 'C.{}(&xc)\n'.format(ty.dispose_fn) + s +=3D 'return xc, err\n' + s +=3D '}\n' + + elif isinstance(f.type, idl.Struct): + s +=3D xenlight_golang_define_to_C(f.type, typename=3Df.name, = nested=3DTrue) + + elif isinstance(f.type, idl.KeyedUnion): + # TODO + pass + + else: + raise Exception('type {} not supported'.format(f.type)) + + if not nested: + s +=3D 'return xc, nil' + s +=3D '}\n' + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 2f917cac58..a155b091a7 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -37,6 +37,13 @@ func (x *IoportRange) fromC(xc *C.libxl_ioport_range) er= ror { return nil } =20 +func (x *IoportRange) toC() (xc C.libxl_ioport_range, err error) { + C.libxl_ioport_range_init(&xc) + xc.first =3D C.uint32_t(x.First) + xc.number =3D C.uint32_t(x.Number) + return xc, nil +} + func (x *IomemRange) fromC(xc *C.libxl_iomem_range) error { x.Start =3D uint64(xc.start) x.Number =3D uint64(xc.number) @@ -45,12 +52,26 @@ func (x *IomemRange) fromC(xc *C.libxl_iomem_range) err= or { return nil } =20 +func (x *IomemRange) toC() (xc C.libxl_iomem_range, err error) { + C.libxl_iomem_range_init(&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 xc, nil +} + func (x *VgaInterfaceInfo) fromC(xc *C.libxl_vga_interface_info) error { x.Kind =3D VgaInterfaceType(xc.kind) =20 return nil } =20 +func (x *VgaInterfaceInfo) toC() (xc C.libxl_vga_interface_info, err error= ) { + C.libxl_vga_interface_info_init(&xc) + xc.kind =3D C.libxl_vga_interface_type(x.Kind) + return xc, nil +} + func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -65,6 +86,24 @@ func (x *VncInfo) fromC(xc *C.libxl_vnc_info) error { return nil } =20 +func (x *VncInfo) toC() (xc C.libxl_vnc_info, err error) { + C.libxl_vnc_info_init(&xc) + xc.enable, err =3D x.Enable.toC() + if err !=3D nil { + C.libxl_vnc_info_dispose(&xc) + return xc, err + } + xc.listen =3D C.CString(x.Listen) + xc.passwd =3D C.CString(x.Passwd) + xc.display =3D C.int(x.Display) + xc.findunused, err =3D x.Findunused.toC() + if err !=3D nil { + C.libxl_vnc_info_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -92,6 +131,43 @@ func (x *SpiceInfo) fromC(xc *C.libxl_spice_info) error= { return nil } =20 +func (x *SpiceInfo) toC() (xc C.libxl_spice_info, err error) { + C.libxl_spice_info_init(&xc) + xc.enable, err =3D x.Enable.toC() + if err !=3D nil { + C.libxl_spice_info_dispose(&xc) + return xc, err + } + xc.port =3D C.int(x.Port) + xc.tls_port =3D C.int(x.TlsPort) + xc.host =3D C.CString(x.Host) + xc.disable_ticketing, err =3D x.DisableTicketing.toC() + if err !=3D nil { + C.libxl_spice_info_dispose(&xc) + return xc, err + } + xc.passwd =3D C.CString(x.Passwd) + xc.agent_mouse, err =3D x.AgentMouse.toC() + if err !=3D nil { + C.libxl_spice_info_dispose(&xc) + return xc, err + } + xc.vdagent, err =3D x.Vdagent.toC() + if err !=3D nil { + C.libxl_spice_info_dispose(&xc) + return xc, err + } + xc.clipboard_sharing, err =3D x.ClipboardSharing.toC() + if err !=3D nil { + C.libxl_spice_info_dispose(&xc) + return xc, err + } + xc.usbredirection =3D C.int(x.Usbredirection) + xc.image_compression =3D C.CString(x.ImageCompression) + xc.streaming_video =3D C.CString(x.StreamingVideo) + return xc, nil +} + func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { if err :=3D x.Enable.fromC(&xc.enable); err !=3D nil { return err @@ -105,6 +181,23 @@ func (x *SdlInfo) fromC(xc *C.libxl_sdl_info) error { return nil } =20 +func (x *SdlInfo) toC() (xc C.libxl_sdl_info, err error) { + C.libxl_sdl_info_init(&xc) + xc.enable, err =3D x.Enable.toC() + if err !=3D nil { + C.libxl_sdl_info_dispose(&xc) + return xc, err + } + xc.opengl, err =3D x.Opengl.toC() + if err !=3D nil { + C.libxl_sdl_info_dispose(&xc) + return xc, err + } + xc.display =3D C.CString(x.Display) + xc.xauthority =3D C.CString(x.Xauthority) + return xc, nil +} + func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { return err @@ -133,6 +226,36 @@ func (x *Dominfo) fromC(xc *C.libxl_dominfo) error { return nil } =20 +func (x *Dominfo) toC() (xc C.libxl_dominfo, err error) { + C.libxl_dominfo_init(&xc) + xc.uuid, err =3D x.Uuid.toC() + if err !=3D nil { + C.libxl_dominfo_dispose(&xc) + return xc, err + } + xc.domid =3D C.libxl_domid(x.Domid) + xc.ssidref =3D C.uint32_t(x.Ssidref) + 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 xc, nil +} + func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) error { x.Poolid =3D uint32(xc.poolid) x.PoolName =3D C.GoString(xc.pool_name) @@ -145,6 +268,20 @@ func (x *Cpupoolinfo) fromC(xc *C.libxl_cpupoolinfo) e= rror { return nil } =20 +func (x *Cpupoolinfo) toC() (xc C.libxl_cpupoolinfo, err error) { + C.libxl_cpupoolinfo_init(&xc) + xc.poolid =3D C.uint32_t(x.Poolid) + 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) + xc.cpumap, err =3D x.Cpumap.toC() + if err !=3D nil { + C.libxl_cpupoolinfo_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *Channelinfo) fromC(xc *C.libxl_channelinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -179,6 +316,19 @@ func (x *ChannelinfoConnectionUnionPty) fromC(xc *C.li= bxl_channelinfo) error { return nil } =20 +func (x *Channelinfo) toC() (xc C.libxl_channelinfo, err error) { + C.libxl_channelinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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 xc, nil +} + func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { if err :=3D x.Uuid.fromC(&xc.uuid); err !=3D nil { return err @@ -188,6 +338,17 @@ func (x *Vminfo) fromC(xc *C.libxl_vminfo) error { return nil } =20 +func (x *Vminfo) toC() (xc C.libxl_vminfo, err error) { + C.libxl_vminfo_init(&xc) + xc.uuid, err =3D x.Uuid.toC() + if err !=3D nil { + C.libxl_vminfo_dispose(&xc) + return xc, err + } + xc.domid =3D C.libxl_domid(x.Domid) + return xc, nil +} + func (x *VersionInfo) fromC(xc *C.libxl_version_info) error { x.XenVersionMajor =3D int(xc.xen_version_major) x.XenVersionMinor =3D int(xc.xen_version_minor) @@ -206,6 +367,24 @@ func (x *VersionInfo) fromC(xc *C.libxl_version_info) = error { return nil } =20 +func (x *VersionInfo) toC() (xc C.libxl_version_info, err error) { + C.libxl_version_info_init(&xc) + xc.xen_version_major =3D C.int(x.XenVersionMajor) + xc.xen_version_minor =3D C.int(x.XenVersionMinor) + xc.xen_version_extra =3D C.CString(x.XenVersionExtra) + xc.compiler =3D C.CString(x.Compiler) + xc.compile_by =3D C.CString(x.CompileBy) + xc.compile_domain =3D C.CString(x.CompileDomain) + xc.compile_date =3D C.CString(x.CompileDate) + xc.capabilities =3D C.CString(x.Capabilities) + xc.changeset =3D C.CString(x.Changeset) + xc.virt_start =3D C.uint64_t(x.VirtStart) + xc.pagesize =3D C.int(x.Pagesize) + xc.commandline =3D C.CString(x.Commandline) + xc.build_id =3D C.CString(x.BuildId) + return xc, nil +} + func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_create_info) error { x.Type =3D DomainType(xc._type) if err :=3D x.Hap.fromC(&xc.hap); err !=3D nil { @@ -239,6 +418,53 @@ func (x *DomainCreateInfo) fromC(xc *C.libxl_domain_cr= eate_info) error { return nil } =20 +func (x *DomainCreateInfo) toC() (xc C.libxl_domain_create_info, err error= ) { + C.libxl_domain_create_info_init(&xc) + xc._type =3D C.libxl_domain_type(x.Type) + xc.hap, err =3D x.Hap.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.oos, err =3D x.Oos.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.ssidref =3D C.uint32_t(x.Ssidref) + xc.ssid_label =3D C.CString(x.SsidLabel) + xc.name =3D C.CString(x.Name) + xc.uuid, err =3D x.Uuid.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.xsdata, err =3D x.Xsdata.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.platformdata, err =3D x.Platformdata.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.poolid =3D C.uint32_t(x.Poolid) + xc.pool_name =3D C.CString(x.PoolName) + xc.run_hotplug_scripts, err =3D x.RunHotplugScripts.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.driver_domain, err =3D x.DriverDomain.toC() + if err !=3D nil { + C.libxl_domain_create_info_dispose(&xc) + return xc, err + } + xc.passthrough =3D C.libxl_passthrough(x.Passthrough) + return xc, nil +} + func (x *DomainRestoreParams) fromC(xc *C.libxl_domain_restore_params) err= or { x.CheckpointedStream =3D int(xc.checkpointed_stream) x.StreamVersion =3D uint32(xc.stream_version) @@ -250,6 +476,19 @@ func (x *DomainRestoreParams) fromC(xc *C.libxl_domain= _restore_params) error { return nil } =20 +func (x *DomainRestoreParams) toC() (xc C.libxl_domain_restore_params, err= error) { + C.libxl_domain_restore_params_init(&xc) + xc.checkpointed_stream =3D C.int(x.CheckpointedStream) + xc.stream_version =3D C.uint32_t(x.StreamVersion) + xc.colo_proxy_script =3D C.CString(x.ColoProxyScript) + xc.userspace_colo_proxy, err =3D x.UserspaceColoProxy.toC() + if err !=3D nil { + C.libxl_domain_restore_params_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *SchedParams) fromC(xc *C.libxl_sched_params) error { x.Vcpuid =3D int(xc.vcpuid) x.Weight =3D int(xc.weight) @@ -261,6 +500,17 @@ func (x *SchedParams) fromC(xc *C.libxl_sched_params) = error { return nil } =20 +func (x *SchedParams) toC() (xc C.libxl_sched_params, err error) { + C.libxl_sched_params_init(&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 xc, nil +} + func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched_params) error { x.Sched =3D Scheduler(xc.sched) numVcpus :=3D int(xc.num_vcpus) @@ -277,6 +527,12 @@ func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched= _params) error { return nil } =20 +func (x *VcpuSchedParams) toC() (xc C.libxl_vcpu_sched_params, err error) { + C.libxl_vcpu_sched_params_init(&xc) + xc.sched =3D C.libxl_scheduler(x.Sched) + return xc, nil +} + func (x *DomainSchedParams) fromC(xc *C.libxl_domain_sched_params) error { x.Sched =3D Scheduler(xc.sched) x.Weight =3D int(xc.weight) @@ -290,6 +546,19 @@ func (x *DomainSchedParams) fromC(xc *C.libxl_domain_s= ched_params) error { return nil } =20 +func (x *DomainSchedParams) toC() (xc C.libxl_domain_sched_params, err err= or) { + C.libxl_domain_sched_params_init(&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 xc, nil +} + func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) error { x.Memkb =3D uint64(xc.memkb) numDistances :=3D int(xc.num_distances) @@ -306,6 +575,18 @@ func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) erro= r { return nil } =20 +func (x *VnodeInfo) toC() (xc C.libxl_vnode_info, err error) { + C.libxl_vnode_info_init(&xc) + xc.memkb =3D C.uint64_t(x.Memkb) + xc.pnode =3D C.uint32_t(x.Pnode) + xc.vcpus, err =3D x.Vcpus.toC() + if err !=3D nil { + C.libxl_vnode_info_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) error { x.Strategy =3D RdmReserveStrategy(xc.strategy) x.Policy =3D RdmReservePolicy(xc.policy) @@ -313,6 +594,13 @@ func (x *RdmReserve) fromC(xc *C.libxl_rdm_reserve) er= ror { return nil } =20 +func (x *RdmReserve) toC() (xc C.libxl_rdm_reserve, err error) { + C.libxl_rdm_reserve_init(&xc) + xc.strategy =3D C.libxl_rdm_reserve_strategy(x.Strategy) + xc.policy =3D C.libxl_rdm_reserve_policy(x.Policy) + return xc, 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 { @@ -625,6 +913,130 @@ func (x *DomainBuildInfoTypeUnionPvh) fromC(xc *C.lib= xl_domain_build_info) error return nil } =20 +func (x *DomainBuildInfo) toC() (xc C.libxl_domain_build_info, err error) { + C.libxl_domain_build_info_init(&xc) + xc.max_vcpus =3D C.int(x.MaxVcpus) + xc.avail_vcpus, err =3D x.AvailVcpus.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.cpumap, err =3D x.Cpumap.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.nodemap, err =3D x.Nodemap.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.numa_placement, err =3D x.NumaPlacement.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, 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) + xc.exec_ssid_label =3D C.CString(x.ExecSsidLabel) + xc.localtime, err =3D x.Localtime.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.disable_migrate, err =3D x.DisableMigrate.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.cpuid, err =3D x.Cpuid.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.blkdev_start =3D C.CString(x.BlkdevStart) + xc.max_grant_frames =3D C.uint32_t(x.MaxGrantFrames) + xc.max_maptrack_frames =3D C.uint32_t(x.MaxMaptrackFrames) + xc.device_model_version =3D C.libxl_device_model_version(x.DeviceModelVer= sion) + xc.device_model_stubdomain, err =3D x.DeviceModelStubdomain.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.device_model =3D C.CString(x.DeviceModel) + xc.device_model_ssidref =3D C.uint32_t(x.DeviceModelSsidref) + xc.device_model_ssid_label =3D C.CString(x.DeviceModelSsidLabel) + xc.device_model_user =3D C.CString(x.DeviceModelUser) + xc.extra, err =3D x.Extra.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.extra_pv, err =3D x.ExtraPv.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.extra_hvm, err =3D x.ExtraHvm.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.sched_params, err =3D x.SchedParams.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.claim_mode, err =3D x.ClaimMode.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.event_channels =3D C.uint32_t(x.EventChannels) + xc.kernel =3D C.CString(x.Kernel) + xc.cmdline =3D C.CString(x.Cmdline) + xc.ramdisk =3D C.CString(x.Ramdisk) + xc.device_tree =3D C.CString(x.DeviceTree) + xc.acpi, err =3D x.Acpi.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.bootloader =3D C.CString(x.Bootloader) + xc.bootloader_args, err =3D x.BootloaderArgs.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.timer_mode =3D C.libxl_timer_mode(x.TimerMode) + xc.nested_hvm, err =3D x.NestedHvm.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.apic, err =3D x.Apic.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.dm_restrict, err =3D x.DmRestrict.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + xc.tee =3D C.libxl_tee_type(x.Tee) + xc.arch_arm.gic_version =3D C.libxl_gic_version(x.ArchArm.GicVersion) + xc.arch_arm.vuart =3D C.libxl_vuart_type(x.ArchArm.Vuart) + xc.altp2m =3D C.libxl_altp2m_mode(x.Altp2M) + return xc, 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) @@ -640,6 +1052,25 @@ func (x *DeviceVfb) fromC(xc *C.libxl_device_vfb) err= or { return nil } =20 +func (x *DeviceVfb) toC() (xc C.libxl_device_vfb, err error) { + C.libxl_device_vfb_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.vnc, err =3D x.Vnc.toC() + if err !=3D nil { + C.libxl_device_vfb_dispose(&xc) + return xc, err + } + xc.sdl, err =3D x.Sdl.toC() + if err !=3D nil { + C.libxl_device_vfb_dispose(&xc) + return xc, err + } + xc.keymap =3D C.CString(x.Keymap) + return xc, 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) @@ -660,6 +1091,26 @@ func (x *DeviceVkb) fromC(xc *C.libxl_device_vkb) err= or { return nil } =20 +func (x *DeviceVkb) toC() (xc C.libxl_device_vkb, err error) { + C.libxl_device_vkb_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + 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) + 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 xc, 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) @@ -690,6 +1141,42 @@ func (x *DeviceDisk) fromC(xc *C.libxl_device_disk) e= rror { return nil } =20 +func (x *DeviceDisk) toC() (xc C.libxl_device_disk, err error) { + C.libxl_device_disk_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.pdev_path =3D C.CString(x.PdevPath) + 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) + 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) + xc.discard_enable, err =3D x.DiscardEnable.toC() + if err !=3D nil { + C.libxl_device_disk_dispose(&xc) + return xc, err + } + xc.colo_enable, err =3D x.ColoEnable.toC() + if err !=3D nil { + C.libxl_device_disk_dispose(&xc) + return xc, err + } + xc.colo_restore_enable, err =3D x.ColoRestoreEnable.toC() + if err !=3D nil { + C.libxl_device_disk_dispose(&xc) + return xc, err + } + xc.colo_host =3D C.CString(x.ColoHost) + xc.colo_port =3D C.int(x.ColoPort) + xc.colo_export =3D C.CString(x.ColoExport) + xc.active_disk =3D C.CString(x.ActiveDisk) + xc.hidden_disk =3D C.CString(x.HiddenDisk) + return xc, 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) @@ -760,6 +1247,78 @@ func (x *DeviceNic) fromC(xc *C.libxl_device_nic) err= or { return nil } =20 +func (x *DeviceNic) toC() (xc C.libxl_device_nic, err error) { + C.libxl_device_nic_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.mtu =3D C.int(x.Mtu) + xc.model =3D C.CString(x.Model) + xc.mac, err =3D x.Mac.toC() + if err !=3D nil { + C.libxl_device_nic_dispose(&xc) + return xc, err + } + xc.ip =3D C.CString(x.Ip) + xc.bridge =3D C.CString(x.Bridge) + xc.ifname =3D C.CString(x.Ifname) + 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) + xc.gatewaydev =3D C.CString(x.Gatewaydev) + xc.coloft_forwarddev =3D C.CString(x.ColoftForwarddev) + xc.colo_sock_mirror_id =3D C.CString(x.ColoSockMirrorId) + xc.colo_sock_mirror_ip =3D C.CString(x.ColoSockMirrorIp) + xc.colo_sock_mirror_port =3D C.CString(x.ColoSockMirrorPort) + xc.colo_sock_compare_pri_in_id =3D C.CString(x.ColoSockComparePriInId) + xc.colo_sock_compare_pri_in_ip =3D C.CString(x.ColoSockComparePriInIp) + xc.colo_sock_compare_pri_in_port =3D C.CString(x.ColoSockComparePriInPort) + xc.colo_sock_compare_sec_in_id =3D C.CString(x.ColoSockCompareSecInId) + xc.colo_sock_compare_sec_in_ip =3D C.CString(x.ColoSockCompareSecInIp) + xc.colo_sock_compare_sec_in_port =3D C.CString(x.ColoSockCompareSecInPort) + xc.colo_sock_compare_notify_id =3D C.CString(x.ColoSockCompareNotifyId) + xc.colo_sock_compare_notify_ip =3D C.CString(x.ColoSockCompareNotifyIp) + xc.colo_sock_compare_notify_port =3D C.CString(x.ColoSockCompareNotifyPor= t) + xc.colo_sock_redirector0_id =3D C.CString(x.ColoSockRedirector0Id) + xc.colo_sock_redirector0_ip =3D C.CString(x.ColoSockRedirector0Ip) + xc.colo_sock_redirector0_port =3D C.CString(x.ColoSockRedirector0Port) + xc.colo_sock_redirector1_id =3D C.CString(x.ColoSockRedirector1Id) + xc.colo_sock_redirector1_ip =3D C.CString(x.ColoSockRedirector1Ip) + xc.colo_sock_redirector1_port =3D C.CString(x.ColoSockRedirector1Port) + xc.colo_sock_redirector2_id =3D C.CString(x.ColoSockRedirector2Id) + xc.colo_sock_redirector2_ip =3D C.CString(x.ColoSockRedirector2Ip) + xc.colo_sock_redirector2_port =3D C.CString(x.ColoSockRedirector2Port) + xc.colo_filter_mirror_queue =3D C.CString(x.ColoFilterMirrorQueue) + xc.colo_filter_mirror_outdev =3D C.CString(x.ColoFilterMirrorOutdev) + xc.colo_filter_redirector0_queue =3D C.CString(x.ColoFilterRedirector0Que= ue) + xc.colo_filter_redirector0_indev =3D C.CString(x.ColoFilterRedirector0Ind= ev) + xc.colo_filter_redirector0_outdev =3D C.CString(x.ColoFilterRedirector0Ou= tdev) + xc.colo_filter_redirector1_queue =3D C.CString(x.ColoFilterRedirector1Que= ue) + xc.colo_filter_redirector1_indev =3D C.CString(x.ColoFilterRedirector1Ind= ev) + xc.colo_filter_redirector1_outdev =3D C.CString(x.ColoFilterRedirector1Ou= tdev) + xc.colo_compare_pri_in =3D C.CString(x.ColoComparePriIn) + xc.colo_compare_sec_in =3D C.CString(x.ColoCompareSecIn) + xc.colo_compare_out =3D C.CString(x.ColoCompareOut) + xc.colo_compare_notify_dev =3D C.CString(x.ColoCompareNotifyDev) + xc.colo_sock_sec_redirector0_id =3D C.CString(x.ColoSockSecRedirector0Id) + xc.colo_sock_sec_redirector0_ip =3D C.CString(x.ColoSockSecRedirector0Ip) + xc.colo_sock_sec_redirector0_port =3D C.CString(x.ColoSockSecRedirector0P= ort) + xc.colo_sock_sec_redirector1_id =3D C.CString(x.ColoSockSecRedirector1Id) + xc.colo_sock_sec_redirector1_ip =3D C.CString(x.ColoSockSecRedirector1Ip) + xc.colo_sock_sec_redirector1_port =3D C.CString(x.ColoSockSecRedirector1P= ort) + xc.colo_filter_sec_redirector0_queue =3D C.CString(x.ColoFilterSecRedirec= tor0Queue) + xc.colo_filter_sec_redirector0_indev =3D C.CString(x.ColoFilterSecRedirec= tor0Indev) + xc.colo_filter_sec_redirector0_outdev =3D C.CString(x.ColoFilterSecRedire= ctor0Outdev) + xc.colo_filter_sec_redirector1_queue =3D C.CString(x.ColoFilterSecRedirec= tor1Queue) + xc.colo_filter_sec_redirector1_indev =3D C.CString(x.ColoFilterSecRedirec= tor1Indev) + xc.colo_filter_sec_redirector1_outdev =3D C.CString(x.ColoFilterSecRedire= ctor1Outdev) + xc.colo_filter_sec_rewriter0_queue =3D C.CString(x.ColoFilterSecRewriter0= Queue) + xc.colo_checkpoint_host =3D C.CString(x.ColoCheckpointHost) + xc.colo_checkpoint_port =3D C.CString(x.ColoCheckpointPort) + return xc, nil +} + func (x *DevicePci) fromC(xc *C.libxl_device_pci) error { x.Func =3D byte(xc._func) x.Dev =3D byte(xc.dev) @@ -776,6 +1335,22 @@ func (x *DevicePci) fromC(xc *C.libxl_device_pci) err= or { return nil } =20 +func (x *DevicePci) toC() (xc C.libxl_device_pci, err error) { + C.libxl_device_pci_init(&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 xc, nil +} + func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) error { x.Start =3D uint64(xc.start) x.Size =3D uint64(xc.size) @@ -784,6 +1359,14 @@ func (x *DeviceRdm) fromC(xc *C.libxl_device_rdm) err= or { return nil } =20 +func (x *DeviceRdm) toC() (xc C.libxl_device_rdm, err error) { + C.libxl_device_rdm_init(&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 xc, nil +} + func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbctrl) error { x.Type =3D UsbctrlType(xc._type) x.Devid =3D Devid(xc.devid) @@ -795,6 +1378,17 @@ func (x *DeviceUsbctrl) fromC(xc *C.libxl_device_usbc= trl) error { return nil } =20 +func (x *DeviceUsbctrl) toC() (xc C.libxl_device_usbctrl, err error) { + C.libxl_device_usbctrl_init(&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) + xc.backend_domname =3D C.CString(x.BackendDomname) + return xc, nil +} + func (x *DeviceUsbdev) fromC(xc *C.libxl_device_usbdev) error { x.Ctrl =3D Devid(xc.ctrl) x.Port =3D int(xc.port) @@ -824,12 +1418,25 @@ func (x *DeviceUsbdevTypeUnionHostdev) fromC(xc *C.l= ibxl_device_usbdev) error { return nil } =20 +func (x *DeviceUsbdev) toC() (xc C.libxl_device_usbdev, err error) { + C.libxl_device_usbdev_init(&xc) + xc.ctrl =3D C.libxl_devid(x.Ctrl) + xc.port =3D C.int(x.Port) + return xc, nil +} + func (x *DeviceDtdev) fromC(xc *C.libxl_device_dtdev) error { x.Path =3D C.GoString(xc.path) =20 return nil } =20 +func (x *DeviceDtdev) toC() (xc C.libxl_device_dtdev, err error) { + C.libxl_device_dtdev_init(&xc) + xc.path =3D C.CString(x.Path) + return xc, 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) @@ -841,6 +1448,19 @@ func (x *DeviceVtpm) fromC(xc *C.libxl_device_vtpm) e= rror { return nil } =20 +func (x *DeviceVtpm) toC() (xc C.libxl_device_vtpm, err error) { + C.libxl_device_vtpm_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.uuid, err =3D x.Uuid.toC() + if err !=3D nil { + C.libxl_device_vtpm_dispose(&xc) + return xc, err + } + return xc, 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) @@ -852,6 +1472,17 @@ func (x *DeviceP9) fromC(xc *C.libxl_device_p9) error= { return nil } =20 +func (x *DeviceP9) toC() (xc C.libxl_device_p9, err error) { + C.libxl_device_p9_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.tag =3D C.CString(x.Tag) + xc.path =3D C.CString(x.Path) + xc.security_model =3D C.CString(x.SecurityModel) + xc.devid =3D C.libxl_devid(x.Devid) + return xc, 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) @@ -860,6 +1491,14 @@ func (x *DevicePvcallsif) fromC(xc *C.libxl_device_pv= callsif) error { return nil } =20 +func (x *DevicePvcallsif) toC() (xc C.libxl_device_pvcallsif, err error) { + C.libxl_device_pvcallsif_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + return xc, 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) @@ -890,6 +1529,15 @@ func (x *DeviceChannelConnectionUnionSocket) fromC(xc= *C.libxl_device_channel) e return nil } =20 +func (x *DeviceChannel) toC() (xc C.libxl_device_channel, err error) { + C.libxl_device_channel_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.name =3D C.CString(x.Name) + return xc, 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) @@ -898,6 +1546,14 @@ func (x *ConnectorParam) fromC(xc *C.libxl_connector_= param) error { return nil } =20 +func (x *ConnectorParam) toC() (xc C.libxl_connector_param, err error) { + C.libxl_connector_param_init(&xc) + 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 xc, 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) @@ -917,6 +1573,15 @@ func (x *DeviceVdispl) fromC(xc *C.libxl_device_vdisp= l) error { return nil } =20 +func (x *DeviceVdispl) toC() (xc C.libxl_device_vdispl, err error) { + C.libxl_device_vdispl_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.be_alloc =3D C.bool(x.BeAlloc) + return xc, nil +} + func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) error { numSampleRates :=3D int(xc.num_sample_rates) cSampleRates :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.sample_rates))= [:numSampleRates:numSampleRates] @@ -937,6 +1602,14 @@ func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) e= rror { return nil } =20 +func (x *VsndParams) toC() (xc C.libxl_vsnd_params, err error) { + C.libxl_vsnd_params_init(&xc) + xc.channels_min =3D C.uint32_t(x.ChannelsMin) + xc.channels_max =3D C.uint32_t(x.ChannelsMax) + xc.buffer_size =3D C.uint32_t(x.BufferSize) + return xc, 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) @@ -947,6 +1620,18 @@ func (x *VsndStream) fromC(xc *C.libxl_vsnd_stream) e= rror { return nil } =20 +func (x *VsndStream) toC() (xc C.libxl_vsnd_stream, err error) { + C.libxl_vsnd_stream_init(&xc) + xc.unique_id =3D C.CString(x.UniqueId) + xc._type =3D C.libxl_vsnd_stream_type(x.Type) + xc.params, err =3D x.Params.toC() + if err !=3D nil { + C.libxl_vsnd_stream_dispose(&xc) + return xc, err + } + return xc, 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 { @@ -966,6 +1651,17 @@ func (x *VsndPcm) fromC(xc *C.libxl_vsnd_pcm) error { return nil } =20 +func (x *VsndPcm) toC() (xc C.libxl_vsnd_pcm, err error) { + C.libxl_vsnd_pcm_init(&xc) + xc.name =3D C.CString(x.Name) + xc.params, err =3D x.Params.toC() + if err !=3D nil { + C.libxl_vsnd_pcm_dispose(&xc) + return xc, err + } + return xc, 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) @@ -989,6 +1685,21 @@ func (x *DeviceVsnd) fromC(xc *C.libxl_device_vsnd) e= rror { return nil } =20 +func (x *DeviceVsnd) toC() (xc C.libxl_device_vsnd, err error) { + C.libxl_device_vsnd_init(&xc) + xc.backend_domid =3D C.libxl_domid(x.BackendDomid) + xc.backend_domname =3D C.CString(x.BackendDomname) + xc.devid =3D C.libxl_devid(x.Devid) + xc.short_name =3D C.CString(x.ShortName) + xc.long_name =3D C.CString(x.LongName) + xc.params, err =3D x.Params.toC() + if err !=3D nil { + C.libxl_device_vsnd_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *DomainConfig) fromC(xc *C.libxl_domain_config) error { if err :=3D x.CInfo.fromC(&xc.c_info); err !=3D nil { return err @@ -1155,6 +1866,26 @@ func (x *DomainConfig) fromC(xc *C.libxl_domain_conf= ig) error { return nil } =20 +func (x *DomainConfig) toC() (xc C.libxl_domain_config, err error) { + C.libxl_domain_config_init(&xc) + xc.c_info, err =3D x.CInfo.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + xc.b_info, err =3D x.BInfo.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, 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 xc, nil +} + func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1168,6 +1899,19 @@ func (x *Diskinfo) fromC(xc *C.libxl_diskinfo) error= { return nil } =20 +func (x *Diskinfo) toC() (xc C.libxl_diskinfo, err error) { + C.libxl_diskinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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 xc, nil +} + func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1182,6 +1926,20 @@ func (x *Nicinfo) fromC(xc *C.libxl_nicinfo) error { return nil } =20 +func (x *Nicinfo) toC() (xc C.libxl_nicinfo, err error) { + C.libxl_nicinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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 xc, nil +} + func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1198,6 +1956,24 @@ func (x *Vtpminfo) fromC(xc *C.libxl_vtpminfo) error= { return nil } =20 +func (x *Vtpminfo) toC() (xc C.libxl_vtpminfo, err error) { + C.libxl_vtpminfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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.uuid, err =3D x.Uuid.toC() + if err !=3D nil { + C.libxl_vtpminfo_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo) error { x.Type =3D UsbctrlType(xc._type) x.Devid =3D Devid(xc.devid) @@ -1215,6 +1991,23 @@ func (x *Usbctrlinfo) fromC(xc *C.libxl_usbctrlinfo)= error { return nil } =20 +func (x *Usbctrlinfo) toC() (xc C.libxl_usbctrlinfo, err error) { + C.libxl_usbctrlinfo_init(&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 =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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 xc, nil +} + func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error { x.Vcpuid =3D uint32(xc.vcpuid) x.Cpu =3D uint32(xc.cpu) @@ -1232,6 +2025,27 @@ func (x *Vcpuinfo) fromC(xc *C.libxl_vcpuinfo) error= { return nil } =20 +func (x *Vcpuinfo) toC() (xc C.libxl_vcpuinfo, err error) { + C.libxl_vcpuinfo_init(&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) + xc.cpumap, err =3D x.Cpumap.toC() + if err !=3D nil { + C.libxl_vcpuinfo_dispose(&xc) + return xc, err + } + xc.cpumap_soft, err =3D x.CpumapSoft.toC() + if err !=3D nil { + C.libxl_vcpuinfo_dispose(&xc) + return xc, err + } + return xc, 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) @@ -1259,6 +2073,35 @@ func (x *Physinfo) fromC(xc *C.libxl_physinfo) error= { return nil } =20 +func (x *Physinfo) toC() (xc C.libxl_physinfo, err error) { + C.libxl_physinfo_init(&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) + xc.hw_cap, err =3D x.HwCap.toC() + if err !=3D nil { + C.libxl_physinfo_dispose(&xc) + return xc, 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 xc, nil +} + func (x *Connectorinfo) fromC(xc *C.libxl_connectorinfo) error { x.UniqueId =3D C.GoString(xc.unique_id) x.Width =3D uint32(xc.width) @@ -1271,6 +2114,18 @@ func (x *Connectorinfo) fromC(xc *C.libxl_connectori= nfo) error { return nil } =20 +func (x *Connectorinfo) toC() (xc C.libxl_connectorinfo, err error) { + C.libxl_connectorinfo_init(&xc) + 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 xc, nil +} + func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1293,6 +2148,18 @@ func (x *Vdisplinfo) fromC(xc *C.libxl_vdisplinfo) e= rror { return nil } =20 +func (x *Vdisplinfo) toC() (xc C.libxl_vdisplinfo, err error) { + C.libxl_vdisplinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + xc.frontend =3D C.CString(x.Frontend) + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + xc.be_alloc =3D C.bool(x.BeAlloc) + return xc, nil +} + func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) error { x.ReqEvtch =3D int(xc.req_evtch) x.ReqRref =3D int(xc.req_rref) @@ -1300,6 +2167,13 @@ func (x *Streaminfo) fromC(xc *C.libxl_streaminfo) e= rror { return nil } =20 +func (x *Streaminfo) toC() (xc C.libxl_streaminfo, err error) { + C.libxl_streaminfo_init(&xc) + xc.req_evtch =3D C.int(x.ReqEvtch) + xc.req_rref =3D C.int(x.ReqRref) + return xc, nil +} + func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { numVsndStreams :=3D int(xc.num_vsnd_streams) cStreams :=3D (*[1 << 28]C.libxl_streaminfo)(unsafe.Pointer(xc.streams))[= :numVsndStreams:numVsndStreams] @@ -1315,6 +2189,11 @@ func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { return nil } =20 +func (x *Pcminfo) toC() (xc C.libxl_pcminfo, err error) { + C.libxl_pcminfo_init(&xc) + return xc, nil +} + func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1336,6 +2215,17 @@ func (x *Vsndinfo) fromC(xc *C.libxl_vsndinfo) error= { return nil } =20 +func (x *Vsndinfo) toC() (xc C.libxl_vsndinfo, err error) { + C.libxl_vsndinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + xc.frontend =3D C.CString(x.Frontend) + xc.frontend_id =3D C.uint32_t(x.FrontendId) + xc.devid =3D C.libxl_devid(x.Devid) + xc.state =3D C.int(x.State) + return xc, nil +} + func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { x.Backend =3D C.GoString(xc.backend) x.BackendId =3D uint32(xc.backend_id) @@ -1349,6 +2239,19 @@ func (x *Vkbinfo) fromC(xc *C.libxl_vkbinfo) error { return nil } =20 +func (x *Vkbinfo) toC() (xc C.libxl_vkbinfo, err error) { + C.libxl_vkbinfo_init(&xc) + xc.backend =3D C.CString(x.Backend) + xc.backend_id =3D C.uint32_t(x.BackendId) + 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 xc, nil +} + func (x *Numainfo) fromC(xc *C.libxl_numainfo) error { x.Size =3D uint64(xc.size) x.Free =3D uint64(xc.free) @@ -1362,6 +2265,13 @@ func (x *Numainfo) fromC(xc *C.libxl_numainfo) error= { return nil } =20 +func (x *Numainfo) toC() (xc C.libxl_numainfo, err error) { + C.libxl_numainfo_init(&xc) + xc.size =3D C.uint64_t(x.Size) + xc.free =3D C.uint64_t(x.Free) + return xc, nil +} + func (x *Cputopology) fromC(xc *C.libxl_cputopology) error { x.Core =3D uint32(xc.core) x.Socket =3D uint32(xc.socket) @@ -1370,6 +2280,14 @@ func (x *Cputopology) fromC(xc *C.libxl_cputopology)= error { return nil } =20 +func (x *Cputopology) toC() (xc C.libxl_cputopology, err error) { + C.libxl_cputopology_init(&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 xc, nil +} + func (x *Pcitopology) fromC(xc *C.libxl_pcitopology) error { x.Seg =3D uint16(xc.seg) x.Bus =3D byte(xc.bus) @@ -1379,6 +2297,15 @@ func (x *Pcitopology) fromC(xc *C.libxl_pcitopology)= error { return nil } =20 +func (x *Pcitopology) toC() (xc C.libxl_pcitopology, err error) { + C.libxl_pcitopology_init(&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 xc, 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) @@ -1387,12 +2314,26 @@ func (x *SchedCreditParams) fromC(xc *C.libxl_sched= _credit_params) error { return nil } =20 +func (x *SchedCreditParams) toC() (xc C.libxl_sched_credit_params, err err= or) { + C.libxl_sched_credit_params_init(&xc) + 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 xc, nil +} + func (x *SchedCredit2Params) fromC(xc *C.libxl_sched_credit2_params) error= { x.RatelimitUs =3D int(xc.ratelimit_us) =20 return nil } =20 +func (x *SchedCredit2Params) toC() (xc C.libxl_sched_credit2_params, err e= rror) { + C.libxl_sched_credit2_params_init(&xc) + xc.ratelimit_us =3D C.int(x.RatelimitUs) + return xc, 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 { @@ -1421,6 +2362,48 @@ func (x *DomainRemusInfo) fromC(xc *C.libxl_domain_r= emus_info) error { return nil } =20 +func (x *DomainRemusInfo) toC() (xc C.libxl_domain_remus_info, err error) { + C.libxl_domain_remus_info_init(&xc) + xc.interval =3D C.int(x.Interval) + xc.allow_unsafe, err =3D x.AllowUnsafe.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.blackhole, err =3D x.Blackhole.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.compression, err =3D x.Compression.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.netbuf, err =3D x.Netbuf.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.netbufscript =3D C.CString(x.Netbufscript) + xc.diskbuf, err =3D x.Diskbuf.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.colo, err =3D x.Colo.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + xc.userspace_colo_proxy, err =3D x.UserspaceColoProxy.toC() + if err !=3D nil { + C.libxl_domain_remus_info_dispose(&xc) + return xc, err + } + return xc, nil +} + func (x *Event) fromC(xc *C.libxl_event) error { if err :=3D x.Link.fromC(&xc.link); err !=3D nil { return err @@ -1490,6 +2473,23 @@ func (x *EventTypeUnionOperationComplete) fromC(xc *= C.libxl_event) error { return nil } =20 +func (x *Event) toC() (xc C.libxl_event, err error) { + C.libxl_event_init(&xc) + xc.link, err =3D x.Link.toC() + if err !=3D nil { + C.libxl_event_dispose(&xc) + return xc, err + } + xc.domid =3D C.libxl_domid(x.Domid) + xc.domuuid, err =3D x.Domuuid.toC() + if err !=3D nil { + C.libxl_event_dispose(&xc) + return xc, err + } + xc.for_user =3D C.uint64_t(x.ForUser) + return xc, 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) @@ -1499,6 +2499,15 @@ func (x *PsrCatInfo) fromC(xc *C.libxl_psr_cat_info)= error { return nil } =20 +func (x *PsrCatInfo) toC() (xc C.libxl_psr_cat_info, err error) { + C.libxl_psr_cat_info_init(&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 xc, nil +} + func (x *PsrHwInfo) fromC(xc *C.libxl_psr_hw_info) error { x.Id =3D uint32(xc.id) x.Type =3D PsrFeatType(xc._type) @@ -1545,3 +2554,9 @@ func (x *PsrHwInfoTypeUnionMba) fromC(xc *C.libxl_psr= _hw_info) error { x.Linear =3D bool(tmp.linear) return nil } + +func (x *PsrHwInfo) toC() (xc C.libxl_psr_hw_info, err error) { + C.libxl_psr_hw_info_init(&xc) + xc.id =3D C.uint32_t(x.Id) + return xc, nil +} --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575993005; cv=none; d=zohomail.com; s=zohoarc; b=Vg0HAt6NXcinkyjThIDdUGOS4Wri7HPKczjYZE3BkYtLxebEGa/+CR9LbiCQK3f7mldIZtLJ6uIn5ZHgH8I6YyFaAjZbwnTcwntPdQIO2SACL6uZqc5lgjti0xTN8r/IqvSgZRZIfqnzKqFDyweR5t1xZ/0EnBas1w3DnNNylbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575993005; 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=+MBbABmbRerdVDb1WL5AlO8caK8XavYvzZ6VDuyfv38=; b=D62zrlk9sEnprA0kxXeK86g3V6u8WYV+pvo8o9udbV3p1FHase5Zxq65H10LUScW1Ey5Sjo+J0InQlK3l0PrWdWU3rHplS0UAbn8M5BeAY9dIxBVwvnmWHNFnrGKb8Vga6b1mPjYcVNjZzh2vN32/B1MbhplL4PNdBUVcABEadA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575993005031964.5052012406838; Tue, 10 Dec 2019 07:50:05 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlJ-0003qC-Uh; Tue, 10 Dec 2019 15:49:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlI-0003pG-Tk for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:20 +0000 Received: from mail-qt1-x82f.google.com (unknown [2607:f8b0:4864:20::82f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 79ccc8c6-1b64-11ea-b6f1-bc764e2007e4; Tue, 10 Dec 2019 15:48:14 +0000 (UTC) Received: by mail-qt1-x82f.google.com with SMTP id w47so3193221qtk.4 for ; Tue, 10 Dec 2019 07:48:14 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:12 -0800 (PST) X-Inumbo-ID: 79ccc8c6-1b64-11ea-b6f1-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:content-transfer-encoding; bh=XV0keTvnjUtyj44I4rd2s4MldHULWb3sptCUA75Q+SY=; b=RK8vWMgdf+9DDIIuHAY2keHSwvH3zLs2mctyikHkt7Y+Tk1q9924lFAG1M2Yta8Cxo XvvMUM+aUkjs3cqtxqgH/2tBbOjohIUzRlCvMLJclmiOtzMeEmHSzzYgFuj4g2B+B7kk E7uq2HwCfFAfIZiWJOKwWLS4ZpQ6JE4JwoLZyuFcZwOESOZG06PttxtoMbBKhh0hEWd3 6QsKtxEUv73Gbhl4vTOUPCKZ7VghlNUIb4etWai+vs/eI2h1cKYzpNFG4thORLxLmlS4 UqrMcutIEEdXakZhqQlrnW1mzcjUV6UMiEa506bfjaryu6hJ453TAXnPM8O0QDXURTAr wseA== 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=XV0keTvnjUtyj44I4rd2s4MldHULWb3sptCUA75Q+SY=; b=M7dBJjo77HnfqdWtAlW4038EoxRNlb4DTcIvd9xFG3/RpCbKX8pW508oCJjN710aHl Sy3C4zBEOnANpl46c8oy0deHot5+YnDiOK/l4UAAec+Qcd0rv3ZhYHSm6pF3QajFIv1z zaBbvB31qkeNDOWnIZGgb7G7//CUdEE0L2EgQsSqotRA1hsVou3rGmVLtRfj5NbTRFUF rb7Zc6P23K8Tl/X3S3WkBhxMNsNdAwzVNIu4GLdKrtBGRMc5S5LpTepE5GPK7mctqbed E4i8zM4BwnfOekpXOIGKweaKht0Pu9ZEqvv9ZxWH73+949M0MIUJ1jzlWyp1vIDjN7bk ohCQ== X-Gm-Message-State: APjAAAUKd8Hz8yF5WC1sN3zvNwa80iScYFzVkHMtgETKT89SanjqYwZj cLYXunKjsz8oY/w9E5LYByC2jJhR X-Google-Smtp-Source: APXvYqx0RKI8JKOogZLVHs5lIzNSLeyPvAFTMyoyLyywd1mIAR77mb2YExlvIwguVRGYyM4YX3SSNQ== X-Received: by 2002:ac8:a8b:: with SMTP id d11mr6275493qti.94.1575992893407; Tue, 10 Dec 2019 07:48:13 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:34 -0500 Message-Id: <23bb9174f06e376c20b8841159643b42a3c1b18e.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 19/22] golang/xenlight: implement keyed union Go to C marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Since the C union cannot be directly populated, populate the fields of the corresponding C struct defined in the cgo preamble, and then copy that struct as bytes into the byte slice that Go uses as the union. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 77 ++++++- tools/golang/xenlight/helpers.gen.go | 325 +++++++++++++++++++++++++++ 2 files changed, 400 insertions(+), 2 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index cb9b18218f..1839ac14b6 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -504,8 +504,7 @@ def xenlight_golang_define_to_C(ty =3D None, typename = =3D None, nested =3D False): s +=3D xenlight_golang_define_to_C(f.type, typename=3Df.name, = nested=3DTrue) =20 elif isinstance(f.type, idl.KeyedUnion): - # TODO - pass + s +=3D xenlight_golang_union_to_C(f.type, f.name, ty.typename,= ty.dispose_fn) =20 else: raise Exception('type {} not supported'.format(f.type)) @@ -516,6 +515,80 @@ def xenlight_golang_define_to_C(ty =3D None, typename = =3D None, nested =3D False): =20 return s =20 +def xenlight_golang_union_to_C(ty =3D None, union_name =3D '', + struct_name =3D '', dispose_fn =3D ''): + keyname =3D ty.keyvar.name + gokeyname =3D xenlight_golang_fmt_name(keyname) + keytype =3D ty.keyvar.type.typename + gokeytype =3D xenlight_golang_fmt_name(keytype) + + interface_name =3D '{}_{}_union'.format(struct_name, keyname) + interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + + cgo_keyname =3D keyname + if cgo_keyname in go_keywords: + cgo_keyname =3D '_' + cgo_keyname + + + s =3D 'xc.{} =3D C.{}(x.{})\n'.format(cgo_keyname,keytype,gokeyname) + s +=3D 'switch x.{}{{\n'.format(gokeyname) + + # Create switch statement to determine how to populate the C union. + for f in ty.fields: + key_val =3D '{}_{}'.format(keytype, f.name) + key_val =3D xenlight_golang_fmt_name(key_val) + if f.type is None: + continue + + s +=3D 'case {}:\n'.format(key_val) + cgotype =3D '{}_{}_union_{}'.format(struct_name,keyname,f.name) + gotype =3D xenlight_golang_fmt_name(cgotype) + goname =3D '{}_{}'.format(keyname,f.name) + goname =3D xenlight_golang_fmt_name(goname,exported=3DFalse) + + field_name =3D xenlight_golang_fmt_name('{}_union'.format(keyname)) + s +=3D 'tmp, ok :=3D x.{}.({})\n'.format(field_name,gotype) + s +=3D 'if !ok {\n' + s +=3D 'C.{}(&xc)\n'.format(dispose_fn) + s +=3D 'return xc,errors.New("wrong type for union key {}")\n'.for= mat(keyname) + s +=3D '}\n' + + s +=3D 'var {} C.{}\n'.format(f.name,cgotype) + for uf in f.type.fields: + gotypename =3D xenlight_golang_fmt_name(uf.type.typename) + ctypename =3D uf.type.typename + gofname =3D xenlight_golang_fmt_name(uf.name) + + is_castable =3D (uf.type.json_parse_type =3D=3D 'JSON_INTEGER'= or + isinstance(uf.type, idl.Enumeration) or + gotypename in go_builtin_types) + + if not is_castable: + s +=3D '{}.{}, err =3D tmp.{}.toC()\n'.format(f.name,uf.na= me,gofname) + s +=3D 'if err !=3D nil {\n' + s +=3D 'C.{}(&xc)\n'.format(dispose_fn) + s +=3D 'return xc,err \n}\n' + + elif gotypename =3D=3D 'string': + s +=3D '{}.{} =3D C.CString(tmp.{})\n'.format(f.name,uf.na= me,gofname) + + else: + s +=3D '{}.{} =3D C.{}(tmp.{})\n'.format(f.name,uf.name,ct= ypename,gofname) + + # The union is still represented as Go []byte. + s +=3D '{}Bytes :=3D C.GoBytes(unsafe.Pointer(&{}),C.sizeof_{})\n'= .format(f.name, + = f.name, + = cgotype) + s +=3D 'copy(xc.{}[:],{}Bytes)\n'.format(union_name,f.name) + + # End switch statement + s +=3D 'default:\n' + err_string =3D '"invalid union key \'%v\'", x.{}'.format(gokeyname) + s +=3D 'return xc, fmt.Errorf({})'.format(err_string) + s +=3D '}\n' + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index a155b091a7..73ad5e9761 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -326,6 +326,21 @@ func (x *Channelinfo) toC() (xc C.libxl_channelinfo, e= rr error) { 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 ChannelConnectionPty: + tmp, ok :=3D x.ConnectionUnion.(ChannelinfoConnectionUnionPty) + if !ok { + C.libxl_channelinfo_dispose(&xc) + return xc, errors.New("wrong type for union key connection") + } + var pty C.libxl_channelinfo_connection_union_pty + 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) + default: + return xc, fmt.Errorf("invalid union key '%v'", x.Connection) + } return xc, nil } =20 @@ -1031,6 +1046,216 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_= build_info, err error) { return xc, 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 { + C.libxl_domain_build_info_dispose(&xc) + return xc, errors.New("wrong type for union key type") + } + var hvm C.libxl_domain_build_info_type_union_hvm + hvm.firmware =3D C.CString(tmp.Firmware) + hvm.bios =3D C.libxl_bios_type(tmp.Bios) + hvm.pae, err =3D tmp.Pae.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.apic, err =3D tmp.Apic.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.acpi, err =3D tmp.Acpi.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.acpi_s3, err =3D tmp.AcpiS3.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.acpi_s4, err =3D tmp.AcpiS4.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.acpi_laptop_slate, err =3D tmp.AcpiLaptopSlate.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.nx, err =3D tmp.Nx.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.viridian, err =3D tmp.Viridian.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.viridian_enable, err =3D tmp.ViridianEnable.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.viridian_disable, err =3D tmp.ViridianDisable.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.timeoffset =3D C.CString(tmp.Timeoffset) + hvm.hpet, err =3D tmp.Hpet.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.vpt_align, err =3D tmp.VptAlign.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.mmio_hole_memkb =3D C.uint64_t(tmp.MmioHoleMemkb) + hvm.timer_mode =3D C.libxl_timer_mode(tmp.TimerMode) + hvm.nested_hvm, err =3D tmp.NestedHvm.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.altp2m, err =3D tmp.Altp2M.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.system_firmware =3D C.CString(tmp.SystemFirmware) + hvm.smbios_firmware =3D C.CString(tmp.SmbiosFirmware) + hvm.acpi_firmware =3D C.CString(tmp.AcpiFirmware) + hvm.hdtype =3D C.libxl_hdtype(tmp.Hdtype) + hvm.nographic, err =3D tmp.Nographic.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.vga, err =3D tmp.Vga.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.vnc, err =3D tmp.Vnc.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.keymap =3D C.CString(tmp.Keymap) + hvm.sdl, err =3D tmp.Sdl.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.spice, err =3D tmp.Spice.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.gfx_passthru, err =3D tmp.GfxPassthru.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.gfx_passthru_kind =3D C.libxl_gfx_passthru_kind(tmp.GfxPassthruKind) + hvm.serial =3D C.CString(tmp.Serial) + hvm.boot =3D C.CString(tmp.Boot) + hvm.usb, err =3D tmp.Usb.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.usbversion =3D C.int(tmp.Usbversion) + hvm.usbdevice =3D C.CString(tmp.Usbdevice) + hvm.vkb_device, err =3D tmp.VkbDevice.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.soundhw =3D C.CString(tmp.Soundhw) + hvm.xen_platform_pci, err =3D tmp.XenPlatformPci.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.usbdevice_list, err =3D tmp.UsbdeviceList.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.vendor_device =3D C.libxl_vendor_device(tmp.VendorDevice) + hvm.ms_vm_genid, err =3D tmp.MsVmGenid.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.serial_list, err =3D tmp.SerialList.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + hvm.rdm, err =3D tmp.Rdm.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, 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 { + C.libxl_domain_build_info_dispose(&xc) + return xc, errors.New("wrong type for union key type") + } + var pv C.libxl_domain_build_info_type_union_pv + pv.kernel =3D C.CString(tmp.Kernel) + pv.slack_memkb =3D C.uint64_t(tmp.SlackMemkb) + pv.bootloader =3D C.CString(tmp.Bootloader) + pv.bootloader_args, err =3D tmp.BootloaderArgs.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + pv.cmdline =3D C.CString(tmp.Cmdline) + pv.ramdisk =3D C.CString(tmp.Ramdisk) + pv.features =3D C.CString(tmp.Features) + pv.e820_host, err =3D tmp.E820Host.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, 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 { + C.libxl_domain_build_info_dispose(&xc) + return xc, errors.New("wrong type for union key type") + } + var pvh C.libxl_domain_build_info_type_union_pvh + pvh.pvshim, err =3D tmp.Pvshim.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + pvh.pvshim_path =3D C.CString(tmp.PvshimPath) + pvh.pvshim_cmdline =3D C.CString(tmp.PvshimCmdline) + 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) + default: + return xc, 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) @@ -1422,6 +1647,22 @@ func (x *DeviceUsbdev) toC() (xc C.libxl_device_usbd= ev, err error) { C.libxl_device_usbdev_init(&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 { + C.libxl_device_usbdev_dispose(&xc) + return xc, 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 xc, fmt.Errorf("invalid union key '%v'", x.Type) + } return xc, nil } =20 @@ -1535,6 +1776,21 @@ func (x *DeviceChannel) toC() (xc C.libxl_device_cha= nnel, err error) { xc.backend_domname =3D C.CString(x.BackendDomname) xc.devid =3D C.libxl_devid(x.Devid) xc.name =3D C.CString(x.Name) + xc.connection =3D C.libxl_channel_connection(x.Connection) + switch x.Connection { + case ChannelConnectionSocket: + tmp, ok :=3D x.ConnectionUnion.(DeviceChannelConnectionUnionSocket) + if !ok { + C.libxl_device_channel_dispose(&xc) + return xc, errors.New("wrong type for union key connection") + } + var socket C.libxl_device_channel_connection_union_socket + 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 xc, fmt.Errorf("invalid union key '%v'", x.Connection) + } return xc, nil } =20 @@ -2487,6 +2743,46 @@ func (x *Event) toC() (xc C.libxl_event, err error) { return xc, 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 { + C.libxl_event_dispose(&xc) + return xc, 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 EventTypeDiskEject: + tmp, ok :=3D x.TypeUnion.(EventTypeUnionDiskEject) + if !ok { + C.libxl_event_dispose(&xc) + return xc, errors.New("wrong type for union key type") + } + var disk_eject C.libxl_event_type_union_disk_eject + disk_eject.vdev =3D C.CString(tmp.Vdev) + disk_eject.disk, err =3D tmp.Disk.toC() + if err !=3D nil { + C.libxl_event_dispose(&xc) + return xc, 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 { + C.libxl_event_dispose(&xc) + return xc, 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) + default: + return xc, fmt.Errorf("invalid union key '%v'", x.Type) + } return xc, nil } =20 @@ -2558,5 +2854,34 @@ func (x *PsrHwInfoTypeUnionMba) fromC(xc *C.libxl_ps= r_hw_info) error { func (x *PsrHwInfo) toC() (xc C.libxl_psr_hw_info, err error) { C.libxl_psr_hw_info_init(&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 { + C.libxl_psr_hw_info_dispose(&xc) + return xc, 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 { + C.libxl_psr_hw_info_dispose(&xc) + return xc, 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 xc, fmt.Errorf("invalid union key '%v'", x.Type) + } return xc, nil } --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575993012; cv=none; d=zohomail.com; s=zohoarc; b=RAv69U72P4KX55IGUwdtr+IdrrqliGRlUlgB6SL4jHAV6CxlxoPSLIx9PDpmYUE9op7/rYAlNmGQ2v3T/9u2Sg9PtTX/d1rhMS+HOf0StBsaUI7TPJ9Ksy1KxRegXCBEgw2N8RGXXrRh+IhbAwgIZe5qoDcuyNyYEWs9yKU0S4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575993012; 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=GrCK2wocbGNbRPie9lchOOPL/IpITEtqGUPO4gByf3w=; b=UjGXnXEcSmtU0f57NZbiFLXq48TB/dLHycL8Kb4X4S+3t3cmw7ubigjx4q96RXI9YMmlLaSSRfCFw5ERNC8gv5fSxwCyE9NjrYi8EWWqeIq0OxghFtecKQbiOcoVnRPHTun3QKa2sn7jJH9RjfQFrS4Ieae0cdIuXyAgmUzGBZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575993012590418.1531016186267; Tue, 10 Dec 2019 07:50:12 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlT-0003zu-SF; Tue, 10 Dec 2019 15:49:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlS-0003z0-UV for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:30 +0000 Received: from mail-qk1-x744.google.com (unknown [2607:f8b0:4864:20::744]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7aa1e862-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:48:15 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id c16so8378823qko.6 for ; Tue, 10 Dec 2019 07:48:15 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:13 -0800 (PST) X-Inumbo-ID: 7aa1e862-1b64-11ea-a1e1-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:content-transfer-encoding; bh=BudUVN1eN5Wzy8WDafjhGteC9aUwDbyqCo7hMdaiTi4=; b=hBUQWIAsSqLRaX/+47gL8R4ajDiKDMQaiDl3I/ANkAIPlAXckhaQACMZo7LyoNkMyF FWy/G0zFLIgM5WRrD4+YtSlutsz6W4BsSk0eLMMsv488zu8dCk3CNfgkal5sEOYnzF/w utaZ15Q971S3dQZbC1hS2xciXpwcWP67hAzM9DCBjnvDh5AowLbzFNYdTs1PO+2aq5NM TnszsZXPp6HnWekb1fjHUBTWzQaS+z+DdvAxHy/HEI2/+1QhfThOM28tQcHfu6/z4UVv MqEfJA4ImlWIZn5+bvgxVL8e57cmOwT1z/QoEcPYRd9dJ6u79n9sWp/qkc27jokYlzq3 cf9Q== 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=BudUVN1eN5Wzy8WDafjhGteC9aUwDbyqCo7hMdaiTi4=; b=fc9Zz7r9JaVBGucFzAvbhP4Bcq3gSyd2f7t5Ng80fTv5zt/0ZKyPCXHIqPxqsj+D2V qIMotjfSgDBAMzTViR9dba1aSqGWyfb4i/tRjTtN8zvcJAFztR948dZCeCgWy31x0Aeq EKyI2UvBFgEmATgwYUq8/+vMDL2VkNB1zZuAPg10WXVSH3CKbdoYbINifpquU4HDyso0 gdVS3FSRraoEfCPDQhRkP/hss2PtCwispEaRuTrM2x8Mg902nO4i8A1/zwqFkHJO8H+R i3fz0tfE6atQ3Do2KmPgOfvOg0gLgnAafJRYPQtLVaU0/ZRGbKNwHxyFO8jVW2E2luH8 xMbw== X-Gm-Message-State: APjAAAXiXlFy/lg85uRsCzI/clMJPB9lMJWrgvpF9R7MdVbTAWCP15La 6gvnE2xNka55JCTQcCzdaQD/Urjk X-Google-Smtp-Source: APXvYqzB0N4eExJYGv9dRT2vsH6DI+zs+NhTKGG/Rv7pGEw2Go+Eptaf5peHaETuc6uiie/S3AnHzA== X-Received: by 2002:ae9:ec03:: with SMTP id h3mr10693513qkg.369.1575992894657; Tue, 10 Dec 2019 07:48:14 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:35 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 20/22] golang/xenlight: implement array Go to C marshaling X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 44 +++- tools/golang/xenlight/helpers.gen.go | 359 +++++++++++++++++++++++++++ 2 files changed, 402 insertions(+), 1 deletion(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 1839ac14b6..24d27e30ad 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -458,7 +458,7 @@ def xenlight_golang_define_to_C(ty =3D None, typename = =3D None, nested =3D False): for f in ty.fields: if f.type.typename is not None: if isinstance(f.type, idl.Array): - # TODO + s +=3D xenlight_golang_array_to_C(f, ty.dispose_fn) continue =20 gotypename =3D xenlight_golang_fmt_name(f.type.typename) @@ -589,6 +589,48 @@ def xenlight_golang_union_to_C(ty =3D None, union_name= =3D '', =20 return s =20 +def xenlight_golang_array_to_C(ty =3D None, dispose_fn =3D ''): + s =3D '' + + gotypename =3D xenlight_golang_fmt_name(ty.type.elem_type.typename) + goname =3D xenlight_golang_fmt_name(ty.name) + ctypename =3D ty.type.elem_type.typename + cname =3D ty.name + clenvar =3D ty.type.lenvar.name + golenvar =3D xenlight_golang_fmt_name(clenvar,exported=3DFalse) + + is_enum =3D isinstance(ty.type.elem_type,idl.Enumeration) + if gotypename in go_builtin_types or is_enum: + s +=3D '{} :=3D len(x.{})\n'.format(golenvar,goname) + s +=3D 'xc.{} =3D (*C.{})(C.malloc(C.size_t({}*{})))\n'.format(cna= me,ctypename, + golenva= r,golenvar) + s +=3D 'xc.{} =3D C.int({})\n'.format(clenvar,golenvar) + s +=3D 'c{} :=3D (*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.= format(goname, + ctyp= ename,cname, + gole= nvar,golenvar) + s +=3D 'for i,v :=3D range x.{} {{\n'.format(goname) + s +=3D 'c{}[i] =3D C.{}(v)\n'.format(goname,ctypename) + s +=3D '}\n' + + return s + + s +=3D '{} :=3D len(x.{})\n'.format(golenvar,goname) + s +=3D 'xc.{} =3D (*C.{})(C.malloc(C.ulong({})*C.sizeof_{}))\n'.format= (cname,ctypename, + golenva= r,ctypename) + s +=3D 'xc.{} =3D C.int({})\n'.format(clenvar,golenvar) + s +=3D 'c{} :=3D (*[1<<28]C.{})(unsafe.Pointer(xc.{}))[:{}:{}]\n'.form= at(goname, + c= typename,cname, + g= olenvar,golenvar) + s +=3D 'for i,v :=3D range x.{} {{\n'.format(goname) + s +=3D 'tmp, err :=3D v.toC()\n' + s +=3D 'if err !=3D nil {\n' + s +=3D 'C.{}(&xc)\n'.format(dispose_fn) + s +=3D 'return xc,err\n}\n' + s +=3D 'c{}[i] =3D tmp\n'.format(goname) + s +=3D '}\n' + + return s + def xenlight_golang_fmt_name(name, exported =3D True): """ Take a given type name and return an diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/h= elpers.gen.go index 73ad5e9761..98b4bba4b2 100644 --- a/tools/golang/xenlight/helpers.gen.go +++ b/tools/golang/xenlight/helpers.gen.go @@ -545,6 +545,18 @@ func (x *VcpuSchedParams) fromC(xc *C.libxl_vcpu_sched= _params) error { func (x *VcpuSchedParams) toC() (xc C.libxl_vcpu_sched_params, err error) { C.libxl_vcpu_sched_params_init(&xc) xc.sched =3D C.libxl_scheduler(x.Sched) + numVcpus :=3D len(x.Vcpus) + xc.vcpus =3D (*C.libxl_sched_params)(C.malloc(C.ulong(numVcpus) * C.sizeo= f_libxl_sched_params)) + xc.num_vcpus =3D C.int(numVcpus) + cVcpus :=3D (*[1 << 28]C.libxl_sched_params)(unsafe.Pointer(xc.vcpus))[:n= umVcpus:numVcpus] + for i, v :=3D range x.Vcpus { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_vcpu_sched_params_dispose(&xc) + return xc, err + } + cVcpus[i] =3D tmp + } return xc, nil } =20 @@ -593,6 +605,13 @@ func (x *VnodeInfo) fromC(xc *C.libxl_vnode_info) erro= r { func (x *VnodeInfo) toC() (xc C.libxl_vnode_info, err error) { C.libxl_vnode_info_init(&xc) xc.memkb =3D C.uint64_t(x.Memkb) + numDistances :=3D len(x.Distances) + xc.distances =3D (*C.uint32_t)(C.malloc(C.size_t(numDistances * numDistan= ces))) + xc.num_distances =3D C.int(numDistances) + cDistances :=3D (*[1 << 28]C.uint32_t)(unsafe.Pointer(xc.distances))[:num= Distances:numDistances] + for i, v :=3D range x.Distances { + cDistances[i] =3D C.uint32_t(v) + } xc.pnode =3D C.uint32_t(x.Pnode) xc.vcpus, err =3D x.Vcpus.toC() if err !=3D nil { @@ -946,6 +965,30 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_bui= ld_info, err error) { C.libxl_domain_build_info_dispose(&xc) return xc, err } + numVcpuHardAffinity :=3D len(x.VcpuHardAffinity) + xc.vcpu_hard_affinity =3D (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuHardA= ffinity) * 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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + cVcpuHardAffinity[i] =3D tmp + } + numVcpuSoftAffinity :=3D len(x.VcpuSoftAffinity) + xc.vcpu_soft_affinity =3D (*C.libxl_bitmap)(C.malloc(C.ulong(numVcpuSoftA= ffinity) * 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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + cVcpuSoftAffinity[i] =3D tmp + } xc.numa_placement, err =3D x.NumaPlacement.toC() if err !=3D nil { C.libxl_domain_build_info_dispose(&xc) @@ -976,6 +1019,18 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_bu= ild_info, err error) { return xc, err } xc.blkdev_start =3D C.CString(x.BlkdevStart) + numVnumaNodes :=3D len(x.VnumaNodes) + 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_n= odes))[:numVnumaNodes:numVnumaNodes] + for i, v :=3D range x.VnumaNodes { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + cVnumaNodes[i] =3D tmp + } 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) @@ -1008,6 +1063,37 @@ func (x *DomainBuildInfo) toC() (xc C.libxl_domain_b= uild_info, err error) { C.libxl_domain_build_info_dispose(&xc) return xc, err } + numIoports :=3D len(x.Ioports) + xc.ioports =3D (*C.libxl_ioport_range)(C.malloc(C.ulong(numIoports) * C.s= izeof_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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + cIoports[i] =3D tmp + } + numIrqs :=3D len(x.Irqs) + 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:numIr= qs] + for i, v :=3D range x.Irqs { + cIrqs[i] =3D C.uint32_t(v) + } + numIomem :=3D len(x.Iomem) + xc.iomem =3D (*C.libxl_iomem_range)(C.malloc(C.ulong(numIomem) * C.sizeof= _libxl_iomem_range)) + xc.num_iomem =3D C.int(numIomem) + cIomem :=3D (*[1 << 28]C.libxl_iomem_range)(unsafe.Pointer(xc.iomem))[:nu= mIomem:numIomem] + for i, v :=3D range x.Iomem { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_build_info_dispose(&xc) + return xc, err + } + cIomem[i] =3D tmp + } xc.claim_mode, err =3D x.ClaimMode.toC() if err !=3D nil { C.libxl_domain_build_info_dispose(&xc) @@ -1835,6 +1921,18 @@ func (x *DeviceVdispl) toC() (xc C.libxl_device_vdis= pl, err error) { xc.backend_domname =3D C.CString(x.BackendDomname) xc.devid =3D C.libxl_devid(x.Devid) xc.be_alloc =3D C.bool(x.BeAlloc) + numConnectors :=3D len(x.Connectors) + xc.connectors =3D (*C.libxl_connector_param)(C.malloc(C.ulong(numConnecto= rs) * C.sizeof_libxl_connector_param)) + xc.num_connectors =3D C.int(numConnectors) + cConnectors :=3D (*[1 << 28]C.libxl_connector_param)(unsafe.Pointer(xc.co= nnectors))[:numConnectors:numConnectors] + for i, v :=3D range x.Connectors { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_device_vdispl_dispose(&xc) + return xc, err + } + cConnectors[i] =3D tmp + } return xc, nil } =20 @@ -1860,6 +1958,20 @@ func (x *VsndParams) fromC(xc *C.libxl_vsnd_params) = error { =20 func (x *VsndParams) toC() (xc C.libxl_vsnd_params, err error) { C.libxl_vsnd_params_init(&xc) + numSampleRates :=3D len(x.SampleRates) + xc.sample_rates =3D (*C.uint32_t)(C.malloc(C.size_t(numSampleRates * numS= ampleRates))) + 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) + } + numSampleFormats :=3D len(x.SampleFormats) + xc.sample_formats =3D (*C.libxl_vsnd_pcm_format)(C.malloc(C.size_t(numSam= pleFormats * numSampleFormats))) + xc.num_sample_formats =3D C.int(numSampleFormats) + cSampleFormats :=3D (*[1 << 28]C.libxl_vsnd_pcm_format)(unsafe.Pointer(xc= .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) @@ -1915,6 +2027,18 @@ func (x *VsndPcm) toC() (xc C.libxl_vsnd_pcm, err er= ror) { C.libxl_vsnd_pcm_dispose(&xc) return xc, err } + numVsndStreams :=3D len(x.Streams) + 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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_vsnd_pcm_dispose(&xc) + return xc, err + } + cStreams[i] =3D tmp + } return xc, nil } =20 @@ -1953,6 +2077,18 @@ func (x *DeviceVsnd) toC() (xc C.libxl_device_vsnd, = err error) { C.libxl_device_vsnd_dispose(&xc) return xc, err } + numVsndPcms :=3D len(x.Pcms) + 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))[:numVsnd= Pcms:numVsndPcms] + for i, v :=3D range x.Pcms { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_device_vsnd_dispose(&xc) + return xc, err + } + cPcms[i] =3D tmp + } return xc, nil } =20 @@ -2134,6 +2270,186 @@ func (x *DomainConfig) toC() (xc C.libxl_domain_con= fig, err error) { C.libxl_domain_config_dispose(&xc) return xc, err } + numDisks :=3D len(x.Disks) + xc.disks =3D (*C.libxl_device_disk)(C.malloc(C.ulong(numDisks) * C.sizeof= _libxl_device_disk)) + xc.num_disks =3D C.int(numDisks) + cDisks :=3D (*[1 << 28]C.libxl_device_disk)(unsafe.Pointer(xc.disks))[:nu= mDisks:numDisks] + for i, v :=3D range x.Disks { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cDisks[i] =3D tmp + } + numNics :=3D len(x.Nics) + xc.nics =3D (*C.libxl_device_nic)(C.malloc(C.ulong(numNics) * C.sizeof_li= bxl_device_nic)) + xc.num_nics =3D C.int(numNics) + cNics :=3D (*[1 << 28]C.libxl_device_nic)(unsafe.Pointer(xc.nics))[:numNi= cs:numNics] + for i, v :=3D range x.Nics { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cNics[i] =3D tmp + } + numPcidevs :=3D len(x.Pcidevs) + xc.pcidevs =3D (*C.libxl_device_pci)(C.malloc(C.ulong(numPcidevs) * C.siz= eof_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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cPcidevs[i] =3D tmp + } + numRdms :=3D len(x.Rdms) + xc.rdms =3D (*C.libxl_device_rdm)(C.malloc(C.ulong(numRdms) * C.sizeof_li= bxl_device_rdm)) + xc.num_rdms =3D C.int(numRdms) + cRdms :=3D (*[1 << 28]C.libxl_device_rdm)(unsafe.Pointer(xc.rdms))[:numRd= ms:numRdms] + for i, v :=3D range x.Rdms { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cRdms[i] =3D tmp + } + numDtdevs :=3D len(x.Dtdevs) + xc.dtdevs =3D (*C.libxl_device_dtdev)(C.malloc(C.ulong(numDtdevs) * C.siz= eof_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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cDtdevs[i] =3D tmp + } + numVfbs :=3D len(x.Vfbs) + xc.vfbs =3D (*C.libxl_device_vfb)(C.malloc(C.ulong(numVfbs) * C.sizeof_li= bxl_device_vfb)) + xc.num_vfbs =3D C.int(numVfbs) + cVfbs :=3D (*[1 << 28]C.libxl_device_vfb)(unsafe.Pointer(xc.vfbs))[:numVf= bs:numVfbs] + for i, v :=3D range x.Vfbs { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cVfbs[i] =3D tmp + } + numVkbs :=3D len(x.Vkbs) + xc.vkbs =3D (*C.libxl_device_vkb)(C.malloc(C.ulong(numVkbs) * C.sizeof_li= bxl_device_vkb)) + xc.num_vkbs =3D C.int(numVkbs) + cVkbs :=3D (*[1 << 28]C.libxl_device_vkb)(unsafe.Pointer(xc.vkbs))[:numVk= bs:numVkbs] + for i, v :=3D range x.Vkbs { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cVkbs[i] =3D tmp + } + numVtpms :=3D len(x.Vtpms) + xc.vtpms =3D (*C.libxl_device_vtpm)(C.malloc(C.ulong(numVtpms) * C.sizeof= _libxl_device_vtpm)) + xc.num_vtpms =3D C.int(numVtpms) + cVtpms :=3D (*[1 << 28]C.libxl_device_vtpm)(unsafe.Pointer(xc.vtpms))[:nu= mVtpms:numVtpms] + for i, v :=3D range x.Vtpms { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cVtpms[i] =3D tmp + } + numP9S :=3D len(x.P9S) + xc.p9s =3D (*C.libxl_device_p9)(C.malloc(C.ulong(numP9S) * C.sizeof_libxl= _device_p9)) + xc.num_p9s =3D C.int(numP9S) + cP9S :=3D (*[1 << 28]C.libxl_device_p9)(unsafe.Pointer(xc.p9s))[:numP9S:n= umP9S] + for i, v :=3D range x.P9S { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cP9S[i] =3D tmp + } + numPvcallsifs :=3D len(x.Pvcallsifs) + xc.pvcallsifs =3D (*C.libxl_device_pvcallsif)(C.malloc(C.ulong(numPvcalls= ifs) * C.sizeof_libxl_device_pvcallsif)) + xc.num_pvcallsifs =3D C.int(numPvcallsifs) + cPvcallsifs :=3D (*[1 << 28]C.libxl_device_pvcallsif)(unsafe.Pointer(xc.p= vcallsifs))[:numPvcallsifs:numPvcallsifs] + for i, v :=3D range x.Pvcallsifs { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cPvcallsifs[i] =3D tmp + } + numVdispls :=3D len(x.Vdispls) + 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.vdispls= ))[:numVdispls:numVdispls] + for i, v :=3D range x.Vdispls { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cVdispls[i] =3D tmp + } + numVsnds :=3D len(x.Vsnds) + xc.vsnds =3D (*C.libxl_device_vsnd)(C.malloc(C.ulong(numVsnds) * C.sizeof= _libxl_device_vsnd)) + xc.num_vsnds =3D C.int(numVsnds) + cVsnds :=3D (*[1 << 28]C.libxl_device_vsnd)(unsafe.Pointer(xc.vsnds))[:nu= mVsnds:numVsnds] + for i, v :=3D range x.Vsnds { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cVsnds[i] =3D tmp + } + numChannels :=3D len(x.Channels) + 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.chann= els))[:numChannels:numChannels] + for i, v :=3D range x.Channels { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cChannels[i] =3D tmp + } + numUsbctrls :=3D len(x.Usbctrls) + 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.usbct= rls))[:numUsbctrls:numUsbctrls] + for i, v :=3D range x.Usbctrls { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cUsbctrls[i] =3D tmp + } + numUsbdevs :=3D len(x.Usbdevs) + 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.usbdevs= ))[:numUsbdevs:numUsbdevs] + for i, v :=3D range x.Usbdevs { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_domain_config_dispose(&xc) + return xc, err + } + cUsbdevs[i] =3D tmp + } 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) @@ -2413,6 +2729,18 @@ func (x *Vdisplinfo) toC() (xc C.libxl_vdisplinfo, e= rr error) { xc.devid =3D C.libxl_devid(x.Devid) xc.state =3D C.int(x.State) xc.be_alloc =3D C.bool(x.BeAlloc) + numConnectors :=3D len(x.Connectors) + xc.connectors =3D (*C.libxl_connectorinfo)(C.malloc(C.ulong(numConnectors= ) * C.sizeof_libxl_connectorinfo)) + xc.num_connectors =3D C.int(numConnectors) + cConnectors :=3D (*[1 << 28]C.libxl_connectorinfo)(unsafe.Pointer(xc.conn= ectors))[:numConnectors:numConnectors] + for i, v :=3D range x.Connectors { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_vdisplinfo_dispose(&xc) + return xc, err + } + cConnectors[i] =3D tmp + } return xc, nil } =20 @@ -2447,6 +2775,18 @@ func (x *Pcminfo) fromC(xc *C.libxl_pcminfo) error { =20 func (x *Pcminfo) toC() (xc C.libxl_pcminfo, err error) { C.libxl_pcminfo_init(&xc) + numVsndStreams :=3D len(x.Streams) + 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 { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_pcminfo_dispose(&xc) + return xc, err + } + cStreams[i] =3D tmp + } return xc, nil } =20 @@ -2479,6 +2819,18 @@ func (x *Vsndinfo) toC() (xc C.libxl_vsndinfo, err e= rror) { xc.frontend_id =3D C.uint32_t(x.FrontendId) xc.devid =3D C.libxl_devid(x.Devid) xc.state =3D C.int(x.State) + numVsndPcms :=3D len(x.Pcms) + xc.pcms =3D (*C.libxl_pcminfo)(C.malloc(C.ulong(numVsndPcms) * C.sizeof_l= ibxl_pcminfo)) + xc.num_vsnd_pcms =3D C.int(numVsndPcms) + cPcms :=3D (*[1 << 28]C.libxl_pcminfo)(unsafe.Pointer(xc.pcms))[:numVsndP= cms:numVsndPcms] + for i, v :=3D range x.Pcms { + tmp, err :=3D v.toC() + if err !=3D nil { + C.libxl_vsndinfo_dispose(&xc) + return xc, err + } + cPcms[i] =3D tmp + } return xc, nil } =20 @@ -2525,6 +2877,13 @@ func (x *Numainfo) toC() (xc C.libxl_numainfo, err e= rror) { C.libxl_numainfo_init(&xc) xc.size =3D C.uint64_t(x.Size) xc.free =3D C.uint64_t(x.Free) + numDists :=3D len(x.Dists) + 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:nu= mDists] + for i, v :=3D range x.Dists { + cDists[i] =3D C.uint32_t(v) + } return xc, nil } =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575993023; cv=none; d=zohomail.com; s=zohoarc; b=FpnDHFjYlzS/+EvO1eD9lrxwqw8Sk7kWuyd3L/YTYfe/P+nt+5uOQAdMxckUj+v/1JfkOkM3KAt6lOmbjsh29DmquiQ8QsG6nkWVNQ+nZvStEkXaCggD+UUqne0VBdgQ1JfCQDPvp3FlKIHk0z5X/yviH0+L4YYn559WVAvvJ2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575993023; 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=DeoWxrcvCIHhIlREqBomMkEDO01l43UMXM51PR+T0Mw=; b=FrwEjuSgiLRAw3Jf9MJQdFYYBQrDkI2Bt1uTj16ngOO2YpdNA/UI1nmQnww1BDcAYKMzp8IqmFmx5Y9H+1/wJB0t2cKiVsPQclJK+ANFi+DzzrB27QHa8nx9plWfYnVsbiGcZGYbgQi/44sy+lauWRTk9+hXP6LBrsrqgAgzOxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575993023812625.2669092810149; Tue, 10 Dec 2019 07:50:23 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehle-0004An-KR; Tue, 10 Dec 2019 15:49:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlc-00048y-UF for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:40 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7b7cb316-1b64-11ea-a1e1-bc764e2007e4; Tue, 10 Dec 2019 15:48:17 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id x1so16723327qkl.12 for ; Tue, 10 Dec 2019 07:48:17 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:15 -0800 (PST) X-Inumbo-ID: 7b7cb316-1b64-11ea-a1e1-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:content-transfer-encoding; bh=ZYBDDhJmHxFl3+b3ETqJi4fQLL+Cu5wc6CLfgXz+gzQ=; b=rBXQP+IeZmvQPeDFSZ24ccWxgEio8WzSmIkULW7oUIOlsaQ0uWlKnZUyYABjNBvrHd VuLewnrvZeNJt7RGEHYOtfpWmg9Sc3VUOAvHC5jaAV4v5a+qAlUO0ayCy4aDyROUDjLt eeDZgbpfFbU6ifcmzZxxV1BoiyNZlXc5YEfzGRMccDux7Qi6tZ8FeyuJQlht8geFx+bB BaAXG2gscdpwv6nXDrNQaTfiTlzeEUcQsyZO5lDQNPEuvYvlucjZpmZNfRPTnGmI9LRq RlP9gRjQlCNo/Np0PrXFvumtI85yPl2xFp+70DApQpgQQVDjPXnppwUvppZ0yQHlvQ9t t2GA== 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=ZYBDDhJmHxFl3+b3ETqJi4fQLL+Cu5wc6CLfgXz+gzQ=; b=qiNHlqZentxm9Z8lnc5LXWguMUAOEeWhbFHs844LHYv0xgOXVXBjNZkVc564SI87y2 5kmQ8E2wcFFYuZzR2way1GNPaj2wkE1w6wcJAuHLt+lW98sRWaW9/iehsqUvTldqEkmm JHWs2ja/Onp2YaHCSBagfffgctqbAs0ykYPH3YOC+irNjnhgQXzIih7vcsOnDfq/HE0I LNqnkmllxNlbKd6HzLsDKUSYwdqbIk6L4GjBe30OCUm8IOXDUgn3vCbHls+2XpVbfnBY EeW7h6kbYwJkK3AHyj3Sb+ovq+lgSew4Hlf3a60NmzY5jVq0LtOgdbgOmI4HWFrDpAx9 g7Xg== X-Gm-Message-State: APjAAAVXhGw8LPzAXO+98kHQPMl/m3QjY7imYK/KMW+VnijM9RdONKld lRXRRZ/DK2NqxY3qnOmLOeJ8h0mh X-Google-Smtp-Source: APXvYqz0wqDEKvj2n2wa4BIWopkQDSpbnPGl6dCOteKUElO2N4R90mX8eztKTR5aYvIlTfSz2B/Ppw== X-Received: by 2002:ae9:efc5:: with SMTP id d188mr33291864qkg.178.1575992896160; Tue, 10 Dec 2019 07:48:16 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:36 -0500 Message-Id: <8330ea427861ef6c5d3b20d381bf40e87937d448.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 21/22] golang/xenlight: revise use of Context type 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Remove the exported global context variable, 'Ctx.' Generally, it is better to not export global variables for use through a Go package. However, there are some exceptions that can be found in the standard library. Add a NewContext function instead, and remove the Open, IsOpen, and CheckOpen functions as a result. Also, comment-out an ineffectual assignment to 'err' inside the function Context.CpupoolInfo so that compilation does not fail. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 219 +++++------------------------- 1 file changed, 34 insertions(+), 185 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index f32eb11384..1c431fa4e5 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -74,6 +74,39 @@ func (e Error) Error() string { return fmt.Sprintf("libxl error: %d", -e) } =20 +// Context represents a libxl_ctx. +type Context struct { + ctx *C.libxl_ctx + logger *C.xentoollog_logger_stdiostream +} + +// NewContext returns a new Context. +func NewContext() (*Context, error) { + var ctx Context + + ctx.logger =3D C.xtl_createlogger_stdiostream(C.stderr, C.XTL_ERROR, 0) + + ret :=3D C.libxl_ctx_alloc(&ctx.ctx, C.LIBXL_VERSION, 0, (*C.xentoollog_l= ogger)(unsafe.Pointer(ctx.logger))) + if ret !=3D 0 { + return nil, Error(ret) + } + + return &ctx, nil +} + +// Close closes the Context. +func (ctx *Context) Close() error { + ret :=3D C.libxl_ctx_free(ctx.ctx) + ctx.ctx =3D nil + C.xtl_logger_destroy((*C.xentoollog_logger)(unsafe.Pointer(ctx.logger))) + + if ret !=3D 0 { + return Error(ret) + } + + return nil +} + /* * Types: Builtins */ @@ -298,11 +331,6 @@ func (cpl CpuidPolicyList) toC() (C.libxl_cpuid_policy= _list, error) { return ccpl, nil } =20 -type Context struct { - ctx *C.libxl_ctx - logger *C.xentoollog_logger_stdiostream -} - // Hwcap represents a libxl_hwcap. type Hwcap [8]uint32 =20 @@ -453,11 +481,6 @@ func SchedulerFromString(name string) (s Scheduler, er= r error) { // 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) { - err :=3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var nbPool C.int =20 c_cpupool_list :=3D C.libxl_list_cpupool(Ctx.ctx, &nbPool) @@ -481,16 +504,11 @@ func (Ctx *Context) ListCpupool() (list []Cpupoolinfo= ) { =20 // int libxl_cpupool_info(libxl_ctx *ctx, libxl_cpupoolinfo *info, uint32_= t poolid); func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool Cpupoolinfo) { - err :=3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var c_cpupool C.libxl_cpupoolinfo =20 ret :=3D C.libxl_cpupool_info(Ctx.ctx, &c_cpupool, C.uint32_t(Poolid)) if ret !=3D 0 { - err =3D Error(-ret) + //err =3D Error(-ret) return } defer C.libxl_cpupoolinfo_dispose(&c_cpupool) @@ -507,11 +525,6 @@ func (Ctx *Context) CpupoolInfo(Poolid uint32) (pool C= pupoolinfo) { // FIXME: uuid // FIXME: Setting poolid func (Ctx *Context) CpupoolCreate(Name string, Scheduler Scheduler, Cpumap= Bitmap) (err error, Poolid uint32) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - poolid :=3D C.uint32_t(C.LIBXL_CPUPOOL_POOLID_ANY) name :=3D C.CString(Name) defer C.free(unsafe.Pointer(name)) @@ -540,11 +553,6 @@ func (Ctx *Context) CpupoolCreate(Name string, Schedul= er Scheduler, Cpumap Bitma =20 // int libxl_cpupool_destroy(libxl_ctx *ctx, uint32_t poolid); func (Ctx *Context) CpupoolDestroy(Poolid uint32) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_cpupool_destroy(Ctx.ctx, C.uint32_t(Poolid)) if ret !=3D 0 { err =3D Error(-ret) @@ -556,11 +564,6 @@ func (Ctx *Context) CpupoolDestroy(Poolid uint32) (err= error) { =20 // int libxl_cpupool_cpuadd(libxl_ctx *ctx, uint32_t poolid, int cpu); func (Ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu int) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_cpupool_cpuadd(Ctx.ctx, C.uint32_t(Poolid), C.int(Cpu)) if ret !=3D 0 { err =3D Error(-ret) @@ -573,11 +576,6 @@ func (Ctx *Context) CpupoolCpuadd(Poolid uint32, Cpu i= nt) (err error) { // int libxl_cpupool_cpuadd_cpumap(libxl_ctx *ctx, uint32_t poolid, // const libxl_bitmap *cpumap); func (Ctx *Context) CpupoolCpuaddCpumap(Poolid uint32, Cpumap Bitmap) (err= error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - cbm, err :=3D Cpumap.toC() if err !=3D nil { return @@ -595,11 +593,6 @@ func (Ctx *Context) CpupoolCpuaddCpumap(Poolid uint32,= Cpumap Bitmap) (err error =20 // int libxl_cpupool_cpuremove(libxl_ctx *ctx, uint32_t poolid, int cpu); func (Ctx *Context) CpupoolCpuremove(Poolid uint32, Cpu int) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_cpupool_cpuremove(Ctx.ctx, C.uint32_t(Poolid), C.int(Cpu= )) if ret !=3D 0 { err =3D Error(-ret) @@ -612,11 +605,6 @@ func (Ctx *Context) CpupoolCpuremove(Poolid uint32, Cp= u int) (err error) { // int libxl_cpupool_cpuremove_cpumap(libxl_ctx *ctx, uint32_t poolid, // const libxl_bitmap *cpumap); func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint32, Cpumap Bitmap) (= err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - cbm, err :=3D Cpumap.toC() if err !=3D nil { return @@ -634,11 +622,6 @@ func (Ctx *Context) CpupoolCpuremoveCpumap(Poolid uint= 32, Cpumap Bitmap) (err er =20 // int libxl_cpupool_rename(libxl_ctx *ctx, const char *name, uint32_t poo= lid); func (Ctx *Context) CpupoolRename(Name string, Poolid uint32) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - name :=3D C.CString(Name) defer C.free(unsafe.Pointer(name)) =20 @@ -653,11 +636,6 @@ func (Ctx *Context) CpupoolRename(Name string, Poolid = uint32) (err error) { =20 // int libxl_cpupool_cpuadd_node(libxl_ctx *ctx, uint32_t poolid, int node= , int *cpus); func (Ctx *Context) CpupoolCpuaddNode(Poolid uint32, Node int) (Cpus int, = err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ccpus :=3D C.int(0) =20 ret :=3D C.libxl_cpupool_cpuadd_node(Ctx.ctx, C.uint32_t(Poolid), C.int(N= ode), &ccpus) @@ -673,11 +651,6 @@ func (Ctx *Context) CpupoolCpuaddNode(Poolid uint32, N= ode int) (Cpus int, err er =20 // int libxl_cpupool_cpuremove_node(libxl_ctx *ctx, uint32_t poolid, int n= ode, int *cpus); func (Ctx *Context) CpupoolCpuremoveNode(Poolid uint32, Node int) (Cpus in= t, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ccpus :=3D C.int(0) =20 ret :=3D C.libxl_cpupool_cpuremove_node(Ctx.ctx, C.uint32_t(Poolid), C.in= t(Node), &ccpus) @@ -693,11 +666,6 @@ func (Ctx *Context) CpupoolCpuremoveNode(Poolid uint32= , Node int) (Cpus int, err =20 // int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t = domid); func (Ctx *Context) CpupoolMovedomain(Poolid uint32, Id Domid) (err error)= { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_cpupool_movedomain(Ctx.ctx, C.uint32_t(Poolid), C.uint32= _t(Id)) if ret !=3D 0 { err =3D Error(-ret) @@ -857,60 +825,8 @@ func (bm Bitmap) String() (s string) { return } =20 -/* - * Context - */ -var Ctx Context - -func (Ctx *Context) IsOpen() bool { - return Ctx.ctx !=3D nil -} - -func (Ctx *Context) Open() (err error) { - if Ctx.ctx !=3D nil { - return - } - - Ctx.logger =3D C.xtl_createlogger_stdiostream(C.stderr, C.XTL_ERROR, 0) - if Ctx.logger =3D=3D nil { - err =3D fmt.Errorf("Cannot open stdiostream") - return - } - - ret :=3D C.libxl_ctx_alloc(&Ctx.ctx, C.LIBXL_VERSION, - 0, (*C.xentoollog_logger)(unsafe.Pointer(Ctx.logger))) - - if ret !=3D 0 { - err =3D Error(-ret) - } - return -} - -func (Ctx *Context) Close() (err error) { - ret :=3D C.libxl_ctx_free(Ctx.ctx) - Ctx.ctx =3D nil - - if ret !=3D 0 { - err =3D Error(-ret) - } - C.xtl_logger_destroy((*C.xentoollog_logger)(unsafe.Pointer(Ctx.logger))) - return -} - -func (Ctx *Context) CheckOpen() (err error) { - if Ctx.ctx =3D=3D nil { - err =3D fmt.Errorf("Context not opened") - } - return -} - //int libxl_get_max_cpus(libxl_ctx *ctx); func (Ctx *Context) GetMaxCpus() (maxCpus int, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_get_max_cpus(Ctx.ctx) if ret < 0 { err =3D Error(-ret) @@ -922,11 +838,6 @@ func (Ctx *Context) GetMaxCpus() (maxCpus int, err err= or) { =20 //int libxl_get_online_cpus(libxl_ctx *ctx); func (Ctx *Context) GetOnlineCpus() (onCpus int, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_get_online_cpus(Ctx.ctx) if ret < 0 { err =3D Error(-ret) @@ -938,10 +849,6 @@ func (Ctx *Context) GetOnlineCpus() (onCpus int, err e= rror) { =20 //int libxl_get_max_nodes(libxl_ctx *ctx); func (Ctx *Context) GetMaxNodes() (maxNodes int, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } ret :=3D C.libxl_get_max_nodes(Ctx.ctx) if ret < 0 { err =3D Error(-ret) @@ -953,10 +860,6 @@ func (Ctx *Context) GetMaxNodes() (maxNodes int, err e= rror) { =20 //int libxl_get_free_memory(libxl_ctx *ctx, uint64_t *memkb); func (Ctx *Context) GetFreeMemory() (memkb uint64, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } var cmem C.uint64_t ret :=3D C.libxl_get_free_memory(Ctx.ctx, &cmem) =20 @@ -972,10 +875,6 @@ func (Ctx *Context) GetFreeMemory() (memkb uint64, err= error) { =20 //int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } var cphys C.libxl_physinfo C.libxl_physinfo_init(&cphys) defer C.libxl_physinfo_dispose(&cphys) @@ -993,11 +892,6 @@ func (Ctx *Context) GetPhysinfo() (physinfo *Physinfo,= err error) { =20 //const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx); func (Ctx *Context) GetVersionInfo() (info *VersionInfo, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var cinfo *C.libxl_version_info =20 cinfo =3D C.libxl_get_version_info(Ctx.ctx) @@ -1008,11 +902,6 @@ func (Ctx *Context) GetVersionInfo() (info *VersionIn= fo, err error) { } =20 func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var cdi C.libxl_dominfo C.libxl_dominfo_init(&cdi) defer C.libxl_dominfo_dispose(&cdi) @@ -1030,11 +919,6 @@ func (Ctx *Context) DomainInfo(Id Domid) (di *Dominfo= , err error) { } =20 func (Ctx *Context) DomainUnpause(Id Domid) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_domain_unpause(Ctx.ctx, C.uint32_t(Id), nil) =20 if ret !=3D 0 { @@ -1045,11 +929,6 @@ func (Ctx *Context) DomainUnpause(Id Domid) (err erro= r) { =20 //int libxl_domain_pause(libxl_ctx *ctx, uint32_t domain); func (Ctx *Context) DomainPause(id Domid) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_domain_pause(Ctx.ctx, C.uint32_t(id), nil) =20 if ret !=3D 0 { @@ -1060,11 +939,6 @@ func (Ctx *Context) DomainPause(id Domid) (err error)= { =20 //int libxl_domain_shutdown(libxl_ctx *ctx, uint32_t domid); func (Ctx *Context) DomainShutdown(id Domid) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_domain_shutdown(Ctx.ctx, C.uint32_t(id), nil) =20 if ret !=3D 0 { @@ -1075,11 +949,6 @@ func (Ctx *Context) DomainShutdown(id Domid) (err err= or) { =20 //int libxl_domain_reboot(libxl_ctx *ctx, uint32_t domid); func (Ctx *Context) DomainReboot(id Domid) (err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - ret :=3D C.libxl_domain_reboot(Ctx.ctx, C.uint32_t(id), nil) =20 if ret !=3D 0 { @@ -1091,11 +960,6 @@ func (Ctx *Context) DomainReboot(id Domid) (err error= ) { //libxl_dominfo * libxl_list_domain(libxl_ctx*, int *nb_domain_out); //void libxl_dominfo_list_free(libxl_dominfo *list, int nb_domain); func (Ctx *Context) ListDomain() (glist []Dominfo) { - err :=3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var nbDomain C.int clist :=3D C.libxl_list_domain(Ctx.ctx, &nbDomain) defer C.libxl_dominfo_list_free(clist, nbDomain) @@ -1118,11 +982,6 @@ func (Ctx *Context) ListDomain() (glist []Dominfo) { // int *nb_vcpu, int *nr_cpus_out); //void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus); func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) { - err :=3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var nbVcpu C.int var nrCpu C.int =20 @@ -1153,11 +1012,6 @@ func (ct ConsoleType) String() (str string) { //int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num, //libxl_console_type type, char **path); func (Ctx *Context) ConsoleGetTty(id Domid, consNum int, conType ConsoleTy= pe) (path string, err error) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var cpath *C.char ret :=3D C.libxl_console_get_tty(Ctx.ctx, C.uint32_t(id), C.int(consNum),= C.libxl_console_type(conType), &cpath) if ret !=3D 0 { @@ -1173,11 +1027,6 @@ func (Ctx *Context) ConsoleGetTty(id Domid, consNum = int, conType ConsoleType) (p //int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, // char **path); func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) (path string, err e= rror) { - err =3D Ctx.CheckOpen() - if err !=3D nil { - return - } - var cpath *C.char ret :=3D C.libxl_primary_console_get_tty(Ctx.ctx, C.uint32_t(domid), &cpa= th) if ret !=3D 0 { --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 07:05:52 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575993014; cv=none; d=zohomail.com; s=zohoarc; b=kmPE8B6BmHAdoE20T2Lj55mXiJppYgzLPpH3wLOFOOj45afGl2M5qQ6CZVxPBv6wWya7yg+ziMMOScoFIfbpWZeG/R2Ru9YqlMo4k0SAOLxYJPPEl+y5C9+DKKXyF5d85bkFqF9cjzFvmhr9DkvPRWvj2TsoTWz3H/MMmiW7WAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575993014; 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=qd23hy8YKNKGUgHBTg12saFzfuem8pGgI9tgf539XYQ=; b=Jb/LMQ0dtGc1Ct1RdaFtbph0tPg53xqf6O1V4yK9/a9ODJ0ish+jupTbZBVOvj72Bvw78Vmmun0IQ2su6BK15hU+REhWCjTeIc8x742bsxjua7hUSNvXim7Q/BM0Nw+XCnP2x68wlfqG/mSlFKPilfdZHyzMCi4gGeVKb+KieNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1575993014281913.4093260787058; Tue, 10 Dec 2019 07:50:14 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlZ-00044k-8A; Tue, 10 Dec 2019 15:49:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iehlX-00043f-Tf for xen-devel@lists.xenproject.org; Tue, 10 Dec 2019 15:49:35 +0000 Received: from mail-qk1-x742.google.com (unknown [2607:f8b0:4864:20::742]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7c2addc4-1b64-11ea-88e7-bc764e2007e4; Tue, 10 Dec 2019 15:48:18 +0000 (UTC) Received: by mail-qk1-x742.google.com with SMTP id z76so103901qka.2 for ; Tue, 10 Dec 2019 07:48:18 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id m29sm1247848qtf.1.2019.12.10.07.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 07:48:16 -0800 (PST) X-Inumbo-ID: 7c2addc4-1b64-11ea-88e7-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:content-transfer-encoding; bh=XNEElzRpeVV8r6SPzsaAXc9nyqLVWFu8pvvM7YDquJg=; b=m1hrrmKsiKv4O+TgfBj+0k7gVh9QIChmmugiqe5D+WaIV4HfLGHFH3nMBgBu0ZGelJ J1+Y3NO/M3XBQmfzwtFndSoTlOhY9putvzKi+SGyQ0kYSXbabuv8zPlFkGXzHZqLWKUH 8fEjWnYLfYgbPh2oHv0tpn/VCf107c85wnga2t9S+Uo39xWGZHv1VY0n+RKf6+q24l8B fpdolIoxTaWP8s/lLYjROT5adGXd09x+opBFd4qHUgIbWk4l1ywAkiMAi/KB/bkNVIu3 Qn3FDrI2/MRxNw4WSTILxpD5yHL1anx/kpLHi1z9LmxkPBIoS+jXuO4y0oa9tB542Pax XX0A== 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=XNEElzRpeVV8r6SPzsaAXc9nyqLVWFu8pvvM7YDquJg=; b=nTDZv5C92jea+P01WIw3J77UTpz6/CoACnjFlW3OrOzTnxokUWXlzPMeiY39HF+VKn JFRPXmLgTBwyz6jt9VkRFw80u0D32ld0k+5wsbo0SLZ87KqFaDh1SRqhA/oOxjO5istw huSIi8pkBxZuzp4SMa+4ehXZ6o95z44BKtOtk0k3BAm5WLVicrWcct2JbctWR8eQ0P8R O9SWdTcBlLgPseN7N6wC0qxrpBbt8EpF5sh2wuMx/jTwHvKTIMr9tDGI3Z+UDy5lHtu+ tHLf6s9ViCF+P+AhAH2IPR11JDFxli3pJcpEkfcfhz7+rEkzUwciUxsr0/lylUN/utq7 KLRg== X-Gm-Message-State: APjAAAWXXG0OYyHjpsN2kqDvmuoqUcu4fsHgjnShzo3qiFZ5SHT3ifq9 eBkxz3/aJppYenXIPj/8PCfkwNVb X-Google-Smtp-Source: APXvYqxiS7dCAB6NEhn5uTnTXit2i8vxnXt/KvWgoPOgYYam790706whPWKci6c6gcO1gF+ItY2p3w== X-Received: by 2002:a37:8b85:: with SMTP id n127mr33692858qkd.353.1575992897563; Tue, 10 Dec 2019 07:48:17 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Tue, 10 Dec 2019 10:47:37 -0500 Message-Id: <76e35746cd42c7aba992cc767f7afe3b1041c6f8.1575990937.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 22/22] golang/xenlight: add error return type to Context.Cpupoolinfo 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook A previous commit that removed Context.CheckOpen revealed an ineffectual assignent to err in Context.Cpupoolinfo, as there is no error return type. Since it appears that the intent is to return an error here, add an error return value to the function signature. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 1c431fa4e5..38d2ba8aa8 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -503,17 +503,17 @@ func (Ctx *Context) ListCpupool() (list []Cpupoolinfo= ) { } =20 // 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 erro= r) { var c_cpupool C.libxl_cpupoolinfo =20 ret :=3D C.libxl_cpupool_info(Ctx.ctx, &c_cpupool, C.uint32_t(Poolid)) if ret !=3D 0 { - //err =3D Error(-ret) + err =3D Error(-ret) return } defer C.libxl_cpupoolinfo_dispose(&c_cpupool) =20 - _ =3D pool.fromC(&c_cpupool) + err =3D pool.fromC(&c_cpupool) =20 return } --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel