This patch prevents 'xm dom{id,name}' from returning stale information
after a domain has exited.
Xend already called XendDomainInfo.update() before returning
information, but did not check to see if the result indicated that the
domain had disappeared. So, it updated the domain (which just bails
if the domain is gone) and then returned info from its internal data
structures. This means that if you run "xm destroy foo", you can then
run "xm domid" or "xm domname" many times, getting stale info.
Instead of modifying Xend's state in a "random place", we just make
sure to throw an error if we know the state is invalid.
This patch causes xm-test 01_shutdown_basic_pos to pass now. Xm-test
uses domid and domname in many places to determine if a domain is
running or not (as, I would imagine, other higher-level tools might).
Having this information consistent with the actual state is a good
thing.
Signed-off-by: Dan Smith <danms@xxxxxxxxxx>
diff -r ca78d9668fdb tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Wed Sep 28 14:06:48 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py Wed Sep 28 08:22:10 2005
@@ -693,7 +693,7 @@
if not info:
info = dom_get(self.domid)
if not info:
- return
+ return False
self.info.update(info)
self.validateInfo()
@@ -701,6 +701,8 @@
log.debug("XendDomainInfo.update done on domain %d: %s", self.domid,
self.info)
+
+ return True
## private:
diff -r ca78d9668fdb tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Wed Sep 28 14:06:48 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Wed Sep 28 08:22:10 2005
@@ -21,6 +21,8 @@
from xen.xend import XendDomain
from xen.xend import PrettyPrint
from xen.xend.Args import FormFn
+from xen.xend.XendError import XendError
+from xen.xend.XendLogging import log
from xen.web.SrvDir import SrvDir
@@ -221,7 +223,9 @@
#
# if op and op[0] in ['vifs', 'vif', 'vbds', 'vbd', 'mem_target_set']:
# return self.perform(req)
- self.dom.update()
+ if not self.dom.update():
+ raise XendError("Domain %s no longer exists" % self.dom.getName())
+
if self.use_sxp(req):
req.setHeader("Content-Type", sxp.mime_type)
sxp.show(self.dom.sxpr(), out=req)
diff -r ca78d9668fdb tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Wed Sep 28 14:06:48 2005
+++ b/tools/python/xen/xm/main.py Wed Sep 28 08:22:10 2005
@@ -32,6 +32,7 @@
warnings.filterwarnings('ignore', category=FutureWarning)
from xen.xend import PrettyPrint
from xen.xend import sxp
+from xen.xend.XendClient import XendError
from xen.xm.opts import *
shorthelp = """Usage: xm <subcommand> [args]
Control, list, and manipulate Xen guest instances
@@ -385,14 +386,24 @@
name = args[0]
from xen.xend.XendClient import server
- dom = server.xend_domain(name)
+ try:
+ dom = server.xend_domain(name)
+ except XendError, e:
+ err("Unable to get info for domain %s" % name)
+ sys.exit(1)
+
print sxp.child_value(dom, 'domid')
def xm_domname(args):
name = args[0]
from xen.xend.XendClient import server
- dom = server.xend_domain(name)
+ try:
+ dom = server.xend_domain(name)
+ except XendError, e:
+ err("Unable to get info for domain %s" % name)
+ sys.exit(1)
+
print sxp.child_value(dom, 'name')
def xm_sched_bvt(args):
@@ -687,7 +698,6 @@
args = argv[2:]
if cmd:
try:
- from xen.xend.XendClient import XendError
rc = cmd(args)
if rc:
usage()
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@xxxxxxxxxx
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|