ia64/xen-unstable

changeset 10864:98ee83ed9d28

[XEND] Better checking of shutdown of domain0.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author kfraser@localhost.localdomain
date Fri Jul 28 17:35:39 2006 +0100 (2006-07-28)
parents affe80cdb485
children 7e25295d8d9d
files tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/shutdown.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 28 17:33:26 2006 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Fri Jul 28 17:35:39 2006 +0100
     1.3 @@ -943,6 +943,8 @@ class XendDomainInfo:
     1.4      def shutdown(self, reason):
     1.5          if not reason in shutdown_reasons.values():
     1.6              raise XendError('Invalid reason: %s' % reason)
     1.7 +        if self.domid == 0:
     1.8 +            raise XendError("Can't specify Domain-0")
     1.9          self.storeDom("control/shutdown", reason)
    1.10  
    1.11  
     2.1 --- a/tools/python/xen/xm/shutdown.py	Fri Jul 28 17:33:26 2006 +0100
     2.2 +++ b/tools/python/xen/xm/shutdown.py	Fri Jul 28 17:35:39 2006 +0100
     2.3 @@ -23,8 +23,6 @@ from xen.xend.XendClient import server
     2.4  from xen.xend import sxp
     2.5  from xen.xm.opts import *
     2.6  
     2.7 -DOM0_ID = '0'
     2.8 -
     2.9  gopts = Opts(use="""[options] [DOM]
    2.10  
    2.11  Shutdown one or more domains gracefully.
    2.12 @@ -51,14 +49,6 @@ gopts.opt('reboot', short='R',
    2.13            use='Shutdown and reboot.')
    2.14  
    2.15  def shutdown(opts, doms, mode, wait):
    2.16 -    if doms == None: doms = server.xend.domains(0)
    2.17 -    dom0_name = sxp.child_value(server.xend.domain(0), 'name')
    2.18 -    for x in [dom0_name, DOM0_ID]:
    2.19 -        if x in doms:
    2.20 -            if opts.vals.all:
    2.21 -                doms.remove(x)
    2.22 -            else:
    2.23 -                opts.err("Can't specify Domain-0")
    2.24      for d in doms:
    2.25          server.xend.domain.shutdown(d, mode)
    2.26      if wait:
    2.27 @@ -86,8 +76,11 @@ def shutdown_mode(opts):
    2.28          return 'poweroff'
    2.29  
    2.30  def main_all(opts, args):
    2.31 +    doms = server.xend.domains(0)
    2.32 +    dom0_name = sxp.child_value(server.xend.domain(0), 'name')
    2.33 +    doms.remove(dom0_name)
    2.34      mode = shutdown_mode(opts)  
    2.35 -    shutdown(opts, None, mode, opts.vals.wait)
    2.36 +    shutdown(opts, doms, mode, opts.vals.wait)
    2.37  
    2.38  def main_dom(opts, args):
    2.39      if len(args) == 0: opts.err('No domain parameter given')