From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 D723FC433ED for ; Tue, 4 May 2021 15:03:20 +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 619836100A for ; Tue, 4 May 2021 15:03:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 619836100A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.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.122512.231065 (Exim 4.92) (envelope-from ) id 1ldwZh-000560-Rz; Tue, 04 May 2021 15:03:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 122512.231065; Tue, 04 May 2021 15:03: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 1ldwZh-00055t-Or; Tue, 04 May 2021 15:03:01 +0000 Received: by outflank-mailman (input) for mailman id 122512; Tue, 04 May 2021 15:03: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 1ldwZg-00055m-Rm for xen-devel@lists.xenproject.org; Tue, 04 May 2021 15:03:00 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c89b14fa-7a20-4a7f-8e60-a47346bcbc15; Tue, 04 May 2021 15:02:59 +0000 (UTC) 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: c89b14fa-7a20-4a7f-8e60-a47346bcbc15 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620140579; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bZGXlmwhAsPJxG4m5DpEz4VqP2Ra9gEBwL/WyieoUwQ=; b=egsxCaPy19OH+ZQCIiyqhAWWcmVjatGhEeQJ4+pwjd4fP/ePC5yoakew YJaWI9Gs8kbPtKrk/1yRJ9hI7H2NSW517Sp4n1lYfsS6oP30PtDw3GJsU vy/fVU33v/aH3ugw7plkTKEUCu/ZVElNpmf78UCTeLTFpXAK2sJxyX8SF U=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: LXlZInGMc84TC13rmkdvYlglLgEPiYzHshJbYVslgnsuVGucC3WnlT2tt2Q9DeaVZATqjJYJUP +YCNFFzNunCebmOumatmw/dVL2cTDBwuC5HHa58nbSYoC5vhDOCn+HY9R30axF8FAcAJkrQdnC IJlehiPu1xdHxgIQnwp7cnpclin2JRD3+mgQzRqsrB8vBlv88h9RWAdynnRAfld7SbKJO7jorX S+X1NcJn2ULIgSKucAN7iB/nFcYfUO0W+ASpaJbCFu766EPyrYlWAjg4Jo8c8wRn3W2aPs5akj erc= X-SBRS: 5.1 X-MesageID: 43044107 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:wNupua/pajgfEffGhfhuk+BJI+orLtY04lQ7vn1ZYzY9SK2lvu qpm+kW0gKxpTYKQXc7mc2BPq7oewK6ybde544NMbC+GDT3oWfAFvAH0aLOyyDtcheTysdzzq FlGpIQNPTRChxAgd/+8E2EFb8bsb+62YSJocub8Ht3VwFtbMhbnmJEIyKWCFd/SgUDJbdRLu v+2uN9qzCteWsaY62AbxFvNYX+jubGm578bRkNCwRP0njtsRqS5KPnCB/d5x8CUlp0sM4f2F LYmA/07LjLiZGG4yLbvlW806hr X-IronPort-AV: E=Sophos;i="5.82,272,1613451600"; d="scan'208";a="43044107" Date: Tue, 4 May 2021 16:02:55 +0100 From: Anthony PERARD To: Nick Rosbrook CC: , , "Nick Rosbrook" , Ian Jackson , Wei Liu Subject: Re: [RFC v2 6/7] libxl: implement device add/remove/destroy functions generation Message-ID: References: <5986715fe1d677533b67c06e9561cd716716d46a.1614734296.git.rosbrookn@ainfosec.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <5986715fe1d677533b67c06e9561cd716716d46a.1614734296.git.rosbrookn@ainfosec.com> On Tue, Mar 02, 2021 at 08:46:18PM -0500, Nick Rosbrook wrote: > +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' That's kind of hard to read, I think we could use python's triple-quote (or triple double-quote) ''' or """ to have a multi-line string and remove all those \t \n Something like: s = ''' {ret} {func}({params}) {{ return ERROR_FAIL; libxl__{rawname}(gc); }} '''.format(ret=return_type, func=func.name, params=params, rawname=func.rawname) That would produce some extra indentation in the generated C file, but that doesn't matter to me. They could be removed with textwrap.dedent() if needed. Thanks, -- Anthony PERARD