Fix xm reboot --wait
PATCH 1/1 Fix xm reboot --wait
Hi,
This patch fixed 'xm reboot' to work as you expected with the wait option. The completion of a VM reboot is detected by observing that its Domain-ID changes.
Best regards,
Kan
tools/python/xen/xm/shutdown.py +31 -11
@@ -49,20 +49,40 @@ gopts.opt('reboot', short='R', use='Shutdown and reboot.') def shutdown(opts, doms, mode, wait): + domids = {} for d in doms: + domids[d] = sxp.child_value(server.xend.domain(d), 'domid') 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) - doms.remove(d) - time.sleep(1) - opts.info("All domains terminated") + if mode == 'reboot': + while doms: + alive = server.xend.domains(0) + reboot = [] + for d in doms: + if d in alive: + domid = sxp.child_value(server.xend.domain(d), 'domid') + if domid == domids[d]: continue + reboot.append(d) + else: + opts.info("Domain %s destroyed by ShutdownWatch" % d) + doms.remove(d) + for d in reboot: + opts.info("Domain %s rebooted" % d) + doms.remove(d) + time.sleep(1) + opts.info("All domains rebooted") + else: + 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_mode(opts): if opts.vals.halt and opts.vals.reboot:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 5 lines · Masaki Kanno
This patch fixed 'xm reboot' to work as you expected with the wait option. The completion of a VM reboot is detected by observing that its Domain-ID changes.
Signed-off-by Masaki Kanno <[email protected]>
What happens currently? Can 'xm reboot' wait forever because it races the re-creation of the domain?
We need a better test than domid. It's not guaranteed that a domain will get a new domid when it restarts. Perhaps xend should support the wait option (since it is involved in the restart), or we could add a restart sequence count to xenstore (but xm oughtn't to access xenstore directly).
-- Keir
Hi Keir,
Quoted 11 lines · Masaki Kanno
Quoted 6 lines
This patch fixed 'xm reboot' to work as you expected with the wait option. The completion of a VM reboot is detected by observing that its Domain-ID changes.
Signed-off-by Masaki Kanno <[email protected]>What happens currently? Can 'xm reboot' wait forever because it races the re-creation of the domain?
Currently 'xm reboot --wait' never ends. (But VM reboot is completed.) The wait option waits for the domain termination by chekcing current domain list (server.xend.domains). But the domain termination cannot be detected because the domain is recreated immediately.
Quoted 5 lines
We need a better test than domid. It's not guaranteed that a domain will get a new domid when it restarts. Perhaps xend should support the wait option (since it is involved in the restart), or we could add a restart sequence count to xenstore (but xm oughtn't to access xenstore directly).
I will remake patch based on your advice.
Best regards,
Kan
Quoted 2 lines
-- Keir
PATCH RESEND 1/1 Fix xm reboot --wait
In reply to Keir FraserHi,
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.
Best regards,
Kan
tools/python/xen/xend/XendDomainInfo.py +9 -0
@@ -699,6 +699,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)
@@ -819,6 +822,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
@@ -1601,6 +1607,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:
tools/python/xen/xend/server/XMLRPCServer.py +2 -1
@@ -76,7 +76,8 @@ def get_log(): methods = ['device_create', 'destroyDevice', 'getDeviceSxprs', 'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown', - 'send_sysrq', 'getVCPUInfo', 'waitForDevices'] + 'send_sysrq', 'getVCPUInfo', 'waitForDevices', + 'getRestartCount'] exclude = ['domain_create', 'domain_restore']
tools/python/xen/xm/shutdown.py +38 -11
59 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi,
Could you possibly comment about this patch?
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg01125.html
Best regards,
Kan
Quoted 19 lines
Hi,
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 <[email protected]>Best regards,
Kan-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Ewan Mellor
AppliedOn Mon, Aug 21, 2006 at 04:11:19PM +0900, Masaki Kanno wrote:
Content-Description: Mail message body
Quoted 9 lines
Hi,
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 <[email protected]>
Applied, thank you.
Ewan.
I think it'd be neater to add a 'synchronous' flag to the shutdown RPC, than to expose a restart counter to xm via a special new server command. Would it be hard to delay the RPC response in xend (and either have xend return a failure response on a timeout, or have xm wait for the RPC response on a timeout)?
-- Keir
Quoted 29 lines · Masaki Kanno
Hi,
Could you possibly comment about this patch?
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg01125.html
Best regards,
KanQuoted 19 lines
Hi,
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 <[email protected]>Best regards,
Kan-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi Keir,
Could you teach about the 'synchronous flag' in detail? Is the 'synchronous flag' a interface that requests the response from xend to xm to be delayed until the reboot of domU is completed?
Best regards,
Kan
Quoted 41 lines
I think it'd be neater to add a 'synchronous' flag to the shutdown RPC, than to expose a restart counter to xm via a special new server command. Would it be hard to delay the RPC response in xend (and either have xend return a failure response on a timeout, or have xm wait for the RPC response on a timeout)?
-- Keir
Quoted 29 lines · Masaki Kanno
Hi,
Could you possibly comment about this patch?
http://lists.xensource.com/archives/html/xen-devel/2006-08/msg01125.html
Best regards,
KanQuoted 19 lines
Hi,
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 <[email protected]>Best regards,
Kan-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · Masaki Kanno
Hi Keir,
Could you teach about the 'synchronous flag' in detail? Is the 'synchronous flag' a interface that requests the response from xend to xm to be delayed until the reboot of domU is completed?
Best regards,
Kan
That's the idea, yes. It seems neater to have xend provide this feature directly rather than place detail sof its implementation in xm itself by making the 'restart counter' available across RPC.
-- Keir
Quoted 8 lines · Masaki Kanno
Quoted 7 lines
Hi Keir,
Could you teach about the 'synchronous flag' in detail? Is the 'synchronous flag' a interface that requests the response from xend to xm to be delayed until the reboot of domU is completed?
Quoted 6 lines
Quoted 2 lines
Best regards,
KanThat's the idea, yes. It seems neater to have xend provide this feature directly rather than place detail sof its implementation in xm itself by making the 'restart counter' available across RPC.
Hi Keir,
Currently, xm reboot command processing is the almost following sequences.
Currently:
------------------------------+------------------------+---------------
xm |xend |domU(VM1)
------------------------------+------------------------+---------------
xm create VM1 | |
| VM1.restart_count==0 |
xm reboot VM1 | |
VM1.getRestartCount() <-----------> |
: Counter is 0 | |
VM1.shutdown('reboot') <----------> |
| VM1.shutdown <-----------> +
| | |
| | shutdown
| | processing
| | |
VM1.getRestartCount() <-----------> | |
: Counter is 0, no count up| <-------------- +
| VM1.destroy |
| VM1.create |
| VM1.restart_count++ |
| |
VM1.getRestartCount() <-----------> |
: Counter is 1, count up! | |
| |
info("Domain VM1 rebooted") | |
| |------------------------------+------------------------+---------------
If xm/xend implemented 'synchronous flag' which was your idea, I think that xm reboot command is the almost following sequences. Am I right?
Synchronous flag:
------------------------------+------------------------+---------------
xm |xend |domU(VM1)
------------------------------+------------------------+---------------
xm create VM1 | |
| |
xm reboot VM1 | |
VM1.shutdown('reboot',sync)-------> |
| | VM1.shutdown <-----------> +
| | | |
| | | shutdown
| | | processing
| | | |
wait | | |
| | <-------------- +
| | VM1.destroy |
V | VM1.create |
<------- Completion response |
| |
info("Domain VM1 rebooted") | |
| |------------------------------+------------------------+---------------
If a user rebooted one VM, both implementations are the same for execute time of xm reboot command. However, xm reboot command has 'all' option. If a user rebooted all VMs with 'all' option, I think that the execute time of xm reboot command lengthen in proportion to the number of VM.
Synchronous flag(--all):
------------------------------+------------------------+---------------
xm |xend |domU
------------------------------+------------------------+---------------
xm create VM1 | |
xm create VM2 | |
| |
xm reboot --all | |
VM1.shutdown('reboot',sync)-------> |
| | VM1.shutdown <-----------> +
| | | |
| | | shutdown
| | | processing
| | | |
wait | | |
| | <-------------- +
| | VM1.destroy |
V | VM1.create |
<------- Completion response |
| |
info("Domain VM1 rebooted") | |
VM2.shutdown('reboot',sync)-------> |
| | VM2.shutdown <-----------> +
| | | |
| | | shutdown
| | | processing
| | | |
wait | | |
| | <-------------- +
| | VM2.destroy |
V | VM2.create |
<------- Completion response |
| |
info("Domain VM2 rebooted") | |
| |------------------------------+------------------------+---------------
As for the current implementation, if a user rebooted all VMs with 'all' option, shutdown processing of each VM is executed in parallel.
Best regards,
Kan
Quoted 3 lines
-- Keir