From patchwork Tue Aug 20 12:51:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Wieczorkiewicz, Pawel" X-Patchwork-Id: 11103773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 759FA1399 for ; Tue, 20 Aug 2019 12:53:14 +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 50D2022CE3 for ; Tue, 20 Aug 2019 12:53:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="odbxgJvK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50D2022CE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i03c4-0000kf-Ua; Tue, 20 Aug 2019 12:51:48 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i03c3-0000kU-J5 for xen-devel@lists.xen.org; Tue, 20 Aug 2019 12:51:47 +0000 X-Inumbo-ID: 43f55632-c349-11e9-8bf7-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 43f55632-c349-11e9-8bf7-12813bfff9fa; Tue, 20 Aug 2019 12:51: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=1566305505; x=1597841505; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hVoPdeyWBLpUeHrB6jau8Zmw2/d8DmPJ6X4Zx4H66ZY=; b=odbxgJvK6xXUtHOO6xkYyzdZGlQX9CfCPphA2T83u+QgP57U6SupFM2P 478Ar/06vX43v2CTBhIS/QcTKjRA8DnJSEfX05lEmooIVDBWWHvrIwlzV flxJ56aoLe7UCUgPsn2+NX1VQCTJgNxULoHOhijcMYtoV35g05qaniJuy k=; X-IronPort-AV: E=Sophos;i="5.64,408,1559520000"; d="scan'208";a="821632886" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 20 Aug 2019 12:51:42 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com (Postfix) with ESMTPS id 20C00A1C2B; Tue, 20 Aug 2019 12:51:42 +0000 (UTC) Received: from EX13D05EUB002.ant.amazon.com (10.43.166.45) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 20 Aug 2019 12:51:23 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D05EUB002.ant.amazon.com (10.43.166.45) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Tue, 20 Aug 2019 12:51:21 +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; Tue, 20 Aug 2019 12:51:20 +0000 From: Pawel Wieczorkiewicz To: Date: Tue, 20 Aug 2019 12:51:08 +0000 Message-ID: <20190820125108.104102-1-wipawel@amazon.de> X-Mailer: git-send-email 2.16.5 In-Reply-To: <20190815094400.126289-1-wipawel@amazon.de> References: <20190815094400.126289-1-wipawel@amazon.de> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [livepatch: independ. modules v3 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, amazein@amazon.de, xen-devel@lists.xenproject.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 minus sizeof(buildid->len)). Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Martin Mazein Reviewed-by: Andra-Irina Paraschiv Reviewed-by: Norbert Manthey Acked-by: Marek Marczykowski-Górecki --- v3: * Instead of allocating XC_PAGE_SIZE plus size of the len field, allocate one XC_PAGE_SIZE for the whole buildid struct. * Modify commit message to reflect the above change. 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..7ed4a253de 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(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"