From patchwork Wed Mar 3 01:46:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68DBCC433E6 for ; Wed, 3 Mar 2021 01:46:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EA61864E67 for ; Wed, 3 Mar 2021 01:46:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA61864E67 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92642.174624 (Exim 4.92) (envelope-from ) id 1lHGat-00085b-Du; Wed, 03 Mar 2021 01:46:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92642.174624; Wed, 03 Mar 2021 01:46:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGat-00085U-An; Wed, 03 Mar 2021 01:46:31 +0000 Received: by outflank-mailman (input) for mailman id 92642; Wed, 03 Mar 2021 01:46:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGar-000841-Pq for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:29 +0000 Received: from mail-qv1-xf2c.google.com (unknown [2607:f8b0:4864:20::f2c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a9e9fbda-26c0-4664-8b1f-192141e9f5d7; Wed, 03 Mar 2021 01:46:24 +0000 (UTC) Received: by mail-qv1-xf2c.google.com with SMTP id r5so10907021qvv.9 for ; Tue, 02 Mar 2021 17:46:24 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:24 -0800 (PST) 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: a9e9fbda-26c0-4664-8b1f-192141e9f5d7 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=d3549LeDdOjw1wfdOgQuNmXcdgerSomgrqy3WUaXdIs=; b=S+W9hRMLlx9zEuE0+c4nDwmnRqQNsttx2156p9Nf12EOhJPyfgvIQ2+wxo8ondrl1J TSISvHwKtcFG99foz4tvClo3W7uqqVIfGiJy+zbbV+F/To6xe7UvF+5dQocBcdWmzQcG oI747VQDFc/GXZQtsWF+ujfvRAYwXzIdm+4YEEFmsu1q6vojCCm3btfoVMuvC7hsyEMX 6K+dChtfvRELSlck1Y5rh4fjsnW+mx0N+s0dSY5zrwHc+Kf/T3Z+e5SQDGIRY7jBNz8+ 4kjzZklUzxcicFr1mgTZWBpBKBZ0ghej3riwma3ZfEtzYNjCDi6rcLILRmWY3eO+aVt2 IUaw== 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=d3549LeDdOjw1wfdOgQuNmXcdgerSomgrqy3WUaXdIs=; b=QKwG2B2wOPcwx2fsf7E9VgCHslhfI1a+OHV92xnj41pUGwFTTngr8kCbnptlz8iwcS YJObfVxRi7LvqbYB9zIg57iYGdgULmfQL7dFqdPJtNwx9H+5F0H1lTXJqtfoi3iWY4J6 DTewSHX4bNtocGfYT6uzCErtt96h1e27hs61l9HvoOqv++UoIwJK1lA8ntPr0BTtQlot 390ttpxwTVoFguPbP7CUsoiXWRCr90DHUoqe3jF0y4bEWI/fBFnQjPRIL0+g17thjsp1 Qi5OLfU49oFsCLDSL00LSYPkpJY31ckCnOVEebNzYYZBU55zudG9GNiFP4SaUyIoE/hh PWeQ== X-Gm-Message-State: AOAM533J7vLTnWW2vM10tzlPGYcftlFA6WcyK/s4vMoI7kiS1nziw0p6 eGLRjt+oJctnfW9gWkej8V33iqPZMIjOUg== X-Google-Smtp-Source: ABdhPJxLArmXxrobJohrB1yLe+OiwyMWj4S102WoUONDq1AiRM3wmVwOxT66SiWHbJpS0nqyQ13e0Q== X-Received: by 2002:a0c:fd63:: with SMTP id k3mr6421373qvs.30.1614735984461; Tue, 02 Mar 2021 17:46:24 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 1/7] libxl: remove extra whitespace from gentypes.py Date: Tue, 2 Mar 2021 20:46:13 -0500 Message-Id: <7a75b14f66acac499a0b17ab1c5595549421bac7.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: No functional change, just remove the extra whitespace from gentypes.py. Signed-off-by: Nick Rosbrook Acked-by: Anthony PERARD --- tools/libs/light/gentypes.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index 9a45e45acc..37de0f68b3 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -40,7 +40,7 @@ def libxl_C_type_define(ty, indent = ""): elif isinstance(ty, idl.Aggregate): if isinstance(ty, idl.KeyedUnion): s += libxl_C_instance_of(ty.keyvar.type, ty.keyvar.name) + ";\n" - + if ty.typename is None: s += "%s {\n" % ty.kind else: @@ -48,7 +48,7 @@ def libxl_C_type_define(ty, indent = ""): for f in ty.fields: if isinstance(ty, idl.KeyedUnion) and f.type is None: continue - + x = libxl_C_instance_of(f.type, f.name) if f.const: x = "const " + x @@ -164,7 +164,7 @@ def libxl_init_members(ty, nesting = 0): return [f for f in ty.fields if not f.const and isinstance(f.type,idl.KeyedUnion)] else: return [] - + def libxl_C_type_do_init(ty, pass_arg, need_zero=True, indent=" "): s=indent if ty.init_val is not None: @@ -229,20 +229,20 @@ def libxl_C_type_member_init(ty, field): raise Exception("Only KeyedUnion is supported for member init") ku = field.type - + s = "" s += "void %s(%s, %s)\n" % (ty.init_fn + "_" + ku.keyvar.name, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE), ku.keyvar.type.make_arg(ku.keyvar.name)) s += "{\n" - + if ku.keyvar.init_val is not None: init_val = ku.keyvar.init_val elif ku.keyvar.type.init_val is not None: init_val = ku.keyvar.type.init_val else: init_val = None - + (nparent,fexpr) = ty.member(ty.pass_arg("p"), ku.keyvar, isref=True) if init_val is not None: s += " assert(%s == %s);\n" % (fexpr, init_val) @@ -732,7 +732,7 @@ if __name__ == '__main__': f.write(libxl_C_type_copy(ty, "dst", "src")) f.write("}\n") f.write("\n") - + for ty in [t for t in types if t.copy_deprecated_fn]: f.write("int %s(libxl_ctx *ctx, %s)\n" % (ty.copy_deprecated_fn, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE))) From patchwork Wed Mar 3 01:46:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 659B8C433E0 for ; Wed, 3 Mar 2021 01:46:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EAA1764E68 for ; Wed, 3 Mar 2021 01:46:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAA1764E68 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92643.174636 (Exim 4.92) (envelope-from ) id 1lHGax-00088I-Nl; Wed, 03 Mar 2021 01:46:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92643.174636; Wed, 03 Mar 2021 01:46:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGax-000889-Jq; Wed, 03 Mar 2021 01:46:35 +0000 Received: by outflank-mailman (input) for mailman id 92643; Wed, 03 Mar 2021 01:46:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGaw-000841-QA for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:34 +0000 Received: from mail-qk1-x732.google.com (unknown [2607:f8b0:4864:20::732]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a3077b7d-79b8-4b66-9feb-f6b58ccb2671; Wed, 03 Mar 2021 01:46:26 +0000 (UTC) Received: by mail-qk1-x732.google.com with SMTP id b130so10897584qkc.10 for ; Tue, 02 Mar 2021 17:46:26 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:25 -0800 (PST) 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: a3077b7d-79b8-4b66-9feb-f6b58ccb2671 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=ITJlz1yVls1L4SWL3IJLaiNjFmwpPVqobYLq7BDZhNc=; b=RHLP7pwFdxbSwR7IR5byQQYXAWJ9le3sztKm+HRoyIm5Aa7VluQLhq1vaFjN0Z4Ebb PoQ+kx53UI5Mqs9qwqGPxzIjW6flbOuQCef7RWrdmz8+YjiyPdfK8ml3+LEyJ2deX1NO fx/bzEHQyhiUin0q+ltzqaQT9BVjdJtA8gLdTHVn0L6+Nqk4+W4/tAGw2LNge1RcXeN7 FQ44JKngxTm2a2ltU5IN9ukz5BV2ArtsbVE08Oe3itdCfAx0MATLg/QuVG+5nrCBu5oy qRU1x4OKbO+fypkqEJXeuvpXKzR3gQAjxCf5AE0fJ6QdHUMg3XyjW+zqUn7jCse+tQQP uR2w== 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=ITJlz1yVls1L4SWL3IJLaiNjFmwpPVqobYLq7BDZhNc=; b=L3pK/pshSCqUjBFEtyBKAv8gEnCRn/zb0FaivDIgpNWhNs5Y7Ymu3rRLA9HmImv9U+ 86D0aVFY/CDvSkTi2akVyjJLPGCyiYCxKHZp/tTogiyQa6dkxqoQ1cA9T8BvvIXrbERs mcGvt6iuS/6uDg8VAzfTDRF88SBQcGCWkGc/npu2XN0URAqm1nsonXfUD9EsWSQ69LWy GPLiJ8hJqI3JWoPZ0JUMZetKmM593SdISSP2ZAMeC/jXahLzFR47m7Xts+Z1j7BPXEuh 1LloAlcZurlH0LESI4oPg87UZVCAnWx7rHiU8PrJiiqd+ECiOch435gs6H+UVl0I8VPC nzkg== X-Gm-Message-State: AOAM531og9/5xy5c68xK6b1f5tWMv6Yg/0lzDXMUVr1XovL3jLFM1VAT uuLdnlx2iMJ8AHHje6g6o/kaDVPFd0ybcw== X-Google-Smtp-Source: ABdhPJwf9vEmttoT9z+hs1iBJXF1N9mUVjBQHHeUJc29/71XkIQSrjGuiRR+Rdf5YH4ajF53eizOMw== X-Received: by 2002:a37:9385:: with SMTP id v127mr12608930qkd.131.1614735985760; Tue, 02 Mar 2021 17:46:25 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 2/7] libxl: add Function class to IDL Date: Tue, 2 Mar 2021 20:46:14 -0500 Message-Id: <2193e7fbc7c359b2e32551370ef57ba371658281.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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, and return type. The CtxFunction class extends this by indicating that a libxl_ctx is a required parmeter. 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/libs/light/gentypes.py | 2 +- tools/libs/light/idl.py | 36 ++++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py index 3e40c3d5dc..484e121746 100644 --- a/tools/golang/xenlight/gengotypes.py +++ b/tools/golang/xenlight/gengotypes.py @@ -725,7 +725,7 @@ def xenlight_golang_fmt_name(name, exported = True): if __name__ == '__main__': idlname = sys.argv[1] - (builtins, types) = idl.parse(idlname) + (builtins, types, _) = idl.parse(idlname) for b in builtins: name = b.typename diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index 37de0f68b3..f9957b79a2 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -592,7 +592,7 @@ if __name__ == '__main__': (_, idlname, header, header_private, header_json, impl) = sys.argv - (builtins,types) = idl.parse(idlname) + (builtins,types,_) = idl.parse(idlname) print("outputting libxl type definitions to %s" % header) diff --git a/tools/libs/light/idl.py b/tools/libs/light/idl.py index d7367503b4..20278c272a 100644 --- a/tools/libs/light/idl.py +++ b/tools/libs/light/idl.py @@ -347,6 +347,35 @@ class OrderedDict(dict): def ordered_items(self): return [(x,self[x]) for x in self.__ordered] +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. + """ + def __init__(self, name=None, params=None, return_type=None, namespace=None): + + if namespace is None: + self.namespace = _get_default_namespace() + else: + self.namespace = namespace + + self.name = self.namespace + name + self.rawname = name + self.params = params + self.return_type = return_type + +class CtxFunction(Function): + """ A function that requires a libxl_ctx. """ + def __init__(self, name=None, params=None, return_type=None): + ctx = Builtin("ctx", passby=PASS_BY_REFERENCE) + params.insert(0, ("ctx", ctx)) + + Function.__init__(self, name, params, return_type) + def parse(f): print("Parsing %s" % f, file=sys.stderr) @@ -358,6 +387,10 @@ def parse(f): globs[n] = t elif isinstance(t,type(object)) and issubclass(t, Type): globs[n] = t + elif isinstance(t, Function): + globs[n] = t + elif isinstance(t,type(object)) and issubclass(t, Function): + globs[n] = t elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE', 'DIR_NONE', 'DIR_IN', 'DIR_OUT', 'DIR_BOTH', 'namespace', 'hidden']: @@ -370,8 +403,9 @@ def parse(f): % (e.lineno, f, e.text)) types = [t for t in locs.ordered_values() if isinstance(t,Type)] + funcs = [f for f in locs.ordered_values() if isinstance(f,Function)] builtins = [t for t in types if isinstance(t,Builtin)] types = [t for t in types if not isinstance(t,Builtin)] - return (builtins,types) + return (builtins,types,funcs) From patchwork Wed Mar 3 01:46:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CD64C43381 for ; Wed, 3 Mar 2021 01:46:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEAF564E6B for ; Wed, 3 Mar 2021 01:46:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEAF564E6B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92644.174648 (Exim 4.92) (envelope-from ) id 1lHGb3-0008Cy-88; Wed, 03 Mar 2021 01:46:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92644.174648; Wed, 03 Mar 2021 01:46:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGb3-0008Cn-3k; Wed, 03 Mar 2021 01:46:41 +0000 Received: by outflank-mailman (input) for mailman id 92644; Wed, 03 Mar 2021 01:46:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGb1-000841-QL for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:39 +0000 Received: from mail-qk1-x72e.google.com (unknown [2607:f8b0:4864:20::72e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 88826741-7be0-4128-96f9-5c5fdacf9a8b; Wed, 03 Mar 2021 01:46:27 +0000 (UTC) Received: by mail-qk1-x72e.google.com with SMTP id g185so3229914qkf.6 for ; Tue, 02 Mar 2021 17:46:27 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:26 -0800 (PST) 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: 88826741-7be0-4128-96f9-5c5fdacf9a8b 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=NSsxG6jC6iAfi1izLJM576IbFfwdbov0QctCg+vigCk=; b=i7XvrduzFBb3vFjJ9h5JkKQLLbFxa5PxO1Guf6ZAdR1g6oa+fd0VX2/XAxWEY4a5OS pLDdYRz5wjNzvNtIj/LY4M9zIVmMV3E7jjbhUu5Zm5yGA9JaFvjSjC3nCJwTBsUwUzS7 UhzcTk6DJINxpem85hn0ACPx4UN2QImq9z8S/5lkcn2nh77h1LsWm2OmJvN9XWyAadYa KouzKt3/O3QmrWfNCztnD0RvJLYqPUVfZC+AEYf6WYNjNGl09PlXSbLIccC4FctWvGPq Un1jdV6gHcpnfjROwHd0GKIuqx92xhLzbYDKmEi/TdrVmpa4JBv4hbGfMYFpveRy/329 s5LA== 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=NSsxG6jC6iAfi1izLJM576IbFfwdbov0QctCg+vigCk=; b=IkrnjDTh71bdfHphEsdykIGN+rXVsNlw3YDxsqGASsbDAnpthrznniAWe7d4phgM3Y vo9MB0hMAcfyH43Qnrpo3aIlzhrcESM505FMPqrq+TCjwpPjdcVGwlxb+yqQ6Bae6IgD 3WbHFVFQLhl6MIlEbjgeCinKpnBnh6QqsY7xsmWDXOvOYefY07fVwztcZjAKdce8uXHb NcWSU1AydTI4lE4PuGRzkqGmqX/NJ3P6klsVc233nmTz7clsjeE165y1IPMmwahfuLc4 JzxzVOuxxKAfC+odM8t6DYSpVwARWzcFT0oESBbqHwuWzCm+/YczNFQTJ18nK57+MgGH 6IBg== X-Gm-Message-State: AOAM530RwaZ0MnbrQOs7B20dIbcJhu3mRNq0AUB1UouwdxICFv4N8oXX 9/0EM9uUAmeHEDhxilgsiJ7cBT0ZtOiDYg== X-Google-Smtp-Source: ABdhPJz4Ks5EvlScGLnpU0G+C2xgzT2jcmx7EX7joUCoj1HPTIlcK/T/y6Vn8a8yV23XO9L4Tw/lww== X-Received: by 2002:ae9:eb57:: with SMTP id b84mr18756591qkg.271.1614735986824; Tue, 02 Mar 2021 17:46:26 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 3/7] libxl: add PASS_BY_CONST_REFERENCE to idl Date: Tue, 2 Mar 2021 20:46:15 -0500 Message-Id: <4b7f52dd28516aa286ab6db90536835b8caed022.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Currently, there is only support for PASS_BY_{REFERENCE,VALUE} in the IDL. As a piece of adding function support, add logic for PASS_BY_CONST_REFERENCE so that function generation code can use Type.make_arg() for function signatures that require const reference parameters. Signed-off-by: Nick Rosbrook --- tools/libs/light/idl.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/libs/light/idl.py b/tools/libs/light/idl.py index 20278c272a..a8a4768efc 100644 --- a/tools/libs/light/idl.py +++ b/tools/libs/light/idl.py @@ -4,6 +4,7 @@ import sys PASS_BY_VALUE = 1 PASS_BY_REFERENCE = 2 +PASS_BY_CONST_REFERENCE = 3 DIR_NONE = 0 DIR_IN = 1 @@ -40,7 +41,7 @@ class Type(object): raise ValueError self.passby = kwargs.setdefault('passby', PASS_BY_VALUE) - if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE]: + if self.passby not in [PASS_BY_VALUE, PASS_BY_REFERENCE, PASS_BY_CONST_REFERENCE]: raise ValueError self.private = kwargs.setdefault('private', False) @@ -109,6 +110,8 @@ class Type(object): if passby == PASS_BY_REFERENCE: return "%s *%s" % (self.typename, n) + elif passby == PASS_BY_CONST_REFERENCE: + return "const %s *%s" % (self.typename, n) else: return "%s %s" % (self.typename, n) @@ -116,7 +119,7 @@ class Type(object): if passby is None: passby = self.passby if isref is None: isref = self.passby == PASS_BY_REFERENCE - if passby == PASS_BY_REFERENCE: + if passby in [PASS_BY_REFERENCE, PASS_BY_CONST_REFERENCE]: if isref: return "%s" % (n) else: @@ -272,7 +275,7 @@ class KeyedUnion(Aggregate): raise ValueError kv_kwargs = dict([(x.lstrip('keyvar_'),y) for (x,y) in kwargs.items() if x.startswith('keyvar_')]) - + self.keyvar = Field(keyvar_type, keyvar_name, **kv_kwargs) for f in fields: @@ -392,6 +395,7 @@ def parse(f): elif isinstance(t,type(object)) and issubclass(t, Function): globs[n] = t elif n in ['PASS_BY_REFERENCE', 'PASS_BY_VALUE', + 'PASS_BY_CONST_REFERENCE', 'DIR_NONE', 'DIR_IN', 'DIR_OUT', 'DIR_BOTH', 'namespace', 'hidden']: globs[n] = t From patchwork Wed Mar 3 01:46:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3A80C433DB for ; Wed, 3 Mar 2021 01:46:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62B2664DF2 for ; Wed, 3 Mar 2021 01:46:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62B2664DF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92645.174660 (Exim 4.92) (envelope-from ) id 1lHGb8-0008IH-Go; Wed, 03 Mar 2021 01:46:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92645.174660; Wed, 03 Mar 2021 01:46:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGb8-0008I9-DO; Wed, 03 Mar 2021 01:46:46 +0000 Received: by outflank-mailman (input) for mailman id 92645; Wed, 03 Mar 2021 01:46:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGb6-000841-QR for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:44 +0000 Received: from mail-qk1-x732.google.com (unknown [2607:f8b0:4864:20::732]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 556a758a-1727-4bff-b2e1-6901913f52b8; Wed, 03 Mar 2021 01:46:28 +0000 (UTC) Received: by mail-qk1-x732.google.com with SMTP id a9so7952555qkn.13 for ; Tue, 02 Mar 2021 17:46:28 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:27 -0800 (PST) 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: 556a758a-1727-4bff-b2e1-6901913f52b8 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=NeaXDX2+Mvblx3YuOcY75d5cOiV30GS5wta6XWp6vVQ=; b=UkhmaFMyBysZaPiAAYUmbOmltiOZOyDhe1ox99Y69kNnkPCuhwwJOHv8A2PZZqtxqP qhlMrxz7U8kvTlZZLwP6SZ1+4IMe0JPc2ssj/HhxOoUSrltNcpWQu6cod57znEDiOeoe EVgoQ6UIqwphXFthBz+S32DBCGiaOkAwRnbqi46qn0tSixAIPn75XGa+ybZjQhbWC1fk cTNUvM4rc7CQjW9qX13O0JriI3RxH47QuCtSPTPJYXzJWH4pxIAVoK7A9bVn8UOxK0j2 IofhyF0li2QQWx9coiCYno0gyDFf5rYT7lhA8/BjibimPxz+m9ojttBEeXYSS5bPkaLf Uz6g== 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=NeaXDX2+Mvblx3YuOcY75d5cOiV30GS5wta6XWp6vVQ=; b=fVHjK2hlmFDuko2wKGcVH3+Doqe7Nw6HTPkawPkxVsHnV5AE7mxDE1OrZBgbbNS2k0 Spb6Gk7cmJ2cXKLErnyxUcAEjnaC8k4GCZuNrBYcwEZzIuhDpSGHTYGskvEkdDauoTl9 vdd3WfmItDbT3w/AfzbLgV0NmlHXVCx1bVvis5L86IMgl0fgYOdQEKzMVwtokEOfYk05 kVTlcq1KNSw4ai7izgxVlb6Nrt+FOKe3813od6EXbz9F4+4Pp7063yXMiECcbuVHe3hO KXd+csmLUwsz0tX/5OuaUsRNjuVHi8XzuElxagdQcDukJStsRoPeErMmZg86KcFJs+Qn 6HmA== X-Gm-Message-State: AOAM5326XdwH+NR00x/3lD9S5NJs6F4PMVqu5A2VS/qESYXjmIWZeKtT bXqlVaIZZGAlL7yX9qKE8nAlRAHppZBLiQ== X-Google-Smtp-Source: ABdhPJyV9rkoVg4yxw6X9Mtgp+kwZR51+U7dCKeRs5TxPUaaKEVo6rH5xZGnyMfl7olyd5mCbzeApA== X-Received: by 2002:a37:ba03:: with SMTP id k3mr15691601qkf.336.1614735988001; Tue, 02 Mar 2021 17:46:28 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 4/7] libxl: add DeviceFunction classes to IDL Date: Tue, 2 Mar 2021 20:46:16 -0500 Message-Id: <5eba989c046387c17549d634841f8215c2fc5893.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Add a DeviceFunction base class, and Device{Add,Remove,Destroy}Function classes to idl.py. These classes will allow the device functions to be generated later in gentypes.py. The base class, DeviceFunction, extends CtxFunction and adds a domid parameter to the function's parameter list. When creating a DeviceFunction, the device parameter must be specified, and extra parameters can be specified if necessary. Rather than indicating specific device actions in the DeviceFunction class, child classes are created for each device function type. Right now, DeviceAddFunction does not extend the base class. DeviceRemoveFunction adds the option of specifying 'custom_remove' parameter when custom remove functions are needed. DeviceDestroyFunction is a child of DeviceRemoveFunction to inherit the custom_remove attribute. Signed-off-by: Nick Rosbrook --- tools/libs/light/idl.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/libs/light/idl.py b/tools/libs/light/idl.py index a8a4768efc..570b168079 100644 --- a/tools/libs/light/idl.py +++ b/tools/libs/light/idl.py @@ -379,6 +379,29 @@ class CtxFunction(Function): Function.__init__(self, name, params, return_type) +class DeviceFunction(CtxFunction): + """ A function that modifies a domain's devices. """ + def __init__(self, name=None, device_param=None, extra_params=None, + return_type=None): + self.device_param = device_param + + params = [ ("domid", uint32), device_param ] + extra_params + + CtxFunction.__init__(self, name, params, return_type) + +class DeviceAddFunction(DeviceFunction): + pass + +class DeviceRemoveFunction(DeviceFunction): + def __init__(self, name=None, device_param=None, extra_params=None, + return_type=None, custom_remove=None): + self.custom_remove = custom_remove + + DeviceFunction.__init__(self, name, device_param, extra_params, return_type) + +class DeviceDestroyFunction(DeviceRemoveFunction): + pass + def parse(f): print("Parsing %s" % f, file=sys.stderr) From patchwork Wed Mar 3 01:46:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 066CEC433E0 for ; Wed, 3 Mar 2021 01:47:01 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A92A64E28 for ; Wed, 3 Mar 2021 01:47:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A92A64E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92647.174671 (Exim 4.92) (envelope-from ) id 1lHGbD-0008NP-Qj; Wed, 03 Mar 2021 01:46:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92647.174671; Wed, 03 Mar 2021 01:46:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbD-0008NG-MF; Wed, 03 Mar 2021 01:46:51 +0000 Received: by outflank-mailman (input) for mailman id 92647; Wed, 03 Mar 2021 01:46:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbB-000841-QS for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:49 +0000 Received: from mail-qv1-xf2b.google.com (unknown [2607:f8b0:4864:20::f2b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 09f5c152-e390-4f4d-b6f9-855b61d9817d; Wed, 03 Mar 2021 01:46:29 +0000 (UTC) Received: by mail-qv1-xf2b.google.com with SMTP id dj14so3383347qvb.1 for ; Tue, 02 Mar 2021 17:46:29 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:28 -0800 (PST) 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: 09f5c152-e390-4f4d-b6f9-855b61d9817d 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=V9qJff+98dFfqpPkCZweLxCXnXyOwxftISf2qu2jFAo=; b=nxoirzlyilLDZu27c+0cBEhVYn5Tx7APDjWJ+n0eC++T3KDUviuf+Pof+D3nV96SYH g3Lmx5Qfe6MDrgqGNHtoc+vpNzSLKkRBZytkaQw4a27AKat80mHXO8FIUwfnGrWtHqDl twL5deZRwi7HFx6kBLDmhCJBpFEztXl5k/kBb5zU4PYMnPPNG5misXwDaKdBbinBa1HJ +1OlGFTksjETj6OS4gYy3FEKeF6SFeMefODsvSq/UXL2XvbRWjVR3swZ2Zh4d4XKXfwb sDqGtzbbSA0eHIGIAjGsFhdVRMWJcZH49Nk0kDvVtg5UNFQ19n1za9fsMcTr53Ebewr8 4PMA== 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=V9qJff+98dFfqpPkCZweLxCXnXyOwxftISf2qu2jFAo=; b=B/ORSFj7SdOv1dyp2Cx9FMfwM6F/cTnok3I1SyHgm6g5pFgQQEI33AVO8fbVxDcgeQ e6jlNwvpULZWbru4xMl+EJzynlJ0pIP2lTCTVky8iMKj8R22s2l8YYOrsYiSZ5Rl1M88 R4M3e+S7Dxvbx7Z8fdr3QM6edIr6OgvJGmip89/41I7QqOH175d3ICfhI3bAGnwk+EeN FORQT98j+PZEHC0GZHNwnPMkWr/IenT6Y78ZMRn9P5i85yS/zUkd74frUUcO+SbDssx1 ZDH1EFQudDE34qnUvPbj9vhIYQKSAIFupRgAsxOJlODOW0G8EZU0Ylc8PkIF0/nZ1098 Dthg== X-Gm-Message-State: AOAM531Aus3d192BGF8yjl3EXPqoA5IriaJ/PrE4s7brwedNVb9FZqJT 4V3tISows2eap0a+ie8IUqrpM1XLQfSwfw== X-Google-Smtp-Source: ABdhPJwkoby6QITo+fIBUYiHPnnJPafLiAMpJzRHMV6/0hpALc44HUW6gmcA5Pyupn2SYcCLUh3Ttw== X-Received: by 2002:ad4:542b:: with SMTP id g11mr6471580qvt.47.1614735989088; Tue, 02 Mar 2021 17:46:29 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 5/7] libxl: add device function definitions to libxl_types.idl Date: Tue, 2 Mar 2021 20:46:17 -0500 Message-Id: <2cd96b7e884c6f0c2667ef7499ff7179b99ea635.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Add definitions to libxl_type.idl for the device functions required by each device. In addition, add a Builtin definition for libxl_asyncop_how, since each device function requires this as a parameter. This is still prepatory work, and a later commit will make use of these new definitions to generate the code from gentypes.py. Signed-off-by: Nick Rosbrook --- tools/libs/light/libxl_types.idl | 202 +++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl index 5b85a7419f..550af7a1c7 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -33,6 +33,8 @@ libxl_hwcap = Builtin("hwcap", passby=PASS_BY_REFERENCE, json_parse_type="JSON_A libxl_ms_vm_genid = Builtin("ms_vm_genid", passby=PASS_BY_REFERENCE, check_default_fn="libxl_ms_vm_genid_is_zero", copy_fn="libxl_ms_vm_genid_copy") +libxl_asyncop_how = Builtin("asyncop_how", passby=PASS_BY_CONST_REFERENCE) + # # Specific integer types # @@ -666,6 +668,24 @@ libxl_device_vfb = Struct("device_vfb", [ ("keymap", string), ]) +libxl_device_vfb_add = DeviceAddFunction("device_vfb_add", + device_param=("vfb", libxl_device_vfb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vfb_remove = DeviceRemoveFunction("device_vfb_remove", + device_param=("vfb", libxl_device_vfb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vfb_destroy = DeviceDestroyFunction("device_vfb_destroy", + device_param=("vfb", libxl_device_vfb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_vkb = Struct("device_vkb", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -684,6 +704,24 @@ libxl_device_vkb = Struct("device_vkb", [ ("multi_touch_num_contacts", uint32) ]) +libxl_device_vkb_add = DeviceAddFunction("device_vkb_add", + device_param=("vkb", libxl_device_vkb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vkb_remove = DeviceRemoveFunction("device_vkb_remove", + device_param=("vkb", libxl_device_vkb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vkb_destroy = DeviceAddFunction("device_vkb_destroy", + device_param=("vkb", libxl_device_vkb), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_disk = Struct("device_disk", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -708,6 +746,24 @@ libxl_device_disk = Struct("device_disk", [ ("hidden_disk", string) ]) +libxl_device_disk_add = DeviceAddFunction("device_disk_add", + device_param=("disk", libxl_device_disk), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_disk_remove = DeviceRemoveFunction("device_disk_remove", + device_param=("disk", libxl_device_disk), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_disk_destroy = DeviceDestroyFunction("device_disk_destroy", + device_param=("disk", libxl_device_disk), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_nic = Struct("device_nic", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -776,6 +832,24 @@ libxl_device_nic = Struct("device_nic", [ ("colo_checkpoint_port", string) ]) +libxl_device_nic_add = DeviceAddFunction("device_nic_add", + device_param=("nic", libxl_device_nic), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_nic_remove = DeviceRemoveFunction("device_nic_remove", + device_param=("nic", libxl_device_nic), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_nic_destroy = DeviceDestroyFunction("device_nic_destroy", + device_param=("nic", libxl_device_nic), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_pci = Struct("device_pci", [ ("func", uint8), ("dev", uint8), @@ -791,6 +865,24 @@ libxl_device_pci = Struct("device_pci", [ ("name", string), ]) +libxl_device_pci_add = DeviceAddFunction("device_pci_add", + device_param=("pci", libxl_device_pci), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_pci_remove = DeviceRemoveFunction("device_pci_remove", + device_param=("pci", libxl_device_pci), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_pci_destroy = DeviceDestroyFunction("device_pci_destroy", + device_param=("pci", libxl_device_pci), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_rdm = Struct("device_rdm", [ ("start", uint64), ("size", uint64), @@ -817,6 +909,26 @@ libxl_device_usbctrl = Struct("device_usbctrl", [ ("backend_domname", string), ]) +libxl_device_usbctrl_add = DeviceAddFunction("device_usbctrl_add", + device_param=("usbctrl", libxl_device_usbctrl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_usbctrl_remove = DeviceRemoveFunction("device_usbctrl_remove", + device_param=("usbctrl", libxl_device_usbctrl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error, + custom_remove="usbctrl" +) + +libxl_device_usbctrl_destroy = DeviceDestroyFunction("device_usbctrl_destroy", + device_param=("usbctrl", libxl_device_usbctrl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error, + custom_remove="usbctrl" +) + libxl_device_usbdev = Struct("device_usbdev", [ ("ctrl", libxl_devid), ("port", integer), @@ -827,6 +939,18 @@ libxl_device_usbdev = Struct("device_usbdev", [ ])), ]) +libxl_device_usbdev_add = DeviceAddFunction("device_usbdev_add", + device_param=("usbdev", libxl_device_usbdev), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_usbdev_remove = DeviceRemoveFunction("device_usbdev_remove", + device_param=("usbdev", libxl_device_usbdev), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_dtdev = Struct("device_dtdev", [ ("path", string), ]) @@ -838,6 +962,24 @@ libxl_device_vtpm = Struct("device_vtpm", [ ("uuid", libxl_uuid), ]) +libxl_device_vtpm_add = DeviceAddFunction("device_vtpm_add", + device_param=("vtpm", libxl_device_vtpm), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vtpm_remove = DeviceRemoveFunction("device_vtpm_remove", + device_param=("vtpm", libxl_device_vtpm), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vtpm_destroy = DeviceDestroyFunction("device_vtpm_destroy", + device_param=("vtpm", libxl_device_vtpm), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_p9 = Struct("device_p9", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -847,12 +989,36 @@ libxl_device_p9 = Struct("device_p9", [ ("devid", libxl_devid), ]) +libxl_device_p9_remove = DeviceRemoveFunction("device_p9_remove", + device_param=("p9", libxl_device_p9), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_p9_destroy = DeviceDestroyFunction("device_p9_destroy", + device_param=("p9", libxl_device_p9), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_pvcallsif = Struct("device_pvcallsif", [ ("backend_domid", libxl_domid), ("backend_domname", string), ("devid", libxl_devid), ]) +libxl_device_pvcallsif_remove = DeviceRemoveFunction("device_pvcallsif_remove", + device_param=("pvcallsif", libxl_device_pvcallsif), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_pvcallsif_destroy = DeviceDestroyFunction("device_pvcallsif_destroy", + device_param=("pvcallsif", libxl_device_pvcallsif), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_device_channel = Struct("device_channel", [ ("backend_domid", libxl_domid), ("backend_domname", string), @@ -879,6 +1045,24 @@ libxl_device_vdispl = Struct("device_vdispl", [ ("connectors", Array(libxl_connector_param, "num_connectors")) ]) +libxl_device_vdispl_add = DeviceAddFunction("device_vdispl_add", + device_param=("vdispl", libxl_device_vdispl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vdispl_remove = DeviceRemoveFunction("device_vdispl_remove", + device_param=("vdispl", libxl_device_vdispl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vdispl_destroy = DeviceDestroyFunction("device_vdispl_destroy", + device_param=("vdispl", libxl_device_vdispl), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_vsnd_pcm_format = Enumeration("vsnd_pcm_format", [ (1, "S8"), (2, "U8"), @@ -942,6 +1126,24 @@ libxl_device_vsnd = Struct("device_vsnd", [ ("pcms", Array(libxl_vsnd_pcm, "num_vsnd_pcms")) ]) +libxl_device_vsnd_add = DeviceAddFunction("device_vsnd_add", + device_param=("vsnd", libxl_device_vsnd), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vsnd_remove = DeviceRemoveFunction("device_vsnd_remove", + device_param=("vsnd", libxl_device_vsnd), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + +libxl_device_vsnd_destroy = DeviceDestroyFunction("device_vsnd_destroy", + device_param=("vsnd", libxl_device_vsnd), + extra_params=[("ao_how", libxl_asyncop_how)], + return_type=libxl_error +) + libxl_domain_config = Struct("domain_config", [ ("c_info", libxl_domain_create_info), ("b_info", libxl_domain_build_info), From patchwork Wed Mar 3 01:46:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 112F2C433E0 for ; Wed, 3 Mar 2021 01:47:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A32BB64DF2 for ; Wed, 3 Mar 2021 01:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A32BB64DF2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92648.174684 (Exim 4.92) (envelope-from ) id 1lHGbI-0008SD-4D; Wed, 03 Mar 2021 01:46:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92648.174684; Wed, 03 Mar 2021 01:46:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbI-0008S5-0T; Wed, 03 Mar 2021 01:46:56 +0000 Received: by outflank-mailman (input) for mailman id 92648; Wed, 03 Mar 2021 01:46:54 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbG-000841-QY for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:54 +0000 Received: from mail-qv1-xf30.google.com (unknown [2607:f8b0:4864:20::f30]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4152de8a-57c6-46b6-b772-e48621250722; Wed, 03 Mar 2021 01:46:31 +0000 (UTC) Received: by mail-qv1-xf30.google.com with SMTP id n4so8641165qvl.4 for ; Tue, 02 Mar 2021 17:46:31 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:30 -0800 (PST) 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: 4152de8a-57c6-46b6-b772-e48621250722 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=ZBxo1ZZtGeZ/L0BM6vs2MRgDVAvnnL5QuvziUxZ+Mfs=; b=c/2/ARFN73/sZw/qonXPJ2alnC439EgjDE8nnYjsOEMkYU2zIXXiC60l8Jj5+SUVhV fPj6546TNsAxyqjYIg5iWcCUZREnxfsSx/bvLwg7x/QNEPySiTPAY6dsyB3LWdiP1WWd z+V/cLGCaFLjpnMNGUKZvneTiiNp7J2IVu3z/KTGAKtr9JXPecQq93znBsho5hb0TwuQ modv5t4aFo28hQ7mJeZM6q6dVrEGTxvYvRBDCfLro/cVVfn+2qyZIZoG0AJ0N5YcLHWo DHxI7365kLhovX0jQ40Cqg+lQHqOHym2iU5d+JbYJYWSXzCnqVnLYLrA7S09C/CvuhnQ v/ww== 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=ZBxo1ZZtGeZ/L0BM6vs2MRgDVAvnnL5QuvziUxZ+Mfs=; b=kg6/j2gRJk+Dqti3F8juVU5u8VSCEUJz82bBCa7H6kQ3x6CN2OSiFGTylFMM3JNDNm ZMic6pr3nZApvwBsT1XyRwvciYl0TxocIXvnaJf1VcP0hO/MFUUuMw5C3xvgHyra1Jgt edBYHWmwLsZWDR2J5kdyW21WqNbUVNA0mcok0F0WNY3JFzvKYH0eBk5Oiyjz2vRIhXIT nKPHZM65j+a1mY5FGjKQfIsbVcPNE+Q0eoiWXlzPiuc7puVghU4JTOBVfw6hkN7vGcbH Pr/Q3b31uwMeiFUrhFxGUwTSOc+jMKjj7u0qPj7EelkvRMjrHCIEkiKI1EiKsrJAlJzS U7kQ== X-Gm-Message-State: AOAM533ctJN9f5sLHfrBSMSQsEzu4m3tip2EdcOVBo3V+Md4/3xohpyy 2D4BPbjQCWtCUlvjODIkDJs+mBKfEbX2hg== X-Google-Smtp-Source: ABdhPJwtuYq4lWi8WRY/KMlmq6VazCxMaPD9FCMWX5jPelkPzARQ/yVIFSB+00K4jzHx3dUmS6N8zA== X-Received: by 2002:a0c:c585:: with SMTP id a5mr662605qvj.60.1614735990468; Tue, 02 Mar 2021 17:46:30 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 6/7] libxl: implement device add/remove/destroy functions generation Date: Tue, 2 Mar 2021 20:46:18 -0500 Message-Id: <5986715fe1d677533b67c06e9561cd716716d46a.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Use the newly added function support in the IDL to generate the function definitions for the device add, remove, and destroy functions. The content of the generated functions is taken from the device fuction macro framework in libxl_internal.h. For now, the definitions are not actually written out to a .c file, but are invoked to ensure there is no build regression introduced. A later commit will replace the existing macros with this generated code. Signed-off-by: Nick Rosbrook --- tools/libs/light/gentypes.py | 91 +++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index f9957b79a2..9f1856399a 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -584,6 +584,85 @@ def libxl_C_enum_from_string(ty, str, e, indent = " "): s = indent + s return s.replace("\n", "\n%s" % indent).rstrip(indent) +def libxl_func_define_device_add(func): + s = '' + + return_type = func.return_type.typename + if isinstance(func.return_type, idl.Enumeration): + return_type = idl.integer.typename + + params = ', '.join([ ty.make_arg(name) for (name,ty) in func.params ]) + + s += '{0} {1}({2})\n'.format(return_type, func.name, params) + s += '{\n' + s += '\tAO_CREATE(ctx, domid, ao_how);\n' + s += '\tlibxl__ao_device *aodev;\n\n' + s += '\tGCNEW(aodev);\n' + s += '\tlibxl__prepare_ao_device(ao, aodev);\n' + s += '\taodev->action = LIBXL__DEVICE_ACTION_ADD;\n' + s += '\taodev->callback = device_addrm_aocomplete;\n' + s += '\taodev->update_json = true;\n' + s += '\tlibxl__{0}(egc, domid, type, aodev);\n\n'.format(func.rawname) + s += '\treturn AO_INPROGRESS;\n' + s += '}\n' + + return s + +def libxl_func_define_device_remove_ext(func, action=None): + s = '' + + flag = None + if action == 'remove': + flag = 'LIBXL__FORCE_AUTO' + elif action == 'destroy': + flag = 'LIBXL__FORCE_ON' + else: + raise Exception('Unsupported action %s' % action) + + # This is used to formulate the function name libxl__device_from_ + devtype = func.device_param[1].rawname.replace('device_','') + + remtype = 'generic' + if func.custom_remove is not None: + remtype = func.custom_remove + + return_type = func.return_type.typename + if isinstance(func.return_type, idl.Enumeration): + return_type = idl.integer.typename + + params = ', '.join([ ty.make_arg(name) for (name,ty) in func.params ]) + + s += '{0} {1}({2})\n'.format(return_type, func.name, params) + s += '{\n' + s += '\tAO_CREATE(ctx, domid, ao_how);\n' + s += '\tlibxl__device *device;\n' + s += '\tlibxl__ao_device *aodev;\n' + s += '\tint rc;\n' + s += '\n' + s += '\tGCNEW(device);\n' + s += '\trc = libxl__device_from_{0}(gc, domid, type, device);\n'.format(devtype) + s += '\tif (rc != 0) goto out;\n' + s += '\n' + s += '\tGCNEW(aodev);\n' + s += '\tlibxl__prepare_ao_device(ao, aodev);\n' + s += '\taodev->action = LIBXL__DEVICE_ACTION_REMOVE;\n' + s += '\taodev->dev = device;\n' + s += '\taodev->callback = device_addrm_aocomplete;\n' + s += '\taodev->force.flag = {0};\n'.format(flag) + s += '\tlibxl__initiate_device_{0}_remove(egc, aodev);\n'.format(remtype) + s += '\n' + s += 'out:\n' + s += '\tif (rc) return AO_CREATE_FAIL(rc);\n' + s += '\treturn AO_INPROGRESS;\n' + s += '}\n' + + return s + +def libxl_func_define_device_remove(func): + return libxl_func_define_device_remove_ext(func, action='remove') + +def libxl_func_define_device_destroy(func): + return libxl_func_define_device_remove_ext(func, action='destroy') if __name__ == '__main__': if len(sys.argv) != 6: @@ -592,7 +671,7 @@ if __name__ == '__main__': (_, idlname, header, header_private, header_json, impl) = sys.argv - (builtins,types,_) = idl.parse(idlname) + (builtins,types,funcs) = idl.parse(idlname) print("outputting libxl type definitions to %s" % header) @@ -794,4 +873,14 @@ if __name__ == '__main__': f.write("}\n") f.write("\n") + for func in funcs: + if type(func) is idl.DeviceAddFunction: + _ = libxl_func_define_device_add(func) + elif type(func) is idl.DeviceRemoveFunction: + _ = libxl_func_define_device_remove(func) + elif type(func) is idl.DeviceDestroyFunction: + _ = libxl_func_define_device_destroy(func) + else: + raise Exception("Unexpected Function class %s" % type(func)) + f.close() From patchwork Wed Mar 3 01:46:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 12112627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 672CBC433DB for ; Wed, 3 Mar 2021 01:47:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F30CA64E28 for ; Wed, 3 Mar 2021 01:47:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F30CA64E28 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.92652.174696 (Exim 4.92) (envelope-from ) id 1lHGbN-00007l-KT; Wed, 03 Mar 2021 01:47:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 92652.174696; Wed, 03 Mar 2021 01:47:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbN-00007c-FY; Wed, 03 Mar 2021 01:47:01 +0000 Received: by outflank-mailman (input) for mailman id 92652; Wed, 03 Mar 2021 01:46:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lHGbL-000841-Qj for xen-devel@lists.xenproject.org; Wed, 03 Mar 2021 01:46:59 +0000 Received: from mail-qv1-xf33.google.com (unknown [2607:f8b0:4864:20::f33]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f23ca88d-6216-4410-ad20-87b8e4b930a4; Wed, 03 Mar 2021 01:46:32 +0000 (UTC) Received: by mail-qv1-xf33.google.com with SMTP id h7so4011913qvm.2 for ; Tue, 02 Mar 2021 17:46:32 -0800 (PST) Received: from six.home (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id g21sm5406145qkk.72.2021.03.02.17.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 17:46:31 -0800 (PST) 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: f23ca88d-6216-4410-ad20-87b8e4b930a4 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=nx6R5ORiCtnIpFZu+0txlPDpQ866FHk77wANc0bUqAI=; b=LiowHAHaHUAMpdlFR0qN7G4RMqMen6UvaUK6BX6rUY4JwiopRGc7CZbG/aDy/Xo+tY XOn5Qd/XdN78psWXxdDDoEXbBBcJmTUrO7ZjXb9/7VVKsusuEbvK8ezE3zqmeqQ/dBA0 maavLGertJurfR37hh0xN4KQw6z7KgOL8kdWwJmUgSS79DuSJG0hLtbb+G/TceGwlYEp jhYi5iNa9Yj/xbKb4XsZkKI3mDvlZsxNYgK89YTEvAWFvTwQRlpDMV6Fagb47uBvmeJ+ hyHkpZjCkph4o5A1Nn2bReSl3U837VyStkFsI1AUweSEvB+1DLXnrIWqMuczBFgZwtfy JxgQ== 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=nx6R5ORiCtnIpFZu+0txlPDpQ866FHk77wANc0bUqAI=; b=hE1vaHLu+DDuSTbgpa2/V1ygAoaMDFOwSMD0qP/leYtlafdCd+/DojOOe7L5Ytl7Ju 8toky+i4GvpZayXvRimMUmcyIn3SQGWOmsslK5Sm/h2RNCq/yobcf+nwZ8oOESmdxoJg E0ASTVTMLZo0a3kjg1Lk/8FW0XSkHS/LLTapNBE3fTURnmCjyjT4H6daTCNoPkTHEndK x9mmNa7OGi4kc/LP5eB+BlEi8Afj7Etsyn/tOj0acon5ffbU2IhwGilyi/PkvQcDcTUn 7G2gKyZGnvUpb7V33C1kJVwSnLj7zPOaaWeVBI/Rw/uKmfUFdOXQYKFgoSBtF6n+3KBu s24w== X-Gm-Message-State: AOAM5316phAANeDKaUYgZuLY63sXTSTFnuYMGUHv+XviDtgcMjAojA7I 5fwksXzbOJ0SZg1Bxn81LLkoqrPIk/vs4g== X-Google-Smtp-Source: ABdhPJw2+E75L/amcMYxB7PZVpDwE8JFQsGQc6/m+RgVKVFczfaVYlCvkNM5ek6oh86zQpbK4Vne1w== X-Received: by 2002:a0c:be86:: with SMTP id n6mr22740714qvi.61.1614735991489; Tue, 02 Mar 2021 17:46:31 -0800 (PST) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Cc: george.dunlap@citrix.com, Nick Rosbrook , Ian Jackson , Wei Liu , Anthony PERARD Subject: [RFC v2 7/7] libxl: replace LIBXL_DEFINE_DEVICE* macro usage with generated code Date: Tue, 2 Mar 2021 20:46:19 -0500 Message-Id: <25b500b54881b8ff3e86c7da5b8a977884471b01.1614734296.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Allow the gentypes.py script to write generated function output to _libxl_types.c, and remove the LIBXL_DEFINE_DEVICE* macro calls in the appropriate locations. Signed-off-by: Nick Rosbrook --- Note: This commit does not build; there is more work to be done, particularly around accessing libxl__device_from* functions, as well as libxl__device__add functions. --- tools/libs/light/gentypes.py | 8 +++++--- tools/libs/light/libxl_9pfs.c | 2 -- tools/libs/light/libxl_console.c | 2 -- tools/libs/light/libxl_disk.c | 2 -- tools/libs/light/libxl_nic.c | 2 -- tools/libs/light/libxl_pvcalls.c | 2 -- tools/libs/light/libxl_usb.c | 3 --- tools/libs/light/libxl_vdispl.c | 2 -- tools/libs/light/libxl_vkb.c | 1 - tools/libs/light/libxl_vsnd.c | 2 -- tools/libs/light/libxl_vtpm.c | 2 -- 11 files changed, 5 insertions(+), 23 deletions(-) diff --git a/tools/libs/light/gentypes.py b/tools/libs/light/gentypes.py index 9f1856399a..5b72b4613e 100644 --- a/tools/libs/light/gentypes.py +++ b/tools/libs/light/gentypes.py @@ -874,12 +874,14 @@ if __name__ == '__main__': f.write("\n") for func in funcs: + f.write("\n") + if type(func) is idl.DeviceAddFunction: - _ = libxl_func_define_device_add(func) + f.write(libxl_func_define_device_add(func)) elif type(func) is idl.DeviceRemoveFunction: - _ = libxl_func_define_device_remove(func) + f.write(libxl_func_define_device_remove(func)) elif type(func) is idl.DeviceDestroyFunction: - _ = libxl_func_define_device_destroy(func) + f.write(libxl_func_define_device_destroy(func)) else: raise Exception("Unexpected Function class %s" % type(func)) diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index 5ab0d3aa21..f4875ea996 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -43,8 +43,6 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid, static LIBXL_DEFINE_UPDATE_DEVID(p9) static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9) -LIBXL_DEFINE_DEVICE_REMOVE(p9) - DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, p9s, .skip_attach = 1, .set_xenstore_config = (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_console.c b/tools/libs/light/libxl_console.c index d8b2bc5465..726bee3b16 100644 --- a/tools/libs/light/libxl_console.c +++ b/tools/libs/light/libxl_console.c @@ -723,8 +723,6 @@ static LIBXL_DEFINE_UPDATE_DEVID(vfb) static LIBXL_DEFINE_DEVICE_FROM_TYPE(vfb) /* vfb */ -LIBXL_DEFINE_DEVICE_REMOVE(vfb) - DEFINE_DEVICE_TYPE_STRUCT(vfb, VFB, vfbs, .skip_attach = 1, .set_xenstore_config = (device_set_xenstore_config_fn_t) diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index 411ffeaca6..16d2667d3a 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -1320,9 +1320,7 @@ out: * libxl_device_disk_destroy * libxl_device_disk_safe_remove */ -LIBXL_DEFINE_DEVICE_ADD(disk) LIBXL_DEFINE_DEVICES_ADD(disk) -LIBXL_DEFINE_DEVICE_REMOVE(disk) LIBXL_DEFINE_DEVICE_SAFE_REMOVE(disk) static int libxl_device_disk_compare(const libxl_device_disk *d1, diff --git a/tools/libs/light/libxl_nic.c b/tools/libs/light/libxl_nic.c index 0b45469dca..f77e1a07a5 100644 --- a/tools/libs/light/libxl_nic.c +++ b/tools/libs/light/libxl_nic.c @@ -525,9 +525,7 @@ static LIBXL_DEFINE_UPDATE_DEVID(nic) static LIBXL_DEFINE_DEVICE_FROM_TYPE(nic) LIBXL_DEFINE_DEVID_TO_DEVICE(nic) -LIBXL_DEFINE_DEVICE_ADD(nic) LIBXL_DEFINE_DEVICES_ADD(nic) -LIBXL_DEFINE_DEVICE_REMOVE(nic) DEFINE_DEVICE_TYPE_STRUCT(nic, VIF, nics, .update_config = libxl_device_nic_update_config, diff --git a/tools/libs/light/libxl_pvcalls.c b/tools/libs/light/libxl_pvcalls.c index 1fbedf651c..6816cc3d4d 100644 --- a/tools/libs/light/libxl_pvcalls.c +++ b/tools/libs/light/libxl_pvcalls.c @@ -32,6 +32,4 @@ static LIBXL_DEFINE_DEVICE_FROM_TYPE(pvcallsif) #define libxl_device_pvcallsif_list NULL #define libxl_device_pvcallsif_compare NULL -LIBXL_DEFINE_DEVICE_REMOVE(pvcallsif) - DEFINE_DEVICE_TYPE_STRUCT(pvcallsif, PVCALLS, pvcallsifs); diff --git a/tools/libs/light/libxl_usb.c b/tools/libs/light/libxl_usb.c index c5ae59681c..af5230b261 100644 --- a/tools/libs/light/libxl_usb.c +++ b/tools/libs/light/libxl_usb.c @@ -547,9 +547,7 @@ static void device_usbctrl_add_done(libxl__egc *egc, aodev->callback(egc, aodev); } -LIBXL_DEFINE_DEVICE_ADD(usbctrl) static LIBXL_DEFINE_DEVICES_ADD(usbctrl) -LIBXL_DEFINE_DEVICE_REMOVE_CUSTOM(usbctrl) static int libxl__device_usbdev_list_for_usbctrl(libxl__gc *gc, uint32_t domid, libxl_devid usbctrl, @@ -1865,7 +1863,6 @@ static void device_usbdev_add_done(libxl__egc *egc, aodev->callback(egc, aodev); } -LIBXL_DEFINE_DEVICE_ADD(usbdev) static LIBXL_DEFINE_DEVICES_ADD(usbdev) static void device_usbdev_remove_timeout(libxl__egc *egc, diff --git a/tools/libs/light/libxl_vdispl.c b/tools/libs/light/libxl_vdispl.c index 60427c76c2..13b6c2be99 100644 --- a/tools/libs/light/libxl_vdispl.c +++ b/tools/libs/light/libxl_vdispl.c @@ -202,8 +202,6 @@ static LIBXL_DEFINE_UPDATE_DEVID(vdispl) static LIBXL_DEFINE_DEVICES_ADD(vdispl) LIBXL_DEFINE_DEVID_TO_DEVICE(vdispl) -LIBXL_DEFINE_DEVICE_ADD(vdispl) -LIBXL_DEFINE_DEVICE_REMOVE(vdispl) LIBXL_DEFINE_DEVICE_LIST(vdispl) DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL, vdispls, diff --git a/tools/libs/light/libxl_vkb.c b/tools/libs/light/libxl_vkb.c index bb88059f93..5b552c262f 100644 --- a/tools/libs/light/libxl_vkb.c +++ b/tools/libs/light/libxl_vkb.c @@ -334,7 +334,6 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb) #define libxl_device_vkb_compare NULL LIBXL_DEFINE_DEVICE_LIST(vkb) -LIBXL_DEFINE_DEVICE_REMOVE(vkb) DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD, vkbs, .skip_attach = 1, diff --git a/tools/libs/light/libxl_vsnd.c b/tools/libs/light/libxl_vsnd.c index bb7942bbc9..16f448c74e 100644 --- a/tools/libs/light/libxl_vsnd.c +++ b/tools/libs/light/libxl_vsnd.c @@ -666,8 +666,6 @@ out: static LIBXL_DEFINE_UPDATE_DEVID(vsnd) static LIBXL_DEFINE_DEVICES_ADD(vsnd) -LIBXL_DEFINE_DEVICE_ADD(vsnd) -LIBXL_DEFINE_DEVICE_REMOVE(vsnd) LIBXL_DEFINE_DEVICE_LIST(vsnd) DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND, vsnds, diff --git a/tools/libs/light/libxl_vtpm.c b/tools/libs/light/libxl_vtpm.c index 0148c572d4..8dcc965860 100644 --- a/tools/libs/light/libxl_vtpm.c +++ b/tools/libs/light/libxl_vtpm.c @@ -227,8 +227,6 @@ static LIBXL_DEFINE_UPDATE_DEVID(vtpm) static LIBXL_DEFINE_DEVICE_FROM_TYPE(vtpm) static LIBXL_DEFINE_DEVICES_ADD(vtpm) -LIBXL_DEFINE_DEVICE_ADD(vtpm) -LIBXL_DEFINE_DEVICE_REMOVE(vtpm) LIBXL_DEFINE_DEVICE_LIST(vtpm) DEFINE_DEVICE_TYPE_STRUCT(vtpm, VTPM, vtpms,