ia64/xen-unstable

changeset 7971:f72da8799418

Remove many unnecessary uses of keyword arguments, to reduce complexity.

Have the self parameter to all the methods be an XsHandle, not a PyObject, to
avoid casting.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Mon Nov 21 17:48:22 2005 +0100 (2005-11-21)
parents e336e186e5f9
children 52f80621b889
files tools/python/xen/lowlevel/xc/xc.c
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Nov 21 17:30:43 2005 +0100
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Nov 21 17:48:22 2005 +0100
     1.3 @@ -32,48 +32,38 @@ typedef struct {
     1.4      int xc_handle;
     1.5  } XcObject;
     1.6  
     1.7 -/*
     1.8 - * Definitions for the 'xc' object type.
     1.9 - */
    1.10 +
    1.11 +static PyObject *dom_op(XcObject *self, PyObject *args,
    1.12 +                        int (*fn)(int, uint32_t));
    1.13  
    1.14 -static PyObject *pyxc_domain_dumpcore(PyObject *self,
    1.15 -				      PyObject *args,
    1.16 -				      PyObject *kwds)
    1.17 +
    1.18 +static PyObject *pyxc_domain_dumpcore(XcObject *self, PyObject *args)
    1.19  {
    1.20 -    XcObject *xc = (XcObject *)self;
    1.21 -
    1.22      uint32_t dom;
    1.23      char *corefile;
    1.24  
    1.25 -    static char *kwd_list[] = { "dom", "corefile", NULL };
    1.26 -
    1.27 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list,
    1.28 -                                      &dom, &corefile) )
    1.29 +    if (!PyArg_ParseTuple(args, "is", &dom, &corefile))
    1.30          return NULL;
    1.31  
    1.32      if ( (corefile == NULL) || (corefile[0] == '\0') )
    1.33          return NULL;
    1.34  
    1.35 -    if ( xc_domain_dumpcore(xc->xc_handle, dom, corefile) != 0 )
    1.36 +    if (xc_domain_dumpcore(self->xc_handle, dom, corefile) != 0)
    1.37          return PyErr_SetFromErrno(xc_error);
    1.38      
    1.39      Py_INCREF(zero);
    1.40      return zero;
    1.41  }
    1.42  
    1.43 -static PyObject *pyxc_handle(PyObject *self)
    1.44 +static PyObject *pyxc_handle(XcObject *self)
    1.45  {
    1.46 -    XcObject *xc = (XcObject *)self;
    1.47 -
    1.48 -    return PyInt_FromLong(xc->xc_handle);
    1.49 +    return PyInt_FromLong(self->xc_handle);
    1.50  }
    1.51  
    1.52 -static PyObject *pyxc_domain_create(PyObject *self,
    1.53 +static PyObject *pyxc_domain_create(XcObject *self,
    1.54                                      PyObject *args,
    1.55                                      PyObject *kwds)
    1.56  {
    1.57 -    XcObject *xc = (XcObject *)self;
    1.58 -
    1.59      uint32_t dom = 0;
    1.60      int      ret, i;
    1.61      uint32_t ssidref = 0;
    1.62 @@ -103,7 +93,7 @@ static PyObject *pyxc_domain_create(PyOb
    1.63          }
    1.64      }
    1.65  
    1.66 -    if ( (ret = xc_domain_create(xc->xc_handle, ssidref, handle, &dom)) < 0 )
    1.67 +    if ( (ret = xc_domain_create(self->xc_handle, ssidref, handle, &dom)) < 0 )
    1.68          return PyErr_SetFromErrno(xc_error);
    1.69  
    1.70      return PyInt_FromLong(dom);
    1.71 @@ -114,92 +104,40 @@ out_exception:
    1.72      return NULL;
    1.73  }
    1.74  
    1.75 -static PyObject *pyxc_domain_max_vcpus(PyObject *self,
    1.76 -                                            PyObject *args,
    1.77 -                                            PyObject *kwds)
    1.78 +static PyObject *pyxc_domain_max_vcpus(XcObject *self, PyObject *args)
    1.79  {
    1.80 -    XcObject *xc = (XcObject *)self;
    1.81 -
    1.82      uint32_t dom, max;
    1.83  
    1.84 -    static char *kwd_list[] = { "dom", "max", NULL };
    1.85 -
    1.86 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &max) )
    1.87 -        return NULL;
    1.88 -
    1.89 -    if ( xc_domain_max_vcpus(xc->xc_handle, dom, max) != 0 )
    1.90 -        return PyErr_SetFromErrno(xc_error);
    1.91 -    
    1.92 -    Py_INCREF(zero);
    1.93 -    return zero;
    1.94 -}
    1.95 +    if (!PyArg_ParseTuple(args, "ii", &dom, &max))
    1.96 +      return NULL;
    1.97  
    1.98 -static PyObject *pyxc_domain_pause(PyObject *self,
    1.99 -                                   PyObject *args,
   1.100 -                                   PyObject *kwds)
   1.101 -{
   1.102 -    XcObject *xc = (XcObject *)self;
   1.103 -
   1.104 -    uint32_t dom;
   1.105 -
   1.106 -    static char *kwd_list[] = { "dom", NULL };
   1.107 -
   1.108 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   1.109 -        return NULL;
   1.110 -
   1.111 -    if ( xc_domain_pause(xc->xc_handle, dom) != 0 )
   1.112 +    if (xc_domain_max_vcpus(self->xc_handle, dom, max) != 0)
   1.113          return PyErr_SetFromErrno(xc_error);
   1.114      
   1.115      Py_INCREF(zero);
   1.116      return zero;
   1.117  }
   1.118  
   1.119 -static PyObject *pyxc_domain_unpause(PyObject *self,
   1.120 -                                     PyObject *args,
   1.121 -                                     PyObject *kwds)
   1.122 +static PyObject *pyxc_domain_pause(XcObject *self, PyObject *args)
   1.123  {
   1.124 -    XcObject *xc = (XcObject *)self;
   1.125 -
   1.126 -    uint32_t dom;
   1.127 -
   1.128 -    static char *kwd_list[] = { "dom", NULL };
   1.129 -
   1.130 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   1.131 -        return NULL;
   1.132 -
   1.133 -    if ( xc_domain_unpause(xc->xc_handle, dom) != 0 )
   1.134 -        return PyErr_SetFromErrno(xc_error);
   1.135 -    
   1.136 -    Py_INCREF(zero);
   1.137 -    return zero;
   1.138 +    return dom_op(self, args, xc_domain_pause);
   1.139  }
   1.140  
   1.141 -static PyObject *pyxc_domain_destroy(PyObject *self,
   1.142 -                                     PyObject *args,
   1.143 -                                     PyObject *kwds)
   1.144 +static PyObject *pyxc_domain_unpause(XcObject *self, PyObject *args)
   1.145  {
   1.146 -    XcObject *xc = (XcObject *)self;
   1.147 -
   1.148 -    uint32_t dom;
   1.149 -
   1.150 -    static char *kwd_list[] = { "dom", NULL };
   1.151 -
   1.152 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   1.153 -        return NULL;
   1.154 -
   1.155 -    if ( xc_domain_destroy(xc->xc_handle, dom) != 0 )
   1.156 -        return PyErr_SetFromErrno(xc_error);
   1.157 -    
   1.158 -    Py_INCREF(zero);
   1.159 -    return zero;
   1.160 +    return dom_op(self, args, xc_domain_unpause);
   1.161  }
   1.162  
   1.163 -static PyObject *pyxc_domain_pincpu(PyObject *self,
   1.164 +static PyObject *pyxc_domain_destroy(XcObject *self, PyObject *args)
   1.165 +{
   1.166 +    return dom_op(self, args, xc_domain_destroy);
   1.167 +}
   1.168 +
   1.169 +
   1.170 +static PyObject *pyxc_domain_pincpu(XcObject *self,
   1.171                                      PyObject *args,
   1.172                                      PyObject *kwds)
   1.173  {
   1.174 -    XcObject *xc = (XcObject *)self;
   1.175 -
   1.176      uint32_t dom;
   1.177      int vcpu = 0, i;
   1.178      cpumap_t cpumap = ~0ULL;
   1.179 @@ -218,19 +156,17 @@ static PyObject *pyxc_domain_pincpu(PyOb
   1.180              cpumap |= (cpumap_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
   1.181      }
   1.182    
   1.183 -    if ( xc_domain_pincpu(xc->xc_handle, dom, vcpu, cpumap) != 0 )
   1.184 +    if ( xc_domain_pincpu(self->xc_handle, dom, vcpu, cpumap) != 0 )
   1.185          return PyErr_SetFromErrno(xc_error);
   1.186      
   1.187      Py_INCREF(zero);
   1.188      return zero;
   1.189  }
   1.190  
   1.191 -static PyObject *pyxc_domain_setcpuweight(PyObject *self,
   1.192 +static PyObject *pyxc_domain_setcpuweight(XcObject *self,
   1.193  					  PyObject *args,
   1.194  					  PyObject *kwds)
   1.195  {
   1.196 -    XcObject *xc = (XcObject *)self;
   1.197 -
   1.198      uint32_t dom;
   1.199      float cpuweight = 1;
   1.200  
   1.201 @@ -240,28 +176,21 @@ static PyObject *pyxc_domain_setcpuweigh
   1.202                                        &dom, &cpuweight) )
   1.203          return NULL;
   1.204  
   1.205 -    if ( xc_domain_setcpuweight(xc->xc_handle, dom, cpuweight) != 0 )
   1.206 +    if ( xc_domain_setcpuweight(self->xc_handle, dom, cpuweight) != 0 )
   1.207          return PyErr_SetFromErrno(xc_error);
   1.208      
   1.209      Py_INCREF(zero);
   1.210      return zero;
   1.211  }
   1.212  
   1.213 -static PyObject *pyxc_domain_sethandle(PyObject *self,
   1.214 -                                       PyObject *args,
   1.215 -                                       PyObject *kwds)
   1.216 +static PyObject *pyxc_domain_sethandle(XcObject *self, PyObject *args)
   1.217  {
   1.218 -    XcObject *xc = (XcObject *)self;
   1.219 -
   1.220      int i;
   1.221      uint32_t dom;
   1.222      PyObject *pyhandle;
   1.223      xen_domain_handle_t handle;
   1.224  
   1.225 -    static char *kwd_list[] = { "dom", "handle", NULL };
   1.226 -
   1.227 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iO", kwd_list, 
   1.228 -                                      &dom, &pyhandle) )
   1.229 +    if (!PyArg_ParseTuple(args, "iO", &dom, &pyhandle))
   1.230          return NULL;
   1.231  
   1.232      if ( !PyList_Check(pyhandle) || 
   1.233 @@ -278,7 +207,7 @@ static PyObject *pyxc_domain_sethandle(P
   1.234          handle[i] = (uint8_t)PyInt_AsLong(p);
   1.235      }
   1.236  
   1.237 -    if ( xc_domain_sethandle(xc->xc_handle, dom, handle) < 0 )
   1.238 +    if (xc_domain_sethandle(self->xc_handle, dom, handle) < 0)
   1.239          return PyErr_SetFromErrno(xc_error);
   1.240      
   1.241      Py_INCREF(zero);
   1.242 @@ -291,11 +220,10 @@ out_exception:
   1.243  }
   1.244  
   1.245  
   1.246 -static PyObject *pyxc_domain_getinfo(PyObject *self,
   1.247 +static PyObject *pyxc_domain_getinfo(XcObject *self,
   1.248                                       PyObject *args,
   1.249                                       PyObject *kwds)
   1.250  {
   1.251 -    XcObject *xc = (XcObject *)self;
   1.252      PyObject *list, *info_dict;
   1.253  
   1.254      uint32_t first_dom = 0;
   1.255 @@ -311,7 +239,7 @@ static PyObject *pyxc_domain_getinfo(PyO
   1.256      if ( (info = malloc(max_doms * sizeof(xc_dominfo_t))) == NULL )
   1.257          return PyErr_NoMemory();
   1.258  
   1.259 -    nr_doms = xc_domain_getinfo(xc->xc_handle, first_dom, max_doms, info);
   1.260 +    nr_doms = xc_domain_getinfo(self->xc_handle, first_dom, max_doms, info);
   1.261  
   1.262      if (nr_doms < 0)
   1.263      {
   1.264 @@ -351,11 +279,10 @@ static PyObject *pyxc_domain_getinfo(PyO
   1.265      return list;
   1.266  }
   1.267  
   1.268 -static PyObject *pyxc_vcpu_getinfo(PyObject *self,
   1.269 +static PyObject *pyxc_vcpu_getinfo(XcObject *self,
   1.270                                     PyObject *args,
   1.271                                     PyObject *kwds)
   1.272  {
   1.273 -    XcObject *xc = (XcObject *)self;
   1.274      PyObject *info_dict, *cpulist;
   1.275  
   1.276      uint32_t dom, vcpu = 0;
   1.277 @@ -369,7 +296,7 @@ static PyObject *pyxc_vcpu_getinfo(PyObj
   1.278                                        &dom, &vcpu) )
   1.279          return NULL;
   1.280  
   1.281 -    rc = xc_domain_get_vcpu_info(xc->xc_handle, dom, vcpu, &info);
   1.282 +    rc = xc_domain_get_vcpu_info(self->xc_handle, dom, vcpu, &info);
   1.283      if ( rc < 0 )
   1.284          return PyErr_SetFromErrno(xc_error);
   1.285  
   1.286 @@ -393,12 +320,10 @@ static PyObject *pyxc_vcpu_getinfo(PyObj
   1.287      return info_dict;
   1.288  }
   1.289  
   1.290 -static PyObject *pyxc_linux_build(PyObject *self,
   1.291 +static PyObject *pyxc_linux_build(XcObject *self,
   1.292                                    PyObject *args,
   1.293                                    PyObject *kwds)
   1.294  {
   1.295 -    XcObject *xc = (XcObject *)self;
   1.296 -
   1.297      uint32_t dom;
   1.298      char *image, *ramdisk = NULL, *cmdline = "";
   1.299      int flags = 0;
   1.300 @@ -418,7 +343,7 @@ static PyObject *pyxc_linux_build(PyObje
   1.301  				      &ramdisk, &cmdline, &flags) )
   1.302          return NULL;
   1.303  
   1.304 -    if ( xc_linux_build(xc->xc_handle, dom, image,
   1.305 +    if ( xc_linux_build(self->xc_handle, dom, image,
   1.306                          ramdisk, cmdline, flags,
   1.307                          store_evtchn, &store_mfn, 
   1.308  			console_evtchn, &console_mfn) != 0 )
   1.309 @@ -429,12 +354,10 @@ static PyObject *pyxc_linux_build(PyObje
   1.310  			 "console_mfn", console_mfn);
   1.311  }
   1.312  
   1.313 -static PyObject *pyxc_vmx_build(PyObject *self,
   1.314 +static PyObject *pyxc_vmx_build(XcObject *self,
   1.315                                  PyObject *args,
   1.316                                  PyObject *kwds)
   1.317  {
   1.318 -    XcObject *xc = (XcObject *)self;
   1.319 -
   1.320      uint32_t dom;
   1.321      char *image;
   1.322      int control_evtchn, store_evtchn;
   1.323 @@ -451,56 +374,41 @@ static PyObject *pyxc_vmx_build(PyObject
   1.324                                        &memsize, &image, &lapic, &vcpus) )
   1.325          return NULL;
   1.326  
   1.327 -    if ( xc_vmx_build(xc->xc_handle, dom, memsize, image, control_evtchn,
   1.328 +    if ( xc_vmx_build(self->xc_handle, dom, memsize, image, control_evtchn,
   1.329                        lapic, vcpus, store_evtchn, &store_mfn) != 0 )
   1.330          return PyErr_SetFromErrno(xc_error);
   1.331  
   1.332      return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
   1.333  }
   1.334  
   1.335 -static PyObject *pyxc_bvtsched_global_set(PyObject *self,
   1.336 -                                          PyObject *args,
   1.337 -                                          PyObject *kwds)
   1.338 +static PyObject *pyxc_bvtsched_global_set(XcObject *self, PyObject *args)
   1.339  {
   1.340 -    XcObject *xc = (XcObject *)self;
   1.341 -
   1.342      unsigned long ctx_allow;
   1.343  
   1.344 -    static char *kwd_list[] = { "ctx_allow", NULL };
   1.345 -
   1.346 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "l", kwd_list, &ctx_allow) )
   1.347 +    if (!PyArg_ParseTuple(args, "l", &ctx_allow))
   1.348          return NULL;
   1.349  
   1.350 -    if ( xc_bvtsched_global_set(xc->xc_handle, ctx_allow) != 0 )
   1.351 +    if (xc_bvtsched_global_set(self->xc_handle, ctx_allow) != 0)
   1.352          return PyErr_SetFromErrno(xc_error);
   1.353      
   1.354      Py_INCREF(zero);
   1.355      return zero;
   1.356  }
   1.357  
   1.358 -static PyObject *pyxc_bvtsched_global_get(PyObject *self,
   1.359 -                                          PyObject *args,
   1.360 -                                          PyObject *kwds)
   1.361 +static PyObject *pyxc_bvtsched_global_get(XcObject *self)
   1.362  {
   1.363 -    XcObject *xc = (XcObject *)self;
   1.364 -    
   1.365      unsigned long ctx_allow;
   1.366      
   1.367 -    if ( !PyArg_ParseTuple(args, "") )
   1.368 -        return NULL;
   1.369 -    
   1.370 -    if ( xc_bvtsched_global_get(xc->xc_handle, &ctx_allow) != 0 )
   1.371 +    if (xc_bvtsched_global_get(self->xc_handle, &ctx_allow) != 0)
   1.372          return PyErr_SetFromErrno(xc_error);
   1.373      
   1.374      return Py_BuildValue("s:l", "ctx_allow", ctx_allow);
   1.375  }
   1.376  
   1.377 -static PyObject *pyxc_bvtsched_domain_set(PyObject *self,
   1.378 +static PyObject *pyxc_bvtsched_domain_set(XcObject *self,
   1.379                                            PyObject *args,
   1.380                                            PyObject *kwds)
   1.381  {
   1.382 -    XcObject *xc = (XcObject *)self;
   1.383 -
   1.384      uint32_t dom;
   1.385      uint32_t mcuadv;
   1.386      int warpback; 
   1.387 @@ -516,7 +424,7 @@ static PyObject *pyxc_bvtsched_domain_se
   1.388                                        &warpl, &warpu) )
   1.389          return NULL;
   1.390  
   1.391 -    if ( xc_bvtsched_domain_set(xc->xc_handle, dom, mcuadv, 
   1.392 +    if ( xc_bvtsched_domain_set(self->xc_handle, dom, mcuadv, 
   1.393                                  warpback, warpvalue, warpl, warpu) != 0 )
   1.394          return PyErr_SetFromErrno(xc_error);
   1.395      
   1.396 @@ -524,11 +432,9 @@ static PyObject *pyxc_bvtsched_domain_se
   1.397      return zero;
   1.398  }
   1.399  
   1.400 -static PyObject *pyxc_bvtsched_domain_get(PyObject *self,
   1.401 -                                          PyObject *args,
   1.402 -                                          PyObject *kwds)
   1.403 +static PyObject *pyxc_bvtsched_domain_get(XcObject *self,
   1.404 +                                          PyObject *args)
   1.405  {
   1.406 -    XcObject *xc = (XcObject *)self;
   1.407      uint32_t dom;
   1.408      uint32_t mcuadv;
   1.409      int warpback; 
   1.410 @@ -536,13 +442,11 @@ static PyObject *pyxc_bvtsched_domain_ge
   1.411      long long warpl;
   1.412      long long warpu;
   1.413      
   1.414 -    static char *kwd_list[] = { "dom", NULL };
   1.415 -
   1.416 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   1.417 +    if (!PyArg_ParseTuple(args, "i", &dom))
   1.418          return NULL;
   1.419      
   1.420 -    if ( xc_bvtsched_domain_get(xc->xc_handle, dom, &mcuadv, &warpback,
   1.421 -                            &warpvalue, &warpl, &warpu) != 0 )
   1.422 +    if (xc_bvtsched_domain_get(self->xc_handle, dom, &mcuadv, &warpback,
   1.423 +                               &warpvalue, &warpl, &warpu) != 0)
   1.424          return PyErr_SetFromErrno(xc_error);
   1.425  
   1.426      return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}",
   1.427 @@ -554,12 +458,10 @@ static PyObject *pyxc_bvtsched_domain_ge
   1.428                           "warpu", warpu);
   1.429  }
   1.430  
   1.431 -static PyObject *pyxc_evtchn_alloc_unbound(PyObject *self,
   1.432 +static PyObject *pyxc_evtchn_alloc_unbound(XcObject *self,
   1.433                                             PyObject *args,
   1.434                                             PyObject *kwds)
   1.435  {
   1.436 -    XcObject *xc = (XcObject *)self;
   1.437 -
   1.438      uint32_t dom, remote_dom;
   1.439      int port;
   1.440  
   1.441 @@ -569,17 +471,16 @@ static PyObject *pyxc_evtchn_alloc_unbou
   1.442                                        &dom, &remote_dom) )
   1.443          return NULL;
   1.444  
   1.445 -    if ( (port = xc_evtchn_alloc_unbound(xc->xc_handle, dom, remote_dom)) < 0 )
   1.446 +    if ( (port = xc_evtchn_alloc_unbound(self->xc_handle, dom, remote_dom)) < 0 )
   1.447          return PyErr_SetFromErrno(xc_error);
   1.448  
   1.449      return PyInt_FromLong(port);
   1.450  }
   1.451  
   1.452 -static PyObject *pyxc_evtchn_status(PyObject *self,
   1.453 +static PyObject *pyxc_evtchn_status(XcObject *self,
   1.454                                      PyObject *args,
   1.455                                      PyObject *kwds)
   1.456  {
   1.457 -    XcObject *xc = (XcObject *)self;
   1.458      PyObject *dict;
   1.459  
   1.460      uint32_t dom = DOMID_SELF;
   1.461 @@ -592,7 +493,7 @@ static PyObject *pyxc_evtchn_status(PyOb
   1.462                                        &port, &dom) )
   1.463          return NULL;
   1.464  
   1.465 -    ret = xc_evtchn_status(xc->xc_handle, dom, port, &status);
   1.466 +    ret = xc_evtchn_status(self->xc_handle, dom, port, &status);
   1.467      if ( ret != 0 )
   1.468          return PyErr_SetFromErrno(xc_error);
   1.469  
   1.470 @@ -630,11 +531,10 @@ static PyObject *pyxc_evtchn_status(PyOb
   1.471      return dict;
   1.472  }
   1.473  
   1.474 -static PyObject *pyxc_physdev_pci_access_modify(PyObject *self,
   1.475 +static PyObject *pyxc_physdev_pci_access_modify(XcObject *self,
   1.476                                                  PyObject *args,
   1.477                                                  PyObject *kwds)
   1.478  {
   1.479 -    XcObject *xc = (XcObject *)self;
   1.480      uint32_t dom;
   1.481      int bus, dev, func, enable, ret;
   1.482  
   1.483 @@ -645,7 +545,7 @@ static PyObject *pyxc_physdev_pci_access
   1.484          return NULL;
   1.485  
   1.486      ret = xc_physdev_pci_access_modify(
   1.487 -        xc->xc_handle, dom, bus, dev, func, enable);
   1.488 +        self->xc_handle, dom, bus, dev, func, enable);
   1.489      if ( ret != 0 )
   1.490          return PyErr_SetFromErrno(xc_error);
   1.491  
   1.492 @@ -653,12 +553,10 @@ static PyObject *pyxc_physdev_pci_access
   1.493      return zero;
   1.494  }
   1.495  
   1.496 -static PyObject *pyxc_readconsolering(PyObject *self,
   1.497 +static PyObject *pyxc_readconsolering(XcObject *self,
   1.498                                        PyObject *args,
   1.499                                        PyObject *kwds)
   1.500  {
   1.501 -    XcObject *xc = (XcObject *)self;
   1.502 -
   1.503      unsigned int clear = 0;
   1.504      char         _str[32768], *str = _str;
   1.505      unsigned int count = 32768;
   1.506 @@ -669,26 +567,20 @@ static PyObject *pyxc_readconsolering(Py
   1.507      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwd_list, &clear) )
   1.508          return NULL;
   1.509  
   1.510 -    ret = xc_readconsolering(xc->xc_handle, &str, &count, clear);
   1.511 +    ret = xc_readconsolering(self->xc_handle, &str, &count, clear);
   1.512      if ( ret < 0 )
   1.513          return PyErr_SetFromErrno(xc_error);
   1.514  
   1.515      return PyString_FromStringAndSize(str, count);
   1.516  }
   1.517  
   1.518 -static PyObject *pyxc_physinfo(PyObject *self,
   1.519 -                               PyObject *args,
   1.520 -                               PyObject *kwds)
   1.521 +static PyObject *pyxc_physinfo(XcObject *self)
   1.522  {
   1.523 -    XcObject *xc = (XcObject *)self;
   1.524      xc_physinfo_t info;
   1.525      char cpu_cap[128], *p=cpu_cap, *q=cpu_cap;
   1.526      int i;
   1.527      
   1.528 -    if ( !PyArg_ParseTuple(args, "") )
   1.529 -        return NULL;
   1.530 -
   1.531 -    if ( xc_physinfo(xc->xc_handle, &info) != 0 )
   1.532 +    if ( xc_physinfo(self->xc_handle, &info) != 0 )
   1.533          return PyErr_SetFromErrno(xc_error);
   1.534  
   1.535      *q=0;
   1.536 @@ -712,11 +604,8 @@ static PyObject *pyxc_physinfo(PyObject 
   1.537                           "hw_caps",          cpu_cap);
   1.538  }
   1.539  
   1.540 -static PyObject *pyxc_xeninfo(PyObject *self,
   1.541 -                              PyObject *args,
   1.542 -                              PyObject *kwds)
   1.543 +static PyObject *pyxc_xeninfo(XcObject *self)
   1.544  {
   1.545 -    XcObject *xc = (XcObject *)self;
   1.546      xen_extraversion_t xen_extra;
   1.547      xen_compile_info_t xen_cc;
   1.548      xen_changeset_info_t xen_chgset;
   1.549 @@ -725,21 +614,21 @@ static PyObject *pyxc_xeninfo(PyObject *
   1.550      long xen_version;
   1.551      char str[128];
   1.552  
   1.553 -    xen_version = xc_version(xc->xc_handle, XENVER_version, NULL);
   1.554 +    xen_version = xc_version(self->xc_handle, XENVER_version, NULL);
   1.555  
   1.556 -    if ( xc_version(xc->xc_handle, XENVER_extraversion, &xen_extra) != 0 )
   1.557 +    if ( xc_version(self->xc_handle, XENVER_extraversion, &xen_extra) != 0 )
   1.558          return PyErr_SetFromErrno(xc_error);
   1.559  
   1.560 -    if ( xc_version(xc->xc_handle, XENVER_compile_info, &xen_cc) != 0 )
   1.561 +    if ( xc_version(self->xc_handle, XENVER_compile_info, &xen_cc) != 0 )
   1.562          return PyErr_SetFromErrno(xc_error);
   1.563  
   1.564 -    if ( xc_version(xc->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
   1.565 +    if ( xc_version(self->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
   1.566          return PyErr_SetFromErrno(xc_error);
   1.567  
   1.568 -    if ( xc_version(xc->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
   1.569 +    if ( xc_version(self->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
   1.570          return PyErr_SetFromErrno(xc_error);
   1.571  
   1.572 -    if ( xc_version(xc->xc_handle, XENVER_platform_parameters, &p_parms) != 0 )
   1.573 +    if ( xc_version(self->xc_handle, XENVER_platform_parameters, &p_parms) != 0 )
   1.574          return PyErr_SetFromErrno(xc_error);
   1.575  
   1.576      sprintf(str, "virt_start=0x%lx", p_parms.virt_start);
   1.577 @@ -758,11 +647,10 @@ static PyObject *pyxc_xeninfo(PyObject *
   1.578  }
   1.579  
   1.580  
   1.581 -static PyObject *pyxc_sedf_domain_set(PyObject *self,
   1.582 +static PyObject *pyxc_sedf_domain_set(XcObject *self,
   1.583                                        PyObject *args,
   1.584                                        PyObject *kwds)
   1.585  {
   1.586 -    XcObject *xc = (XcObject *)self;
   1.587      uint32_t domid;
   1.588      uint64_t period, slice, latency;
   1.589      uint16_t extratime, weight;
   1.590 @@ -773,7 +661,7 @@ static PyObject *pyxc_sedf_domain_set(Py
   1.591                                       &domid, &period, &slice,
   1.592                                       &latency, &extratime, &weight) )
   1.593          return NULL;
   1.594 -   if ( xc_sedf_domain_set(xc->xc_handle, domid, period,
   1.595 +   if ( xc_sedf_domain_set(self->xc_handle, domid, period,
   1.596                             slice, latency, extratime,weight) != 0 )
   1.597          return PyErr_SetFromErrno(xc_error);
   1.598  
   1.599 @@ -781,22 +669,17 @@ static PyObject *pyxc_sedf_domain_set(Py
   1.600      return zero;
   1.601  }
   1.602  
   1.603 -static PyObject *pyxc_sedf_domain_get(PyObject *self,
   1.604 -                                      PyObject *args,
   1.605 -                                      PyObject *kwds)
   1.606 +static PyObject *pyxc_sedf_domain_get(XcObject *self, PyObject *args)
   1.607  {
   1.608 -    XcObject *xc = (XcObject *)self;
   1.609      uint32_t domid;
   1.610      uint64_t period, slice,latency;
   1.611      uint16_t weight, extratime;
   1.612      
   1.613 -    static char *kwd_list[] = { "dom", NULL };
   1.614 -
   1.615 -    if( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &domid) )
   1.616 +    if(!PyArg_ParseTuple(args, "i", &domid))
   1.617          return NULL;
   1.618      
   1.619 -    if ( xc_sedf_domain_get( xc->xc_handle, domid, &period,
   1.620 -                                &slice,&latency,&extratime,&weight) )
   1.621 +    if (xc_sedf_domain_get(self->xc_handle, domid, &period,
   1.622 +                           &slice,&latency,&extratime,&weight))
   1.623          return PyErr_SetFromErrno(xc_error);
   1.624  
   1.625      return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i,s:i}",
   1.626 @@ -808,34 +691,25 @@ static PyObject *pyxc_sedf_domain_get(Py
   1.627                           "weight",    weight);
   1.628  }
   1.629  
   1.630 -static PyObject *pyxc_domain_setmaxmem(PyObject *self,
   1.631 -                                       PyObject *args,
   1.632 -                                       PyObject *kwds)
   1.633 +static PyObject *pyxc_domain_setmaxmem(XcObject *self, PyObject *args)
   1.634  {
   1.635 -    XcObject *xc = (XcObject *)self;
   1.636 -
   1.637      uint32_t dom;
   1.638      unsigned int maxmem_kb;
   1.639  
   1.640 -    static char *kwd_list[] = { "dom", "maxmem_kb", NULL };
   1.641 -
   1.642 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, 
   1.643 -                                      &dom, &maxmem_kb) )
   1.644 +    if (!PyArg_ParseTuple(args, "ii", &dom, &maxmem_kb))
   1.645          return NULL;
   1.646  
   1.647 -    if ( xc_domain_setmaxmem(xc->xc_handle, dom, maxmem_kb) != 0 )
   1.648 +    if (xc_domain_setmaxmem(self->xc_handle, dom, maxmem_kb) != 0)
   1.649          return PyErr_SetFromErrno(xc_error);
   1.650      
   1.651      Py_INCREF(zero);
   1.652      return zero;
   1.653  }
   1.654  
   1.655 -static PyObject *pyxc_domain_memory_increase_reservation(PyObject *self,
   1.656 +static PyObject *pyxc_domain_memory_increase_reservation(XcObject *self,
   1.657  							 PyObject *args,
   1.658  							 PyObject *kwds)
   1.659  {
   1.660 -    XcObject *xc = (XcObject *)self;
   1.661 -
   1.662      uint32_t dom;
   1.663      unsigned long mem_kb;
   1.664      unsigned int extent_order = 0 , address_bits = 0;
   1.665 @@ -850,7 +724,7 @@ static PyObject *pyxc_domain_memory_incr
   1.666      /* round down to nearest power of 2. Assume callers using extent_order>0
   1.667         know what they are doing */
   1.668      nr_extents = (mem_kb / (XC_PAGE_SIZE/1024)) >> extent_order;
   1.669 -    if ( xc_domain_memory_increase_reservation(xc->xc_handle, dom, 
   1.670 +    if ( xc_domain_memory_increase_reservation(self->xc_handle, dom, 
   1.671  					       nr_extents, extent_order, 
   1.672  					       address_bits, NULL) )
   1.673          return PyErr_SetFromErrno(xc_error);
   1.674 @@ -859,11 +733,10 @@ static PyObject *pyxc_domain_memory_incr
   1.675      return zero;
   1.676  }
   1.677  
   1.678 -static PyObject *pyxc_domain_ioport_permission(PyObject *self,
   1.679 +static PyObject *pyxc_domain_ioport_permission(XcObject *self,
   1.680                                                 PyObject *args,
   1.681                                                 PyObject *kwds)
   1.682  {
   1.683 -    XcObject *xc = (XcObject *)self;
   1.684      uint32_t dom;
   1.685      int first_port, nr_ports, allow_access, ret;
   1.686  
   1.687 @@ -874,7 +747,7 @@ static PyObject *pyxc_domain_ioport_perm
   1.688          return NULL;
   1.689  
   1.690      ret = xc_domain_ioport_permission(
   1.691 -        xc->xc_handle, dom, first_port, nr_ports, allow_access);
   1.692 +        self->xc_handle, dom, first_port, nr_ports, allow_access);
   1.693      if ( ret != 0 )
   1.694          return PyErr_SetFromErrno(xc_error);
   1.695  
   1.696 @@ -882,10 +755,27 @@ static PyObject *pyxc_domain_ioport_perm
   1.697      return zero;
   1.698  }
   1.699  
   1.700 +
   1.701 +static PyObject *dom_op(XcObject *self, PyObject *args,
   1.702 +                        int (*fn)(int, uint32_t))
   1.703 +{
   1.704 +    uint32_t dom;
   1.705 +
   1.706 +    if (!PyArg_ParseTuple(args, "i", &dom))
   1.707 +        return NULL;
   1.708 +
   1.709 +    if (fn(self->xc_handle, dom) != 0)
   1.710 +        return PyErr_SetFromErrno(xc_error);
   1.711 +
   1.712 +    Py_INCREF(zero);
   1.713 +    return zero;
   1.714 +}
   1.715 +
   1.716 +
   1.717  static PyMethodDef pyxc_methods[] = {
   1.718      { "handle",
   1.719        (PyCFunction)pyxc_handle,
   1.720 -      0, "\n"
   1.721 +      METH_NOARGS, "\n"
   1.722        "Query the xc control interface file descriptor.\n\n"
   1.723        "Returns: [int] file descriptor\n" },
   1.724  
   1.725 @@ -898,7 +788,7 @@ static PyMethodDef pyxc_methods[] = {
   1.726  
   1.727      { "domain_max_vcpus", 
   1.728        (PyCFunction)pyxc_domain_max_vcpus,
   1.729 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.730 +      METH_VARARGS, "\n"
   1.731        "Set the maximum number of VCPUs a domain may create.\n"
   1.732        " dom       [int, 0]:      Domain identifier to use.\n"
   1.733        " max     [int, 0]:      New maximum number of VCPUs in domain.\n"
   1.734 @@ -906,7 +796,7 @@ static PyMethodDef pyxc_methods[] = {
   1.735  
   1.736      { "domain_dumpcore", 
   1.737        (PyCFunction)pyxc_domain_dumpcore, 
   1.738 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.739 +      METH_VARARGS, "\n"
   1.740        "Dump core of a domain.\n"
   1.741        " dom [int]: Identifier of domain to dump core of.\n"
   1.742        " corefile [string]: Name of corefile to be created.\n\n"
   1.743 @@ -914,21 +804,21 @@ static PyMethodDef pyxc_methods[] = {
   1.744  
   1.745      { "domain_pause", 
   1.746        (PyCFunction)pyxc_domain_pause, 
   1.747 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.748 +      METH_VARARGS, "\n"
   1.749        "Temporarily pause execution of a domain.\n"
   1.750        " dom [int]: Identifier of domain to be paused.\n\n"
   1.751        "Returns: [int] 0 on success; -1 on error.\n" },
   1.752  
   1.753      { "domain_unpause", 
   1.754        (PyCFunction)pyxc_domain_unpause, 
   1.755 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.756 +      METH_VARARGS, "\n"
   1.757        "(Re)start execution of a domain.\n"
   1.758        " dom [int]: Identifier of domain to be unpaused.\n\n"
   1.759        "Returns: [int] 0 on success; -1 on error.\n" },
   1.760  
   1.761      { "domain_destroy", 
   1.762        (PyCFunction)pyxc_domain_destroy, 
   1.763 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.764 +      METH_VARARGS, "\n"
   1.765        "Destroy a domain.\n"
   1.766        " dom [int]:    Identifier of domain to be destroyed.\n\n"
   1.767        "Returns: [int] 0 on success; -1 on error.\n" },
   1.768 @@ -952,7 +842,7 @@ static PyMethodDef pyxc_methods[] = {
   1.769  
   1.770      { "domain_sethandle", 
   1.771        (PyCFunction)pyxc_domain_sethandle,
   1.772 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.773 +      METH_VARARGS, "\n"
   1.774        "Set domain's opaque handle.\n"
   1.775        " dom [int]:            Identifier of domain.\n"
   1.776        " handle [list of 16 ints]: New opaque handle.\n"
   1.777 @@ -1026,7 +916,7 @@ static PyMethodDef pyxc_methods[] = {
   1.778  
   1.779      { "bvtsched_global_get",
   1.780        (PyCFunction)pyxc_bvtsched_global_get,
   1.781 -      METH_KEYWORDS, "\n"
   1.782 +      METH_NOARGS, "\n"
   1.783        "Get global tuning parameters for BVT scheduler.\n"
   1.784        "Returns: [dict]:\n"
   1.785        " ctx_allow [int]: context switch allowance\n" },
   1.786 @@ -1045,7 +935,7 @@ static PyMethodDef pyxc_methods[] = {
   1.787  
   1.788      { "bvtsched_domain_get",
   1.789        (PyCFunction)pyxc_bvtsched_domain_get,
   1.790 -      METH_KEYWORDS, "\n"
   1.791 +      METH_VARARGS, "\n"
   1.792        "Get per-domain tuning parameters under the BVT scheduler.\n"
   1.793        " dom [int]: Identifier of domain to be queried.\n"
   1.794        "Returns [dict]:\n"
   1.795 @@ -1069,7 +959,7 @@ static PyMethodDef pyxc_methods[] = {
   1.796  
   1.797      { "sedf_domain_get",
   1.798        (PyCFunction)pyxc_sedf_domain_get,
   1.799 -      METH_KEYWORDS, "\n"
   1.800 +      METH_VARARGS, "\n"
   1.801        "Get the current scheduling parameters for a domain when running with\n"
   1.802        "the Atropos scheduler."
   1.803        " dom       [int]: domain to query\n"
   1.804 @@ -1123,21 +1013,21 @@ static PyMethodDef pyxc_methods[] = {
   1.805  
   1.806      { "physinfo",
   1.807        (PyCFunction)pyxc_physinfo,
   1.808 -      METH_VARARGS, "\n"
   1.809 +      METH_NOARGS, "\n"
   1.810        "Get information about the physical host machine\n"
   1.811        "Returns [dict]: information about the hardware"
   1.812        "        [None]: on failure.\n" },
   1.813  
   1.814      { "xeninfo",
   1.815        (PyCFunction)pyxc_xeninfo,
   1.816 -      METH_VARARGS, "\n"
   1.817 +      METH_NOARGS, "\n"
   1.818        "Get information about the Xen host\n"
   1.819        "Returns [dict]: information about Xen"
   1.820        "        [None]: on failure.\n" },
   1.821  
   1.822      { "domain_setmaxmem", 
   1.823        (PyCFunction)pyxc_domain_setmaxmem, 
   1.824 -      METH_VARARGS | METH_KEYWORDS, "\n"
   1.825 +      METH_VARARGS, "\n"
   1.826        "Set a domain's memory limit\n"
   1.827        " dom [int]: Identifier of domain.\n"
   1.828        " maxmem_kb [int]: .\n"
   1.829 @@ -1241,3 +1131,11 @@ PyMODINIT_FUNC initxc(void)
   1.830      setbuf(stdout, NULL);
   1.831      setbuf(stderr, NULL);
   1.832  }
   1.833 +
   1.834 +
   1.835 +/*
   1.836 + * Local variables:
   1.837 + *  c-indent-level: 4
   1.838 + *  c-basic-offset: 4
   1.839 + * End:
   1.840 + */