From nobody Thu Apr 18 20:42:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1595856437; cv=none; d=zohomail.com; s=zohoarc; b=gxzYxqYLlKXMORt67sayYwCOa/zaQIXJYlMiRJ4yBmu/nLuiLqUbIoSdAvSmSdAO7xgjJqbXRO7OFiOpSnEyUyBt9LO6StYE+9QmaTkaizjkbikpnPjfXgWbF/rSLuMtm2OyUwONk7bM2kX+4dPc2FcLVkCVbx9pAmc+oGwINMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595856437; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=fQYtwtQaGUDLFVyGXBolzVdpnWY9LOq5bEy771jxh3esy2DYebdbHnwpatx2YwXaf5wppbM8uLSD6OVs/IkD5wpKFSdGEnUrFt8eo4ers7D8qE/cE7MGM/xrDGmM6F2zKmI0BGmulWdiPsyV79zFUdudJDq9rDDxcqZV4FZeWvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1595856437243536.452198093143; Mon, 27 Jul 2020 06:27:17 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039R-0001Vu-OC; Mon, 27 Jul 2020 13:26:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039Q-0001Vb-Dz for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 13:26:44 +0000 Received: from mail-qk1-x72a.google.com (unknown [2607:f8b0:4864:20::72a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cde0e7a1-d00c-11ea-8abe-bc764e2007e4; Mon, 27 Jul 2020 13:26:40 +0000 (UTC) Received: by mail-qk1-x72a.google.com with SMTP id l23so15195448qkk.0 for ; Mon, 27 Jul 2020 06:26:40 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id t8sm11828003qtc.50.2020.07.27.06.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 06:26:38 -0700 (PDT) X-Inumbo-ID: cde0e7a1-d00c-11ea-8abe-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=AoNJiUMrGU1/zEcVI7rNtQsygstiui6pLZ/O79Gk45wErhqsFyZeXorPFU8EsqyGWv p3dmphPgk/gPAsY70nwA+zdMiOy36q17JfiR9hys2QwDiD1/WczxcuVHy1eg0ZZwTODP uKpv+ItSTW7lX1qDUMQYI0/s6Mkjp4XJTnmLr1EmfFLnTLTbMuJVzFbjx4KaR0iWlNWl 4dIPZWNhU03R7Fdj3emaHVlvP60qgEeNPjsStugzCN6ZkvksBHD7yQJRKL730/oVuzvr 99Rswo1yVL7OYds1gt68gcDN0aQ1dIRL6sQMNHZ4l1KO7/D5NdsF9Iq5ehHsyo7Luqk2 gFYg== 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=KaMEYjlDG3HM6TfMMDf5x6QCTVdKePy2b/fpNHgqtT4=; b=A66FOtJ0mLQkqX1iU1mRXDQfn0ow25f/8tvWykOzalaQx6t5R/05lnTYmQuBQePKIK Fzrdvc1/Rx9sU3aXUXYqxiYieuCXtMdeHYNmD6DUUri/J9o5M+6M6D1oEYUtLWgFrAkg 5nkBRZLyMM9D08xbaXetiyoyI/EeQUURbYyChB7vb3X3fs/0NGqcTDXTfv/43WrcvtpT 4N8EAld5Jwr7R0IEG1cbvq+a0+VVftqIJxQYyp5myazoab8FhdjrXCt8yKzjKaHBsga/ BGqmCuw4X8VyF6eo4l+3ltnmbqQimmF6OxiqBTYRp/1655qe8WHF+aYVV1c1AoLJFcNM 5LPw== X-Gm-Message-State: AOAM530JEJ6Mc+r5rLur5H/d59hBuwi7Xke9ia8sIxxrI7xOUK/WbZBb AzUNJ/ETn7cZomdcGNLQjuZ9Cw2CBgA= X-Google-Smtp-Source: ABdhPJwh5q3SSQneLjUt5N34KQd0L5ewFAMB6FFOFYJbRJ4Fv2ddzOGdKpRH9TNoBLqx2vdusuMLTg== X-Received: by 2002:a05:620a:153c:: with SMTP id n28mr9178029qkk.285.1595856399792; Mon, 27 Jul 2020 06:26:39 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [RFC PATCH 1/2] libxl: add Function class to IDL Date: Mon, 27 Jul 2020 09:26:32 -0400 Message-Id: <7e1774dffe69c702f738566abeb04a3a9d29e21b.1595854292.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Anthony PERARD , Ian Jackson , george.dunlap@citrix.com, Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a Function and CtxFunction classes to idl.py to allow generator scripts to generate wrappers which are repetitive and straight forward when doing so by hand. Examples of such functions are the device_add/remove functions. To start, a Function has attributes for namespace, name, parameters, return type, and an indication if the return value should be interpreted as a status code. The CtxFunction class extends this by indicating that a libxl_ctx is a required parmeter, and can optionally be an async function. Also, add logic to idl.parse to return the list of functions found in an IDL file. For now, have users of idl.py -- i.e. libxl/gentypes.py and golang/xenlight/gengotypes.py -- ignore the list of functions returned. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/gengotypes.py | 2 +- tools/libxl/gentypes.py | 2 +- tools/libxl/idl.py | 46 ++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/ge= ngotypes.py index 557fecd07b..bd3663c9ea 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -718,7 +718,7 @@ def xenlight_golang_fmt_name(name, exported =3D True): if __name__ =3D=3D '__main__': idlname =3D sys.argv[1] =20 - (builtins, types) =3D idl.parse(idlname) + (builtins, types, _) =3D idl.parse(idlname) =20 for b in builtins: name =3D b.typename diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py index 9a45e45acc..ac7306f3f7 100644 --- a/tools/libxl/gentypes.py +++ b/tools/libxl/gentypes.py @@ -592,7 +592,7 @@ if __name__ =3D=3D '__main__': =20 (_, idlname, header, header_private, header_json, impl) =3D sys.argv =20 - (builtins,types) =3D idl.parse(idlname) + (builtins,types,_) =3D idl.parse(idlname) =20 print("outputting libxl type definitions to %s" % header) =20 diff --git a/tools/libxl/idl.py b/tools/libxl/idl.py index d7367503b4..1839871f86 100644 --- a/tools/libxl/idl.py +++ b/tools/libxl/idl.py @@ -347,6 +347,45 @@ class OrderedDict(dict): def ordered_items(self): return [(x,self[x]) for x in self.__ordered] =20 +class Function(object): + """ + A general description of a function signature. + + Attributes: + name (str): name of the function, excluding namespace. + params (list of (str,Type)): list of function parameters. + return_type (Type): the Type (if any), returned by the function. + return_is_status (bool): Indicates that the return value should be + interpreted as an error/status code. + """ + def __init__(self, name=3DNone, params=3DNone, return_type=3DNone, + return_is_status=3DFalse, namespace=3DNone): + + if namespace is None: + self.namespace =3D _get_default_namespace() + else: + self.namespace =3D namespace + + self.name =3D self.namespace + name + self.params =3D params + self.return_type =3D return_type + self.return_is_status =3D return_is_status + +class CtxFunction(Function): + """ + A function that requires a libxl_ctx. + + Attributes: + is_asyncop (bool): indicates that the function accepts a + libxl_asyncop_how parameter. + """ + def __init__(self, name=3DNone, params=3DNone, return_type=3DNone, + return_is_status=3DFalse, is_asyncop=3DFalse): + + self.is_asyncop =3D is_asyncop + + Function.__init__(self, name, params, return_type, return_is_statu= s) + def parse(f): print("Parsing %s" % f, file=3Dsys.stderr) =20 @@ -358,6 +397,10 @@ def parse(f): globs[n] =3D t elif isinstance(t,type(object)) and issubclass(t, Type): globs[n] =3D t + elif isinstance(t, Function): + globs[n] =3D t + elif isinstance(t,type(object)) and issubclass(t, Function): + globs[n] =3D t elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE', 'DIR_NONE', 'DIR_IN', 'DIR_OUT', 'DIR_BOTH', 'namespace', 'hidden']: @@ -370,8 +413,9 @@ def parse(f): % (e.lineno, f, e.text)) =20 types =3D [t for t in locs.ordered_values() if isinstance(t,Type)] + funcs =3D [f for f in locs.ordered_values() if isinstance(f,Function)] =20 builtins =3D [t for t in types if isinstance(t,Builtin)] types =3D [t for t in types if not isinstance(t,Builtin)] =20 - return (builtins,types) + return (builtins,types,funcs) --=20 2.17.1 From nobody Thu Apr 18 20:42:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1595856437; cv=none; d=zohomail.com; s=zohoarc; b=IZX3irLRWznyaS2iGiX/5y06sFd9bXW/rTfkjAdZET1y0icCQt1YoX8F+aeJ1LfG0i69h0yV+b+KQHmkjxHsUIPwvUg4AHffHBXd09aKN846EkOGutU+oY8KY7E6ZGvah4XaedT+3k1+3tvctkP3vu7eGP1X4bGMO4Hb75AUtcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595856437; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=CV8gyjU9PwIWw8K/PGrpSXQm3oWpb9KSiaV2uQ4454U=; b=B3TYy8dpIkzuKWjNK0dwYMJNxusHIQ1ub/1vM6N862uZL+tZvJJldu3Z+K93/JYQpYG2dDsVlbzZ/P9jOCPHGKPckdGcXWjaP2VRn8XMS4YNCg7l/r7aSAUP0Uam7ks08hNaJRsdVwZE4sqnGXwmuN0xPYpnDMMJy1blaoL83Qo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1595856437457775.2848136938665; Mon, 27 Jul 2020 06:27:17 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039X-0001WL-1c; Mon, 27 Jul 2020 13:26:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k039V-0001Vb-E5 for xen-devel@lists.xenproject.org; Mon, 27 Jul 2020 13:26:49 +0000 Received: from mail-qk1-x736.google.com (unknown [2607:f8b0:4864:20::736]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id cf386830-d00c-11ea-8abe-bc764e2007e4; Mon, 27 Jul 2020 13:26:42 +0000 (UTC) Received: by mail-qk1-x736.google.com with SMTP id l6so15157261qkc.6 for ; Mon, 27 Jul 2020 06:26:42 -0700 (PDT) Received: from six.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id t8sm11828003qtc.50.2020.07.27.06.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 06:26:40 -0700 (PDT) X-Inumbo-ID: cf386830-d00c-11ea-8abe-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=CV8gyjU9PwIWw8K/PGrpSXQm3oWpb9KSiaV2uQ4454U=; b=lay2kK3CCt51wkbTIp8LTo2lZhzDQnuSNFU+0RWOUNzK9LMgcSIkudUrTf9IAiY1GA fM9vgNgJkZRjrBny0DX0qd/5qTR2n9PkCKhfmzcBXazOhD12PgaaH4vzE/WYn2dWIGHf PFB3TsoOP5ItV+VnAZdkmyXToxDIHYFgdGZOQaSHWlyXNkyg+IPjqJbg1JrL6MC1qA+o vUEsEkGE2QX1o6s2XCuCNL3tRCABo8VQmN92QcqZwYjpM3Jn6WzYZTYrXpCuAS+Dhg5G ZWjwfdYxKZHXD9hQukmZTvdQyOWf7HzFNcc26yEN0c+5ozfQcc2Vrloo9WXSYz3G0CEG ztLw== 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=CV8gyjU9PwIWw8K/PGrpSXQm3oWpb9KSiaV2uQ4454U=; b=lE3xe9zvjYEXFEgF6iYmbaL68UoRbgUmA9tB50YS5OrVwCNDezBu4nHN4cfK4U0ANQ hBgcdEeJlXt4emztcdL5NopXprtgpA6ol42EpB6TFofksX7YcSwmXfaF4WhSnp8PCxC0 AS8HGn6Z5Em6RplgWcPb4g/zaUWIEbf0UAknQeUBoxWoSYhTTj3sYTsBOo9pw/4OlArN t/zsplJNSo4ZRu4O2eLDspnrLa0KKOOy/UMyGL/iMNplXCjetq4seKYkHfqCNRzJFtCR OyJKJ5eZLIqRHkZBAiC6nq2KWE0XJ7Hg6Peu554G0w1QGRzBSJKQRfsM8NOjrheCqx9I dPUg== X-Gm-Message-State: AOAM530ebiFQYTrPV5PHbph8c0/rh5kiQ2dKJ+FwnDR6eViXEnw1D/6m UWHGnnH5cfm1BJyyBYGZqPrWA8P/n6Q= X-Google-Smtp-Source: ABdhPJwHEgYH4RxJ65dlOvT3skSegMWUJKq1BEmSOXGP8QWPnZMs5dxi3yTrOWud3p4+upZklo4niA== X-Received: by 2002:a37:a503:: with SMTP id o3mr22160178qke.162.1595856401512; Mon, 27 Jul 2020 06:26:41 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [RFC PATCH 2/2] libxl: prototype libxl_device_nic_add/remove with IDL Date: Mon, 27 Jul 2020 09:26:33 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Anthony PERARD , Ian Jackson , george.dunlap@citrix.com, Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a DeviceFunction class and describe prototypes for libxl_device_nic_add/remove in libxl_types.idl. Signed-off-by: Nick Rosbrook -- This is mostly to serve as an example of how the first patch would be used for function support in the IDL. --- tools/libxl/idl.py | 8 ++++++++ tools/libxl/libxl_types.idl | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/tools/libxl/idl.py b/tools/libxl/idl.py index 1839871f86..15085af8c7 100644 --- a/tools/libxl/idl.py +++ b/tools/libxl/idl.py @@ -386,6 +386,14 @@ class CtxFunction(Function): =20 Function.__init__(self, name, params, return_type, return_is_statu= s) =20 +class DeviceFunction(CtxFunction): + """ A function that modifies a device. """ + def __init__(self, name=3DNone, device_param=3DNone): + params =3D [ ("domid", uint32), device_param ] + + CtxFunction.__init__(self, name=3Dname, params=3Dparams, return_ty= pe=3Dinteger, + return_is_status=3DTrue, is_asyncop=3DTrue) + def parse(f): print("Parsing %s" % f, file=3Dsys.stderr) =20 diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9d3f05f399..22ba93ee4b 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -769,6 +769,12 @@ libxl_device_nic =3D Struct("device_nic", [ ("colo_checkpoint_port", string) ]) =20 +libxl_device_nic_add =3D DeviceFunction("device_nic_add", + ("nic", libxl_device_nic)) + +libxl_device_nic_remove =3D DeviceFunction("device_nic_remove", + ("nic", libxl_device_nic)) + libxl_device_pci =3D Struct("device_pci", [ ("func", uint8), ("dev", uint8), --=20 2.17.1