From: john.levon@sun.com
To: xen-devel@lists.xensource.com
Subject: [PATCH] Fix xend xenstore handling
Date: Fri, 21 Dec 2007 06:45:57 -0800 [thread overview]
Message-ID: <b29e155a85ef663170b0.1198248357@hatchback> (raw)
# HG changeset patch
# User john.levon@sun.com
# Date 1198248324 28800
# Node ID b29e155a85ef663170b0651798c84db79bafcdd8
# Parent d7974e8d8f5131356e7c8fc87f880d737044e91b
Fix xend xenstore handling.
xend can get into a situation where two processes are attempting to
interact with the xenstore socket, with disastrous results. Fix the two
bad users of xstransact, add a big warning, and fix the destructor so
future mistakes will be detected earlier.
Signed-off-by: John Levon <john.levon@sun.com>
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -1533,10 +1533,9 @@ class XendDomainInfo:
except:
# Log and swallow any exceptions in removal --
# there's nothing more we can do.
- log.exception("Device release failed: %s; %s; %s",
- self.info['name_label'], devclass, dev)
-
-
+ log.exception("Device release failed: %s; %s; %s",
+ self.info['name_label'], devclass, dev)
+ t.abort()
def getDeviceController(self, name):
"""Get the device controller for this domain, and if it
@@ -1848,7 +1847,6 @@ class XendDomainInfo:
# build list of phantom devices to be removed after normal devices
plist = []
if self.domid is not None:
- from xen.xend.xenstore.xstransact import xstransact
t = xstransact("%s/device/vbd" % GetDomainPath(self.domid))
for dev in t.list():
backend_phantom_vbd = xstransact.Read("%s/device/vbd/%s/phantom_vbd" \
@@ -1858,6 +1856,7 @@ class XendDomainInfo:
% backend_phantom_vbd)
plist.append(backend_phantom_vbd)
plist.append(frontend_phantom_vbd)
+ t.abort()
return plist
def _cleanup_phantom_devs(self, plist):
diff --git a/tools/python/xen/xend/server/pciif.py b/tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py
+++ b/tools/python/xen/xend/server/pciif.py
@@ -22,8 +22,6 @@ from xen.xend import sxp
from xen.xend import sxp
from xen.xend.XendError import VmError
from xen.xend.XendLogging import log
-
-from xen.xend.xenstore.xstransact import xstransact
from xen.xend.server.DevController import DevController
diff --git a/tools/python/xen/xend/xenstore/xstransact.py b/tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py
+++ b/tools/python/xen/xend/xenstore/xstransact.py
@@ -7,8 +7,16 @@
from xen.xend.xenstore.xsutil import xshandle
+class xstransact:
+ """WARNING: Be very careful if you're instantiating an xstransact object
+ yourself (i.e. not using the capitalized static helpers like .Read().
+ It is essential that you clean up the object in place via
+ t.commit/abort(): GC can happen at any time, including contexts where
+ it's not safe to to use the shared xenstore socket fd. In particular,
+ if xend forks, and GC occurs, we can have two processes trying to
+ use the same xenstore fd, and all hell breaks loose.
+ """
-class xstransact:
def __init__(self, path = ""):
@@ -22,8 +30,9 @@ class xstransact:
self.in_transaction = True
def __del__(self):
+ # see above.
if self.in_transaction:
- xshandle().transaction_end(self.transaction, True)
+ raise RuntimeError("ERROR: GC of live transaction")
def commit(self):
if not self.in_transaction:
next reply other threads:[~2007-12-21 14:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-21 14:45 john.levon [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-12-21 14:57 [PATCH] Fix xend xenstore handling John Levon
2007-12-21 15:08 ` Daniel P. Berrange
2007-12-21 15:27 ` John Levon
2007-12-21 15:31 ` Daniel P. Berrange
2007-12-21 3:42 john.levon
2007-12-22 0:53 ` John Levon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b29e155a85ef663170b0.1198248357@hatchback \
--to=john.levon@sun.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.