From patchwork Thu Aug 15 09:44:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11095497 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 0B6FB14F7 for ; Thu, 15 Aug 2019 09:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC1A928869 for ; Thu, 15 Aug 2019 09:46:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E043F2886E; Thu, 15 Aug 2019 09:46:26 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, 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 6315628869 for ; Thu, 15 Aug 2019 09:46:26 +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 1hyCJL-0005Uu-Ma; Thu, 15 Aug 2019 09:44:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hyCJK-0005Um-GR for xen-devel@lists.xenproject.org; Thu, 15 Aug 2019 09:44:46 +0000 X-Inumbo-ID: 50b1dd5c-bf41-11e9-96f7-bc764e2007e4 Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 50b1dd5c-bf41-11e9-96f7-bc764e2007e4; Thu, 15 Aug 2019 09:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1565862285; x=1597398285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=R6w7bBOukGiWxc+2EZSJrHo/ukXGPMN8gR8UczrUSck=; b=ajQfgHnZ56Jjz9KxuzAQ0uspXH+WrWg7v952Fey48wzLsda1gJgEwhof CqPqGPUMG35pW8zNNxuY5Xi2pQFWC5lp0fAZ+0BKOetA0yoPX0DWn3/xQ McuJ14dqNLPqalVt/x/iuEBXyay/6gagvr8S2URGRB75mQ0SOJsnFddFy g=; X-IronPort-AV: E=Sophos;i="5.64,388,1559520000"; d="scan'208";a="415542196" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-2225282c.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 15 Aug 2019 09:44:44 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2c-2225282c.us-west-2.amazon.com (Postfix) with ESMTPS id 12E07A2936; Thu, 15 Aug 2019 09:44:44 +0000 (UTC) Received: from EX13D03EUC003.ant.amazon.com (10.43.164.192) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 15 Aug 2019 09:44:43 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 15 Aug 2019 09:44:42 +0000 Received: from dev-dsk-wipawel-1a-0c4e6d58.eu-west-1.amazon.com (10.4.134.33) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 15 Aug 2019 09:44:40 +0000 From: Pawel Wieczorkiewicz To: Date: Thu, 15 Aug 2019 09:44:00 +0000 Message-ID: <20190815094400.126289-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20190416125832.32881-3-wipawel@amazon.de> References: <20190416125832.32881-3-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [livepatch: independ. modules 3/3] python: Add XC binding for Xen build ID X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 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?= , mpohlack@amazon.de, wipawel@amazon.de, xen-devel@lists.xenproject.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extend the list of xc() object methods with additional one to display Xen's buildid. The implementation follows the libxl implementation (e.g. max buildid size assumption being XC_PAGE_SIZE). Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Martin Mazein Reviewed-by: Andra-Irina Paraschiv Reviewed-by: Norbert Manthey Signed-off-by: Pawel Wieczorkiewicz > Reviewed-by: Martin Mazein > Reviewed-by: Andra-Irina Paraschiv > Reviewed-by: Norbert Manthey > --- v2: * No code change * Adding maintainers --- tools/python/xen/lowlevel/xc/xc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 522cbe3b9c..5459d6834d 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -1211,6 +1211,26 @@ out: return ret_obj ? ret_obj : pyxc_error_to_exception(self->xc_handle); } +static PyObject *pyxc_xenbuildid(XcObject *self) +{ + xen_build_id_t *buildid; + int i, r; + char *str; + + buildid = alloca(sizeof(buildid->len) + XC_PAGE_SIZE); + buildid->len = XC_PAGE_SIZE - sizeof(*buildid); + + r = xc_version(self->xc_handle, XENVER_build_id, buildid); + if ( r <= 0 ) + return pyxc_error_to_exception(self->xc_handle); + + str = alloca((r * 2) + 1); + for ( i = 0; i < r; i++ ) + snprintf(&str[i * 2], 3, "%02hhx", buildid->buf[i]); + + return Py_BuildValue("s", str); +} + static PyObject *pyxc_xeninfo(XcObject *self) { xen_extraversion_t xen_extra; @@ -2294,6 +2314,13 @@ static PyMethodDef pyxc_methods[] = { "Returns [dict]: information about Xen" " [None]: on failure.\n" }, + { "buildid", + (PyCFunction)pyxc_xenbuildid, + METH_NOARGS, "\n" + "Get Xen buildid\n" + "Returns [str]: Xen buildid" + " [None]: on failure.\n" }, + { "shadow_control", (PyCFunction)pyxc_shadow_control, METH_VARARGS | METH_KEYWORDS, "\n"