From patchwork Mon Apr 29 22:42:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 10922589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C73811390 for ; Mon, 29 Apr 2019 22:45:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACA462851E for ; Mon, 29 Apr 2019 22:45:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DD852853A; Mon, 29 Apr 2019 22:45:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E9542851E for ; Mon, 29 Apr 2019 22:45:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLEzA-0001i0-SS; Mon, 29 Apr 2019 22:42:56 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLEz9-0001hv-Nh for xen-devel@lists.xenproject.org; Mon, 29 Apr 2019 22:42:55 +0000 X-Inumbo-ID: 206f7818-6ad0-11e9-843c-bc764e045a96 Received: from out4-smtp.messagingengine.com (unknown [66.111.4.28]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 206f7818-6ad0-11e9-843c-bc764e045a96; Mon, 29 Apr 2019 22:42:54 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 0803A21FB7; Mon, 29 Apr 2019 18:42:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 29 Apr 2019 18:42:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Yq1ucv A489h2CHkR6Q9+P6k8g7+0IkiMStA0jH+/DLQ=; b=S+Htnf00GMXwHc0Q/tUKx+ XRAoCmqExJo/JPAHyT2EpW4Jgw8HwwUk77EyMpKJy9i3XeRwotq4bjBZyrTvyz+O v58P7u2O4YqIWsalMArLBy26N/K9zwd0QDs/nsKQb7iJGWoSx2IT2YViOU5v0U/h P/Ey91PRbwk3bifB7ViF6Qe9ZIaQNiaPMnO0brlCtKm1SCfYQZeJz2FqtKb6Qmqz Ec/oUfkkjEDeXgqodIdhsCA5yldA1JA94hTOuPCQdXBV+i+3N25pCg8hmeYTmpse P9u5xeEVAd2O1pXmb/NoX9AGGZqos28g7wVftAA+uTlLD/2IQLqp9Gf6D/peJDNQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrieefgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofggtghogfesthekredtredtjeenucfhrhhomhepofgrrhgvkhcu ofgrrhgtiiihkhhofihskhhiqdfikphrvggtkhhiuceomhgrrhhmrghrvghksehinhhvih hsihgslhgvthhhihhnghhslhgrsgdrtghomheqnecukfhppeeluddrieehrdefgedrfeef necurfgrrhgrmhepmhgrihhlfhhrohhmpehmrghrmhgrrhgvkhesihhnvhhishhisghlvg hthhhinhhgshhlrggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id D5DDDE4122; Mon, 29 Apr 2019 18:42:51 -0400 (EDT) From: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 00:42:52 +0200 Message-Id: <20190429224252.29000-1-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.17.2 MIME-Version: 1.0 Organization: Invisible Things Lab Subject: [Xen-devel] [PATCH v2] python: Adjust xc_physinfo wrapper for updated virt_caps bits X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Ian Jackson , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit f089fddd94 "xen: report PV capability in sysctl and use it in toolstack" changed meaning of virt_caps bit 1 - previously it was "directio", but was changed to "pv" and "directio" was moved to bit 2. Adjust python wrapper to use #defines for the bits values, and add reporting of both "pv_directio" and "hvm_directio". Signed-off-by: Marek Marczykowski-Górecki Acked-by: Wei Liu Acked-by: Ian Jackson --- This should be backported to 4.12 Cc: Ian Jackson Changes in v2: - Check XEN_SYSCTL_PHYSCAP_* instead of hardcoding bits values - Do not duplicate virtcap_names entries, instead append _directio in sprintf() --- tools/python/xen/lowlevel/xc/xc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index cc8175a11e..9c03c8272e 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -973,11 +973,17 @@ static PyObject *pyxc_physinfo(XcObject *self) xc_physinfo_t pinfo; char cpu_cap[128], virt_caps[128], *p; int i; - const char *virtcap_names[] = { "hvm", "hvm_directio" }; + const char *virtcap_names[] = { "hvm", "pv" }; + const unsigned virtcaps_bits[] = { XEN_SYSCTL_PHYSCAP_hvm, + XEN_SYSCTL_PHYSCAP_pv }; if ( xc_physinfo(self->xc_handle, &pinfo) != 0 ) return pyxc_error_to_exception(self->xc_handle); + /* + * Keep in sync with tools/xl/xl_info.c:output_xeninfo + * and struct xen_sysctl_physinfo (especially bit fields). + */ p = cpu_cap; *p = '\0'; for ( i = 0; i < sizeof(pinfo.hw_cap)/4; i++ ) @@ -986,9 +992,13 @@ static PyObject *pyxc_physinfo(XcObject *self) p = virt_caps; *p = '\0'; - for ( i = 0; i < 2; i++ ) - if ( (pinfo.capabilities >> i) & 1 ) + for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ ) + if ( pinfo.capabilities & virtcaps_bits[i] ) p += sprintf(p, "%s ", virtcap_names[i]); + if ( pinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio ) + for ( i = 0; i < ARRAY_SIZE(virtcaps_bits); i++ ) + if ( pinfo.capabilities & virtcaps_bits[i] ) + p += sprintf(p, "%s_directio ", virtcap_names[i]); if ( p != virt_caps ) *(p-1) = '\0';