From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCHv3] 1/3] libxc: prefer using privcmd character device Date: Wed, 2 Dec 2015 11:42:49 +0000 Message-ID: <20151202114249.GE21588@citrix.com> References: <1448998075-23878-1-git-send-email-cardoe@cardoe.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1448998075-23878-1-git-send-email-cardoe@cardoe.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: Doug Goldstein Cc: Wei Liu , Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, Dec 01, 2015 at 01:27:53PM -0600, Doug Goldstein wrote: > Prefer using the character device over the proc file if the character > device exists. This follows similar conversions of xenbus to avoid > issues with FMODE_ATOMIC_POS added in Linux 3.14 and newer. > > CC: Ian Jackson > CC: Stefano Stabellini > CC: Ian Campbell > CC: Wei Liu > Signed-off-by: Doug Goldstein Acked-by: Wei Liu > --- > tools/libxc/xc_linux_osdep.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c > index 76c55ff..c3a3a14 100644 > --- a/tools/libxc/xc_linux_osdep.c > +++ b/tools/libxc/xc_linux_osdep.c > @@ -46,7 +46,13 @@ > static xc_osdep_handle linux_privcmd_open(xc_interface *xch) > { > int flags, saved_errno; > - int fd = open("/proc/xen/privcmd", O_RDWR); > + int fd = open("/dev/xen/privcmd", O_RDWR); /* prefer this newer interface */ > + > + if ( fd == -1 && ( errno == ENOENT || errno == ENXIO || errno == ENODEV )) > + { > + /* Fallback to /proc/xen/privcmd */ > + fd = open("/proc/xen/privcmd", O_RDWR); > + } > > if ( fd == -1 ) > { > -- > 2.4.10 >