From: Martin Lucina Subject: Re: [PATCH] xenconsole: Allow non-interactive use Date: Fri, 24 Jul 2015 13:36:12 +0200 Message-ID: <20150724113612.GC25338@nodbug.lucina.net> References: <1437584888-9074-1-git-send-email-martin@lucina.net> <1437641330.19412.37.camel@citrix.com> <20150723150915.GA23015@nodbug.lucina.net> <1437664991.24746.10.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZIbGt-0005h3-B4 for xen-devel@lists.xenproject.org; Fri, 24 Jul 2015 11:36:11 +0000 Content-Disposition: inline In-Reply-To: <1437664991.24746.10.camel@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: Ian Campbell Cc: xen-devel@lists.xenproject.org, Wei Liu , Ian Jackson , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Thursday, 23.07.2015 at=A016:23, Ian Campbell wrote: > On Thu, 2015-07-23 at 17:09 +0200, Martin Lucina wrote: > = > > > But maybe it would be better to set max_fd =3D -1 on declaration and = > > > do > > > the max dance here as with the following cases? > > = > > Declaring max_fd =3D -1 is indeed clearer, I can do a v2 with that = > > change if you like. > = > If you are happy to then yes, please. > = > > One other bug that my change makes potentially easier to trigger is that > > you can run "xl console DOMID" multiple times with the same DOMID and t= he > > result is broken; each instance gets part of the data written to the > > console. > > = > > Any ideas on how to address this in a simple fashion? > = > Perhaps the client should take some exclusive lock (fcntl based?) on an > fd of an open file with domid in the name. Failure to get the lock > should result in the client exiting with some message indicating the > console is in use. That begs the question of where to put the lock file. eg. NetBSD does not seem to have /var/lock. I tried using flock(pty_fd, LOCK_EX | LOCK_NB) locks directly on the pty device and contrary to the documentation claiming support for regular files only it worked fine. I tested using the xenconsole code on my Debian dom0, and flock(1) on NetBSD. Would you consider this approach? Martin