mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
Merged.
This commit is contained in:
commit
1676162e17
162 files changed
+7271
-1638
No files matched your search
@@ -135,9 +135,9 @@ static PyObject *pyxc_domain_destroy(XcObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *pyxc_domain_pincpu(XcObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
static PyObject *pyxc_vcpu_setaffinity(XcObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
uint32_t dom;
|
||||
int vcpu = 0, i;
|
||||
@@ -157,7 +157,7 @@ static PyObject *pyxc_domain_pincpu(XcObject *self,
|
||||
cpumap |= (cpumap_t)1 << PyInt_AsLong(PyList_GetItem(cpulist, i));
|
||||
}
|
||||
|
||||
if ( xc_domain_pincpu(self->xc_handle, dom, vcpu, cpumap) != 0 )
|
||||
if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
@@ -297,7 +297,7 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self,
|
||||
&dom, &vcpu) )
|
||||
return NULL;
|
||||
|
||||
rc = xc_domain_get_vcpu_info(self->xc_handle, dom, vcpu, &info);
|
||||
rc = xc_vcpu_getinfo(self->xc_handle, dom, vcpu, &info);
|
||||
if ( rc < 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
@@ -362,21 +362,23 @@ static PyObject *pyxc_vmx_build(XcObject *self,
|
||||
uint32_t dom;
|
||||
char *image;
|
||||
int control_evtchn, store_evtchn;
|
||||
int vcpus = 1;
|
||||
int lapic = 0;
|
||||
int memsize;
|
||||
int vcpus = 1;
|
||||
int acpi = 0;
|
||||
int apic = 0;
|
||||
unsigned long store_mfn = 0;
|
||||
|
||||
static char *kwd_list[] = { "dom", "control_evtchn", "store_evtchn",
|
||||
"memsize", "image", "lapic", "vcpus", NULL };
|
||||
"memsize", "image", "vcpus", "acpi", "apic",
|
||||
NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisii", kwd_list,
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiisiii", kwd_list,
|
||||
&dom, &control_evtchn, &store_evtchn,
|
||||
&memsize, &image, &lapic, &vcpus) )
|
||||
&memsize, &image, &vcpus, &acpi, &apic) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_vmx_build(self->xc_handle, dom, memsize, image, control_evtchn,
|
||||
lapic, vcpus, store_evtchn, &store_mfn) != 0 )
|
||||
vcpus, acpi, apic, store_evtchn, &store_mfn) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
return Py_BuildValue("{s:i}", "store_mfn", store_mfn);
|
||||
@@ -774,6 +776,52 @@ static PyObject *pyxc_domain_ioport_permission(XcObject *self,
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_irq_permission(PyObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
XcObject *xc = (XcObject *)self;
|
||||
uint32_t dom;
|
||||
int pirq, allow_access, ret;
|
||||
|
||||
static char *kwd_list[] = { "dom", "pirq", "allow_access", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
|
||||
&dom, &pirq, &allow_access) )
|
||||
return NULL;
|
||||
|
||||
ret = xc_domain_irq_permission(
|
||||
xc->xc_handle, dom, pirq, allow_access);
|
||||
if ( ret != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_iomem_permission(PyObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
XcObject *xc = (XcObject *)self;
|
||||
uint32_t dom;
|
||||
unsigned long first_pfn, nr_pfns, allow_access, ret;
|
||||
|
||||
static char *kwd_list[] = { "dom", "first_pfn", "nr_pfns", "allow_access", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illi", kwd_list,
|
||||
&dom, &first_pfn, &nr_pfns, &allow_access) )
|
||||
return NULL;
|
||||
|
||||
ret = xc_domain_iomem_permission(
|
||||
xc->xc_handle, dom, first_pfn, nr_pfns, allow_access);
|
||||
if ( ret != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *dom_op(XcObject *self, PyObject *args,
|
||||
int (*fn)(int, uint32_t))
|
||||
@@ -842,8 +890,8 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" dom [int]: Identifier of domain to be destroyed.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_pincpu",
|
||||
(PyCFunction)pyxc_domain_pincpu,
|
||||
{ "vcpu_setaffinity",
|
||||
(PyCFunction)pyxc_vcpu_setaffinity,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Pin a VCPU to a specified set CPUs.\n"
|
||||
" dom [int]: Identifier of domain to which VCPU belongs.\n"
|
||||
@@ -1070,6 +1118,25 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_irq_permission",
|
||||
(PyCFunction)pyxc_domain_irq_permission,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Allow a domain access to a physical IRQ\n"
|
||||
" dom [int]: Identifier of domain to be allowed access.\n"
|
||||
" pirq [int]: The Physical IRQ\n"
|
||||
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_iomem_permission",
|
||||
(PyCFunction)pyxc_domain_iomem_permission,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Allow a domain access to a range of IO memory pages\n"
|
||||
" dom [int]: Identifier of domain to be allowed access.\n"
|
||||
" first_pfn [long]: First page of I/O Memory\n"
|
||||
" nr_pfns [long]: Number of pages of I/O Memory (>0)\n"
|
||||
" allow_access [int]: Non-zero means enable access; else disable access\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "pages_to_kib",
|
||||
(PyCFunction)pyxc_pages_to_kib,
|
||||
METH_VARARGS, "\n"
|
||||
|
||||
@@ -443,7 +443,7 @@ class XendDomain:
|
||||
cpumap = map(lambda x: int(x),
|
||||
cpumap.replace("[", "").replace("]", "").split(","))
|
||||
try:
|
||||
return xc.domain_pincpu(dominfo.getDomid(), vcpu, cpumap)
|
||||
return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
|
||||
except Exception, ex:
|
||||
raise XendError(str(ex))
|
||||
|
||||
|
||||
@@ -1179,7 +1179,7 @@ class XendDomainInfo:
|
||||
for v in range(0, self.info['max_vcpu_id']+1):
|
||||
# pincpu takes a list of ints
|
||||
cpu = [ int( cpus[v % len(cpus)] ) ]
|
||||
xc.domain_pincpu(self.domid, v, cpu)
|
||||
xc.vcpu_setaffinity(self.domid, v, cpu)
|
||||
|
||||
m = self.image.getDomainMemory(self.info['memory'] * 1024)
|
||||
balloon.free(m)
|
||||
|
||||
@@ -189,11 +189,16 @@ class VmxImageHandler(ImageHandler):
|
||||
def configure(self, imageConfig, deviceConfig):
|
||||
ImageHandler.configure(self, imageConfig, deviceConfig)
|
||||
|
||||
info = xc.xeninfo()
|
||||
if not 'hvm' in info['xen_caps']:
|
||||
raise VmError("vmx: not an Intel VT platform, we stop creating!")
|
||||
|
||||
self.dmargs = self.parseDeviceModelArgs(imageConfig, deviceConfig)
|
||||
self.device_model = sxp.child_value(imageConfig, 'device_model')
|
||||
if not self.device_model:
|
||||
raise VmError("vmx: missing device model")
|
||||
self.display = sxp.child_value(imageConfig, 'display')
|
||||
self.xauthority = sxp.child_value(imageConfig, 'xauthority')
|
||||
|
||||
self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)),
|
||||
("image/device-model", self.device_model),
|
||||
@@ -204,10 +209,8 @@ class VmxImageHandler(ImageHandler):
|
||||
|
||||
self.dmargs += self.configVNC(imageConfig)
|
||||
|
||||
self.lapic = 0
|
||||
lapic = sxp.child_value(imageConfig, 'lapic')
|
||||
if not lapic is None:
|
||||
self.lapic = int(lapic)
|
||||
self.acpi = int(sxp.child_value(imageConfig, 'acpi', 0))
|
||||
self.apic = int(sxp.child_value(imageConfig, 'apic', 0))
|
||||
|
||||
def buildDomain(self):
|
||||
# Create an event channel
|
||||
@@ -222,17 +225,18 @@ class VmxImageHandler(ImageHandler):
|
||||
log.debug("control_evtchn = %d", self.device_channel)
|
||||
log.debug("store_evtchn = %d", store_evtchn)
|
||||
log.debug("memsize = %d", self.vm.getMemoryTarget() / 1024)
|
||||
log.debug("lapic = %d", self.lapic)
|
||||
log.debug("vcpus = %d", self.vm.getVCpuCount())
|
||||
log.debug("acpi = %d", self.acpi)
|
||||
log.debug("apic = %d", self.apic)
|
||||
|
||||
return xc.vmx_build(dom = self.vm.getDomid(),
|
||||
image = self.kernel,
|
||||
control_evtchn = self.device_channel,
|
||||
store_evtchn = store_evtchn,
|
||||
memsize = self.vm.getMemoryTarget() / 1024,
|
||||
lapic = self.lapic,
|
||||
vcpus = self.vm.getVCpuCount())
|
||||
|
||||
vcpus = self.vm.getVCpuCount(),
|
||||
acpi = self.acpi,
|
||||
apic = self.apic)
|
||||
|
||||
# Return a list of cmd line args to the device models based on the
|
||||
# xm config file
|
||||
@@ -264,44 +268,44 @@ class VmxImageHandler(ImageHandler):
|
||||
nics = 0
|
||||
for (name, info) in deviceConfig:
|
||||
if name == 'vbd':
|
||||
uname = sxp.child_value(info, 'uname')
|
||||
typedev = sxp.child_value(info, 'dev')
|
||||
(_, vbdparam) = string.split(uname, ':', 1)
|
||||
if re.match('^ioemu:', typedev):
|
||||
(emtype, vbddev) = string.split(typedev, ':', 1)
|
||||
else:
|
||||
emtype = 'vbd'
|
||||
vbddev = typedev
|
||||
if emtype != 'ioemu':
|
||||
continue;
|
||||
vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
|
||||
if vbddev not in vbddev_list:
|
||||
raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
|
||||
ret.append("-%s" % vbddev)
|
||||
ret.append("%s" % vbdparam)
|
||||
uname = sxp.child_value(info, 'uname')
|
||||
typedev = sxp.child_value(info, 'dev')
|
||||
(_, vbdparam) = string.split(uname, ':', 1)
|
||||
if 'ioemu:' in typedev:
|
||||
(emtype, vbddev) = string.split(typedev, ':', 1)
|
||||
else:
|
||||
emtype = 'vbd'
|
||||
vbddev = typedev
|
||||
if emtype == 'vbd':
|
||||
continue;
|
||||
vbddev_list = ['hda', 'hdb', 'hdc', 'hdd']
|
||||
if vbddev not in vbddev_list:
|
||||
raise VmError("vmx: for qemu vbd type=file&dev=hda~hdd")
|
||||
ret.append("-%s" % vbddev)
|
||||
ret.append("%s" % vbdparam)
|
||||
if name == 'vif':
|
||||
type = sxp.child_value(info, 'type')
|
||||
if type != 'ioemu':
|
||||
continue
|
||||
nics += 1
|
||||
if mac != None:
|
||||
continue
|
||||
mac = sxp.child_value(info, 'mac')
|
||||
bridge = sxp.child_value(info, 'bridge')
|
||||
if mac == None:
|
||||
mac = randomMAC()
|
||||
if bridge == None:
|
||||
bridge = 'xenbr0'
|
||||
ret.append("-macaddr")
|
||||
ret.append("%s" % mac)
|
||||
ret.append("-bridge")
|
||||
ret.append("%s" % bridge)
|
||||
type = sxp.child_value(info, 'type')
|
||||
if type != 'ioemu':
|
||||
continue
|
||||
nics += 1
|
||||
if mac != None:
|
||||
continue
|
||||
mac = sxp.child_value(info, 'mac')
|
||||
bridge = sxp.child_value(info, 'bridge')
|
||||
if mac == None:
|
||||
mac = randomMAC()
|
||||
if bridge == None:
|
||||
bridge = 'xenbr0'
|
||||
ret.append("-macaddr")
|
||||
ret.append("%s" % mac)
|
||||
ret.append("-bridge")
|
||||
ret.append("%s" % bridge)
|
||||
if name == 'vtpm':
|
||||
instance = sxp.child_value(info, 'pref_instance')
|
||||
ret.append("-instance")
|
||||
ret.append("%s" % instance)
|
||||
instance = sxp.child_value(info, 'pref_instance')
|
||||
ret.append("-instance")
|
||||
ret.append("%s" % instance)
|
||||
ret.append("-nics")
|
||||
ret.append("%d" % nics)
|
||||
ret.append("%d" % nics)
|
||||
return ret
|
||||
|
||||
def configVNC(self, config):
|
||||
@@ -340,6 +344,8 @@ class VmxImageHandler(ImageHandler):
|
||||
env = dict(os.environ)
|
||||
if self.display:
|
||||
env['DISPLAY'] = self.display
|
||||
if self.xauthority:
|
||||
env['XAUTHORITY'] = self.xauthority
|
||||
log.info("spawning device models: %s %s", self.device_model, args)
|
||||
self.pid = os.spawnve(os.P_NOWAIT, self.device_model, args, env)
|
||||
log.info("device model pid: %d", self.pid)
|
||||
|
||||
@@ -31,7 +31,7 @@ class BlkifController(DevController):
|
||||
"""Block device interface controller. Handles all block devices
|
||||
for a domain.
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, vm):
|
||||
"""Create a block device controller.
|
||||
"""
|
||||
@@ -40,9 +40,9 @@ class BlkifController(DevController):
|
||||
|
||||
def getDeviceDetails(self, config):
|
||||
"""@see DevController.getDeviceDetails"""
|
||||
|
||||
|
||||
dev = sxp.child_value(config, 'dev')
|
||||
if re.match('^ioemu:', dev):
|
||||
if 'ioemu:' in dev:
|
||||
return (None,{},{})
|
||||
|
||||
devid = blkif.blkdev_name_to_number(dev)
|
||||
|
||||
@@ -160,9 +160,13 @@ gopts.var('cpus', val='CPUS',
|
||||
fn=set_int, default=None,
|
||||
use="CPUS to run the domain on.")
|
||||
|
||||
gopts.var('lapic', val='LAPIC',
|
||||
gopts.var('acpi', val='ACPI',
|
||||
fn=set_int, default=0,
|
||||
use="Disable or enable local APIC of VMX domain.")
|
||||
use="Disable or enable ACPI of VMX domain.")
|
||||
|
||||
gopts.var('apic', val='APIC',
|
||||
fn=set_int, default=0,
|
||||
use="Disable or enable APIC of VMX domain.")
|
||||
|
||||
gopts.var('vcpus', val='VCPUS',
|
||||
fn=set_int, default=1,
|
||||
@@ -388,6 +392,10 @@ gopts.var('display', val='DISPLAY',
|
||||
fn=set_value, default=None,
|
||||
use="X11 display to use")
|
||||
|
||||
gopts.var('xauthority', val='XAUTHORITY',
|
||||
fn=set_value, default=None,
|
||||
use="X11 Authority to use")
|
||||
|
||||
|
||||
def err(msg):
|
||||
"""Print an error to stderr and exit.
|
||||
@@ -526,7 +534,8 @@ def configure_vmx(config_image, vals):
|
||||
"""
|
||||
args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
|
||||
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'audio',
|
||||
'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic']
|
||||
'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'acpi', 'apic',
|
||||
'xauthority' ]
|
||||
for a in args:
|
||||
if (vals.__dict__[a]):
|
||||
config_image.append([a, vals.__dict__[a]])
|
||||
@@ -801,6 +810,9 @@ def parseCommandLine(argv):
|
||||
if not gopts.vals.display:
|
||||
gopts.vals.display = os.getenv("DISPLAY")
|
||||
|
||||
if not gopts.vals.xauthority:
|
||||
gopts.vals.xauthority = os.getenv("XAUTHORITY")
|
||||
|
||||
# Process remaining args as config variables.
|
||||
for arg in args:
|
||||
if '=' in arg:
|
||||
|
||||
@@ -390,7 +390,6 @@ def xm_brief_list(doms):
|
||||
|
||||
|
||||
def xm_vcpu_list(args):
|
||||
print 'Name ID VCPU CPU State Time(s) CPU Affinity'
|
||||
|
||||
from xen.xend.XendClient import server
|
||||
if args:
|
||||
@@ -401,6 +400,8 @@ def xm_vcpu_list(args):
|
||||
lambda x: server.xend_domain_vcpuinfo(sxp.child_value(x, 'name')),
|
||||
doms)
|
||||
|
||||
print 'Name ID VCPU CPU State Time(s) CPU Affinity'
|
||||
|
||||
for dom in dominfo:
|
||||
def get_info(n):
|
||||
return sxp.child_value(dom, n)
|
||||
@@ -625,6 +626,8 @@ def xm_sched_sedf(args):
|
||||
server.xend_domain_cpu_sedf_set(dom, *v)
|
||||
|
||||
def xm_info(args):
|
||||
arg_check(args, "info", 0)
|
||||
|
||||
from xen.xend.XendClient import server
|
||||
info = server.xend_node()
|
||||
|
||||
@@ -645,9 +648,12 @@ def xm_console(args):
|
||||
|
||||
|
||||
def xm_top(args):
|
||||
arg_check(args, "top", 0)
|
||||
|
||||
os.execvp('xentop', ['xentop'])
|
||||
|
||||
def xm_dmesg(args):
|
||||
arg_check(args, "dmesg", 0)
|
||||
|
||||
gopts = Opts(use="""[-c|--clear]
|
||||
|
||||
|
||||