direct-io.hg

changeset 5505:a263fcd442b2

bitkeeper revision 1.1713.3.15 (42b53156pSSLSNwQRl51kxkAtBPgTQ)

xsnode.py:
fileno is a method now.
netif.py, blkif.py, XendDomainInfo.py:
Cleanup interface to DB.
xs.c:
Don't special case xs_fileno.
Update comments.
Signed-off-by: Mike Wray <mike.wray@hp.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Sun Jun 19 08:48:22 2005 +0000 (2005-06-19)
parents a9acc88e9d79
children 182cb4aae17d
files tools/python/xen/lowlevel/xs/xs.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/server/blkif.py tools/python/xen/xend/server/netif.py tools/python/xen/xend/xenstore/xsnode.py
line diff
     1.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Fri Jun 17 18:18:44 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Sun Jun 19 08:48:22 2005 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  /* 
     1.5 -    Python interface to the Xen Store Daemon.
     1.6 -    Copyright (C) 2005 Mike Wray Hewlett-Packard
     1.7 -*/
     1.8 + * Python interface to the Xen Store Daemon.
     1.9 + * Copyright (C) 2005 Mike Wray Hewlett-Packard
    1.10 + */
    1.11  
    1.12  #include <Python.h>
    1.13  
    1.14 @@ -196,6 +196,7 @@ static PyObject *xspy_mkdir(PyObject *se
    1.15  #define xspy_rm_doc "\n"			\
    1.16  	"Remove a path.\n"			\
    1.17  	" path [string] : path to remove\n"	\
    1.18 +	"\n"					\
    1.19  	"Returns: [int] 0 on success.\n"	\
    1.20  	"Raises RuntimeError on error.\n"	\
    1.21  	"\n"
    1.22 @@ -339,13 +340,14 @@ static PyObject *xspy_set_permissions(Py
    1.23      return val;
    1.24  }
    1.25  
    1.26 -#define xspy_watch_doc "\n"					\
    1.27 -	"Watch a path, get notifications when it changes.\n"	\
    1.28 -	" path  [string] : xenstore path.\n"			\
    1.29 -	" token [string] : returned in watch notification\n"	\
    1.30 -	"\n"							\
    1.31 -	"Returns: [int] 0 on success.\n"			\
    1.32 -	"Raises RuntimeError on error.\n"			\
    1.33 +#define xspy_watch_doc "\n"						\
    1.34 +	"Watch a path, get notifications when it changes.\n"		\
    1.35 +	" path     [string] : xenstore path.\n"				\
    1.36 +	" priority [int]    : watch priority (default 0).\n"		\
    1.37 +	" token    [string] : returned in watch notification.\n"	\
    1.38 +	"\n"								\
    1.39 +	"Returns: [int] 0 on success.\n"				\
    1.40 +	"Raises RuntimeError on error.\n"				\
    1.41  	"\n"
    1.42  
    1.43  static PyObject *xspy_watch(PyObject *self, PyObject *args, PyObject *kwds)
    1.44 @@ -371,12 +373,14 @@ static PyObject *xspy_watch(PyObject *se
    1.45      return val;
    1.46  }
    1.47  
    1.48 -#define xspy_read_watch_doc "\n"		\
    1.49 -	"Read a watch notification.\n"		\
    1.50 -	" path [string]: xenstore path.\n"	\
    1.51 -	"\n"					\
    1.52 -	"Returns: [tuple] (path, token).\n"	\
    1.53 -	"Raises RuntimeError on error.\n"	\
    1.54 +#define xspy_read_watch_doc "\n"				\
    1.55 +	"Read a watch notification.\n"				\
    1.56 +	"The notification must be acknowledged by passing\n"	\
    1.57 +	"the token to acknowledge_watch().\n"			\
    1.58 +	" path [string]: xenstore path.\n"			\
    1.59 +	"\n"							\
    1.60 +	"Returns: [tuple] (path, token).\n"			\
    1.61 +	"Raises RuntimeError on error.\n"			\
    1.62  	"\n"
    1.63  
    1.64  static PyObject *xspy_read_watch(PyObject *self, PyObject *args,
    1.65 @@ -408,7 +412,7 @@ static PyObject *xspy_read_watch(PyObjec
    1.66  
    1.67  #define xspy_acknowledge_watch_doc "\n"					\
    1.68  	"Acknowledge a watch notification that has been read.\n"	\
    1.69 -	" token [string] : returned in watch notification\n"		\
    1.70 +	" token [string] : from the watch notification\n"		\
    1.71  	"\n"								\
    1.72  	"Returns: [int] 0 on success.\n"				\
    1.73  	"Raises RuntimeError on error.\n"				\
    1.74 @@ -499,7 +503,7 @@ static PyObject *xspy_transaction_start(
    1.75  #define xspy_transaction_end_doc "\n"					\
    1.76  	"End the current transaction.\n"				\
    1.77  	"Attempts to commit the transaction unless abort is true.\n"	\
    1.78 -	" abort [int]: Abort flag..\n"					\
    1.79 +	" abort [int]: abort flag (default 0).\n"			\
    1.80  	"\n"								\
    1.81  	"Returns: [int] 0 on success.\n"				\
    1.82  	"Raises RuntimeError on error.\n"				\
    1.83 @@ -556,10 +560,7 @@ static PyObject *xspy_introduce_domain(P
    1.84      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    1.85                                       &dom, &page, &port, &path))
    1.86          goto exit;
    1.87 -    printf("%s> dom=%u page=0x%08lx port=%u path=%s\n", __FUNCTION__, dom,
    1.88 -	   page, port, path);
    1.89      xsval = xs_introduce_domain(xh, dom, page, port, path);
    1.90 -    printf("%s> xsval=%d\n", __FUNCTION__, xsval);
    1.91      val = pyvalue_int(xsval);
    1.92   exit:
    1.93      return val;
    1.94 @@ -590,9 +591,7 @@ static PyObject *xspy_release_domain(PyO
    1.95      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    1.96                                       &dom))
    1.97          goto exit;
    1.98 -    printf("%s> dom=%u\n", __FUNCTION__, dom);
    1.99      xsval = xs_release_domain(xh, dom);
   1.100 -    printf("%s> xsval=%d\n", __FUNCTION__, xsval);
   1.101      val = pyvalue_int(xsval);
   1.102   exit:
   1.103      return val;
   1.104 @@ -651,6 +650,28 @@ static PyObject *xspy_shutdown(PyObject 
   1.105      return val;
   1.106  }
   1.107  
   1.108 +#define xspy_fileno_doc "\n"					\
   1.109 +	"Get the file descriptor of the xenstore socket.\n"	\
   1.110 +	"Allows an xs object to be passed to select().\n"	\
   1.111 +	"\n"							\
   1.112 +	"Returns: [int] file descriptor.\n"			\
   1.113 +	"\n"
   1.114 +
   1.115 +static PyObject *xspy_fileno(PyObject *self, PyObject *args, PyObject *kwds)
   1.116 +{
   1.117 +    static char *kwd_spec[] = { NULL };
   1.118 +    static char *arg_spec = "";
   1.119 +
   1.120 +    struct xs_handle *xh = xshandle(self);
   1.121 +    PyObject *val = NULL;
   1.122 +
   1.123 +    if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec))
   1.124 +        goto exit;
   1.125 +    val = PyInt_FromLong((xh ? xs_fileno(xh) : -1));
   1.126 + exit:
   1.127 +    return val;
   1.128 +}
   1.129 +
   1.130  #define XSPY_METH(_name) {			\
   1.131      .ml_name  = #_name,				\
   1.132      .ml_meth  = (PyCFunction) xspy_ ## _name,	\
   1.133 @@ -675,17 +696,14 @@ static PyMethodDef xshandle_methods[] = 
   1.134       XSPY_METH(release_domain),
   1.135       XSPY_METH(close),
   1.136       XSPY_METH(shutdown),
   1.137 +     XSPY_METH(fileno),
   1.138       { /* Terminator. */ },
   1.139  };
   1.140  
   1.141  static PyObject *xshandle_getattr(PyObject *self, char *name)
   1.142  {
   1.143      PyObject *val = NULL;
   1.144 -    if (strcmp(name, "fileno") == 0) {
   1.145 -        struct xs_handle *xh = xshandle(self);
   1.146 -        val = PyInt_FromLong((xh ? xs_fileno(xh) : -1));
   1.147 -    } else
   1.148 -        val = Py_FindMethod(xshandle_methods, self, name);
   1.149 +    val = Py_FindMethod(xshandle_methods, self, name);
   1.150      return val;
   1.151  }
   1.152  
   1.153 @@ -754,7 +772,7 @@ static PyMethodDef xs_methods[] = {
   1.154        "Raises RuntimeError on error.\n"
   1.155        "\n"
   1.156      },
   1.157 -    { NULL, NULL, 0, NULL }
   1.158 +    { /* Terminator. */ }
   1.159  };
   1.160  
   1.161  PyMODINIT_FUNC initxs (void)
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jun 17 18:18:44 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sun Jun 19 08:48:22 2005 +0000
     2.3 @@ -511,7 +511,7 @@ class XendDomainInfo:
     2.4              self.configure_restart()
     2.5              self.construct_image()
     2.6              self.configure()
     2.7 -            self.exportToDB()
     2.8 +            self.exportToDB(save=True)
     2.9          except Exception, ex:
    2.10              # Catch errors, cleanup and re-raise.
    2.11              print 'Domain construction error:', ex
    2.12 @@ -523,7 +523,7 @@ class XendDomainInfo:
    2.13      def register_domain(self):
    2.14          xd = get_component('xen.xend.XendDomain')
    2.15          xd._add_domain(self)
    2.16 -        self.exportToDB()
    2.17 +        self.exportToDB(save=True)
    2.18  
    2.19      def configure_cpus(self, config):
    2.20          try:
     3.1 --- a/tools/python/xen/xend/server/blkif.py	Fri Jun 17 18:18:44 2005 +0000
     3.2 +++ b/tools/python/xen/xend/server/blkif.py	Sun Jun 19 08:48:22 2005 +0000
     3.3 @@ -50,6 +50,9 @@ class BlkifBackend:
     3.4      def getId(self):
     3.5          return self.id
     3.6  
     3.7 +    def getEvtchn(self):
     3.8 +        return self.evtchn
     3.9 +
    3.10      def closeEvtchn(self):
    3.11          if self.evtchn:
    3.12              channel.eventChannelClose(self.evtchn)
    3.13 @@ -198,7 +201,7 @@ class BlkDev(Dev):
    3.14          backend = self.getBackend()
    3.15          if backend and backend.evtchn:
    3.16              db = self.db.addChild("evtchn")
    3.17 -            backend.evtchn.exportToDB(db, save=save)
    3.18 +            backend.evtchn.saveToDB(db, save=save)
    3.19  
    3.20      def init(self, recreate=False, reboot=False):
    3.21          self.frontendDomain = self.getDomain()
     4.1 --- a/tools/python/xen/xend/server/netif.py	Fri Jun 17 18:18:44 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/netif.py	Sun Jun 19 08:48:22 2005 +0000
     4.3 @@ -95,7 +95,7 @@ class NetDev(Dev):
     4.4          Dev.exportToDB(self, save=save)
     4.5          if self.evtchn:
     4.6              db = self.db.addChild("evtchn")
     4.7 -            self.evtchn.exportToDB(db, save=save)
     4.8 +            self.evtchn.saveToDB(db, save=save)
     4.9  
    4.10      def init(self, recreate=False, reboot=False):
    4.11          self.destroyed = False
     5.1 --- a/tools/python/xen/xend/xenstore/xsnode.py	Fri Jun 17 18:18:44 2005 +0000
     5.2 +++ b/tools/python/xen/xend/xenstore/xsnode.py	Sun Jun 19 08:48:22 2005 +0000
     5.3 @@ -64,7 +64,7 @@ class Watcher:
     5.4  
     5.5      def fileno(self):
     5.6          if self.xs:
     5.7 -            return self.xs.fileno
     5.8 +            return self.xs.fileno()
     5.9          else:
    5.10              return -1
    5.11