Adds 'memory_sharing' option to domain config scripts. It passes domain id to

the tapdisk2 process if sharing is enabled (tapdisk2 is not normally aware what
domain it is working for).

Signed-off-by: Grzegorz Milos <Grzegorz.Milos@citrix.com>
This commit is contained in:
Keir Fraser committed 2009-12-17 06:27:57 +00:00
1 parent ab562bd46c
commit 57ea955dd3
9 files changed
+77 -4

No files matched your search

+24
View File
@@ -1658,6 +1658,22 @@ static PyObject *pyxc_tmem_shared_auth(XcObject *self,
return zero;
}
static PyObject *pyxc_dom_set_memshr(XcObject *self, PyObject *args)
{
uint32_t dom;
int enable;
if (!PyArg_ParseTuple(args, "ii", &dom, &enable))
return NULL;
if (xc_memshr_control(self->xc_handle, dom, enable) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyMethodDef pyxc_methods[] = {
{ "handle",
(PyCFunction)pyxc_handle,
@@ -2162,6 +2178,14 @@ static PyMethodDef pyxc_methods[] = {
" auth [int]: 0|1 .\n"
"Returns: [int] 0 on success; exception on error.\n" },
{ "dom_set_memshr",
(PyCFunction)pyxc_dom_set_memshr,
METH_VARARGS, "\n"
"Enable/disable memory sharing for the domain.\n"
" dom [int]: Domain identifier.\n"
" enable [int,0|1]: Disable or enable?\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ NULL, NULL, 0, NULL }
};
+13 -1
View File
@@ -230,6 +230,7 @@ XENAPI_CFG_TYPES = {
'suppress_spurious_page_faults': bool0,
's3_integrity' : int,
'superpages' : int,
'memory_sharing': int,
}
# List of legacy configuration keys that have no equivalent in the
@@ -328,7 +329,7 @@ class XendConfig(dict):
dict.__init__(self)
self.update(self._defaults())
if filename:
try:
sxp_obj = sxp.parse(open(filename,'r'))
@@ -390,6 +391,7 @@ class XendConfig(dict):
'shadow_memory': 0,
'memory_static_max': 0,
'memory_dynamic_max': 0,
'memory_sharing': 0,
'devices': {},
'on_xend_start': 'ignore',
'on_xend_stop': 'ignore',
@@ -441,6 +443,12 @@ class XendConfig(dict):
if not self["memory_static_max"] > 0:
raise XendConfigError("memory_static_max must be greater " \
"than zero")
if self["memory_sharing"] and not self.is_hvm():
raise XendConfigError("memory_sharing can only be enabled " \
"for HVM domains")
if self["memory_sharing"] and not self.is_hap():
raise XendConfigError("memory_sharing can only be enabled " \
"for HAP enabled boxes")
def _actions_sanity_check(self):
for event in ['shutdown', 'reboot', 'crash']:
@@ -2150,6 +2158,10 @@ class XendConfig(dict):
val = sxp.child_value(image_sxp, 'superpages')
if val is not None:
self['superpages'] = val
val = sxp.child_value(image_sxp, 'memory_sharing')
if val is not None:
self['memory_sharing'] = val
for key in XENAPI_PLATFORM_CFG_TYPES.keys():
val = sxp.child_value(image_sxp, key, None)
+3
View File
@@ -84,6 +84,7 @@ class ImageHandler:
ostype = None
superpages = 0
memory_sharing = 0
def __init__(self, vm, vmConfig):
self.vm = vm
@@ -820,6 +821,8 @@ class HVMImageHandler(ImageHandler):
self.apic = int(vmConfig['platform'].get('apic', 0))
self.acpi = int(vmConfig['platform'].get('acpi', 0))
self.guest_os_type = vmConfig['platform'].get('guest_os_type')
self.memory_sharing = int(vmConfig['memory_sharing'])
xc.dom_set_memshr(self.vm.getDomid(), self.memory_sharing)
# Return a list of cmd line args to the device models based on the
@@ -198,7 +198,10 @@ class Blktap2Controller(BlktapController):
self.deviceClass = 'tap2'
return devid
cmd = [ TAPDISK_BINARY, '-n', '%s:%s' % (params, file) ]
if self.vm.image.memory_sharing:
cmd = [ TAPDISK_BINARY, '-n', '%s:%s' % (params, file), '-s', '%d' % self.vm.getDomid() ]
else:
cmd = [ TAPDISK_BINARY, '-n', '%s:%s' % (params, file) ]
(rc,stdout,stderr) = doexec(cmd)
if rc != 0:
+6 -1
View File
@@ -196,6 +196,10 @@ gopts.var('shadow_memory', val='MEMORY',
fn=set_int, default=0,
use="Domain shadow memory in MB.")
gopts.var('memory_sharing', val='no|yes',
fn=set_bool, default=0,
use="Should memory be shared?")
gopts.var('cpu', val='CPU',
fn=set_int, default=None,
use="CPU to run the VCPU0 on.")
@@ -1058,7 +1062,8 @@ def configure_hvm(config_image, vals):
'usb', 'usbdevice',
'vcpus', 'vnc', 'vncconsole', 'vncdisplay', 'vnclisten',
'vncunused', 'viridian', 'vpt_align',
'xauthority', 'xen_extended_power_mgmt', 'xen_platform_pci' ]
'xauthority', 'xen_extended_power_mgmt', 'xen_platform_pci',
'memory_sharing' ]
for a in args:
if a in vals.__dict__ and vals.__dict__[a] is not None:
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.