From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Creekmore Subject: [PATCH v2] libxenstore: prefer using the character device Date: Thu, 27 Aug 2015 09:04:38 -0500 Message-ID: <1440684278-16838-1-git-send-email-jonathan.creekmore@gmail.com> References: <55D2FF72.7050006@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZUxoJ-0007xm-VZ for xen-devel@lists.xenproject.org; Thu, 27 Aug 2015 14:05:48 +0000 Received: by qgeh99 with SMTP id h99so13200988qge.0 for ; Thu, 27 Aug 2015 07:05:45 -0700 (PDT) In-Reply-To: <55D2FF72.7050006@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: wei.liu@citrix.com, Jonathan Creekmore , ian.jackson@eu.citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org With the addition of FMODE_ATOMIC_POS in the Linux 3.14 kernel, concurrent blocking file accesses to a single open file descriptor can cause a deadlock trying to grab the file position lock. If a watch has been set up, causing a read_thread to blocking read on the file descriptor, then future writes that would cause the background read to complete will block waiting on the file position lock before they can execute. This race condition only occurs when libxenstore is accessing the xenstore daemon through the /proc/xen/xenbus file and not through the unix domain socket, which is the case when the xenstore daemon is running as a stub domain or when oxenstored is passed --disable-socket. Accessing the daemon from the true character device also does not exhibit this problem. On Linux, prefer using the character device file over the proc file if the character device exists. Signed-off-by: Jonathan Creekmore --- tools/xenstore/xs_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/xenstore/xs_lib.c b/tools/xenstore/xs_lib.c index af4f75a..0c7744e 100644 --- a/tools/xenstore/xs_lib.c +++ b/tools/xenstore/xs_lib.c @@ -81,6 +81,8 @@ const char *xs_domain_dev(void) #if defined(__RUMPUSER_XEN__) || defined(__RUMPRUN__) return "/dev/xen/xenbus"; #elif defined(__linux__) + if (access("/dev/xen/xenbus", F_OK) == 0) + return "/dev/xen/xenbus"; return "/proc/xen/xenbus"; #elif defined(__NetBSD__) return "/kern/xen/xenbus"; -- 2.1.4