All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Dingwall <james@dingwall.me.uk>
To: xen-devel@lists.xen.org
Subject: Python Bindings Status
Date: Thu, 12 Mar 2015 11:02:47 +0000	[thread overview]
Message-ID: <20150312110247.GA814@dingwall.me.uk> (raw)

Hi,

I am trying to use the libxl python bindings but having mixed levels of success.  I assume that the current 
status of this is unsupported as the build of the xl.so is disabled by default but perhaps completing the 
missing parts could be quite trivial?  I have managed to enabled the build with the patch the follow below.

I can for example:

from __future__ import print_function
from xen.lowlevel import xl
xlctx = xl.ctx()
for domu in xlctx.list_domains():
    print(xlctx.domid_to_name(domu.domid))

However other parts such as xl.version_info() do not seem to work.  Looking at the wrapper code which is 
generated in the build it seems that the object which would store the version information is allocated and 
initialised but never populated:

xen-4.5.0/tools/python/xen/lowlevel/xl/_pyxl_types.c:
static int Pyversion_info_init(Py_version_info *self, PyObject *args, PyObject *kwds)
{
    memset(&self->obj, 0, sizeof(self->obj));
    return genwrap__obj_init((PyObject *)self, args, kwds);
}

static PyObject *Pyversion_info_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
    Py_version_info *self = (Py_version_info *)type->tp_alloc(type, 0);
    if (self == NULL)
        return NULL;
    memset(&self->obj, 0, sizeof(self->obj));
    return (PyObject *)self;
}

I can see that the version_info libxl function takes a ctx argument but passing in xl.ctx() to xl.version_info() 
does not change anything, i.e. print(xl.version_info().xen_version_major) always shows 0.

What level of experience/effort would be required to address this?

Thanks,
James

diff --git a/tools/python/setup.py b/tools/python/setup.py
index 439c429..029869e 100644
--- a/tools/python/setup.py
+++ b/tools/python/setup.py
@@ -31,13 +31,13 @@ xl = Extension("xl",
                extra_compile_args = extra_compile_args,
                include_dirs       = [ PATH_XEN, PATH_LIBXL, PATH_LIBXC + "/include", "xen/lowlevel/xl" ],
                library_dirs       = [ PATH_LIBXL ],
-               libraries          = [ "xenlight" ],
-               depends            = [ PATH_LIBXL + "/libxenlight.so" ],
+               libraries          = [ "xenlight", "xlutil" ],
+               depends            = [ PATH_LIBXL + "/libxenlight.so", PATH_LIBXL + "/libxlutil.so" ],
                sources            = [ "xen/lowlevel/xl/xl.c", "xen/lowlevel/xl/_pyxl_types.c" ])

 plat = os.uname()[0]
 modules = [ xc, xs ]
-#modules.extend([ xl ])
+modules.extend([ xl ])

 setup(name            = 'xen',
       version         = '3.0',

             reply	other threads:[~2015-03-12 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 11:02 James Dingwall [this message]
2015-03-12 16:10 ` Python Bindings Status Ian Campbell

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=20150312110247.GA814@dingwall.me.uk \
    --to=james@dingwall.me.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.