ia64/xen-unstable

changeset 16998:d04593aa1605

xm reboot: Fix wait option of xm reboot command

When I rebooted a domain by xm reboot command with wait option,
I saw the following message. But, rebooting the domain succeeded.
Domain vm1 destroyed for failed in rebooting

The cause why the message was shown is the domain is destroyed
temporarily by processing of xm reboot command. The domain
information is not gotten from Xend by server.xend.domains()
function till recreating the domain is completed.
This patch fixes processing of xm reboot command in Xm side.
It waits just a bit till recreating the domain is completed,
then it measures the success or failure of the reboot of the
domain.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 07 09:27:46 2008 +0000 (2008-02-07)
parents 45b2e7d59e3a
children 58e5e9ae0f8d
files tools/python/xen/xm/shutdown.py
line diff
     1.1 --- a/tools/python/xen/xm/shutdown.py	Thu Feb 07 09:21:19 2008 +0000
     1.2 +++ b/tools/python/xen/xm/shutdown.py	Thu Feb 07 09:27:46 2008 +0000
     1.3 @@ -24,6 +24,8 @@ from opts import *
     1.4  from main import server, serverType, SERVER_XEN_API, get_single_vm
     1.5  from xen.xend.XendAPIConstants import *
     1.6  
     1.7 +RECREATING_TIMEOUT = 30
     1.8 +
     1.9  gopts = Opts(use="""[options] [DOM]
    1.10  
    1.11  Shutdown one or more domains gracefully.
    1.12 @@ -53,6 +55,7 @@ def wait_reboot(opts, doms, rcs):
    1.13      if serverType == SERVER_XEN_API:
    1.14          opts.err("Cannot wait for reboot w/ XenAPI (yet)")
    1.15  
    1.16 +    recreating = {}
    1.17      while doms:
    1.18          alive = server.xend.domains(0)
    1.19          reboot = []
    1.20 @@ -61,9 +64,17 @@ def wait_reboot(opts, doms, rcs):
    1.21                  rc = server.xend.domain.getRestartCount(d)
    1.22                  if rc == rcs[d]: continue
    1.23                  reboot.append(d)
    1.24 +
    1.25 +            # Probably the domain is being recreated now.
    1.26 +            # We have to wait just a bit for recreating the domain.
    1.27 +            elif not recreating.has_key(d):
    1.28 +                recreating[d] = 0
    1.29              else:
    1.30 -                opts.info("Domain %s destroyed for failed in rebooting" % d)
    1.31 -                doms.remove(d)
    1.32 +                recreating[d] += 1
    1.33 +                if recreating[d] > RECREATING_TIMEOUT:
    1.34 +                    opts.info("Domain %s destroyed for failing to reboot" % d)
    1.35 +                    doms.remove(d)
    1.36 +
    1.37          for d in reboot:
    1.38              opts.info("Domain %s rebooted" % d)
    1.39              doms.remove(d)