[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] In addition to setting opaque handle during domain



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID d48bc069122cad701be691ad456b5b3f1a0c479f
# Parent  bd3268de41453531bd340463eb7546120a9348c9
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@xxxxxxxxxxxxx>

diff -r bd3268de4145 -r d48bc069122c tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Fri Oct 14 14:40:48 2005
+++ b/tools/libxc/xc_domain.c   Fri Oct 14 15:01:11 2005
@@ -334,6 +334,16 @@
     return do_dom0_op(xc_handle, &op);
 }
 
+int xc_domain_sethandle(int xc_handle, uint32_t domid, 
+                        xen_domain_handle_t handle)
+{
+    dom0_op_t op;
+    op.cmd = DOM0_SETDOMAINHANDLE;
+    op.u.setdomainhandle.domain = (domid_t)domid;
+    memcpy(op.u.setdomainhandle.handle, handle, sizeof(xen_domain_handle_t));
+    return do_dom0_op(xc_handle, &op);
+}
+
 /*
  * Local variables:
  * mode: C
diff -r bd3268de4145 -r d48bc069122c tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Oct 14 14:40:48 2005
+++ b/tools/libxc/xenctrl.h     Fri Oct 14 15:01:11 2005
@@ -257,6 +257,8 @@
                                   domid_t domid,
                                   int vcpu);
 
+int xc_domain_sethandle(int xc_handle, uint32_t domid, 
+                        xen_domain_handle_t handle);
 
 typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
 int xc_shadow_control(int xc_handle,
diff -r bd3268de4145 -r d48bc069122c tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Fri Oct 14 14:40:48 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Fri Oct 14 15:01:11 2005
@@ -236,6 +236,47 @@
         return NULL;
 
     if ( xc_domain_setcpuweight(xc->xc_handle, dom, cpuweight) != 0 )
+        return PyErr_SetFromErrno(xc_error);
+    
+    Py_INCREF(zero);
+    return zero;
+}
+
+static PyObject *pyxc_domain_sethandle(PyObject *self,
+                                       PyObject *args,
+                                       PyObject *kwds)
+{
+    XcObject *xc = (XcObject *)self;
+
+    int i;
+    uint32_t dom;
+    PyObject *pyhandle;
+    xen_domain_handle_t handle;
+
+    static char *kwd_list[] = { "dom", "handle", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iO", kwd_list, 
+                                      &dom, &pyhandle) )
+        return NULL;
+
+    if ( !PyList_Check(pyhandle) || 
+         (PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
+    {
+    out_exception:
+        errno = EINVAL;
+        PyErr_SetFromErrno(xc_error);
+        return NULL;
+    }
+
+    for ( i = 0; i < sizeof(xen_domain_handle_t); i++ )
+    {
+        PyObject *p = PyList_GetItem(pyhandle, i);
+        if ( !PyInt_Check(p) )
+            goto out_exception;
+        handle[i] = (uint8_t)PyInt_AsLong(p);
+    }
+
+    if ( xc_domain_sethandle(xc->xc_handle, dom, handle) < 0 )
         return PyErr_SetFromErrno(xc_error);
     
     Py_INCREF(zero);
@@ -873,6 +914,14 @@
       " cpuweight [float, 1]: VCPU being pinned.\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
+    { "domain_sethandle", 
+      (PyCFunction)pyxc_domain_sethandle,
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Set domain's opaque handle.\n"
+      " dom [int]:            Identifier of domain.\n"
+      " handle [list of 16 ints]: New opaque handle.\n"
+      "Returns: [int] 0 on success; -1 on error.\n" },
+
     { "domain_getinfo", 
       (PyCFunction)pyxc_domain_getinfo, 
       METH_VARARGS | METH_KEYWORDS, "\n"
diff -r bd3268de4145 -r d48bc069122c xen/common/dom0_ops.c
--- a/xen/common/dom0_ops.c     Fri Oct 14 14:40:48 2005
+++ b/xen/common/dom0_ops.c     Fri Oct 14 15:01:11 2005
@@ -557,6 +557,21 @@
     }
     break;
 
+    case DOM0_SETDOMAINHANDLE:
+    {
+        struct domain *d; 
+        ret = -ESRCH;
+        d = find_domain_by_id(op->u.setdomainhandle.domain);
+        if ( d != NULL )
+        {
+            memcpy(d->handle, op->u.setdomainhandle.handle,
+                   sizeof(xen_domain_handle_t));
+            put_domain(d);
+            ret = 0;
+        }
+    }
+    break;
+
 #ifdef PERF_COUNTERS
     case DOM0_PERFCCONTROL:
     {
diff -r bd3268de4145 -r d48bc069122c xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Fri Oct 14 14:40:48 2005
+++ b/xen/include/public/dom0_ops.h     Fri Oct 14 15:01:11 2005
@@ -405,6 +405,11 @@
     unsigned int max;           /* maximum number of vcpus */
 } dom0_max_vcpus_t;
 
+#define DOM0_SETDOMAINHANDLE 44
+typedef struct {
+    domid_t domain;
+    xen_domain_handle_t handle;
+} dom0_setdomainhandle_t;
 
 typedef struct {
     uint32_t cmd;
@@ -443,6 +448,7 @@
         dom0_platform_quirk_t    platform_quirk;
         dom0_physical_memory_map_t physical_memory_map;
         dom0_max_vcpus_t         max_vcpus;
+        dom0_setdomainhandle_t   setdomainhandle;
         uint8_t                  pad[128];
     } u;
 } dom0_op_t;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.