bitkeeper revision 1.1488 (428e0104FPjt2icUt6-UvaVbiv-4aQ)

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@cl.cam.ac.uk>
This commit is contained in:
cl349@firebug.cl.cam.ac.uk committed 2005-05-20 15:23:48 +00:00
1 parent 781113f6a0
commit 19a92cce63
5 files changed
+123 -59

No files matched your search

+72 -17
View File
@@ -69,20 +69,15 @@ static PyObject *pyxc_domain_create(PyObject *self,
{
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 @@ static PyObject *pyxc_domain_pincpu(PyObject *self,
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 @@ static PyObject *pyxc_domain_setmaxmem(PyObject *self,
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 @@ static PyMethodDef pyxc_methods[] = {
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 @@ static PyMethodDef pyxc_methods[] = {
" 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 @@ static PyMethodDef pyxc_methods[] = {
" state_file [str]: Name of state file. Must not currently exist.\n"
" progress [int, 1]: Bool - display a running progress indication?\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "plan9_build",
(PyCFunction)pyxc_plan9_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new Plan 9 guest OS.\n"
" dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" cmdline [str, n/a]: Kernel parameters, if any.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "linux_restore",
(PyCFunction)pyxc_linux_restore,
@@ -1038,6 +1076,15 @@ static PyMethodDef pyxc_methods[] = {
" vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "plan9_build",
(PyCFunction)pyxc_plan9_build,
METH_VARARGS | METH_KEYWORDS, "\n"
"Build a new Plan 9 guest OS.\n"
" dom [long]: Identifier of domain to build into.\n"
" image [str]: Name of kernel image file. May be gzipped.\n"
" cmdline [str, n/a]: Kernel parameters, if any.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "vmx_build",
(PyCFunction)pyxc_vmx_build,
METH_VARARGS | METH_KEYWORDS, "\n"
@@ -1207,6 +1254,14 @@ static PyMethodDef pyxc_methods[] = {
" maxmem_kb [long]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_memory_increase_reservation",
(PyCFunction)pyxc_domain_memory_increase_reservation,
METH_VARARGS | METH_KEYWORDS, "\n"
"Increase a domain's memory reservation\n"
" dom [int]: Identifier of domain.\n"
" mem_kb [long]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ NULL, NULL, 0, NULL }
};
+6 -2
View File
@@ -681,8 +681,7 @@ class XendDomainInfo:
raise VmError('invalid cpu')
cpu_weight = self.cpu_weight
memory = memory * 1024 + self.pgtable_size(memory)
dom = xc.domain_create(dom= dom, mem_kb= memory,
cpu= cpu, cpu_weight= cpu_weight)
dom = xc.domain_create(dom= dom)
if self.bootloader:
try:
if kernel: os.unlink(kernel)
@@ -693,6 +692,11 @@ class XendDomainInfo:
if dom <= 0:
raise VmError('Creating domain failed: name=%s memory=%d'
% (self.name, memory))
xc.domain_setcpuweight(dom, cpu_weight)
xc.domain_setmaxmem(dom, memory)
xc.domain_memory_increase_reservation(dom, memory)
if cpu != -1:
xc.domain_pincpu(dom, 0, 1<<int(cpu))
log.debug('init_domain> Created domain=%d name=%s memory=%d', dom, self.name, memory)
self.setdom(dom)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.