qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Chunyan Liu <cyliu@suse.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Add -f option to qemu-nbd
Date: Thu, 17 Nov 2011 10:14:02 +0000	[thread overview]
Message-ID: <CAJSP0QUgmLji5mG4ctXOWrSLZ=Ws0Lw1Rg0PmM8gojFoacKbLQ@mail.gmail.com> (raw)
In-Reply-To: <1321464215.3664.218.camel@zakaz.uk.xensource.com>

On Wed, Nov 16, 2011 at 5:23 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
> On Wed, 2011-11-16 at 10:34 +0000, Stefan Hajnoczi wrote:
>> On Wed, Nov 16, 2011 at 6:57 AM, Chunyan Liu <cyliu@suse.com> wrote:
>> > Currently qemu-nbd does not support finding free nbd device for users like
>> > "losetup -f" and issuing "qemu-nbd -c /dev/nbdX disk.img" won't report error
>> > message when /dev/nbd is already in use. It makes things a little confusing.
>> > This patch adds "-f" option to qemu-nbd to support finding a free nbd device
>> > for users. Please review and share your comments. Thanks.
>> >
>> > Signed-off-by: Chunyan Liu <cyliu@suse.com>
>> > ---
>> >  qemu-nbd.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> >  1 files changed, 64 insertions(+), 1 deletions(-)
>>
>> This patch finds a free device but does not immediately attach to it
>> and use it.  Interfaces 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
>>
>> That way it is safe to execute multiple qemu-nbd -f at the same time
>> without race conditions.
>
> I agree, but you'd also need some locking inside qemu-nbd wouldn't you?
> Or have it just keep trying devices until one works perhaps.

Right, I haven't checked the nbd driver iterface but you'd have to
actually open the device and claim it in order to atomically find out
if it is free.  But that's probably not much more work than what this
patch does, it just has the advantage of being safer.

Stefan

  reply	other threads:[~2011-11-17 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-16  6:57 [Qemu-devel] [PATCH] Add -f option to qemu-nbd Chunyan Liu
2011-11-16 10:34 ` Stefan Hajnoczi
2011-11-16 11:49   ` Zhi Yong Wu
2011-11-16 14:27     ` Stefan Hajnoczi
2011-11-17  4:38       ` Zhi Yong Wu
2011-11-16 17:23   ` Ian Campbell
2011-11-17 10:14     ` Stefan Hajnoczi [this message]
2011-11-17 11:34     ` Chun Yan Liu
2011-11-17 13:33       ` Stefan Hajnoczi

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='CAJSP0QUgmLji5mG4ctXOWrSLZ=Ws0Lw1Rg0PmM8gojFoacKbLQ@mail.gmail.com' \
    --to=stefanha@gmail.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=cyliu@suse.com \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).