val = 2
else:
val = 0
-
+
try:
curses.curs_set(val)
except _curses.error:
def get_partition_offsets(file):
image_type = identify_disk_image(file)
if image_type == DISK_TYPE_RAW:
- # No MBR: assume whole disk filesystem, which is like a
+ # No MBR: assume whole disk filesystem, which is like a
# single partition starting at 0
return [0]
elif image_type == DISK_TYPE_HYBRIDISO:
partbuf = buf[poff:poff+16]
offset = struct.unpack("<L", partbuf[8:12])[0] * SECTOR_SIZE
type = struct.unpack("<B", partbuf[4:5])[0]
-
+
# offset == 0 implies this partition is not enabled
if offset == 0:
continue
screen.noutrefresh()
win = curses.newwin(1, 74, startx, starty + 2)
curses.textpad.Textbox.__init__(self, win)
-
+
self.line = list(line)
self.pos = len(line)
self.cancelled = False
if self.cancelled:
return None
return string.join(self.line, "")
-
+
class Grub:
ENTRY_WIN_LINES = 8
self.entry_win = curses.newwin(Grub.ENTRY_WIN_LINES + 2, 74, 2, 1)
self.text_win = curses.newwin(10, 70, 12, 5)
curses.def_prog_mode()
-
+
curses.reset_prog_mode()
self.screen.erase()
self.start_image = self.selected_image
if self.selected_image < self.start_image:
self.start_image = self.selected_image
-
+
for y in range(self.start_image, len(self.cf.images)):
i = self.cf.images[y]
if y > self.start_image + maxy:
l = img.lines[idx].expandtabs().ljust(70)
if len(l) > 70:
l = l[:69] + ">"
-
+
self.entry_win.addstr(idp, 2, l)
if idx == curline:
self.entry_win.attroff(curses.A_REVERSE)
self.command_line_mode()
if self.isdone:
return
-
+
# bound at the top and bottom
if curline < 0:
curline = 0
lines = []
while 1:
t = GrubLineEditor(self.screen, y, 2)
- enable_cursor(True)
+ enable_cursor(True)
ret = t.edit()
if ret:
if ret in ("quit", "return"):
lines.append(ret)
continue
- # if we got boot, then we want to boot the entered image
+ # if we got boot, then we want to boot the entered image
img = self.cf.new_image("entered", lines)
self.cf.add_image(img)
self.selected_image = len(self.cf.images) - 1
def read_config(self, fn, fs = None):
"""Read the given file to parse the config. If fs = None, then
we're being given a raw config file rather than a disk image."""
-
+
if not os.access(fn, os.R_OK):
raise RuntimeError("Unable to access %s" %(fn,))
while not self.isdone:
self.run_main(timeout)
timeout = -1
-
+
return self.selected_image
def run_main(self, timeout = -1):
self.start_image = 0
while (timeout == -1 or mytime < int(timeout)):
draw()
- if timeout != -1 and mytime != -1:
+ if timeout != -1 and mytime != -1:
self.screen.addstr(20, 5, "Will boot selected entry in %2d seconds"
%(int(timeout) - mytime))
else:
self.selected_image = 0
elif self.selected_image >= len(self.cf.images):
self.selected_image = len(self.cf.images) - 1
-
+
def get_entry_idx(cf, entry):
# first, see if the given entry is numeric
try:
# Unpleasant. Typically we'll have 'root=foo -k' or 'root=foo /kernel -k',
# and we need to maintain Xen properties (root= and ip=) and the kernel
# before any user args.
-
+
xenargs = ""
userargs = ""
-
+
if not cfg["args"]:
cfg["args"] = cfg["kernel"]
else:
cfg["args"] = xenargs + " " + cfg["kernel"] + " " + userargs
return cfg
-
+
def sniff_netware(fs, cfg):
if not fs.file_exists("/nwserver/xnloader.sys"):
return cfg
if args:
s += "(args %s)" % repr(args)
return s
-
+
def format_simple(kernel, ramdisk, args, sep):
for check in (kernel, ramdisk, args):
if check is not None and sep in check:
if __name__ == "__main__":
sel = None
-
+
def usage():
print("Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] [--offset=] <image>" %(sys.argv[0],), file=sys.stderr)
opts, args = getopt.gnu_getopt(sys.argv[1:], 'qilnh::',
["quiet", "interactive", "list-entries", "not-really", "help",
"output=", "output-format=", "output-directory=", "offset=",
- "entry=", "kernel=",
+ "entry=", "kernel=",
"ramdisk=", "args=", "isconfig", "debug"])
except getopt.GetoptError:
usage()
os.write(fd, ostring)
else:
os.write(fd, ostring.encode())
-
+
/******************************************************************************
* Xc.c
- *
+ *
* Copyright (c) 2003-2004, K A Fraser (University of Cambridge)
*/
if ( xc_domain_dumpcore(self->xc_handle, dom, corefile) != 0 )
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
return NULL;
if ( pyhandle != NULL )
{
- if ( !PyList_Check(pyhandle) ||
+ if ( !PyList_Check(pyhandle) ||
(PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
goto out_exception;
if (xc_domain_max_vcpus(self->xc_handle, dom, max) != 0)
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
if ( xc_domain_shutdown(self->xc_handle, dom, reason) != 0 )
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
static char *kwd_list[] = { "domid", "vcpu", "cpumap", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list,
&dom, &vcpu, &cpulist) )
return NULL;
if ( (cpulist != NULL) && PyList_Check(cpulist) )
{
- for ( i = 0; i < PyList_Size(cpulist); i++ )
+ for ( i = 0; i < PyList_Size(cpulist); i++ )
{
long cpu = PyLongOrInt_AsLong(PyList_GetItem(cpulist, i));
if ( cpu < 0 || cpu >= nr_cpus )
cpumap[cpu / 8] |= 1 << (cpu % 8);
}
}
-
+
if ( xc_vcpu_setaffinity(self->xc_handle, dom, vcpu, cpumap,
NULL, XEN_VCPUAFFINITY_HARD) != 0 )
{
return pyxc_error_to_exception(self->xc_handle);
}
Py_INCREF(zero);
- free(cpumap);
+ free(cpumap);
return zero;
}
if (!PyArg_ParseTuple(args, "iO", &dom, &pyhandle))
return NULL;
- if ( !PyList_Check(pyhandle) ||
+ if ( !PyList_Check(pyhandle) ||
(PyList_Size(pyhandle) != sizeof(xen_domain_handle_t)) )
{
goto out_exception;
if (xc_domain_sethandle(self->xc_handle, dom, handle) < 0)
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
xc_dominfo_t *info;
static char *kwd_list[] = { "first_dom", "max_doms", NULL };
-
+
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list,
&first_dom, &max_doms) )
return NULL;
int nr_cpus;
static char *kwd_list[] = { "domid", "vcpu", NULL };
-
+
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &vcpu) )
return NULL;
int param;
uint64_t value;
- static char *kwd_list[] = { "domid", "param", NULL };
+ static char *kwd_list[] = { "domid", "param", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list,
&dom, ¶m) )
return NULL;
int param;
uint64_t value;
- static char *kwd_list[] = { "domid", "param", "value", NULL };
+ static char *kwd_list[] = { "domid", "param", "value", NULL };
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiL", kwd_list,
&dom, ¶m, &value) )
return NULL;
if ( rc < 0 )
{
- free(sdev_array);
+ free(sdev_array);
return pyxc_error_to_exception(self->xc_handle);
}
static char *kwd_list[] = { "domid", "bus", "dev", "func", "enable", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiii", kwd_list,
&dom, &bus, &dev, &func, &enable) )
return NULL;
"nr_nodes", pinfo.nr_nodes,
"threads_per_core", pinfo.threads_per_core,
"cores_per_socket", pinfo.cores_per_socket,
- "nr_cpus", pinfo.nr_cpus,
+ "nr_cpus", pinfo.nr_cpus,
"total_memory", pages_to_kib(pinfo.total_pages),
"free_memory", pages_to_kib(pinfo.free_pages),
"scrub_memory", pages_to_kib(pinfo.scrub_pages),
static char *kwd_list[] = { "dom", "op", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &op) )
return NULL;
-
+
if ( xc_shadow_control(xc->xc_handle, dom, op, NULL, 0) < 0 )
return pyxc_error_to_exception(xc->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
static char *kwd_list[] = { "dom", "mb", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
&dom, &mbarg) )
return NULL;
-
- if ( mbarg < 0 )
+
+ if ( mbarg < 0 )
op = XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION;
- else
+ else
{
mb = mbarg;
op = XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION;
}
if ( xc_shadow_control(xc->xc_handle, dom, op, &mb, 0) < 0 )
return pyxc_error_to_exception(xc->xc_handle);
-
+
mbarg = mb;
return Py_BuildValue("i", mbarg);
}
static PyObject *pyxc_sched_id_get(XcObject *self) {
-
+
int sched_id;
if (xc_sched_id(self->xc_handle, &sched_id) != 0)
return PyErr_SetFromErrno(xc_error_obj);
static char *kwd_list[] = { "domid", "weight", "cap", NULL };
static char kwd_type[] = "I|HH";
struct xen_domctl_sched_credit sdom;
-
+
weight = 0;
cap = (uint16_t)~0U;
- if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,
+ if( !PyArg_ParseTupleAndKeywords(args, kwds, kwd_type, kwd_list,
&domid, &weight, &cap) )
return NULL;
{
uint32_t domid;
struct xen_domctl_sched_credit sdom;
-
+
if( !PyArg_ParseTuple(args, "I", &domid) )
return NULL;
-
+
if ( xc_sched_credit_domain_get(self->xc_handle, domid, &sdom) != 0 )
return pyxc_error_to_exception(self->xc_handle);
if (xc_domain_setmaxmem(self->xc_handle, dom, maxmem_kb) != 0)
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
if (!PyArg_ParseTuple(args, "ii", &dom, &mem_kb))
return NULL;
- mem_pages = mem_kb / 4;
+ mem_pages = mem_kb / 4;
if (xc_domain_set_pod_target(self->xc_handle, dom, mem_pages,
NULL, NULL, NULL) != 0)
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
if ( xc_domain_set_memmap_limit(self->xc_handle, dom, maplimit_kb) != 0 )
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
static char *kwd_list[] = { "domid", "first_port", "nr_ports", "allow_access", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiii", kwd_list,
&dom, &first_port, &nr_ports, &allow_access) )
return NULL;
static char *kwd_list[] = { "domid", "pirq", "allow_access", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list,
&dom, &pirq, &allow_access) )
return NULL;
static char *kwd_list[] = { "domid", "first_pfn", "nr_pfns", "allow_access", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illi", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illi", kwd_list,
&dom, &first_pfn, &nr_pfns, &allow_access) )
return NULL;
static char *kwd_list[] = { "domid", "trigger", "vcpu", NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list,
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|i", kwd_list,
&dom, &trigger, &vcpu) )
return NULL;
if (xc_memshr_control(self->xc_handle, dom, enable) != 0)
return pyxc_error_to_exception(self->xc_handle);
-
+
Py_INCREF(zero);
return zero;
}
if (!xc_handle) {
return PyErr_SetFromErrno(xc_error_obj);
}
-
+
ret = xc_flask_sid_to_context(xc_handle, sid, ctx, ctx_len);
-
+
xc_interface_close(xc_handle);
-
+
if ( ret != 0 ) {
errno = -ret;
return PyErr_SetFromErrno(xc_error_obj);
int ret;
static char *kwd_list[] = { "policy", NULL };
-
+
if( !PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwd_list, &policy, &len) )
return NULL;
if (!xc_handle) {
return PyErr_SetFromErrno(xc_error_obj);
}
-
+
ret = xc_flask_getenforce(xc_handle);
-
+
xc_interface_close(xc_handle);
-
+
if ( ret < 0 ) {
errno = -ret;
return PyErr_SetFromErrno(xc_error_obj);
if (!xc_handle) {
return PyErr_SetFromErrno(xc_error_obj);
}
-
+
ret = xc_flask_setenforce(xc_handle, mode);
-
+
xc_interface_close(xc_handle);
-
+
if ( ret != 0 ) {
errno = -ret;
return PyErr_SetFromErrno(xc_error_obj);
uint32_t req, allowed, decided, auditallow, auditdeny, seqno;
int ret;
- static char *kwd_list[] = { "src_context", "tar_context",
+ static char *kwd_list[] = { "src_context", "tar_context",
"tar_class", "req_permissions",
"decided", "auditallow","auditdeny",
"seqno", NULL };
if (!xc_handle) {
return PyErr_SetFromErrno(xc_error_obj);
}
-
+
ret = xc_flask_access(xc_handle, scon, tcon, tclass, req, &allowed, &decided,
&auditallow, &auditdeny, &seqno);
-
+
xc_interface_close(xc_handle);
if ( ret != 0 ) {
}
static PyMethodDef pyxc_methods[] = {
- { "domain_create",
- (PyCFunction)pyxc_domain_create,
+ { "domain_create",
+ (PyCFunction)pyxc_domain_create,
METH_VARARGS | METH_KEYWORDS, "\n"
"Create a new domain.\n"
" dom [int, 0]: Domain identifier to use (allocated if zero).\n"
"Returns: [int] new domain identifier; -1 on error.\n" },
- { "domain_max_vcpus",
+ { "domain_max_vcpus",
(PyCFunction)pyxc_domain_max_vcpus,
METH_VARARGS, "\n"
"Set the maximum number of VCPUs a domain may create.\n"
" max [int, 0]: New maximum number of VCPUs in domain.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_dumpcore",
- (PyCFunction)pyxc_domain_dumpcore,
+ { "domain_dumpcore",
+ (PyCFunction)pyxc_domain_dumpcore,
METH_VARARGS, "\n"
"Dump core of a domain.\n"
" dom [int]: Identifier of domain to dump core of.\n"
" corefile [string]: Name of corefile to be created.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_pause",
- (PyCFunction)pyxc_domain_pause,
+ { "domain_pause",
+ (PyCFunction)pyxc_domain_pause,
METH_VARARGS, "\n"
"Temporarily pause execution of a domain.\n"
" dom [int]: Identifier of domain to be paused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_unpause",
- (PyCFunction)pyxc_domain_unpause,
+ { "domain_unpause",
+ (PyCFunction)pyxc_domain_unpause,
METH_VARARGS, "\n"
"(Re)start execution of a domain.\n"
" dom [int]: Identifier of domain to be unpaused.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_destroy",
- (PyCFunction)pyxc_domain_destroy,
+ { "domain_destroy",
+ (PyCFunction)pyxc_domain_destroy,
METH_VARARGS, "\n"
"Destroy a domain.\n"
" dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_destroy_hook",
- (PyCFunction)pyxc_domain_destroy_hook,
+ { "domain_destroy_hook",
+ (PyCFunction)pyxc_domain_destroy_hook,
METH_VARARGS, "\n"
"Add a hook for arch stuff before destroy a domain.\n"
" dom [int]: Identifier of domain to be destroyed.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_resume",
+ { "domain_resume",
(PyCFunction)pyxc_domain_resume,
METH_VARARGS, "\n"
"Resume execution of a suspended domain.\n"
" fast [int]: Use cooperative resume.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_shutdown",
+ { "domain_shutdown",
(PyCFunction)pyxc_domain_shutdown,
METH_VARARGS, "\n"
"Shutdown a domain.\n"
" reason [int, 0]: Reason for shutdown.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "vcpu_setaffinity",
- (PyCFunction)pyxc_vcpu_setaffinity,
+ { "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"
" cpumap [list, []]: list of usable CPUs.\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_sethandle",
+ { "domain_sethandle",
(PyCFunction)pyxc_domain_sethandle,
METH_VARARGS, "\n"
"Set domain's opaque handle.\n"
" handle [list of 16 ints]: New opaque handle.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_getinfo",
- (PyCFunction)pyxc_domain_getinfo,
+ { "domain_getinfo",
+ (PyCFunction)pyxc_domain_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding a set of domains, in increasing id order.\n"
" first_dom [int, 0]: First domain to retrieve info about.\n"
"reason why it shut itself down.\n"
" cpupool [int] Id of cpupool domain is bound to.\n" },
- { "vcpu_getinfo",
- (PyCFunction)pyxc_vcpu_getinfo,
+ { "vcpu_getinfo",
+ (PyCFunction)pyxc_vcpu_getinfo,
METH_VARARGS | METH_KEYWORDS, "\n"
"Get information regarding a VCPU.\n"
" dom [int]: Domain to retrieve info about.\n"
" xenstore_domid [int]: \n"
"Returns: None on success. Raises exception on error.\n" },
- { "hvm_get_param",
+ { "hvm_get_param",
(PyCFunction)pyxc_hvm_param_get,
METH_VARARGS | METH_KEYWORDS, "\n"
"get a parameter of HVM guest OS.\n"
" param [int]: No. of HVM param.\n"
"Returns: [long] value of the param.\n" },
- { "hvm_set_param",
+ { "hvm_set_param",
(PyCFunction)pyxc_hvm_param_set,
METH_VARARGS | METH_KEYWORDS, "\n"
"set a parameter of HVM guest OS.\n"
" dom [int]: Domain to deassign device from.\n"
" pci_str [str]: PCI devices.\n"
"Returns: [int] 0 on success, or device bdf that can't be deassigned.\n" },
-
+
{ "sched_id_get",
(PyCFunction)pyxc_sched_id_get,
METH_NOARGS, "\n"
"Get the current scheduler type in use.\n"
- "Returns: [int] sched_id.\n" },
+ "Returns: [int] sched_id.\n" },
{ "sched_credit_domain_set",
(PyCFunction)pyxc_sched_credit_domain_set,
"Returns: [dict]\n"
" weight [short]: domain's scheduling weight\n"},
- { "evtchn_alloc_unbound",
+ { "evtchn_alloc_unbound",
(PyCFunction)pyxc_evtchn_alloc_unbound,
METH_VARARGS | METH_KEYWORDS, "\n"
"Allocate an unbound port that will await a remote connection.\n"
" remote_dom [int]: Remote domain to accept connections from.\n\n"
"Returns: [int] Unbound event-channel port.\n" },
- { "evtchn_reset",
+ { "evtchn_reset",
(PyCFunction)pyxc_evtchn_reset,
METH_VARARGS | METH_KEYWORDS, "\n"
"Reset all connections.\n"
" func [int]: PCI function\n"
" enable [int]: Non-zero means enable access; else disable access\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
-
- { "readconsolering",
- (PyCFunction)pyxc_readconsolering,
+
+ { "readconsolering",
+ (PyCFunction)pyxc_readconsolering,
METH_VARARGS | METH_KEYWORDS, "\n"
"Read Xen's console ring.\n"
" clear [int, 0]: Bool - clear the ring after reading from it?\n\n"
"Returns [str]: Xen buildid"
" [None]: on failure.\n" },
- { "shadow_control",
- (PyCFunction)pyxc_shadow_control,
+ { "shadow_control",
+ (PyCFunction)pyxc_shadow_control,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set parameter for shadow pagetable interface\n"
" dom [int]: Identifier of domain.\n"
" op [int, 0]: operation\n\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "shadow_mem_control",
- (PyCFunction)pyxc_shadow_mem_control,
+ { "shadow_mem_control",
+ (PyCFunction)pyxc_shadow_mem_control,
METH_VARARGS | METH_KEYWORDS, "\n"
"Set or read shadow pagetable memory use\n"
" dom [int]: Identifier of domain.\n"
" mb [int, -1]: MB of shadow memory this domain should have.\n\n"
"Returns: [int] MB of shadow memory in use by this domain.\n" },
- { "domain_setmaxmem",
- (PyCFunction)pyxc_domain_setmaxmem,
+ { "domain_setmaxmem",
+ (PyCFunction)pyxc_domain_setmaxmem,
METH_VARARGS, "\n"
"Set a domain's memory limit\n"
" dom [int]: Identifier of domain.\n"
" maxmem_kb [int]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_set_target_mem",
- (PyCFunction)pyxc_domain_set_target_mem,
+ { "domain_set_target_mem",
+ (PyCFunction)pyxc_domain_set_target_mem,
METH_VARARGS, "\n"
"Set a domain's memory target\n"
" dom [int]: Identifier of domain.\n"
" mem_kb [int]: .\n"
"Returns: [int] 0 on success; -1 on error.\n" },
- { "domain_set_memmap_limit",
- (PyCFunction)pyxc_domain_set_memmap_limit,
+ { "domain_set_memmap_limit",
+ (PyCFunction)pyxc_domain_set_memmap_limit,
METH_VARARGS, "\n"
"Set a domain's physical memory mapping limit\n"
" dom [int]: Identifier of domain.\n"
"Inject debug keys into Xen.\n"
" keys [str]: String of keys to inject.\n" },
- { "dom_set_memshr",
+ { "dom_set_memshr",
(PyCFunction)pyxc_dom_set_memshr,
METH_VARARGS, "\n"
"Enable/disable memory sharing for the domain.\n"
METH_VARARGS | METH_KEYWORDS, "\n"
"Loads a policy into the hypervisor.\n"
" policy [str]: policy to be load\n"
- "Returns: [int]: 0 on success; -1 on failure.\n" },
-
+ "Returns: [int]: 0 on success; -1 on failure.\n" },
+
{ "flask_getenforce",
(PyCFunction)pyflask_getenforce,
METH_NOARGS, "\n"
"Returns the current mode of the Flask XSM module.\n"
- "Returns: [int]: 0 for permissive; 1 for enforcing; -1 on failure.\n" },
+ "Returns: [int]: 0 for permissive; 1 for enforcing; -1 on failure.\n" },
{ "flask_setenforce",
(PyCFunction)pyflask_setenforce,
METH_VARARGS | METH_KEYWORDS, "\n"
"Modifies the current mode for the Flask XSM module.\n"
" mode [int]: mode to change to\n"
- "Returns: [int]: 0 on success; -1 on failure.\n" },
+ "Returns: [int]: 0 on success; -1 on failure.\n" },
{ "flask_access",
(PyCFunction)pyflask_access,
" auditdeny [int] permissions set to audit on deny\n"
" seqno [int] not used\n"
"Returns: [int]: 0 on all permission granted; -1 if any permissions are \
- denied\n" },
+ denied\n" },
{ NULL, NULL, 0, NULL }
};
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; under version 2 of the License.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
#####################################################################
parser.add_option("-p", "--prefix", dest="prefix",
default = "log", help="prefix to use for output files")
parser.add_option("-t", "--time", dest="duration",
- action="store", type="int", default=10,
+ action="store", type="int", default=10,
help="stop logging to file after this much time has elapsed (in seconds). set to 0 to keep logging indefinitely")
parser.add_option("-i", "--interval", dest="interval",
action="store", type="int", default=1000,
return [total/(float(passed)/10**9), avg]
def stats(self, passed):
- return [self.gotten_stats(passed), self.allocated_stats(passed), self.blocked_stats(passed),
+ return [self.gotten_stats(passed), self.allocated_stats(passed), self.blocked_stats(passed),
self.waited_stats(passed), self.ec_stats(passed), self.io_stats(passed)]
# report values over desired interval
dominfos = {}
for i in range(0, NDOMAINS):
dominfos[i] = DomainInfo()
-
+
passed = 1 # to prevent zero division
curid = startat
numbuckets = 0
lost_samples = []
ffp_samples = []
-
+
while passed < duration:
for i in range(0, NDOMAINS):
if dom_in_use[i]:
dominfos[i].blocked_sum += samples[curid][3*NDOMAINS + i]
dominfos[i].exec_count += samples[curid][4*NDOMAINS + i]
dominfos[i].iocount_sum += samples[curid][5*NDOMAINS + i]
-
+
passed += samples[curid][6*NDOMAINS]
lost_samples.append(samples[curid][6*NDOMAINS + 2])
ffp_samples.append(samples[curid][6*NDOMAINS + 3])
cpu_10sec_usage = 0.0
heartbeat = 1
global dom_in_use, options
-
+
# mmap the (the first chunk of the) file
shmf = open(SHM_FILE, "r+")
shm = mmap.mmap(shmf.fileno(), QOS_DATA_SIZE)
stdscr.keypad(1)
stdscr.timeout(1000)
[maxy, maxx] = stdscr.getmaxyx()
-
+
# display in a loop
while True:
cpuidx = cpuidx + 1
# calculate starting and ending datapoints; never look at "next" since
- # it represents live data that may be in transition.
+ # it represents live data that may be in transition.
startat = next - 1
if next + 10 < NSAMPLES:
endat = next + 10
if h1[dom][0][1] > 0 or domain_id[dom] == IDLE_DOMAIN:
# display gotten
- row += 1
+ row += 1
col = 2
display_domain_id(stdscr, row, col, domain_id[dom])
col += 4
if dom != IDLE_DOMAIN:
cpu_1sec_usage = cpu_1sec_usage + h1[dom][0][1]
-
+
# display allocated
if options.allocated:
row += 1
row += 1
col = 2
display_domain_id(stdscr, row, col, domain_id[dom])
-
+
col += 28
display(stdscr, row, col, "%d/s" % h2[dom][4])
col += 42
display(stdscr, row, 1, star)
display(stdscr, row, 2, TOTALS % (total_h2_cpu, total_h1_cpu))
row += 1
-# display(stdscr, row, 2,
-# "\tFFP: %d (Min: %d, Max: %d)\t\t\tFFP: %d (Min: %d, Max %d)" %
+# display(stdscr, row, 2,
+# "\tFFP: %d (Min: %d, Max: %d)\t\t\tFFP: %d (Min: %d, Max %d)" %
# (math.ceil(f2[1]), f2[0], f2[2], math.ceil(f1[1]), f1[0], f1[2]), _c.A_BOLD)
if l1[1] > 1 :
row += 1
- display(stdscr, row, 2,
- "\tRecords lost: %d (Min: %d, Max: %d)\t\t\tRecords lost: %d (Min: %d, Max %d)" %
+ display(stdscr, row, 2,
+ "\tRecords lost: %d (Min: %d, Max: %d)\t\t\tRecords lost: %d (Min: %d, Max %d)" %
(math.ceil(l2[1]), l2[0], l2[2], math.ceil(l1[1]), l1[0], l1[2]), _c.A_BOLD)
# grab a char from tty input; exit if interrupt hit
c = stdscr.getch()
except:
break
-
+
# q = quit
if c == ord('q'):
break
-
+
# c = cycle to a new cpu of interest
if c == ord('c'):
cpu = (cpu + 1) % ncpu
def close(self):
if self.opened:
self.file.close()
-
+
def writelog():
global options
h1[dom][1],
h1[dom][2][0], h1[dom][2][1], h1[dom][2][2],
h1[dom][3][0], h1[dom][3][1], h1[dom][3][2],
- h1[dom][4],
+ h1[dom][4],
h1[dom][5][0], h1[dom][5][1]))
outfiles[dom].flush()
curr = time.time()
options.mspersample > options.duration * 1000:
parser.error("option --ms_per_sample: too large (> %d ms)" %
(options.duration * 1000))
-
+
start_xenbaked()
if options.live:
show_livestats(options.cpu)