From nobody Mon Feb 9 16:20:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1621888696; cv=none; d=zohomail.com; s=zohoarc; b=cJeA2c4/bNpJ3hynbnZH15TDeIuUNgLd1GnCP5w9omeXdjMuQcVgv7145f5238zmiCcZ//eFafWxvXiE9vxWtpt7UGlH2Ye0xoxaDdMcfLevwvPeP/0LlNJWRdhKKXgGg3SL2Mr1NbsfCX/l7q27bku2k0MbgxCMLCb9AJWvGn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621888696; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=hfBP94KizJpDruLBLBLMUfOcD8AldREODeB/q9SIq2M=; b=FpqCmU+pa3wywaI+dUBcSpfC6Cl7WKv+Dh+reRbZ1GihC3V+V5XE8bMFve5l1C+N301pQuK1qCB6C0qXkJ1cNG1hNzspsZ4+jlYP7E0Mb9Yq7UgjFLcAmGpL9VsuFnaKsXJFYnYegsXBXlMJPwtJFG9sc9qabVtTdWRzv+8Z298= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass 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 1621888696845266.6278834722947; Mon, 24 May 2021 13:38:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.131883.246304 (Exim 4.92) (envelope-from ) id 1llHKs-0003Aj-6M; Mon, 24 May 2021 20:38:02 +0000 Received: by outflank-mailman (output) from mailman id 131883.246304; Mon, 24 May 2021 20:38:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1llHKs-0003AY-2A; Mon, 24 May 2021 20:38:02 +0000 Received: by outflank-mailman (input) for mailman id 131883; Mon, 24 May 2021 20:38:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1llHKq-0001ey-S5 for xen-devel@lists.xenproject.org; Mon, 24 May 2021 20:38:00 +0000 Received: from mail-qt1-x829.google.com (unknown [2607:f8b0:4864:20::829]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3e19ada3-e1b5-41ea-b64a-fbe3971da842; Mon, 24 May 2021 20:37:43 +0000 (UTC) Received: by mail-qt1-x829.google.com with SMTP id s12so12402206qta.3 for ; Mon, 24 May 2021 13:37:43 -0700 (PDT) Received: from localhost.localdomain (c-73-89-138-5.hsd1.vt.comcast.net. [73.89.138.5]) by smtp.gmail.com with ESMTPSA id t25sm5142847qkt.62.2021.05.24.13.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 13:37:43 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3e19ada3-e1b5-41ea-b64a-fbe3971da842 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=hfBP94KizJpDruLBLBLMUfOcD8AldREODeB/q9SIq2M=; b=EQMocBqOydCDD/W8SK/dRmkPliwTZBPDqqBue37vjCJUpXE7Kazzvg3C0+yP6P18Ii SfhM0N145Miw5QwY7hJq+dRJc/v1S4Rie7TO5ZA3rT1Jlni76D5sx9SwsCJSVlHQxnsX WY34MhAbv/qGh332hnI+zir9IDLTnNlCkAxVd1IrVcG4yzAM4iGiSVT+fbdEXMa9RiyC ubjhuVK2GJrSvhjNjRF/U52xlmzAo5eF1a5BYLminyYi9qBDYbFkk6Vh19o3PsZJOmik 1WFJqU/5Gz6RT1ZCY2N3QK+lVZ+7ejaaLFjq/J5s30t2uQIilmL0Aiuwn7hd3GUNVowB C4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=hfBP94KizJpDruLBLBLMUfOcD8AldREODeB/q9SIq2M=; b=CoJyKzt1vSaoFrfQX3iggknKs0kp+u0HCWACOL/xPQU+Zsikb1RjWXLr+4vUAKkvOT 1P2Mr5b1b4JrABLAFvqXXTHf7hB7bz6RK3zRzkxu5IdVvT6IWd9Y7PD60CPpnTo5AQq7 nHTs22ZtKkKzm752sAD665nVQp24xuhyobJ7q3sEriUgDvrPkz6DYzDg4u6Iw0PGQdls 3ZRGkN2yL4g2sO0uEPGUIfSDHF/rGUvCKG+WtqRCX8mef9Jwa//LEbWg5IXa8LKdJh6G 3+1PerPMtIyNiwL9IqAiAfeHgF+HBrcYiyiaoeZ3U7L/j2rx9q2Jo9Lu/BwgpD1U9A8O v8og== X-Gm-Message-State: AOAM532xqX1Mmai9CZHk2mVSwRd8GKVFLI/Ayw3KKFR7GZOXbu4zKZVL y57B325N0wr6ZPq5GZy8LIA= X-Google-Smtp-Source: ABdhPJyKe6Or6ryElDeBwz+s/qA1wfWs/ZYdvbgEtPXmQ70fTLPF1ZXiKPco+HZJ8+TI5BqNoB/45A== X-Received: by 2002:ac8:66da:: with SMTP id m26mr28281280qtp.102.1621888663707; Mon, 24 May 2021 13:37:43 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.prg, xen-devel@lists.xenproject.org Cc: Nick Rosbrook , George Dunlap , Ian Jackson , Wei Liu Subject: [RESEND PATCH 04/12] golang/xenlight: export keyed union interface types Date: Mon, 24 May 2021 16:36:45 -0400 Message-Id: <29a3fbc93262cb9b31f02d6c94c018b200dfa43e.1621887506.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For structs that have a keyed union, e.g. DomainBuildInfo, the TypeUnion field must be exported so that package users can get/set the fields within. This means that users are aware of the existence of the interface type used in those fields (see [1]), so it is awkward that the interface itself is not exported. However, the single method within the interface must remain unexported so that users cannot mistakenly "implement" those interfaces. Since there seems to be no reason to do otherwise, export the keyed union interface types. [1] https://pkg.go.dev/xenbits.xenproject.org/git-http/xen.git/tools/golang= /xenlight?tab=3Ddoc#DeviceUsbdev Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/gengotypes.py | 6 +-- tools/golang/xenlight/types.gen.go | 58 ++++++++++++++--------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index e6daa9b92f..3796632f7d 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -159,7 +159,7 @@ def xenlight_golang_define_union(ty =3D None, struct_na= me =3D '', union_name =3D ''): extras =3D [] =20 interface_name =3D '{0}_{1}_union'.format(struct_name, ty.keyvar.name) - interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + interface_name =3D xenlight_golang_fmt_name(interface_name) =20 s +=3D 'type {0} interface {{\n'.format(interface_name) s +=3D 'is{0}()\n'.format(interface_name) @@ -341,7 +341,7 @@ def xenlight_golang_union_from_C(ty =3D None, union_nam= e =3D '', struct_name =3D ''): field_name =3D xenlight_golang_fmt_name('{0}_union'.format(keyname)) =20 interface_name =3D '{0}_{1}_union'.format(struct_name, keyname) - interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + interface_name =3D xenlight_golang_fmt_name(interface_name) =20 cgo_keyname =3D keyname if cgo_keyname in go_keywords: @@ -546,7 +546,7 @@ def xenlight_golang_union_to_C(ty =3D None, union_name = =3D '', gokeytype =3D xenlight_golang_fmt_name(keytype) =20 interface_name =3D '{0}_{1}_union'.format(struct_name, keyname) - interface_name =3D xenlight_golang_fmt_name(interface_name, exported= =3DFalse) + interface_name =3D xenlight_golang_fmt_name(interface_name) =20 cgo_keyname =3D keyname if cgo_keyname in go_keywords: diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/typ= es.gen.go index f2ceceb61c..a214dd9df6 100644 --- a/tools/golang/xenlight/types.gen.go +++ b/tools/golang/xenlight/types.gen.go @@ -337,18 +337,18 @@ State int Evtch int Rref int Connection ChannelConnection -ConnectionUnion channelinfoConnectionUnion +ConnectionUnion ChannelinfoConnectionUnion } =20 -type channelinfoConnectionUnion interface { -ischannelinfoConnectionUnion() +type ChannelinfoConnectionUnion interface { +isChannelinfoConnectionUnion() } =20 type ChannelinfoConnectionUnionPty struct { Path string } =20 -func (x ChannelinfoConnectionUnionPty) ischannelinfoConnectionUnion(){} +func (x ChannelinfoConnectionUnionPty) isChannelinfoConnectionUnion(){} =20 type Vminfo struct { Uuid Uuid @@ -510,7 +510,7 @@ Apic Defbool DmRestrict Defbool Tee TeeType Type DomainType -TypeUnion domainBuildInfoTypeUnion +TypeUnion DomainBuildInfoTypeUnion ArchArm struct { GicVersion GicVersion Vuart VuartType @@ -522,8 +522,8 @@ Altp2M Altp2MMode VmtraceBufKb int } =20 -type domainBuildInfoTypeUnion interface { -isdomainBuildInfoTypeUnion() +type DomainBuildInfoTypeUnion interface { +isDomainBuildInfoTypeUnion() } =20 type DomainBuildInfoTypeUnionHvm struct { @@ -575,7 +575,7 @@ RdmMemBoundaryMemkb uint64 McaCaps uint64 } =20 -func (x DomainBuildInfoTypeUnionHvm) isdomainBuildInfoTypeUnion(){} +func (x DomainBuildInfoTypeUnionHvm) isDomainBuildInfoTypeUnion(){} =20 type DomainBuildInfoTypeUnionPv struct { Kernel string @@ -588,7 +588,7 @@ Features string E820Host Defbool } =20 -func (x DomainBuildInfoTypeUnionPv) isdomainBuildInfoTypeUnion(){} +func (x DomainBuildInfoTypeUnionPv) isDomainBuildInfoTypeUnion(){} =20 type DomainBuildInfoTypeUnionPvh struct { Pvshim Defbool @@ -597,7 +597,7 @@ PvshimCmdline string PvshimExtra string } =20 -func (x DomainBuildInfoTypeUnionPvh) isdomainBuildInfoTypeUnion(){} +func (x DomainBuildInfoTypeUnionPvh) isDomainBuildInfoTypeUnion(){} =20 type DeviceVfb struct { BackendDomid Domid @@ -761,11 +761,11 @@ type DeviceUsbdev struct { Ctrl Devid Port int Type UsbdevType -TypeUnion deviceUsbdevTypeUnion +TypeUnion DeviceUsbdevTypeUnion } =20 -type deviceUsbdevTypeUnion interface { -isdeviceUsbdevTypeUnion() +type DeviceUsbdevTypeUnion interface { +isDeviceUsbdevTypeUnion() } =20 type DeviceUsbdevTypeUnionHostdev struct { @@ -773,7 +773,7 @@ Hostbus byte Hostaddr byte } =20 -func (x DeviceUsbdevTypeUnionHostdev) isdeviceUsbdevTypeUnion(){} +func (x DeviceUsbdevTypeUnionHostdev) isDeviceUsbdevTypeUnion(){} =20 type DeviceDtdev struct { Path string @@ -807,18 +807,18 @@ BackendDomname string Devid Devid Name string Connection ChannelConnection -ConnectionUnion deviceChannelConnectionUnion +ConnectionUnion DeviceChannelConnectionUnion } =20 -type deviceChannelConnectionUnion interface { -isdeviceChannelConnectionUnion() +type DeviceChannelConnectionUnion interface { +isDeviceChannelConnectionUnion() } =20 type DeviceChannelConnectionUnionSocket struct { Path string } =20 -func (x DeviceChannelConnectionUnionSocket) isdeviceChannelConnectionUnion= (){} +func (x DeviceChannelConnectionUnionSocket) isDeviceChannelConnectionUnion= (){} =20 type ConnectorParam struct { UniqueId string @@ -1116,31 +1116,31 @@ Domid Domid Domuuid Uuid ForUser uint64 Type EventType -TypeUnion eventTypeUnion +TypeUnion EventTypeUnion } =20 -type eventTypeUnion interface { -iseventTypeUnion() +type EventTypeUnion interface { +isEventTypeUnion() } =20 type EventTypeUnionDomainShutdown struct { ShutdownReason byte } =20 -func (x EventTypeUnionDomainShutdown) iseventTypeUnion(){} +func (x EventTypeUnionDomainShutdown) isEventTypeUnion(){} =20 type EventTypeUnionDiskEject struct { Vdev string Disk DeviceDisk } =20 -func (x EventTypeUnionDiskEject) iseventTypeUnion(){} +func (x EventTypeUnionDiskEject) isEventTypeUnion(){} =20 type EventTypeUnionOperationComplete struct { Rc int } =20 -func (x EventTypeUnionOperationComplete) iseventTypeUnion(){} +func (x EventTypeUnionOperationComplete) isEventTypeUnion(){} =20 type PsrCmtType int const( @@ -1175,11 +1175,11 @@ PsrFeatTypeMba PsrFeatType =3D 2 type PsrHwInfo struct { Id uint32 Type PsrFeatType -TypeUnion psrHwInfoTypeUnion +TypeUnion PsrHwInfoTypeUnion } =20 -type psrHwInfoTypeUnion interface { -ispsrHwInfoTypeUnion() +type PsrHwInfoTypeUnion interface { +isPsrHwInfoTypeUnion() } =20 type PsrHwInfoTypeUnionCat struct { @@ -1188,7 +1188,7 @@ CbmLen uint32 CdpEnabled bool } =20 -func (x PsrHwInfoTypeUnionCat) ispsrHwInfoTypeUnion(){} +func (x PsrHwInfoTypeUnionCat) isPsrHwInfoTypeUnion(){} =20 type PsrHwInfoTypeUnionMba struct { CosMax uint32 @@ -1196,5 +1196,5 @@ ThrtlMax uint32 Linear bool } =20 -func (x PsrHwInfoTypeUnionMba) ispsrHwInfoTypeUnion(){} +func (x PsrHwInfoTypeUnionMba) isPsrHwInfoTypeUnion(){} =20 --=20 2.17.1