Fix xm pause/unpause command for inactive managed domain
PATCH 1/1 Fix xm pause/unpause command for inactive managed domain
Hi,
When I tried xm pause/unpause command to an inactive managed domain, I saw the following error messages. And I found TypeError messages in xend.log.
# xm list vm1 Name ID Mem VCPUs State Time(s) vm1 256 2 0.0 # xm pause vm1 Error: int() argument must be a string or a number Usage: xm pause <Domain>
Pause execution of a domain.
# xm unpause vm1 Error: int() argument must be a string or a number Usage: xm unpause <Domain>
Unpause a paused domain.
[2007-07-10 11:56:29 4945] ERROR (XendDomain:1148) domain_pause Traceback (most recent call last):
File "//usr/lib/python/xen/xend/XendDomain.py", line 1142, in domain_pause
int(dominfo.getDomid()))
TypeError: int() argument must be a string or a number [2007-07-10 11:56:34 4945] ERROR (XendDomain:1123) domain_unpause Traceback (most recent call last):
File "//usr/lib/python/xen/xend/XendDomain.py", line 1117, in domain_unpause
int(dominfo.getDomid()))
TypeError: int() argument must be a string or a number
I wrote two patches. When you try xm pause/unpause command to the inactive managed domain, xm pause/unpause command causes command error even if you use either patch. The difference of two patches is as follows. I think that xm_pause_unpause_2.patch is better than xm_pause_unpause_1.patch. Which do you choose?
xm_pause_unpause_1.patch:
- If you try xm pause command to a paused domain, xm pause command causes command error.
- If you try xm unpause command to a running domain, xm unpause command causes command error.
xm_pause_unpause_2.patch:
- Even if you try xm pause command to a paused domain, xm pause command does not cause command error.
- Even if you try xm unpause command to a running domain, xm unpause command does not cause command error.
- Even if without the patch, the results are same.
Best regards,
Kan
tools/python/xen/xend/XendDomain.py +18 -0
@@ -1112,6 +1112,15 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot unpause privileged domain %s" % domid) + state = dominfo._stateGet() + if state == DOM_STATE_RUNNING: + raise VMBadState("Domain '%s' is already running" % domid, + POWER_STATE_NAMES[DOM_STATE_PAUSED], + POWER_STATE_NAMES[DOM_STATE_RUNNING]) + if state != DOM_STATE_PAUSED: + raise VMBadState("Domain '%s' is not started" % domid, + POWER_STATE_NAMES[DOM_STATE_PAUSED], + POWER_STATE_NAMES[state]) log.info("Domain %s (%d) unpaused.", dominfo.getName(), int(dominfo.getDomid())) dominfo.unpause()
@@ -1137,6 +1146,15 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot pause privileged domain %s" % domid) + state = dominfo._stateGet() + if state == DOM_STATE_PAUSED: + raise VMBadState("Domain '%s' is already paused" % domid, + POWER_STATE_NAMES[DOM_STATE_RUNNING], + POWER_STATE_NAMES[DOM_STATE_PAUSED]) + if state != DOM_STATE_RUNNING: + raise VMBadState("Domain '%s' is not started" % domid, + POWER_STATE_NAMES[DOM_STATE_RUNNING], + POWER_STATE_NAMES[state]) log.info("Domain %s (%d) paused.", dominfo.getName(), int(dominfo.getDomid())) dominfo.pause()
tools/python/xen/xend/XendDomain.py +8 -0
@@ -1112,6 +1112,10 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot unpause privileged domain %s" % domid) + if dominfo._stateGet() not in (DOM_STATE_PAUSED, DOM_STATE_RUNNING): + raise VMBadState("Domain '%s' is not started" % domid, + POWER_STATE_NAMES[DOM_STATE_PAUSED], + POWER_STATE_NAMES[dominfo._stateGet()]) log.info("Domain %s (%d) unpaused.", dominfo.getName(), int(dominfo.getDomid())) dominfo.unpause()
@@ -1137,6 +1141,10 @@ class XendDomain: raise XendInvalidDomain(str(domid)) if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot pause privileged domain %s" % domid) + if dominfo._stateGet() not in (DOM_STATE_RUNNING, DOM_STATE_PAUSED): + raise VMBadState("Domain '%s' is not started" % domid, + POWER_STATE_NAMES[DOM_STATE_RUNNING], + POWER_STATE_NAMES[dominfo._stateGet()]) log.info("Domain %s (%d) paused.", dominfo.getName(), int(dominfo.getDomid())) dominfo.pause()
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel