mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
This patch fixed 'xm reboot' to work as you expected with the wait
option. This patch adds a restart sequence counter to xenstore. The completion of a VM reboot is detected by observing that its restart sequence counter changes. Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
This commit is contained in:
1 parent
cc8a2f5273
commit
773367b449
3 files changed
+52
-15
No files matched your search
@@ -703,6 +703,9 @@ class XendDomainInfo:
|
||||
if security[idx][0] == 'ssidref':
|
||||
to_store['security/ssidref'] = str(security[idx][1])
|
||||
|
||||
if not self.readVm('xend/restart_count'):
|
||||
to_store['xend/restart_count'] = str(0)
|
||||
|
||||
log.debug("Storing VM details: %s", to_store)
|
||||
|
||||
self.writeVm(to_store)
|
||||
@@ -824,6 +827,9 @@ class XendDomainInfo:
|
||||
def setResume(self, state):
|
||||
self.info['resume'] = state
|
||||
|
||||
def getRestartCount(self):
|
||||
return self.readVm('xend/restart_count')
|
||||
|
||||
def refreshShutdown(self, xeninfo = None):
|
||||
# If set at the end of this method, a restart is required, with the
|
||||
# given reason. This restart has to be done out of the scope of
|
||||
@@ -1615,6 +1621,9 @@ class XendDomainInfo:
|
||||
try:
|
||||
new_dom = XendDomain.instance().domain_create(config)
|
||||
new_dom.unpause()
|
||||
rst_cnt = self.readVm('xend/restart_count')
|
||||
rst_cnt = int(rst_cnt) + 1
|
||||
self.writeVm('xend/restart_count', str(rst_cnt))
|
||||
new_dom.removeVm(RESTART_IN_PROGRESS)
|
||||
except:
|
||||
if new_dom:
|
||||
|
||||
@@ -78,7 +78,8 @@ def get_log():
|
||||
methods = ['device_create', 'device_configure', 'destroyDevice',
|
||||
'getDeviceSxprs',
|
||||
'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown',
|
||||
'send_sysrq', 'getVCPUInfo', 'waitForDevices']
|
||||
'send_sysrq', 'getVCPUInfo', 'waitForDevices',
|
||||
'getRestartCount']
|
||||
|
||||
exclude = ['domain_create', 'domain_restore']
|
||||
|
||||
|
||||
@@ -48,21 +48,48 @@ gopts.opt('reboot', short='R',
|
||||
fn=set_true, default=0,
|
||||
use='Shutdown and reboot.')
|
||||
|
||||
def shutdown(opts, doms, mode, wait):
|
||||
for d in doms:
|
||||
server.xend.domain.shutdown(d, mode)
|
||||
if wait:
|
||||
while doms:
|
||||
alive = server.xend.domains(0)
|
||||
dead = []
|
||||
for d in doms:
|
||||
if d in alive: continue
|
||||
dead.append(d)
|
||||
for d in dead:
|
||||
opts.info("Domain %s terminated" % d)
|
||||
def wait_reboot(opts, doms, rcs):
|
||||
while doms:
|
||||
alive = server.xend.domains(0)
|
||||
reboot = []
|
||||
for d in doms:
|
||||
if d in alive:
|
||||
rc = server.xend.domain.getRestartCount(d)
|
||||
if rc == rcs[d]: continue
|
||||
reboot.append(d)
|
||||
else:
|
||||
opts.info("Domain %s destroyed for failed in rebooting" % d)
|
||||
doms.remove(d)
|
||||
time.sleep(1)
|
||||
opts.info("All domains terminated")
|
||||
for d in reboot:
|
||||
opts.info("Domain %s rebooted" % d)
|
||||
doms.remove(d)
|
||||
time.sleep(1)
|
||||
opts.info("All domains rebooted")
|
||||
|
||||
def wait_shutdown(opts, doms):
|
||||
while doms:
|
||||
alive = server.xend.domains(0)
|
||||
dead = []
|
||||
for d in doms:
|
||||
if d in alive: continue
|
||||
dead.append(d)
|
||||
for d in dead:
|
||||
opts.info("Domain %s terminated" % d)
|
||||
doms.remove(d)
|
||||
time.sleep(1)
|
||||
opts.info("All domains terminated")
|
||||
|
||||
def shutdown(opts, doms, mode, wait):
|
||||
rcs = {}
|
||||
for d in doms:
|
||||
rcs[d] = server.xend.domain.getRestartCount(d)
|
||||
server.xend.domain.shutdown(d, mode)
|
||||
|
||||
if wait:
|
||||
if mode == 'reboot':
|
||||
wait_reboot(opts, doms, rcs)
|
||||
else:
|
||||
wait_shutdown(opts, doms)
|
||||
|
||||
def shutdown_mode(opts):
|
||||
if opts.vals.halt and opts.vals.reboot:
|
||||
|
||||