ia64/xen-unstable

changeset 7389:d48bc069122c

In addition to setting opaque handle during domain
creation, allow it to be changed after creation via
DOM0_SETDOMAINHANDLE operation (and libxc
xc_domain_sethandle, and via Pyhton wrapper fn).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Oct 14 16:01:11 2005 +0100 (2005-10-14)
parents bd3268de4145
children f9b300fab36e
files tools/libxc/xc_domain.c tools/libxc/xenctrl.h tools/python/xen/lowlevel/xc/xc.c xen/common/dom0_ops.c xen/include/public/dom0_ops.h
line diff
     1.1 --- a/tools/libxc/xc_domain.c	Fri Oct 14 15:40:48 2005 +0100
     1.2 +++ b/tools/libxc/xc_domain.c	Fri Oct 14 16:01:11 2005 +0100
     1.3 @@ -334,6 +334,16 @@ int xc_domain_max_vcpus(int xc_handle, u
     1.4      return do_dom0_op(xc_handle, &op);
     1.5  }
     1.6  
     1.7 +int xc_domain_sethandle(int xc_handle, uint32_t domid, 
     1.8 +                        xen_domain_handle_t handle)
     1.9 +{
    1.10 +    dom0_op_t op;
    1.11 +    op.cmd = DOM0_SETDOMAINHANDLE;
    1.12 +    op.u.setdomainhandle.domain = (domid_t)domid;
    1.13 +    memcpy(op.u.setdomainhandle.handle, handle, sizeof(xen_domain_handle_t));
    1.14 +    return do_dom0_op(xc_handle, &op);
    1.15 +}
    1.16 +
    1.17  /*
    1.18   * Local variables:
    1.19   * mode: C
     2.1 --- a/tools/libxc/xenctrl.h	Fri Oct 14 15:40:48 2005 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Fri Oct 14 16:01:11 2005 +0100
     2.3 @@ -257,6 +257,8 @@ long long xc_domain_get_cpu_usage(int xc
     2.4                                    domid_t domid,
     2.5                                    int vcpu);
     2.6  
     2.7 +int xc_domain_sethandle(int xc_handle, uint32_t domid, 
     2.8 +                        xen_domain_handle_t handle);
     2.9  
    2.10  typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
    2.11  int xc_shadow_control(int xc_handle,
     3.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 14 15:40:48 2005 +0100
     3.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 14 16:01:11 2005 +0100
     3.3 @@ -242,6 +242,47 @@ static PyObject *pyxc_domain_setcpuweigh
     3.4      return zero;
     3.5  }
     3.6  
     3.7 +static PyObject *pyxc_domain_sethandle(PyObject *self,
     3.8 +                                       PyObject *args,
     3.9 +                                       PyObject *kwds)
    3.10 +{
    3.11 +    XcObject *xc = (XcObject *)self;
    3.12 +
    3.13 +    int i;
    3.14 +    uint32_t dom;
    3.15 +    PyObject *pyhandle;
    3.16 +    xen_domain_handle_t handle;
    3.17 +
    3.18 +    static char *kwd_list[] = { "dom", "handle", NULL };
    3.19 +
    3.20 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iO", kwd_list, 
    3.21 +                                      &dom, &pyhandle) )
    3.22 +        return NULL;
    3.23 +
    3.24 +    if ( !PyList_Check(pyhandle) || 
    3.25 +         (PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
    3.26 +    {
    3.27 +    out_exception:
    3.28 +        errno = EINVAL;
    3.29 +        PyErr_SetFromErrno(xc_error);
    3.30 +        return NULL;
    3.31 +    }
    3.32 +
    3.33 +    for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
    3.34 +    {
    3.35 +        PyObject *p = PyList_GetItem(pyhandle, i);
    3.36 +        if ( !PyInt_Check(p) )
    3.37 +            goto out_exception;
    3.38 +        handle[i] = (uint8_t)PyInt_AsLong(p);
    3.39 +    }
    3.40 +
    3.41 +    if ( xc_domain_sethandle(xc->xc_handle, dom, handle) < 0 )
    3.42 +        return PyErr_SetFromErrno(xc_error);
    3.43 +    
    3.44 +    Py_INCREF(zero);
    3.45 +    return zero;
    3.46 +}
    3.47 +
    3.48  static PyObject *pyxc_domain_getinfo(PyObject *self,
    3.49                                       PyObject *args,
    3.50                                       PyObject *kwds)
    3.51 @@ -873,6 +914,14 @@ static PyMethodDef pyxc_methods[] = {
    3.52        " cpuweight [float, 1]: VCPU being pinned.\n"
    3.53        "Returns: [int] 0 on success; -1 on error.\n" },
    3.54  
    3.55 +    { "domain_sethandle", 
    3.56 +      (PyCFunction)pyxc_domain_sethandle,
    3.57 +      METH_VARARGS | METH_KEYWORDS, "\n"
    3.58 +      "Set domain's opaque handle.\n"
    3.59 +      " dom [int]:            Identifier of domain.\n"
    3.60 +      " handle [list of 16 ints]: New opaque handle.\n"
    3.61 +      "Returns: [int] 0 on success; -1 on error.\n" },
    3.62 +
    3.63      { "domain_getinfo", 
    3.64        (PyCFunction)pyxc_domain_getinfo, 
    3.65        METH_VARARGS | METH_KEYWORDS, "\n"
     4.1 --- a/xen/common/dom0_ops.c	Fri Oct 14 15:40:48 2005 +0100
     4.2 +++ b/xen/common/dom0_ops.c	Fri Oct 14 16:01:11 2005 +0100
     4.3 @@ -557,6 +557,21 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     4.4      }
     4.5      break;
     4.6  
     4.7 +    case DOM0_SETDOMAINHANDLE:
     4.8 +    {
     4.9 +        struct domain *d; 
    4.10 +        ret = -ESRCH;
    4.11 +        d = find_domain_by_id(op->u.setdomainhandle.domain);
    4.12 +        if ( d != NULL )
    4.13 +        {
    4.14 +            memcpy(d->handle, op->u.setdomainhandle.handle,
    4.15 +                   sizeof(xen_domain_handle_t));
    4.16 +            put_domain(d);
    4.17 +            ret = 0;
    4.18 +        }
    4.19 +    }
    4.20 +    break;
    4.21 +
    4.22  #ifdef PERF_COUNTERS
    4.23      case DOM0_PERFCCONTROL:
    4.24      {
     5.1 --- a/xen/include/public/dom0_ops.h	Fri Oct 14 15:40:48 2005 +0100
     5.2 +++ b/xen/include/public/dom0_ops.h	Fri Oct 14 16:01:11 2005 +0100
     5.3 @@ -405,6 +405,11 @@ typedef struct {
     5.4      unsigned int max;           /* maximum number of vcpus */
     5.5  } dom0_max_vcpus_t;
     5.6  
     5.7 +#define DOM0_SETDOMAINHANDLE 44
     5.8 +typedef struct {
     5.9 +    domid_t domain;
    5.10 +    xen_domain_handle_t handle;
    5.11 +} dom0_setdomainhandle_t;
    5.12  
    5.13  typedef struct {
    5.14      uint32_t cmd;
    5.15 @@ -443,6 +448,7 @@ typedef struct {
    5.16          dom0_platform_quirk_t    platform_quirk;
    5.17          dom0_physical_memory_map_t physical_memory_map;
    5.18          dom0_max_vcpus_t         max_vcpus;
    5.19 +        dom0_setdomainhandle_t   setdomainhandle;
    5.20          uint8_t                  pad[128];
    5.21      } u;
    5.22  } dom0_op_t;