direct-io.hg

changeset 6700:4856f000d35d

Make error reporting consistent.
Also note addition of Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS
which slipped in in previous merge changeset: allow other threads
to run during communication with xenstored.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Fri Sep 09 13:08:25 2005 +0000 (2005-09-09)
parents cdfa7dd00c44
children 47dca2f335de
files tools/python/xen/lowlevel/xs/xs.c
line diff
     1.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Fri Sep 09 10:20:25 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Fri Sep 09 13:08:25 2005 +0000
     1.3 @@ -89,7 +89,7 @@ static PyObject *xspy_read(PyObject *sel
     1.4      PyObject *val = NULL;
     1.5  
     1.6      if (!xh)
     1.7 -	goto exit;
     1.8 +        goto exit;
     1.9      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    1.10                                       &path))
    1.11          goto exit;
    1.12 @@ -97,13 +97,13 @@ static PyObject *xspy_read(PyObject *sel
    1.13      xsval = xs_read(xh, path, &xsval_n);
    1.14      Py_END_ALLOW_THREADS
    1.15      if (!xsval) {
    1.16 -        val = pyvalue_int(0);
    1.17 +        PyErr_SetFromErrno(PyExc_RuntimeError);
    1.18          goto exit;
    1.19      }
    1.20      val = PyString_FromStringAndSize(xsval, xsval_n);
    1.21   exit:
    1.22      if (xsval)
    1.23 -	free(xsval);
    1.24 +        free(xsval);
    1.25      return val;
    1.26  }
    1.27  
    1.28 @@ -114,7 +114,7 @@ static PyObject *xspy_read(PyObject *sel
    1.29  	" create [int]    : create flag, default 0.\n"		\
    1.30  	" excl   [int]    : exclusive flag, default 0.\n"	\
    1.31  	"\n"							\
    1.32 -	"Returns: [int] 0 on success.\n"			\
    1.33 +	"Returns None on success.\n"				\
    1.34  	"Raises RuntimeError on error.\n"			\
    1.35  	"\n"
    1.36  
    1.37 @@ -134,18 +134,23 @@ static PyObject *xspy_write(PyObject *se
    1.38      int xsval = 0;
    1.39  
    1.40      if (!xh)
    1.41 -	goto exit;
    1.42 +        goto exit;
    1.43      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
    1.44                                       &path, &data, &data_n, &create, &excl))
    1.45          goto exit;
    1.46      if (create)
    1.47 -	flags |= O_CREAT;
    1.48 +        flags |= O_CREAT;
    1.49      if (excl)
    1.50 -	flags |= O_EXCL;
    1.51 +        flags |= O_EXCL;
    1.52      Py_BEGIN_ALLOW_THREADS
    1.53      xsval = xs_write(xh, path, data, data_n, flags);
    1.54      Py_END_ALLOW_THREADS
    1.55 -    val = pyvalue_int(xsval);
    1.56 +    if (!xsval) {
    1.57 +        PyErr_SetFromErrno(PyExc_RuntimeError);
    1.58 +        goto exit;
    1.59 +    }
    1.60 +    Py_INCREF(Py_None);
    1.61 +    val = Py_None;
    1.62   exit:
    1.63      return val;
    1.64  }
    1.65 @@ -171,14 +176,14 @@ static PyObject *xspy_ls(PyObject *self,
    1.66      int i;
    1.67  
    1.68      if (!xh)
    1.69 -	goto exit;
    1.70 +        goto exit;
    1.71      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path))
    1.72          goto exit;
    1.73      Py_BEGIN_ALLOW_THREADS
    1.74      xsval = xs_directory(xh, path, &xsval_n);
    1.75      Py_END_ALLOW_THREADS
    1.76      if (!xsval) {
    1.77 -        val = pyvalue_int(0);
    1.78 +        PyErr_SetFromErrno(PyExc_RuntimeError);
    1.79          goto exit;
    1.80      }
    1.81      val = PyList_New(xsval_n);
    1.82 @@ -192,7 +197,7 @@ static PyObject *xspy_ls(PyObject *self,
    1.83  	"Make a directory.\n"					\
    1.84  	" path [string]: path to directory to create.\n"	\
    1.85  	"\n"							\
    1.86 -	"Returns: [int] 0 on success.\n"			\
    1.87 +	"Returns None on success.\n"				\
    1.88  	"Raises RuntimeError on error.\n"			\
    1.89  	"\n"
    1.90  
    1.91 @@ -207,13 +212,18 @@ static PyObject *xspy_mkdir(PyObject *se
    1.92      int xsval = 0;
    1.93  
    1.94      if (!xh)
    1.95 -	goto exit;
    1.96 +        goto exit;
    1.97      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path))
    1.98          goto exit;
    1.99      Py_BEGIN_ALLOW_THREADS
   1.100      xsval = xs_mkdir(xh, path);
   1.101      Py_END_ALLOW_THREADS
   1.102 -    val = pyvalue_int(xsval);
   1.103 +    if (!xsval) {
   1.104 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.105 +        goto exit;
   1.106 +    }
   1.107 +    Py_INCREF(Py_None);
   1.108 +    val = Py_None;
   1.109   exit:
   1.110      return val;
   1.111  }
   1.112 @@ -222,7 +232,7 @@ static PyObject *xspy_mkdir(PyObject *se
   1.113  	"Remove a path.\n"			\
   1.114  	" path [string] : path to remove\n"	\
   1.115  	"\n"					\
   1.116 -	"Returns: [int] 0 on success.\n"	\
   1.117 +	"Returns None on success.\n"		\
   1.118  	"Raises RuntimeError on error.\n"	\
   1.119  	"\n"
   1.120  
   1.121 @@ -237,13 +247,18 @@ static PyObject *xspy_rm(PyObject *self,
   1.122      int xsval = 0;
   1.123  
   1.124      if (!xh)
   1.125 -	goto exit;
   1.126 +        goto exit;
   1.127      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path))
   1.128          goto exit;
   1.129      Py_BEGIN_ALLOW_THREADS
   1.130      xsval = xs_rm(xh, path);
   1.131      Py_END_ALLOW_THREADS
   1.132 -    val = pyvalue_int(xsval);
   1.133 +    if (!xsval) {
   1.134 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.135 +        goto exit;
   1.136 +    }
   1.137 +    Py_INCREF(Py_None);
   1.138 +    val = Py_None;
   1.139   exit:
   1.140      return val;
   1.141  }
   1.142 @@ -257,7 +272,7 @@ static PyObject *xspy_rm(PyObject *self,
   1.143  	"\n"
   1.144  
   1.145  static PyObject *xspy_get_permissions(PyObject *self, PyObject *args,
   1.146 -				      PyObject *kwds)
   1.147 +                                      PyObject *kwds)
   1.148  {
   1.149      static char *kwd_spec[] = { "path", NULL };
   1.150      static char *arg_spec = "s|";
   1.151 @@ -270,7 +285,7 @@ static PyObject *xspy_get_permissions(Py
   1.152      int i;
   1.153  
   1.154      if (!xh)
   1.155 -	goto exit;
   1.156 +        goto exit;
   1.157      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path))
   1.158          goto exit;
   1.159      Py_BEGIN_ALLOW_THREADS
   1.160 @@ -297,12 +312,12 @@ static PyObject *xspy_get_permissions(Py
   1.161  	" path  [string] : xenstore path.\n"	\
   1.162  	" perms          : permissions.\n"	\
   1.163  	"\n"					\
   1.164 -	"Returns: [int] 0 on success.\n"	\
   1.165 +	"Returns None on success.\n"		\
   1.166  	"Raises RuntimeError on error.\n"	\
   1.167  	"\n"
   1.168  
   1.169  static PyObject *xspy_set_permissions(PyObject *self, PyObject *args,
   1.170 -				      PyObject *kwds)
   1.171 +                                      PyObject *kwds)
   1.172  {
   1.173      static char *kwd_spec[] = { "path", "perms", NULL };
   1.174      static char *arg_spec = "sO";
   1.175 @@ -335,7 +350,7 @@ static PyObject *xspy_set_permissions(Py
   1.176      }
   1.177      tuple0 = PyTuple_New(0);
   1.178      if (!tuple0)
   1.179 -	goto exit;
   1.180 +        goto exit;
   1.181      for (i = 0; i < xsperms_n; i++) {
   1.182          /* Domain the permissions apply to. */
   1.183          int dom = 0;
   1.184 @@ -343,22 +358,27 @@ static PyObject *xspy_set_permissions(Py
   1.185          int p_read = 0, p_write = 0;
   1.186          PyObject *p = PyList_GetItem(perms, i);
   1.187          if (!PyArg_ParseTupleAndKeywords(tuple0, p, perm_spec, perm_names,
   1.188 -					 &dom, &p_read, &p_write))
   1.189 +                                         &dom, &p_read, &p_write))
   1.190              goto exit;
   1.191          xsperms[i].id = dom;
   1.192          if (p_read)
   1.193 -	    xsperms[i].perms |= XS_PERM_READ;
   1.194 +            xsperms[i].perms |= XS_PERM_READ;
   1.195          if (p_write)
   1.196 -	    xsperms[i].perms |= XS_PERM_WRITE;
   1.197 +            xsperms[i].perms |= XS_PERM_WRITE;
   1.198      }
   1.199      Py_BEGIN_ALLOW_THREADS
   1.200      xsval = xs_set_permissions(xh, path, xsperms, xsperms_n);
   1.201      Py_END_ALLOW_THREADS
   1.202 -    val = pyvalue_int(xsval);
   1.203 +    if (!xsval) {
   1.204 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.205 +        goto exit;
   1.206 +    }
   1.207 +    Py_INCREF(Py_None);
   1.208 +    val = Py_None;
   1.209   exit:
   1.210      Py_XDECREF(tuple0);
   1.211      if (xsperms)
   1.212 -	free(xsperms);
   1.213 +        free(xsperms);
   1.214      return val;
   1.215  }
   1.216  
   1.217 @@ -389,7 +409,7 @@ static PyObject *xspy_watch(PyObject *se
   1.218      int xsval = 0;
   1.219  
   1.220      if (!xh)
   1.221 -	goto exit;
   1.222 +        goto exit;
   1.223      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, 
   1.224                                       &path, &token))
   1.225          goto exit;
   1.226 @@ -399,19 +419,19 @@ static PyObject *xspy_watch(PyObject *se
   1.227      xsval = xs_watch(xh, path, token_str);
   1.228      Py_END_ALLOW_THREADS
   1.229      if (!xsval) {
   1.230 -	val = PyErr_SetFromErrno(PyExc_RuntimeError);
   1.231 -	Py_DECREF(token);
   1.232 -	goto exit;
   1.233 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.234 +        Py_DECREF(token);
   1.235 +        goto exit;
   1.236      }
   1.237  
   1.238      for (i = 0; i < PyList_Size(xsh->watches); i++) {
   1.239 -	if (PyList_GetItem(xsh->watches, i) == Py_None) {
   1.240 -	    PyList_SetItem(xsh->watches, i, token);
   1.241 -	    break;
   1.242 -	}
   1.243 +        if (PyList_GetItem(xsh->watches, i) == Py_None) {
   1.244 +            PyList_SetItem(xsh->watches, i, token);
   1.245 +            break;
   1.246 +        }
   1.247      }
   1.248      if (i == PyList_Size(xsh->watches))
   1.249 -	PyList_Append(xsh->watches, token);
   1.250 +        PyList_Append(xsh->watches, token);
   1.251      Py_INCREF(Py_None);
   1.252      val = Py_None;
   1.253   exit:
   1.254 @@ -429,7 +449,7 @@ static PyObject *xspy_watch(PyObject *se
   1.255  	"\n"
   1.256  
   1.257  static PyObject *xspy_read_watch(PyObject *self, PyObject *args,
   1.258 -				 PyObject *kwds)
   1.259 +                                 PyObject *kwds)
   1.260  {
   1.261      static char *kwd_spec[] = { NULL };
   1.262      static char *arg_spec = "";
   1.263 @@ -442,33 +462,33 @@ static PyObject *xspy_read_watch(PyObjec
   1.264      int i;
   1.265  
   1.266      if (!xh)
   1.267 -	goto exit;
   1.268 +        goto exit;
   1.269      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec))
   1.270          goto exit;
   1.271      Py_BEGIN_ALLOW_THREADS
   1.272      xsval = xs_read_watch(xh);
   1.273      Py_END_ALLOW_THREADS
   1.274      if (!xsval) {
   1.275 -	val = PyErr_SetFromErrno(PyExc_RuntimeError);
   1.276 -	goto exit;
   1.277 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.278 +        goto exit;
   1.279      }
   1.280      if (sscanf(xsval[1], "%li", (unsigned long *)&token) != 1) {
   1.281 -	PyErr_SetString(PyExc_RuntimeError, "invalid token");
   1.282 -	goto exit;
   1.283 +        PyErr_SetString(PyExc_RuntimeError, "invalid token");
   1.284 +        goto exit;
   1.285      }
   1.286      for (i = 0; i < PyList_Size(xsh->watches); i++) {
   1.287 -	if (token == PyList_GetItem(xsh->watches, i))
   1.288 -	    break;
   1.289 +        if (token == PyList_GetItem(xsh->watches, i))
   1.290 +            break;
   1.291      }
   1.292      if (i == PyList_Size(xsh->watches)) {
   1.293 -	PyErr_SetString(PyExc_RuntimeError, "invalid token");
   1.294 -	goto exit;
   1.295 +        PyErr_SetString(PyExc_RuntimeError, "invalid token");
   1.296 +        goto exit;
   1.297      }
   1.298      /* Create tuple (path, token). */
   1.299      val = Py_BuildValue("(sO)", xsval[0], token);
   1.300   exit:
   1.301      if (xsval)
   1.302 -	free(xsval);
   1.303 +        free(xsval);
   1.304      return val;
   1.305  }
   1.306  
   1.307 @@ -481,7 +501,7 @@ static PyObject *xspy_read_watch(PyObjec
   1.308  	"\n"
   1.309  
   1.310  static PyObject *xspy_acknowledge_watch(PyObject *self, PyObject *args,
   1.311 -					PyObject *kwds)
   1.312 +                                        PyObject *kwds)
   1.313  {
   1.314      static char *kwd_spec[] = { "token", NULL };
   1.315      static char *arg_spec = "O";
   1.316 @@ -493,7 +513,7 @@ static PyObject *xspy_acknowledge_watch(
   1.317      int xsval = 0;
   1.318  
   1.319      if (!xh)
   1.320 -	goto exit;
   1.321 +        goto exit;
   1.322      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &token))
   1.323          goto exit;
   1.324      sprintf(token_str, "%li", (unsigned long)token);
   1.325 @@ -501,8 +521,8 @@ static PyObject *xspy_acknowledge_watch(
   1.326      xsval = xs_acknowledge_watch(xh, token_str);
   1.327      Py_END_ALLOW_THREADS
   1.328      if (!xsval) {
   1.329 -	val = PyErr_SetFromErrno(PyExc_RuntimeError);
   1.330 -	goto exit;
   1.331 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.332 +        goto exit;
   1.333      }
   1.334      Py_INCREF(Py_None);
   1.335      val = Py_None;
   1.336 @@ -534,26 +554,26 @@ static PyObject *xspy_unwatch(PyObject *
   1.337      int xsval = 0;
   1.338  
   1.339      if (!xh)
   1.340 -	goto exit;
   1.341 +        goto exit;
   1.342      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path,
   1.343 -				     &token))
   1.344 +                                     &token))
   1.345          goto exit;
   1.346      sprintf(token_str, "%li", (unsigned long)token);
   1.347      Py_BEGIN_ALLOW_THREADS
   1.348      xsval = xs_unwatch(xh, path, token_str);
   1.349      Py_END_ALLOW_THREADS
   1.350      if (!xsval)
   1.351 -	val = PyErr_SetFromErrno(PyExc_RuntimeError);
   1.352 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.353      else {
   1.354 -	Py_INCREF(Py_None);
   1.355 -	val = Py_None;
   1.356 +        Py_INCREF(Py_None);
   1.357 +        val = Py_None;
   1.358      }
   1.359      for (i = 0; i < PyList_Size(xsh->watches); i++) {
   1.360 -	if (token == PyList_GetItem(xsh->watches, i)) {
   1.361 -	    Py_INCREF(Py_None);
   1.362 -	    PyList_SetItem(xsh->watches, i, Py_None);
   1.363 -	    break;
   1.364 -	}
   1.365 +        if (token == PyList_GetItem(xsh->watches, i)) {
   1.366 +            Py_INCREF(Py_None);
   1.367 +            PyList_SetItem(xsh->watches, i, Py_None);
   1.368 +            break;
   1.369 +        }
   1.370      }
   1.371   exit:
   1.372      return val;
   1.373 @@ -564,12 +584,12 @@ static PyObject *xspy_unwatch(PyObject *
   1.374  	"Only one transaction can be active at a time.\n"	\
   1.375  	" path [string]: xenstore path.\n"			\
   1.376  	"\n"							\
   1.377 -	"Returns: [int] 0 on success.\n"			\
   1.378 +	"Returns None on success.\n"				\
   1.379  	"Raises RuntimeError on error.\n"			\
   1.380  	"\n"
   1.381  
   1.382  static PyObject *xspy_transaction_start(PyObject *self, PyObject *args,
   1.383 -					PyObject *kwds)
   1.384 +                                        PyObject *kwds)
   1.385  {
   1.386      static char *kwd_spec[] = { "path", NULL };
   1.387      static char *arg_spec = "s|";
   1.388 @@ -580,13 +600,18 @@ static PyObject *xspy_transaction_start(
   1.389      int xsval = 0;
   1.390  
   1.391      if (!xh)
   1.392 -	goto exit;
   1.393 +        goto exit;
   1.394      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &path))
   1.395          goto exit;
   1.396      Py_BEGIN_ALLOW_THREADS
   1.397      xsval = xs_transaction_start(xh, path);
   1.398      Py_END_ALLOW_THREADS
   1.399 -    val = pyvalue_int(xsval);
   1.400 +    if (!xsval) {
   1.401 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.402 +        goto exit;
   1.403 +    }
   1.404 +    Py_INCREF(Py_None);
   1.405 +    val = Py_None;
   1.406   exit:
   1.407      return val;
   1.408  }
   1.409 @@ -596,12 +621,12 @@ static PyObject *xspy_transaction_start(
   1.410  	"Attempts to commit the transaction unless abort is true.\n"	\
   1.411  	" abort [int]: abort flag (default 0).\n"			\
   1.412  	"\n"								\
   1.413 -	"Returns: [int] 0 on success.\n"				\
   1.414 +	"Returns None on success.\n"					\
   1.415  	"Raises RuntimeError on error.\n"				\
   1.416  	"\n"
   1.417  
   1.418  static PyObject *xspy_transaction_end(PyObject *self, PyObject *args,
   1.419 -				      PyObject *kwds)
   1.420 +                                      PyObject *kwds)
   1.421  {
   1.422      static char *kwd_spec[] = { "abort", NULL };
   1.423      static char *arg_spec = "|i";
   1.424 @@ -612,13 +637,18 @@ static PyObject *xspy_transaction_end(Py
   1.425      int xsval = 0;
   1.426  
   1.427      if (!xh)
   1.428 -	goto exit;
   1.429 +        goto exit;
   1.430      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec, &abort))
   1.431          goto exit;
   1.432      Py_BEGIN_ALLOW_THREADS
   1.433      xsval = xs_transaction_end(xh, abort);
   1.434      Py_END_ALLOW_THREADS
   1.435 -    val = pyvalue_int(xsval);
   1.436 +    if (!xsval) {
   1.437 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.438 +        goto exit;
   1.439 +    }
   1.440 +    Py_INCREF(Py_None);
   1.441 +    val = Py_None;
   1.442   exit:
   1.443      return val;
   1.444  }
   1.445 @@ -630,12 +660,12 @@ static PyObject *xspy_transaction_end(Py
   1.446  	" port [int]   : port the domain is using for xenstore\n"	\
   1.447  	" path [string]: path to the domain's data in xenstore\n"	\
   1.448  	"\n"								\
   1.449 -	"Returns: [int] 0 on success.\n"				\
   1.450 +	"Returns None on success.\n"					\
   1.451  	"Raises RuntimeError on error.\n"				\
   1.452  	"\n"
   1.453  
   1.454  static PyObject *xspy_introduce_domain(PyObject *self, PyObject *args,
   1.455 -				       PyObject *kwds)
   1.456 +                                       PyObject *kwds)
   1.457  {
   1.458      static char *kwd_spec[] = { "dom", "page", "port", "path", NULL };
   1.459      static char *arg_spec = "iiis|";
   1.460 @@ -649,14 +679,19 @@ static PyObject *xspy_introduce_domain(P
   1.461      int xsval = 0;
   1.462  
   1.463      if (!xh)
   1.464 -	goto exit;
   1.465 +        goto exit;
   1.466      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
   1.467                                       &dom, &page, &port, &path))
   1.468          goto exit;
   1.469      Py_BEGIN_ALLOW_THREADS
   1.470      xsval = xs_introduce_domain(xh, dom, page, port, path);
   1.471      Py_END_ALLOW_THREADS
   1.472 -    val = pyvalue_int(xsval);
   1.473 +    if (!xsval) {
   1.474 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.475 +        goto exit;
   1.476 +    }
   1.477 +    Py_INCREF(Py_None);
   1.478 +    val = Py_None;
   1.479   exit:
   1.480      return val;
   1.481  }
   1.482 @@ -666,12 +701,12 @@ static PyObject *xspy_introduce_domain(P
   1.483  	"Unless this is done the domain will not be released.\n"	\
   1.484  	" dom [int]: domain id\n"					\
   1.485  	"\n"								\
   1.486 -	"Returns: [int] 0 on success.\n"				\
   1.487 +	"Returns None on success.\n"					\
   1.488  	"Raises RuntimeError on error.\n"				\
   1.489  	"\n"
   1.490  
   1.491  static PyObject *xspy_release_domain(PyObject *self, PyObject *args,
   1.492 -				     PyObject *kwds)
   1.493 +                                     PyObject *kwds)
   1.494  {
   1.495      static char *kwd_spec[] = { "dom", NULL };
   1.496      static char *arg_spec = "i|";
   1.497 @@ -682,14 +717,19 @@ static PyObject *xspy_release_domain(PyO
   1.498      int xsval = 0;
   1.499  
   1.500      if (!xh)
   1.501 -	goto exit;
   1.502 +        goto exit;
   1.503      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
   1.504                                       &dom))
   1.505          goto exit;
   1.506      Py_BEGIN_ALLOW_THREADS
   1.507      xsval = xs_release_domain(xh, dom);
   1.508      Py_END_ALLOW_THREADS
   1.509 -    val = pyvalue_int(xsval);
   1.510 +    if (!xsval) {
   1.511 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.512 +        goto exit;
   1.513 +    }
   1.514 +    Py_INCREF(Py_None);
   1.515 +    val = Py_None;
   1.516   exit:
   1.517      return val;
   1.518  }
   1.519 @@ -697,7 +737,7 @@ static PyObject *xspy_release_domain(PyO
   1.520  #define xspy_close_doc "\n"			\
   1.521  	"Close the connection to xenstore.\n"	\
   1.522  	"\n"					\
   1.523 -	"Returns: [int] 0 on success.\n"	\
   1.524 +	"Returns None on success.\n"		\
   1.525  	"Raises RuntimeError on error.\n"	\
   1.526  	"\n"
   1.527  
   1.528 @@ -710,20 +750,20 @@ static PyObject *xspy_close(PyObject *se
   1.529      XsHandle *xsh = (XsHandle *)self;
   1.530      struct xs_handle *xh = xshandle(self);
   1.531      PyObject *val = NULL;
   1.532 -    int xsval = 1;
   1.533  
   1.534      if (!xh)
   1.535 -	goto exit;
   1.536 +        goto exit;
   1.537      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec))
   1.538          goto exit;
   1.539      for (i = 0; i < PyList_Size(xsh->watches); i++) {
   1.540 -	/* TODO: xs_unwatch watches */
   1.541 -	Py_INCREF(Py_None);
   1.542 -	PyList_SetItem(xsh->watches, i, Py_None);
   1.543 +        /* TODO: xs_unwatch watches */
   1.544 +        Py_INCREF(Py_None);
   1.545 +        PyList_SetItem(xsh->watches, i, Py_None);
   1.546      }
   1.547      xs_daemon_close(xh);
   1.548      xsh->xh = NULL;
   1.549 -    val = pyvalue_int(xsval);
   1.550 +    Py_INCREF(Py_None);
   1.551 +    val = Py_None;
   1.552   exit:
   1.553      return val;
   1.554  }
   1.555 @@ -731,7 +771,7 @@ static PyObject *xspy_close(PyObject *se
   1.556  #define xspy_shutdown_doc "\n"			\
   1.557  	"Shutdown the xenstore daemon.\n"	\
   1.558  	"\n"					\
   1.559 -	"Returns: [int] 0 on success.\n"	\
   1.560 +	"Returns None on success.\n"		\
   1.561  	"Raises RuntimeError on error.\n"	\
   1.562  	"\n"
   1.563  
   1.564 @@ -745,13 +785,18 @@ static PyObject *xspy_shutdown(PyObject 
   1.565      int xsval = 0;
   1.566  
   1.567      if (!xh)
   1.568 -	goto exit;
   1.569 +        goto exit;
   1.570      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec))
   1.571          goto exit;
   1.572      Py_BEGIN_ALLOW_THREADS
   1.573      xsval = xs_shutdown(xh);
   1.574      Py_END_ALLOW_THREADS
   1.575 -    val = pyvalue_int(xsval);
   1.576 +    if (!xsval) {
   1.577 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.578 +        goto exit;
   1.579 +    }
   1.580 +    Py_INCREF(Py_None);
   1.581 +    val = Py_None;
   1.582   exit:
   1.583      return val;
   1.584  }
   1.585 @@ -852,17 +897,18 @@ static PyObject *xshandle_open(PyObject 
   1.586  
   1.587      if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
   1.588                                       &readonly))
   1.589 -	return NULL;
   1.590 +        return NULL;
   1.591  
   1.592      xsh = PyObject_New(XsHandle, &xshandle_type);
   1.593      if (!xsh)
   1.594 -	return NULL;
   1.595 +        return NULL;
   1.596      xsh->watches = PyList_New(0);
   1.597      if (!xsh->watches)
   1.598 -	goto exit;
   1.599 +        goto exit;
   1.600      xsh->xh = (readonly ? xs_daemon_open_readonly() : xs_daemon_open());
   1.601      if (!xsh->xh) {
   1.602 -	Py_DECREF(xsh->watches);
   1.603 +        Py_DECREF(xsh->watches);
   1.604 +        PyErr_SetFromErrno(PyExc_RuntimeError);
   1.605          goto exit;
   1.606      }
   1.607      val = (PyObject *)xsh;