bitkeeper revision 1.1108.14.6 (410649f9zyS54Re8bSXNwM_nPxqrOw)

Add support for setting and getting domain maxmem.
This commit is contained in:
mjw@wray-m-3.hpl.hp.com committed 2004-07-27 12:26:33 +00:00
1 parent ba2e13cf57
commit deb5f9442a
7 files changed
+54 -16

No files matched your search

+6 -5
View File
@@ -906,15 +906,15 @@ static PyObject *pyxc_domain_setmaxmem(PyObject *self,
XcObject *xc = (XcObject *)self;
u32 dom;
unsigned long max_memkb;
unsigned long maxmem_kb;
static char *kwd_list[] = { "dom", "max_memkb", NULL };
static char *kwd_list[] = { "dom", "maxmem_kb", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, &max_memkb) )
&dom, &maxmem_kb) )
return NULL;
if ( xc_domain_setmaxmem(xc->xc_handle, dom, max_memkb) != 0 )
if ( xc_domain_setmaxmem(xc->xc_handle, dom, maxmem_kb) != 0 )
return PyErr_SetFromErrno(xc_error);
Py_INCREF(zero);
@@ -980,6 +980,7 @@ static PyMethodDef pyxc_methods[] = {
" blocked [int]: Bool - is the domain blocked waiting for an event?\n"
" running [int]: Bool - is the domain currently running?\n"
" mem_kb [int]: Memory reservation, in kilobytes\n"
" maxmem_kb [int]: Maximum memory limit, in kilobytes\n"
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
" name [str]: Identifying name\n"
" shutdown_reason [int]: Numeric code from guest OS, explaining "
@@ -1228,7 +1229,7 @@ static PyMethodDef pyxc_methods[] = {
METH_VARARGS | METH_KEYWORDS, "\n"
"Set a domain's memory limit\n"
" dom [int]: Identifier of domain.\n"
" max_memkb [long]: .\n"
" maxmem_kb [long]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ NULL, NULL, 0, NULL }
+5 -3
View File
@@ -510,6 +510,11 @@ class Xend:
'latency' : latency,
'xtratime': xtratime })
def xend_domain_maxmem_set(self, id, memory):
return self.xendPost(self.domainurl(id),
{ 'op' : 'maxmem_set',
'memory' : memory })
def xend_domain_vifs(self, id):
return self.xendGet(self.domainurl(id),
{ 'op' : 'vifs' })
@@ -565,9 +570,6 @@ class Xend:
{'op' : 'inject',
'event' : fileof(sxpr) })
def xend_dmesg(self):
return self.xendGet(self.dmesgurl())
def xendmain(srv, asynch, fn, args):
if asynch:
client = AsynchXendClientProtocol()
+11
View File
@@ -686,6 +686,17 @@ class XendDomain:
dom = int(dom)
return xc.shadow_control(dom, op)
def domain_maxmem_set(self, dom, mem):
"""Set the memory limit for a domain.
@param dom: domain
@param mem: memory limit (in MB)
@return: 0 on success, -1 on error
"""
dom = int(dom)
maxmem = int(mem) * 1024
return xc.domain_setmaxmem(dom, maxmem_kb = maxmem)
def instance():
"""Singleton constructor. Use this instead of the class constructor.
+7 -6
View File
@@ -408,12 +408,13 @@ class XendDomainInfo:
['memory', self.memory] ]
if self.info:
run = (self.info['running'] and 'r') or '-'
block = (self.info['blocked'] and 'b') or '-'
stop = (self.info['paused'] and 'p') or '-'
susp = (self.info['shutdown'] and 's') or '-'
crash = (self.info['crashed'] and 'c') or '-'
state = run + block + stop + susp + crash
sxpr.append(['maxmem', self.info['maxmem_kb']/1024 ])
run = (self.info['running'] and 'r') or '-'
block = (self.info['blocked'] and 'b') or '-'
pause = (self.info['paused'] and 'p') or '-'
shut = (self.info['shutdown'] and 's') or '-'
crash = (self.info['crashed'] and 'c') or '-'
state = run + block + pause + shut + crash
sxpr.append(['state', state])
if self.info['shutdown']:
reason = shutdown_reason(self.info['shutdown_reason'])
@@ -151,6 +151,13 @@ class SrvDomain(SrvDir):
val = fn(req.args, {'dom': self.dom.id})
return val
def op_maxmem_set(self, op, req):
fn = FormFn(self.xd.domain_maxmem_set,
[['dom', 'int'],
['memory', 'int']])
val = fn(req.args, {'dom': self.dom.id})
return val
def op_vifs(self, op, req):
return self.xd.domain_vif_ls(self.dom.id)
+17 -1
View File
@@ -351,6 +351,22 @@ class ProgPincpu(Prog):
xm.prog(ProgPincpu)
class ProgMaxmem(Prog):
group = 'domain'
name = 'maxmem'
info = """Set domain memory limit."""
def help(self, args):
print args[0], "DOM MEMORY"
print "\nSet the memory limit for domain DOM to MEMORY megabytes."
def main(self, args):
if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
v = map(int, args[1:3])
server.xend_domain_maxmem_set(*v)
xm.prog(ProgMaxmem)
class ProgBvt(Prog):
group = 'scheduler'
name = "bvt"
@@ -529,7 +545,7 @@ class ProgDmesg(Prog):
info = """Print Xen boot output."""
def main(self, args):
print server.xend_dmesg()[1]
print server.xend_node_dmesg()[1]
xm.prog(ProgDmesg)
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.