ChangeSet 1.1488, 2005/05/20 16:23:48+01:00, cl349@xxxxxxxxxxxxxxxxxxxx
XendDomainInfo.py, xc.c, xc_linux_restore.c, xc_domain.c, xc.h:
Split pincpu, setcpuweight, setmaxmem and memory increase reservation
out of xc_domain_create. Add glue to get the missing functions
exposed
to python and use.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
libxc/xc.h | 7 +-
libxc/xc_domain.c | 51 ++++++++-------------
libxc/xc_linux_restore.c | 27 +++++++++--
python/xen/lowlevel/xc/xc.c | 89 ++++++++++++++++++++++++++++++--------
python/xen/xend/XendDomainInfo.py | 8 ++-
5 files changed, 123 insertions(+), 59 deletions(-)
diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h
--- a/tools/libxc/xc.h 2005-05-20 13:03:07 -04:00
+++ b/tools/libxc/xc.h 2005-05-20 13:03:07 -04:00
@@ -124,9 +124,6 @@
typedef dom0_getdomaininfo_t xc_domaininfo_t;
int xc_domain_create(int xc_handle,
- unsigned int mem_kb,
- int cpu,
- float cpu_weight,
u32 *pdomid);
@@ -406,6 +403,10 @@
int xc_domain_setmaxmem(int xc_handle,
u32 domid,
unsigned int max_memkb);
+
+int xc_domain_memory_increase_reservation(int xc_handle,
+ u32 domid,
+ unsigned int mem_kb);
typedef dom0_perfc_desc_t xc_perfc_desc_t;
/* IMPORTANT: The caller is responsible for mlock()'ing the @desc array. */
diff -Nru a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c 2005-05-20 13:03:07 -04:00
+++ b/tools/libxc/xc_domain.c 2005-05-20 13:03:07 -04:00
@@ -9,15 +9,10 @@
#include "xc_private.h"
int xc_domain_create(int xc_handle,
- unsigned int mem_kb,
- int cpu,
- float cpu_weight,
u32 *pdomid)
{
- int err, errno_saved;
+ int err;
dom0_op_t op;
- u32 vcpu = 0; /* FIXME, hard coded initial pin to vcpu 0 */
- cpumap_t cpumap = 1 << cpu;
op.cmd = DOM0_CREATEDOMAIN;
op.u.createdomain.domain = (domid_t)*pdomid;
@@ -25,33 +20,7 @@
return err;
*pdomid = (u16)op.u.createdomain.domain;
-
- if ( (cpu != -1) &&
- ((err = xc_domain_pincpu(xc_handle, *pdomid, vcpu, &cpumap)) != 0) )
- goto fail;
-
- if ( (err = xc_domain_setcpuweight(xc_handle, *pdomid, cpu_weight)) != 0 )
- goto fail;
-
- if ( (err = xc_domain_setmaxmem(xc_handle, *pdomid, mem_kb)) != 0 )
- goto fail;
-
- if ( (err = do_dom_mem_op(xc_handle, MEMOP_increase_reservation,
- NULL, mem_kb/4, 0, *pdomid)) != (mem_kb/4) )
- {
- if ( err > 0 )
- errno = ENOMEM;
- err = -1;
- goto fail;
- }
-
return 0;
-
- fail:
- errno_saved = errno;
- (void)xc_domain_destroy(xc_handle, *pdomid);
- errno = errno_saved;
- return err;
}
@@ -255,4 +224,22 @@
op.u.setdomainmaxmem.domain = (domid_t)domid;
op.u.setdomainmaxmem.max_memkb = max_memkb;
return do_dom0_op(xc_handle, &op);
+}
+
+int xc_domain_memory_increase_reservation(int xc_handle,
+ u32 domid,
+ unsigned int mem_kb)
+{
+ int err;
+
+ err = do_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL,
+ mem_kb / 4, 0, domid);
+ if (err == mem_kb / 4)
+ return 0;
+
+ if (err > 0) {
+ errno = ENOMEM;
+ err = -1;
+ }
+ return err;
}
diff -Nru a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c 2005-05-20 13:03:08 -04:00
+++ b/tools/libxc/xc_linux_restore.c 2005-05-20 13:03:08 -04:00
@@ -167,14 +167,31 @@
}
/* Create domain on CPU -1 so that it may auto load-balance in future. */
- if ( xc_domain_create(xc_handle, nr_pfns * (PAGE_SIZE / 1024),
- -1, 1, &dom) )
+ if ( xc_domain_create(xc_handle, &dom) )
{
- xcio_error(ioctxt, "Could not create domain. pfns=%ld, %ldKB",
- nr_pfns, nr_pfns * (PAGE_SIZE / 1024));
+ xcio_error(ioctxt, "Could not create domain.");
goto out;
}
-
+ if ( xc_domain_setcpuweight(xc_handle, dom, 1) )
+ {
+ xcio_error(ioctxt, "Could not set domain cpuweight.");
+ goto out;
+ }
+ if ( xc_domain_setmaxmem(xc_handle, dom, nr_pfns * (PAGE_SIZE / 1024)) )
+ {
+ xcio_error(ioctxt, "Could not set domain maxmem. pfns=%ld, %ldKB",
+ nr_pfns, nr_pfns * (PAGE_SIZE / 1024));
+ goto out;
+ }
+ if ( xc_domain_memory_increase_reservation(xc_handle, dom,
+ nr_pfns * (PAGE_SIZE / 1024)) )
+ {
+ xcio_error(ioctxt,
+ "Could not increase domain memory reservation. pfns=%ld",
+ nr_pfns);
+ goto out;
+ }
+
ioctxt->domain = dom;
xcio_info(ioctxt, "Created domain %u\n", dom);
diff -Nru a/tools/python/xen/lowlevel/xc/xc.c
b/tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c 2005-05-20 13:03:08 -04:00
+++ b/tools/python/xen/lowlevel/xc/xc.c 2005-05-20 13:03:08 -04:00
@@ -69,20 +69,15 @@
{
XcObject *xc = (XcObject *)self;
- unsigned int mem_kb = 0;
- int cpu = -1;
- float cpu_weight = 1;
u32 dom = 0;
int ret;
- static char *kwd_list[] = { "dom", "mem_kb", "cpu", "cpu_weight", NULL };
+ static char *kwd_list[] = { "dom", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiif", kwd_list,
- &dom, &mem_kb, &cpu, &cpu_weight))
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwd_list, &dom))
return NULL;
- if ( (ret = xc_domain_create(
- xc->xc_handle, mem_kb, cpu, cpu_weight, &dom)) < 0 )
+ if ( (ret = xc_domain_create(xc->xc_handle, &dom)) < 0 )
return PyErr_SetFromErrno(xc_error);
return PyInt_FromLong(dom);
@@ -171,6 +166,28 @@
return zero;
}
+static PyObject *pyxc_domain_setcpuweight(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+
+ u32 dom;
+ float cpuweight = 1;
+
+ static char *kwd_list[] = { "dom", "cpuweight", NULL };
+
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|f", kwd_list,
+ &dom, &cpuweight) )
+ 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_getinfo(PyObject *self,
PyObject *args,
PyObject *kwds)
@@ -928,6 +945,28 @@
return zero;
}
+static PyObject *pyxc_domain_memory_increase_reservation(PyObject *self,
+ PyObject *args,
+ PyObject *kwds)
+{
+ XcObject *xc = (XcObject *)self;
+
+ u32 dom;
+ unsigned long mem_kb;
+
+ static char *kwd_list[] = { "dom", "mem_kb", NULL };
+
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
+ &dom, &mem_kb) )
+ return NULL;
+
+ if ( xc_domain_memory_increase_reservation(xc->xc_handle, dom, mem_kb) )
+ return PyErr_SetFromErrno(xc_error);
+
+ Py_INCREF(zero);
+ return zero;
+}
+
static PyMethodDef pyxc_methods[] = {
{ "domain_create",
@@ -935,7 +974,6 @@
METH_VARARGS | METH_KEYWORDS, "\n"
"Create a new domain.\n"
" dom [int, 0]: Domain identifier to use (allocated if
zero).\n"
- " mem_kb [int, 0]: Memory allocation, in kilobytes.\n"
"Returns: [int] new domain identifier; -1 on error.\n" },
{ "domain_dumpcore",
@@ -976,6 +1014,14 @@
" cpumap [int, -1]: Bitmap of usable CPUs.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
+ { "domain_setcpuweight",
+ (PyCFunction)pyxc_domain_setcpuweight,
+ METH_VARARGS | METH_KEYWORDS, "\n"
+ "Set cpuweight scheduler parameter for domain.\n"
+ " dom [int]: Identifier of domain to be changed.\n"
+ " cpuweight [float, 1]: VCPU being pinned.\n"
+ "Returns: [int] 0 on success; -1 on error.\n" },
+
{ "domain_getinfo",
(PyCFunction)pyxc_domain_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
@@ -1010,14 +1056,6 @@
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|