On Wed, Nov 16, 2011 at 11:49 AM, Zhi Yong Wu <zwu.ker...@gmail.com> wrote: > On Wed, Nov 16, 2011 at 6:34 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote: >> On Wed, Nov 16, 2011 at 6:57 AM, Chunyan Liu <cy...@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 <cy...@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 > 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 would change the command-line interface and break existing users. There might be scripts or tools that call out to qemu-nbd, they would break if we changed the meaning of -c. Stefan