2011/11/23 Stefan Hajnoczi <stefa...@gmail.com>

> On Wed, Nov 23, 2011 at 10:14 AM, Chunyan Liu <cy...@suse.com> wrote:
> > V3:
> > Remove file lock in main().
> > Try to find new free nbd device and connect to it if connecting to the
> first
> > first found free nbd device failed.
> >
> > Signed-off-by: Chunyan Liu <cy...@suse.com>
> > ---
> >  qemu-nbd.c |   80
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 files changed, 79 insertions(+), 1 deletions(-)
>
> I not seeing the part where you adjusted the ioctl order.
>
> The /proc/partitions scanning is unnecessary since we can just loop
> over /dev/ndb%d and try to initialize.  If a device is in use then
> init will fail and we need to try the next one.  If a device is free
> we can continue with normal operation.  I guess I'm saying that once
> you fix the ioctl order then there's no need for another mechanism to
> test whether or not a device is in use.
>

The way of scanning /proc/partitions to find an unused nbd device first can
borrow the code for "qemu-nbd -c" to do the left things. .
The way of loop over /dev/nbd%d and try to initialize, from the first
thought, needs do all things in the loop, including handling -v, nbd_init,
nbd_client, etc. That part of code is quite similar to "qemu-nbd -c". I
don't know if that is better?



>

Also please use QEMU coding style, you can run
> qemu/scripts/checkpatch.pl on your patches.
>
> Stefan
>
>

Reply via email to