mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
bitkeeper revision 1.1400 (4284b9fcQX9z9IzwMeHwdHYRkEIjFA)
Merge
This commit is contained in:
commit
5149cc539b
85 files changed
+2850
-763
No files matched your search
@@ -155,15 +155,16 @@ static PyObject *pyxc_domain_pincpu(PyObject *self,
|
||||
XcObject *xc = (XcObject *)self;
|
||||
|
||||
u32 dom;
|
||||
int cpu = -1;
|
||||
int vcpu = 0;
|
||||
cpumap_t cpumap = 0xFFFFFFFF;
|
||||
|
||||
static char *kwd_list[] = { "dom", "cpu", NULL };
|
||||
static char *kwd_list[] = { "dom", "vcpu", "cpumap", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
|
||||
&dom, &cpu) )
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|ii", kwd_list,
|
||||
&dom, &vcpu, &cpumap) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_domain_pincpu(xc->xc_handle, dom, cpu) != 0 )
|
||||
if ( xc_domain_pincpu(xc->xc_handle, dom, vcpu, &cpumap) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
@@ -175,10 +176,10 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
|
||||
PyObject *kwds)
|
||||
{
|
||||
XcObject *xc = (XcObject *)self;
|
||||
PyObject *list;
|
||||
PyObject *list, *vcpu_list, *cpumap_list, *info_dict;
|
||||
|
||||
u32 first_dom = 0;
|
||||
int max_doms = 1024, nr_doms, i;
|
||||
int max_doms = 1024, nr_doms, i, j;
|
||||
xc_dominfo_t *info;
|
||||
|
||||
static char *kwd_list[] = { "first_dom", "max_doms", NULL };
|
||||
@@ -195,23 +196,33 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
|
||||
list = PyList_New(nr_doms);
|
||||
for ( i = 0 ; i < nr_doms; i++ )
|
||||
{
|
||||
PyList_SetItem(
|
||||
list, i,
|
||||
Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
|
||||
",s:l,s:L,s:l,s:i}",
|
||||
"dom", info[i].domid,
|
||||
"cpu", info[i].cpu,
|
||||
"dying", info[i].dying,
|
||||
"crashed", info[i].crashed,
|
||||
"shutdown", info[i].shutdown,
|
||||
"paused", info[i].paused,
|
||||
"blocked", info[i].blocked,
|
||||
"running", info[i].running,
|
||||
"mem_kb", info[i].nr_pages*4,
|
||||
"cpu_time", info[i].cpu_time,
|
||||
"maxmem_kb", info[i].max_memkb,
|
||||
"shutdown_reason", info[i].shutdown_reason
|
||||
));
|
||||
vcpu_list = PyList_New(MAX_VIRT_CPUS);
|
||||
cpumap_list = PyList_New(MAX_VIRT_CPUS);
|
||||
for ( j = 0; j < MAX_VIRT_CPUS; j++ ) {
|
||||
PyList_SetItem( vcpu_list, j,
|
||||
Py_BuildValue("i", info[i].vcpu_to_cpu[j]));
|
||||
PyList_SetItem( cpumap_list, j,
|
||||
Py_BuildValue("i", info[i].cpumap[j]));
|
||||
}
|
||||
|
||||
info_dict = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
|
||||
",s:l,s:L,s:l,s:i}",
|
||||
"dom", info[i].domid,
|
||||
"vcpus", info[i].vcpus,
|
||||
"dying", info[i].dying,
|
||||
"crashed", info[i].crashed,
|
||||
"shutdown", info[i].shutdown,
|
||||
"paused", info[i].paused,
|
||||
"blocked", info[i].blocked,
|
||||
"running", info[i].running,
|
||||
"mem_kb", info[i].nr_pages*4,
|
||||
"cpu_time", info[i].cpu_time,
|
||||
"maxmem_kb", info[i].max_memkb,
|
||||
"shutdown_reason", info[i].shutdown_reason);
|
||||
PyDict_SetItemString( info_dict, "vcpu_to_cpu", vcpu_list );
|
||||
PyDict_SetItemString( info_dict, "cpumap", cpumap_list );
|
||||
PyList_SetItem( list, i, info_dict);
|
||||
|
||||
}
|
||||
|
||||
free(info);
|
||||
@@ -959,9 +970,10 @@ static PyMethodDef pyxc_methods[] = {
|
||||
{ "domain_pincpu",
|
||||
(PyCFunction)pyxc_domain_pincpu,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Pin a domain to a specified CPU.\n"
|
||||
" dom [int]: Identifier of domain to be pinned.\n"
|
||||
" cpu [int, -1]: CPU to pin to, or -1 to unpin\n\n"
|
||||
"Pin a VCPU to a specified set CPUs.\n"
|
||||
" dom [int]: Identifier of domain to which VCPU belongs.\n"
|
||||
" vcpu [int, 0]: VCPU being pinned.\n"
|
||||
" cpumap [int, -1]: Bitmap of usable CPUs.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_getinfo",
|
||||
@@ -976,6 +988,7 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" domain-id space was reached.\n"
|
||||
" dom [int]: Identifier of domain to which this info pertains\n"
|
||||
" cpu [int]: CPU to which this domain is bound\n"
|
||||
" vcpus [int]: Number of Virtual CPUS in this domain\n"
|
||||
" dying [int]: Bool - is the domain dying?\n"
|
||||
" crashed [int]: Bool - has the domain crashed?\n"
|
||||
" shutdown [int]: Bool - has the domain shut itself down?\n"
|
||||
@@ -986,7 +999,8 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" maxmem_kb [int]: Maximum memory limit, in kilobytes\n"
|
||||
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
|
||||
" shutdown_reason [int]: Numeric code from guest OS, explaining "
|
||||
"reason why it shut itself down.\n" },
|
||||
"reason why it shut itself down.\n"
|
||||
" vcpu_to_cpu [[int]]: List that maps VCPUS to CPUS\n" },
|
||||
|
||||
{ "linux_save",
|
||||
(PyCFunction)pyxc_linux_save,
|
||||
|
||||
@@ -236,10 +236,11 @@ class Xend:
|
||||
'live' : live,
|
||||
'resource' : resource })
|
||||
|
||||
def xend_domain_pincpu(self, id, cpu):
|
||||
def xend_domain_pincpu(self, id, vcpu, cpumap):
|
||||
return self.xendPost(self.domainurl(id),
|
||||
{'op' : 'pincpu',
|
||||
'cpu' : cpu })
|
||||
'vcpu' : vcpu,
|
||||
'cpumap' : cpumap })
|
||||
|
||||
def xend_domain_cpu_bvt_set(self, id, mcuadv, warpback, warpvalue, warpl, warpu):
|
||||
return self.xendPost(self.domainurl(id),
|
||||
|
||||
@@ -675,15 +675,16 @@ class XendDomain:
|
||||
xmigrate = XendMigrate.instance()
|
||||
return xmigrate.save_begin(dominfo, dst)
|
||||
|
||||
def domain_pincpu(self, id, cpu):
|
||||
"""Pin a domain to a cpu.
|
||||
def domain_pincpu(self, id, vcpu, cpumap):
|
||||
"""Set which cpus vcpu can use
|
||||
|
||||
@param id: domain
|
||||
@param cpu: cpu number
|
||||
@param id: domain
|
||||
@param vcpu: vcpu number
|
||||
@param cpumap: bitmap of usbale cpus
|
||||
"""
|
||||
dominfo = self.domain_lookup(id)
|
||||
try:
|
||||
return xc.domain_pincpu(int(dominfo.id), cpu)
|
||||
return xc.domain_pincpu(int(dominfo.id), vcpu, cpumap)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
|
||||
@@ -419,8 +419,12 @@ class XendDomainInfo:
|
||||
if self.info['shutdown']:
|
||||
reason = shutdown_reason(self.info['shutdown_reason'])
|
||||
sxpr.append(['shutdown_reason', reason])
|
||||
sxpr.append(['cpu', self.info['cpu']])
|
||||
sxpr.append(['cpu', self.info['vcpu_to_cpu'][0]])
|
||||
sxpr.append(['cpu_time', self.info['cpu_time']/1e9])
|
||||
sxpr.append(['vcpus', self.info['vcpus']])
|
||||
sxpr.append(['cpumap', self.info['cpumap']])
|
||||
sxpr.append(['vcpu_to_cpu', ''.join(map(lambda x: str(x),
|
||||
self.info['vcpu_to_cpu'][0:self.info['vcpus']]))])
|
||||
|
||||
if self.start_time:
|
||||
up_time = time.time() - self.start_time
|
||||
@@ -529,7 +533,8 @@ class XendDomainInfo:
|
||||
raise VmError('missing memory size')
|
||||
cpu = sxp.child_value(config, 'cpu')
|
||||
if self.recreate and self.dom and cpu is not None:
|
||||
xc.domain_pincpu(self.dom, int(cpu))
|
||||
#xc.domain_pincpu(self.dom, int(cpu))
|
||||
xc.domain_pincpu(self.dom, 0, 1<<int(cpu))
|
||||
try:
|
||||
image = sxp.child_value(self.config, 'image')
|
||||
vcpus = sxp.child_value(image, 'vcpus')
|
||||
|
||||
@@ -88,7 +88,8 @@ class SrvDomain(SrvDir):
|
||||
def op_pincpu(self, op, req):
|
||||
fn = FormFn(self.xd.domain_pincpu,
|
||||
[['dom', 'str'],
|
||||
['cpu', 'int']])
|
||||
['vcpu', 'int'],
|
||||
['cpumap', 'int']])
|
||||
val = fn(req.args, {'dom': self.dom.id})
|
||||
return val
|
||||
|
||||
|
||||
+56
-11
@@ -6,6 +6,8 @@ import os.path
|
||||
import sys
|
||||
from getopt import getopt
|
||||
import socket
|
||||
import warnings
|
||||
warnings.filterwarnings('ignore', category=FutureWarning)
|
||||
|
||||
from xen.xend import PrettyPrint
|
||||
from xen.xend import sxp
|
||||
@@ -340,8 +342,8 @@ class ProgList(Prog):
|
||||
name = "list"
|
||||
info = """List information about domains."""
|
||||
|
||||
short_options = 'l'
|
||||
long_options = ['long']
|
||||
short_options = 'lv'
|
||||
long_options = ['long','vcpus']
|
||||
|
||||
def help(self, args):
|
||||
if help:
|
||||
@@ -350,11 +352,13 @@ class ProgList(Prog):
|
||||
Either all domains or the domains given.
|
||||
|
||||
-l, --long Get more detailed information.
|
||||
-v, --vcpus Show VCPU to CPU mapping.
|
||||
"""
|
||||
return
|
||||
|
||||
def main(self, args):
|
||||
use_long = 0
|
||||
show_vcpus = 0
|
||||
(options, params) = getopt(args[1:],
|
||||
self.short_options,
|
||||
self.long_options)
|
||||
@@ -362,6 +366,8 @@ class ProgList(Prog):
|
||||
for (k, v) in options:
|
||||
if k in ['-l', '--long']:
|
||||
use_long = 1
|
||||
if k in ['-v', '--vcpus']:
|
||||
show_vcpus = 1
|
||||
|
||||
if n == 0:
|
||||
doms = server.xend_domains()
|
||||
@@ -371,11 +377,13 @@ class ProgList(Prog):
|
||||
|
||||
if use_long:
|
||||
self.long_list(doms)
|
||||
elif show_vcpus:
|
||||
self.show_vcpus(doms)
|
||||
else:
|
||||
self.brief_list(doms)
|
||||
|
||||
def brief_list(self, doms):
|
||||
print 'Name Id Mem(MB) CPU State Time(s) Console'
|
||||
print 'Name Id Mem(MB) CPU VCPU(s) State Time(s) Console'
|
||||
for dom in doms:
|
||||
info = server.xend_domain(dom)
|
||||
d = {}
|
||||
@@ -383,6 +391,7 @@ class ProgList(Prog):
|
||||
d['name'] = sxp.child_value(info, 'name', '??')
|
||||
d['mem'] = int(sxp.child_value(info, 'memory', '0'))
|
||||
d['cpu'] = int(sxp.child_value(info, 'cpu', '0'))
|
||||
d['vcpus'] = int(sxp.child_value(info, 'vcpus', '0'))
|
||||
d['state'] = sxp.child_value(info, 'state', '??')
|
||||
d['cpu_time'] = float(sxp.child_value(info, 'cpu_time', '0'))
|
||||
console = sxp.child(info, 'console')
|
||||
@@ -390,9 +399,27 @@ class ProgList(Prog):
|
||||
d['port'] = sxp.child_value(console, 'console_port')
|
||||
else:
|
||||
d['port'] = ''
|
||||
print ("%(name)-16s %(dom)3d %(mem)7d %(cpu)3d %(state)5s %(cpu_time)7.1f %(port)4s"
|
||||
print ("%(name)-16s %(dom)3d %(mem)7d %(cpu)3d %(vcpus)5d %(state)5s %(cpu_time)7.1f %(port)4s"
|
||||
% d)
|
||||
|
||||
def show_vcpus(self, doms):
|
||||
print 'Name Id VCPU CPU CPUMAP'
|
||||
for dom in doms:
|
||||
info = server.xend_domain(dom)
|
||||
vcpu_to_cpu = sxp.child_value(info, 'vcpu_to_cpu', '?').replace('-','')
|
||||
cpumap = sxp.child_value(info, 'cpumap', [])
|
||||
mask = ((int(sxp.child_value(info, 'vcpus', '0')))**2) - 1
|
||||
count = 0
|
||||
for cpu in vcpu_to_cpu:
|
||||
d = {}
|
||||
d['name'] = sxp.child_value(info, 'name', '??')
|
||||
d['dom'] = int(sxp.child_value(info, 'id', '-1'))
|
||||
d['vcpu'] = int(count)
|
||||
d['cpu'] = int(cpu)
|
||||
d['cpumap'] = int(cpumap[count])&mask
|
||||
count = count + 1
|
||||
print ("%(name)-16s %(dom)3d %(vcpu)4d %(cpu)3d 0x%(cpumap)x" % d)
|
||||
|
||||
def long_list(self, doms):
|
||||
for dom in doms:
|
||||
info = server.xend_domain(dom)
|
||||
@@ -474,17 +501,35 @@ xm.prog(ProgUnpause)
|
||||
class ProgPincpu(Prog):
|
||||
group = 'domain'
|
||||
name = "pincpu"
|
||||
info = """Pin a domain to a cpu. """
|
||||
info = """Set which cpus a VCPU can use. """
|
||||
|
||||
def help(self, args):
|
||||
print args[0],'DOM CPU'
|
||||
print '\nPin domain DOM to cpu CPU.'
|
||||
print args[0],'DOM VCPU CPUS'
|
||||
print '\nSet which cpus VCPU in domain DOM can use.'
|
||||
|
||||
# convert list of cpus to bitmap integer value
|
||||
def make_map(self, cpulist):
|
||||
cpus = []
|
||||
cpumap = 0
|
||||
for c in cpulist.split(','):
|
||||
if len(c) > 1:
|
||||
(x,y) = c.split('-')
|
||||
for i in range(int(x),int(y)+1):
|
||||
cpus.append(int(i))
|
||||
else:
|
||||
cpus.append(int(c))
|
||||
cpus.sort()
|
||||
for c in cpus:
|
||||
cpumap = cpumap | 1<<c
|
||||
|
||||
return cpumap
|
||||
|
||||
def main(self, args):
|
||||
if len(args) != 3: self.err("%s: Invalid argument(s)" % args[0])
|
||||
dom = args[1]
|
||||
cpu = int(args[2])
|
||||
server.xend_domain_pincpu(dom, cpu)
|
||||
if len(args) != 4: self.err("%s: Invalid argument(s)" % args[0])
|
||||
dom = args[1]
|
||||
vcpu = int(args[2])
|
||||
cpumap = self.make_map(args[3]);
|
||||
server.xend_domain_pincpu(dom, vcpu, cpumap)
|
||||
|
||||
xm.prog(ProgPincpu)
|
||||
|
||||
|
||||