xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Pawel Wieczorkiewicz <wipawel@amazon.de>
To: xen-devel@lists.xen.org
Cc: mpohlack@amazon.de, ross.lagerwall@citrix.com,
	Pawel Wieczorkiewicz <wipawel@amazon.de>,
	Marek Marczykowski-Gorecki <marmarek@invisiblethingslab.com>,
	konrad.wilk@oracle.com
Subject: [livepatch: independ. modules 3/3] python: Add XC binding for Xen build ID
Date: Tue, 16 Apr 2019 12:58:32 +0000	[thread overview]
Message-ID: <20190416125832.32881-3-wipawel@amazon.de> (raw)
In-Reply-To: <20190416125832.32881-1-wipawel@amazon.de>

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 <wipawel@amazon.de>
Reviewed-by: Martin Mazein <amazein@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>

CC: Marek Marczykowski-Gorecki <marmarek@invisiblethingslab.com>
---
 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 cc8175a11e..66db18ec3a 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -1202,6 +1202,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;
@@ -2350,6 +2370,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"
-- 
2.16.5




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Christian Schlaeger, Ralf Herbrich
Ust-ID: DE 289 237 879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-04-16 12:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 12:58 [livepatch: independ. modules 1/3] livepatch: Always check hypervisor build ID upon hotpatch upload Pawel Wieczorkiewicz
2019-04-16 12:58 ` [livepatch: independ. modules 2/3] livepatch: Allow to override inter-modules buildid dependency Pawel Wieczorkiewicz
2019-08-20 13:28   ` [Xen-devel] [livepatch: independ. modules v2 " Pawel Wieczorkiewicz
2019-08-20 13:35     ` Julien Grall
2019-08-20 14:09       ` Wieczorkiewicz, Pawel
2019-08-20 14:28         ` Julien Grall
2019-08-20 14:52           ` Wieczorkiewicz, Pawel
2019-08-20 15:11             ` Julien Grall
2019-04-16 12:58 ` Pawel Wieczorkiewicz [this message]
2019-08-15  9:44   ` [Xen-devel] [livepatch: independ. modules 3/3] python: Add XC binding for Xen build ID Pawel Wieczorkiewicz
2019-08-16 12:47     ` Wei Liu
2019-08-16 12:52       ` Wieczorkiewicz, Pawel
2019-08-19 20:40     ` Marek Marczykowski-Górecki
2019-08-20 11:04       ` Wieczorkiewicz, Pawel
2019-08-20 12:51     ` [Xen-devel] [livepatch: independ. modules v3 " Pawel Wieczorkiewicz
2019-08-20 13:00       ` Marek Marczykowski-Górecki
2019-04-23 15:47 ` [livepatch: independ. modules 1/3] livepatch: Always check hypervisor build ID upon hotpatch upload Konrad Rzeszutek Wilk
2019-04-29  9:46 ` [livepatch: independ. modules v2 " Pawel Wieczorkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416125832.32881-3-wipawel@amazon.de \
    --to=wipawel@amazon.de \
    --cc=konrad.wilk@oracle.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=mpohlack@amazon.de \
    --cc=ross.lagerwall@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).