ia64/xen-unstable

changeset 6921:931526414a64

Add bindings for xs_get_domain_path().
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Sep 16 22:27:04 2005 +0000 (2005-09-16)
parents 6a48f88101d3
children 8ff691d008f4
files tools/python/xen/lowlevel/xs/xs.c tools/python/xen/xend/xenstore/xsutil.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Fri Sep 16 20:12:42 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Fri Sep 16 22:27:04 2005 +0000
     1.3 @@ -812,6 +812,48 @@ static PyObject *xspy_shutdown(PyObject 
     1.4      return val;
     1.5  }
     1.6  
     1.7 +#define xspy_get_domain_path_doc "\n"			\
     1.8 +	"Return store path of domain.\n"		\
     1.9 +	" domid [int]: domain id\n"			\
    1.10 +	"\n"						\
    1.11 +	"Returns: [string] domain store path.\n"	\
    1.12 +	"         None if domid doesn't exist.\n"	\
    1.13 +	"Raises RuntimeError on error.\n"		\
    1.14 +	"\n"
    1.15 +
    1.16 +static PyObject *xspy_get_domain_path(PyObject *self, PyObject *args,
    1.17 +				      PyObject *kwds)
    1.18 +{
    1.19 +    static char *kwd_spec[] = { "domid", NULL };
    1.20 +    static char *arg_spec = "i";
    1.21 +    int domid = 0;
    1.22 +
    1.23 +    struct xs_handle *xh = xshandle(self);
    1.24 +    char *xsval = NULL;
    1.25 +    PyObject *val = NULL;
    1.26 +
    1.27 +    if (!xh)
    1.28 +        goto exit;
    1.29 +    if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    1.30 +                                     &domid))
    1.31 +        goto exit;
    1.32 +    Py_BEGIN_ALLOW_THREADS
    1.33 +    xsval = xs_get_domain_path(xh, domid);
    1.34 +    Py_END_ALLOW_THREADS
    1.35 +    if (!xsval) {
    1.36 +        if (errno == ENOENT) {
    1.37 +            Py_INCREF(Py_None);
    1.38 +            val = Py_None;
    1.39 +        } else
    1.40 +            PyErr_SetFromErrno(PyExc_RuntimeError);
    1.41 +        goto exit;
    1.42 +    }
    1.43 +    val = PyString_FromString(xsval);
    1.44 +    free(xsval);
    1.45 + exit:
    1.46 +    return val;
    1.47 +}
    1.48 +
    1.49  #define xspy_fileno_doc "\n"					\
    1.50  	"Get the file descriptor of the xenstore socket.\n"	\
    1.51  	"Allows an xs object to be passed to select().\n"	\
    1.52 @@ -858,6 +900,7 @@ static PyMethodDef xshandle_methods[] = 
    1.53       XSPY_METH(release_domain),
    1.54       XSPY_METH(close),
    1.55       XSPY_METH(shutdown),
    1.56 +     XSPY_METH(get_domain_path),
    1.57       XSPY_METH(fileno),
    1.58       { /* Terminator. */ },
    1.59  };
     2.1 --- a/tools/python/xen/xend/xenstore/xsutil.py	Fri Sep 16 20:12:42 2005 +0000
     2.2 +++ b/tools/python/xen/xend/xenstore/xsutil.py	Fri Sep 16 22:27:04 2005 +0000
     2.3 @@ -18,3 +18,6 @@ def xshandle():
     2.4  
     2.5  def IntroduceDomain(domid, page, port, path):
     2.6      return xshandle().introduce_domain(domid, page, port, path)
     2.7 +
     2.8 +def GetDomainPath(domid):
     2.9 +    return xshandle().get_domain_path(domid)