From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQdzI-0003LP-4P for qemu-devel@nongnu.org; Wed, 16 Nov 2011 06:49:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQdzD-0007a3-0W for qemu-devel@nongnu.org; Wed, 16 Nov 2011 06:49:08 -0500 Received: from mail-vw0-f45.google.com ([209.85.212.45]:36609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQdzC-0007Zz-T7 for qemu-devel@nongnu.org; Wed, 16 Nov 2011 06:49:02 -0500 Received: by vws17 with SMTP id 17so8338353vws.4 for ; Wed, 16 Nov 2011 03:49:02 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1321426669-7337-1-git-send-email-cyliu@suse.com> Date: Wed, 16 Nov 2011 19:49:02 +0800 Message-ID: From: Zhi Yong Wu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Add -f option to qemu-nbd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Chunyan Liu , qemu-devel@nongnu.org On Wed, Nov 16, 2011 at 6:34 PM, Stefan Hajnoczi wrote= : > On Wed, Nov 16, 2011 at 6:57 AM, Chunyan Liu wrote: >> Currently qemu-nbd does not support finding free nbd device for users li= ke >> "losetup -f" and issuing "qemu-nbd -c /dev/nbdX disk.img" won't report e= rror >> message when /dev/nbd is already in use. It makes things a little confus= ing. >> This patch adds "-f" option to qemu-nbd to support finding a free nbd de= vice >> for users. Please review and share your comments. Thanks. >> >> Signed-off-by: Chunyan Liu >> --- >> =A0qemu-nbd.c | =A0 65 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++++- >> =A01 files changed, 64 insertions(+), 1 deletions(-) > > This patch finds a free device but does not immediately attach to it > and use it. =A0Interfaces like this are prone to race conditions, I > think it would make more sense to combine the -f option with running > the actual NBD server. > > I suggest: > qemu-nbd -f disk.img Why must we add one new option? I prefer to not adding new option, only enhance existing function of qemu-nbd -c disk.img. > > That way it is safe to execute multiple qemu-nbd -f at the same time > without race conditions. =A0Plus it probably makes the user's life > easier than having to say qemu-nbd -c $(qemu-nbd -f) disk.img. > > Stefan > > --=20 Regards, Zhi Yong Wu