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

Re: [Nbd] How to find a free NBD device?



On Mon, Mar 3, 2014 at 1:16 PM, Andreas Klauer
<Andreas.Klauer@...1264...> wrote:
> On Mon, Mar 03, 2014 at 06:41:47PM +0100, Andreas Klauer wrote:
>> Is there something I'm missing?
>
> Sorry, I see this has been discussed earlier on this list:
>
> http://sourceforge.net/p/nbd/mailman/message/31467855/
>
> Another thing I found is a patch for qemu-nbd:
> (the patch didn't seem to make it though)
>
> http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg02201.html
>
> That patch discussion also mentions a NBD_SET_LOCK but I could not
> find any other reference to that...
>
> So the method seems to be:
>
> 1) check /proc/partitions
> 2) check /sys/block/nbd*/pid
> 3) lock your own program and hope no-one is racing you

Yes, that's basically it. And if any ioctl returns -EBUSY, then retry
from the start. BTW, "losetup --find" just looks at /proc/partitions.



Reply to: