# HG changeset patch
# User emellor@ewan
# Node ID fe401301929ed51cca4641d35ea305bcf7f10892
# Parent 034ada135379666b6c20b30788b206c2daa1af11
Change rebooting specification so that we can have domains crash and stay
around to be debugged, for example.
Fix problem in XendDomainInfo.eventChannel caused by a mis-merge.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
diff -r 034ada135379 -r fe401301929e tools/examples/xmexample.vmx
--- a/tools/examples/xmexample.vmx Fri Sep 30 12:58:08 2005
+++ b/tools/examples/xmexample.vmx Fri Sep 30 12:59:28 2005
@@ -48,12 +48,36 @@
disk = [ 'file:/var/images/min-el3-i386.img,ioemu:hda,w' ]
#----------------------------------------------------------------------------
-# Set according to whether you want the domain restarted when it exits.
-# The default is 'onreboot', which restarts the domain when it shuts down
-# with exit code reboot.
-# Other values are 'always', and 'never'.
+# Configure the behaviour when a domain exits. There are three 'reasons'
+# for a domain to stop: poweroff, reboot, and crash. For each of these you
+# may specify "destroy", meaning that the domain is cleaned up as normal,
+# "restart", meaning that a new domain is started in place of the old one, or
+# "preserve", meaning that no clean-up is done until the domain is manually
+# destroyed (using xm destroy, for example).
+#
+# The default is
+#
+# on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# For backwards compatibility we also support the deprecated option restart
+#
+# restart = 'onreboot' means on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'destroy'
+#
+# restart = 'always' means on_poweroff = 'restart'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# restart = 'never' means on_poweroff = 'destroy'
+# on_reboot = 'destroy'
+# on_crash = 'destroy'
-#restart = 'onreboot'
+#on_poweroff = 'destroy'
+#on_reboot = 'restart'
+#on_crash = 'restart'
#============================================================================
diff -r 034ada135379 -r fe401301929e tools/examples/xmexample1
--- a/tools/examples/xmexample1 Fri Sep 30 12:58:08 2005
+++ b/tools/examples/xmexample1 Fri Sep 30 12:59:28 2005
@@ -91,11 +91,35 @@
extra = "4"
#----------------------------------------------------------------------------
-# Set according to whether you want the domain restarted when it exits.
-# The default is 'onreboot', which restarts the domain when it shuts down
-# with exit code reboot.
-# Other values are 'always', and 'never'.
+# Configure the behaviour when a domain exits. There are three 'reasons'
+# for a domain to stop: poweroff, reboot, and crash. For each of these you
+# may specify "destroy", meaning that the domain is cleaned up as normal,
+# "restart", meaning that a new domain is started in place of the old one, or
+# "preserve", meaning that no clean-up is done until the domain is manually
+# destroyed (using xm destroy, for example).
+#
+# The default is
+#
+# on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# For backwards compatibility we also support the deprecated option restart
+#
+# restart = 'onreboot' means on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'destroy'
+#
+# restart = 'always' means on_poweroff = 'restart'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# restart = 'never' means on_poweroff = 'destroy'
+# on_reboot = 'destroy'
+# on_crash = 'destroy'
-#restart = 'onreboot'
+#on_poweroff = 'destroy'
+#on_reboot = 'restart'
+#on_crash = 'restart'
#============================================================================
diff -r 034ada135379 -r fe401301929e tools/examples/xmexample2
--- a/tools/examples/xmexample2 Fri Sep 30 12:58:08 2005
+++ b/tools/examples/xmexample2 Fri Sep 30 12:59:28 2005
@@ -127,11 +127,35 @@
extra = "4 VMID=%d usr=/dev/sda6" % vmid
#----------------------------------------------------------------------------
-# Set according to whether you want the domain restarted when it exits.
-# The default is 'onreboot', which restarts the domain when it shuts down
-# with exit code reboot.
-# Other values are 'always', and 'never'.
+# Configure the behaviour when a domain exits. There are three 'reasons'
+# for a domain to stop: poweroff, reboot, and crash. For each of these you
+# may specify "destroy", meaning that the domain is cleaned up as normal,
+# "restart", meaning that a new domain is started in place of the old one, or
+# "preserve", meaning that no clean-up is done until the domain is manually
+# destroyed (using xm destroy, for example).
+#
+# The default is
+#
+# on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# For backwards compatibility we also support the deprecated option restart
+#
+# restart = 'onreboot' means on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'destroy'
+#
+# restart = 'always' means on_poweroff = 'restart'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# restart = 'never' means on_poweroff = 'destroy'
+# on_reboot = 'destroy'
+# on_crash = 'destroy'
-#restart = 'onreboot'
+#on_poweroff = 'destroy'
+#on_reboot = 'restart'
+#on_crash = 'restart'
#============================================================================
diff -r 034ada135379 -r fe401301929e tools/examples/xmexample3
--- a/tools/examples/xmexample3 Fri Sep 30 12:58:08 2005
+++ b/tools/examples/xmexample3 Fri Sep 30 12:59:28 2005
@@ -124,11 +124,35 @@
extra = "4 VMID=%d" % vmid
#----------------------------------------------------------------------------
-# Set according to whether you want the domain restarted when it exits.
-# The default is 'onreboot', which restarts the domain when it shuts down
-# with exit code reboot.
-# Other values are 'always', and 'never'.
+# Configure the behaviour when a domain exits. There are three 'reasons'
+# for a domain to stop: poweroff, reboot, and crash. For each of these you
+# may specify "destroy", meaning that the domain is cleaned up as normal,
+# "restart", meaning that a new domain is started in place of the old one, or
+# "preserve", meaning that no clean-up is done until the domain is manually
+# destroyed (using xm destroy, for example).
+#
+# The default is
+#
+# on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# For backwards compatibility we also support the deprecated option restart
+#
+# restart = 'onreboot' means on_poweroff = 'destroy'
+# on_reboot = 'restart'
+# on_crash = 'destroy'
+#
+# restart = 'always' means on_poweroff = 'restart'
+# on_reboot = 'restart'
+# on_crash = 'restart'
+#
+# restart = 'never' means on_poweroff = 'destroy'
+# on_reboot = 'destroy'
+# on_crash = 'destroy'
-#restart = 'onreboot'
+#on_poweroff = 'destroy'
+#on_reboot = 'restart'
+#on_crash = 'restart'
#============================================================================
diff -r 034ada135379 -r fe401301929e tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Fri Sep 30 12:58:08 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Sep 30 12:59:28 2005
@@ -67,14 +67,10 @@
DOMAIN_CRASH : "crash",
}
-RESTART_ALWAYS = 'always'
-RESTART_ONREBOOT = 'onreboot'
-RESTART_NEVER = 'never'
-
restart_modes = [
- RESTART_ALWAYS,
- RESTART_ONREBOOT,
- RESTART_NEVER,
+ "restart",
+ "destroy",
+ "preserve"
]
STATE_VM_OK = "ok"
@@ -112,7 +108,10 @@
('name', str),
('ssidref', int),
('cpu_weight', float),
- ('bootloader', str)
+ ('bootloader', str),
+ ('on_poweroff', str),
+ ('on_reboot', str),
+ ('on_crash', str)
]
@@ -135,8 +134,6 @@
vm.storeVmDetails()
vm.configure()
vm.create_channel()
-# vm.exportToDB()
-# vm.refreshShutdown()
vm.storeDomDetails()
return vm
@@ -272,7 +269,6 @@
result['maxmem'] = get_cfg('maxmem', int)
result['maxmem_kb'] = get_cfg('maxmem_kb', int)
result['cpu'] = get_cfg('cpu', int)
- result['restart_mode'] = get_cfg('restart')
result['image'] = get_cfg('image')
try:
@@ -295,6 +291,30 @@
c = sxp.child0(d)
result['device'].append((sxp.name(c), c))
+ # Configuration option "restart" is deprecated. Parse it, but
+ # let on_xyz override it if they are present.
+ restart = get_cfg('restart')
+ if restart:
+ def handle_restart(event, val):
+ if not event in result:
+ result[event] = val
+
+ if restart == "onreboot":
+ handle_restart('on_poweroff', 'destroy')
+ handle_restart('on_reboot', 'restart')
+ handle_restart('on_crash', 'destroy')
+ elif restart == "always":
+ handle_restart('on_poweroff', 'restart')
+ handle_restart('on_reboot', 'restart')
+ handle_restart('on_crash', 'restart')
+ elif restart == "never":
+ handle_restart('on_poweroff', 'destroy')
+ handle_restart('on_reboot', 'destroy')
+ handle_restart('on_crash', 'destroy')
+ else:
+ log.warn("Ignoring malformed and deprecated config option "
+ "restart = %s", restart)
+
log.debug("parseConfig: result is %s" % str(result))
return result
@@ -347,7 +367,9 @@
self.info[name] = val
params = (("name", str),
- ("restart_mode", str),
+ ("on_poweroff", str),
+ ("on_reboot", str),
+ ("on_crash", str),
("image", str),
("start_time", float))
@@ -375,7 +397,9 @@
try:
defaultInfo('name', lambda: "Domain-%d" % self.domid)
defaultInfo('ssidref', lambda: 0)
- defaultInfo('restart_mode', lambda: RESTART_ONREBOOT)
+ defaultInfo('on_poweroff', lambda: "destroy")
+ defaultInfo('on_reboot', lambda: "restart")
+ defaultInfo('on_crash', lambda: "restart")
defaultInfo('cpu', lambda: None)
defaultInfo('cpu_weight', lambda: 1.0)
defaultInfo('bootloader', lambda: None)
@@ -459,9 +483,10 @@
raise VmError('invalid device (%s, %s)' %
(str(n), str(c)))
- if self.info['restart_mode'] not in restart_modes:
- raise VmError('invalid restart mode: ' +
- str(self.info['restart_mode']))
+ for event in ['on_poweroff', 'on_reboot', 'on_crash']:
+ if self.info[event] not in restart_modes:
+ raise VmError('invalid restart event: %s = %s' %
+ (event, str(self.info[event])))
if 'cpumap' not in self.info:
if [self.info['vcpus'] == 1]:
@@ -509,14 +534,14 @@
to_store = {
'uuid': self.uuid,
- # !!!
+ # XXX
'memory/target': str(self.info['memory_KiB'])
}
if self.infoIsSet('image'):
to_store['image'] = sxp.to_string(self.info['image'])
- for k in ['name', 'ssidref', 'restart_mode']:
+ for k in ['name', 'ssidref', 'on_poweroff', 'on_reboot', 'on_crash']:
if self.infoIsSet(k):
to_store[k] = str(self.info[k])
@@ -625,7 +650,7 @@
if xroot.get_enable_dump():
self.dumpCore()
- restart_reason = 'crashed'
+ restart_reason = 'crash'
elif xeninfo['shutdown']:
reason = shutdown_reason(xeninfo['shutdown_reason'])
@@ -682,10 +707,16 @@
def maybeRestart(self, reason):
- if self.restart_needed(reason):
- self.restart()
- else:
- self.destroy()
+ # Dispatch to the correct method based upon the configured on_{reason}
+ # behaviour.
+ {"destroy" : self.destroy,
+ "restart" : self.restart,
+ "preserve" : self.preserve}[self.info['on_' + reason]]()
+
+
+ def preserve(self):
+ log.info("Preserving dead domain %s (%d).", self.info['name'],
+ self.domid)
def dumpCore(self):
@@ -998,7 +1029,6 @@
"""
self.create_channel()
self.image.createImage()
-# !!! self.exportToDB()
IntroduceDomain(self.domid, self.store_mfn,
self.store_channel.port1, self.dompath)
self.configure_vcpus()
@@ -1091,7 +1121,6 @@
# The port is not yet set, i.e. the channel has not yet been
# created.
pass
- ret = channel.eventChannel(0, self.domid, port1=port, port2=0)
# Stale port information from above causes an Invalid Argument to be
# thrown by the eventChannel call below. To recover, we throw away
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|