* [PATCH] Fix stale-state issue with 'xm dom{id,name}'
@ 2005-09-28 15:35 Dan Smith
0 siblings, 0 replies; only message in thread
From: Dan Smith @ 2005-09-28 15:35 UTC (permalink / raw)
To: Xen Developers
[-- Attachment #1: Type: text/plain, Size: 954 bytes --]
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@us.ibm.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: domid_fix.patch --]
[-- Type: text/x-patch, Size: 2852 bytes --]
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()
[-- Attachment #3: Type: text/plain, Size: 87 bytes --]
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms@us.ibm.com
[-- Attachment #4: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-09-28 15:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-28 15:35 [PATCH] Fix stale-state issue with 'xm dom{id,name}' Dan Smith
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.