Skip to contentSkip to conversation

tmem tools: tmem control plane python foundation

PATCH New Dan Magenheimer 1 participant 1 message Feb 6, 2009 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 tmem tools: tmem control plane python foundation

[2] tmem control plane python foundation

tools/python/xen/lowlevel/xc/xc.c +52 -0
diff -r c8962b24fb50 tools/python/xen/lowlevel/xc/xc.c
@@ -1500,6 +1500,46 @@ static PyObject *dom_op(XcObject *self, 
 
     if (fn(self->xc_handle, dom) != 0)
         return pyxc_error_to_exception();
+
+    Py_INCREF(zero);
+    return zero;
+}
+
+static PyObject *pyxc_tmem_control(XcObject *self,
+                                   PyObject *args,
+                                   PyObject *kwds)
+{
+    int32_t pool_id;
+    uint32_t subop;
+    uint32_t cli_id;
+    uint32_t arg1;
+    uint32_t arg2;
+    char _buf[32768], *buf;
+
+    static char *kwd_list[] = { "pool_id", "subop", "cli_id", "arg1", "arg2", "buf", NULL };
+
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiiis", kwd_list,
+                                      &pool_id, &subop, &cli_id, &arg1, &arg2, &buf) )
+        return NULL;
+
+    if ( (subop == TMEMC_LIST) && (arg1 > 32768) )
+        arg1 = 32768;
+
+    if ( (xc_tmem_control(self->xc_handle, pool_id, subop, cli_id, arg1, arg2, _buf)) < 0 )
+        return pyxc_error_to_exception();
+
+    switch (subop) {
+        case TMEMC_LIST:
+            return Py_BuildValue("s", _buf);
+        case TMEMC_FREEZE:
+        case TMEMC_THAW:
+        case TMEMC_DESTROY:
+        case TMEMC_SET_WEIGHT:
+        case TMEMC_SET_CAP:
+        case TMEMC_SET_COMPRESS:
+        default:
+            break;
+    }
 
     Py_INCREF(zero);
     return zero;
@@ -1964,6 +2004,18 @@ static PyMethodDef pyxc_methods[] = {
       " dom [int]: Identifier of domain.\n" },
 #endif
 
+    { "tmem_control",
+      (PyCFunction)pyxc_tmem_control,
+      METH_VARARGS | METH_KEYWORDS, "\n"
+      "Do various control on a tmem pool.\n"
+      " pool_id [int]: Identifier of the tmem pool (ignored).\n"
+      " subop [int]: Supplementary Operation.\n"
+      " cli_id [int]: Client identifier.\n"
+      " arg1 [int]: Argument.\n"
+      " arg2 [int]: Argument.\n"
+      " buf [str]: Buffer.\n\n"
+      "Returns: [int] 0 or [str] tmem info on success; exception on error.\n" },
+
     { NULL, NULL, 0, NULL }
 };
 
tools/python/xen/xend/XendAPI.py +64 -1

77 lines not on this page · raw message

tools/python/xen/xend/server/XMLRPCServer.py +5 -1
diff -r c8962b24fb50 tools/python/xen/xend/server/XMLRPCServer.py
@@ -198,7 +198,11 @@ class XMLRPCServer:
                     self.server.register_function(fn, "xend.domain.%s" % name[7:])
 
         # Functions in XendNode and XendDmesg
-        for type, lst, n in [(XendNode, ['info', 'send_debug_keys'], 'node'),
+        for type, lst, n in [(XendNode,
+                              ['info', 'send_debug_keys', 'tmem_list',
+                               'tmem_freeze', 'tmem_thaw', 'tmem_destroy',
+                               'tmem_set_weight', 'tmem_set_cap', 'tmem_set_compress'],
+                              'node'),
                              (XendDmesg, ['info', 'clear'], 'node.dmesg')]:
             inst = type.instance()
             for name in lst:
tools/python/xen/xend/XendNode.py +56 -0

68 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel