qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Add -f option to qemu-nbd


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] Add -f option to qemu-nbd
Date: Thu, 17 Nov 2011 10:14:02 +0000

On Wed, Nov 16, 2011 at 5:23 PM, Ian Campbell <address@hidden> wrote:
> On Wed, 2011-11-16 at 10:34 +0000, Stefan Hajnoczi wrote:
>> On Wed, Nov 16, 2011 at 6:57 AM, Chunyan Liu <address@hidden> 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 <address@hidden>
>> > ---
>> >  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 via email to

[Prev in Thread] Current Thread [Next in Thread]