mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
[XEND] Better checking of shutdown of domain0.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
This commit is contained in:
1 parent
ffb974095f
commit
87f45629c6
2 files changed
+6
-11
No files matched your search
@@ -943,6 +943,8 @@ class XendDomainInfo:
|
||||
def shutdown(self, reason):
|
||||
if not reason in shutdown_reasons.values():
|
||||
raise XendError('Invalid reason: %s' % reason)
|
||||
if self.domid == 0:
|
||||
raise XendError("Can't specify Domain-0")
|
||||
self.storeDom("control/shutdown", reason)
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ from xen.xend.XendClient import server
|
||||
from xen.xend import sxp
|
||||
from xen.xm.opts import *
|
||||
|
||||
DOM0_ID = '0'
|
||||
|
||||
gopts = Opts(use="""[options] [DOM]
|
||||
|
||||
Shutdown one or more domains gracefully.
|
||||
@@ -51,14 +49,6 @@ gopts.opt('reboot', short='R',
|
||||
use='Shutdown and reboot.')
|
||||
|
||||
def shutdown(opts, doms, mode, wait):
|
||||
if doms == None: doms = server.xend.domains(0)
|
||||
dom0_name = sxp.child_value(server.xend.domain(0), 'name')
|
||||
for x in [dom0_name, DOM0_ID]:
|
||||
if x in doms:
|
||||
if opts.vals.all:
|
||||
doms.remove(x)
|
||||
else:
|
||||
opts.err("Can't specify Domain-0")
|
||||
for d in doms:
|
||||
server.xend.domain.shutdown(d, mode)
|
||||
if wait:
|
||||
@@ -86,8 +76,11 @@ def shutdown_mode(opts):
|
||||
return 'poweroff'
|
||||
|
||||
def main_all(opts, args):
|
||||
doms = server.xend.domains(0)
|
||||
dom0_name = sxp.child_value(server.xend.domain(0), 'name')
|
||||
doms.remove(dom0_name)
|
||||
mode = shutdown_mode(opts)
|
||||
shutdown(opts, None, mode, opts.vals.wait)
|
||||
shutdown(opts, doms, mode, opts.vals.wait)
|
||||
|
||||
def main_dom(opts, args):
|
||||
if len(args) == 0: opts.err('No domain parameter given')
|
||||
|
||||