Add nomigrate config option to disable migration/restore

The new nomigrate option can be set to non-zero in vm.cfg
(for both hvm and pvm) to disallow a guest from being
migrated or restored.  (Save is still allowed for the purpose
of checkpointing.)  The option persists into a save file
and is also communicated into the hypervisor, the latter
for the purposes of a to-be-added hypercall for communicating
to guests that migration is disallowed (which will be
used initially for userland TSC-related sensing, but may
find other uses).

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
This commit is contained in:
Keir Fraser committed 2009-10-20 08:45:12 +01:00
1 parent 5cee2dafd8
commit 87cb99a6dd
12 files changed
+94 -3

No files matched your search

+21
View File
@@ -1485,6 +1485,20 @@ static PyObject *pyxc_domain_set_tsc_native(XcObject *self, PyObject *args)
return zero;
}
static PyObject *pyxc_domain_disable_migrate(XcObject *self, PyObject *args)
{
uint32_t dom;
if (!PyArg_ParseTuple(args, "i", &dom))
return NULL;
if (xc_domain_disable_migrate(self->xc_handle, dom) != 0)
return pyxc_error_to_exception();
Py_INCREF(zero);
return zero;
}
static PyObject *pyxc_domain_send_trigger(XcObject *self,
PyObject *args,
PyObject *kwds)
@@ -2015,6 +2029,13 @@ static PyMethodDef pyxc_methods[] = {
" is_native [int]: 1=native, 0=emulate.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_disable_migrate",
(PyCFunction)pyxc_domain_disable_migrate,
METH_VARARGS, "\n"
"Marks domain as non-migratable AND non-restoreable\n"
" dom [int]: Domain whose TSC mode is being set.\n"
"Returns: [int] 0 on success; -1 on error.\n" },
{ "domain_send_trigger",
(PyCFunction)pyxc_domain_send_trigger,
METH_VARARGS | METH_KEYWORDS, "\n"
+13 -2
View File
@@ -226,6 +226,19 @@ def restore(xd, fd, dominfo = None, paused = False, relocating = False):
else:
dominfo = xd.restore_(vmconfig)
image_cfg = dominfo.info.get('image', {})
is_hvm = dominfo.info.is_hvm()
if is_hvm:
nomigrate = dominfo.info['platform'].get('nomigrate', 0)
else:
nomigrate = dominfo.info['platform'].get('nomigrate')
if nomigrate is None:
nomigrate = 0
if int(nomigrate) != 0:
dominfo.destroy()
raise XendError("cannot restore non-migratable domain")
# repin domain vcpus if a target node number was specified
# this is done prior to memory allocation to aide in memory
# distribution for NUMA systems.
@@ -248,8 +261,6 @@ def restore(xd, fd, dominfo = None, paused = False, relocating = False):
assert console_port
# if hvm, pass mem size to calculate the store_mfn
image_cfg = dominfo.info.get('image', {})
is_hvm = dominfo.info.is_hvm()
if is_hvm:
apic = int(dominfo.info['platform'].get('apic', 0))
pae = int(dominfo.info['platform'].get('pae', 0))
+4
View File
@@ -146,6 +146,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
'localtime': int,
'monitor': int,
'nographic': int,
'nomigrate': int,
'pae' : int,
'rtc_timeoffset': int,
'serial': str,
@@ -479,6 +480,9 @@ class XendConfig(dict):
if 'tsc_native' not in self['platform']:
self['platform']['tsc_native'] = 0
if 'nomigrate' not in self['platform']:
self['platform']['nomigrate'] = 0
if self.is_hvm():
if 'timer_mode' not in self['platform']:
self['platform']['timer_mode'] = 1
+5
View File
@@ -2464,6 +2464,11 @@ class XendDomainInfo:
if arch.type == "x86" and hvm and viridian is not None:
xc.hvm_set_param(self.domid, HVM_PARAM_VIRIDIAN, long(viridian))
# If nomigrate is set, disable migration
nomigrate = self.info["platform"].get("nomigrate")
if arch.type == "x86" and nomigrate is not None and long(nomigrate) != 0:
xc.domain_disable_migrate(self.domid)
# Optionally enable virtual HPET
hpet = self.info["platform"].get("hpet")
if hvm and hpet is not None:
+8 -1
View File
@@ -225,6 +225,10 @@ gopts.var('tsc_native', val='TSC_NATIVE',
fn=set_int, default=0,
use="""TSC mode (0=emulate TSC, 1=native TSC).""")
gopts.var('nomigrate', val='NOMIGRATE',
fn=set_int, default=0,
use="""migratability (0=migration enabled, 1=migration disabled).""")
gopts.var('vpt_align', val='VPT_ALIGN',
fn=set_int, default=1,
use="Enable aligning all periodic vpt to reduce timer interrupts.")
@@ -737,6 +741,9 @@ def configure_image(vals):
if vals.tsc_native is not None:
config_image.append(['tsc_native', vals.tsc_native])
if vals.nomigrate is not None:
config_image.append(['nomigrate', vals.nomigrate])
return config_image
def configure_disks(config_devs, vals):
@@ -1020,7 +1027,7 @@ def make_config(vals):
config.append([n, v])
map(add_conf, ['name', 'memory', 'maxmem', 'shadow_memory',
'restart', 'on_poweroff', 'tsc_native',
'restart', 'on_poweroff', 'tsc_native', 'nomigrate',
'on_reboot', 'on_crash', 'vcpus', 'vcpu_avail', 'features',
'on_xend_start', 'on_xend_stop', 'target', 'cpuid',
'cpuid_check', 'machine_address_size', 'suppress_spurious_page_faults'])
+1
View File
@@ -1079,6 +1079,7 @@ class sxp2xml:
'xen_platform_pci',
'tsc_native'
'description',
'nomigrate'
]
platform_configs = []
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.