qemu-nbd: open the block device after starting the client thread
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 4 Nov 2011 14:51:24 +0000 (15:51 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 11 Nov 2011 13:02:58 +0000 (14:02 +0100)
commit87f79a5e72e3df2f30ecb47e4fca901726b79b19
tree6bcec5b805731e5013e8b0a205e92d04cd1757ee
parentd460a26b0ece1cb6cb999b58e60cd06a83a5eb03
qemu-nbd: open the block device after starting the client thread

This is cleaner, because we do not need to close the block device when
there is an error opening /dev/nbdX.  It was done this way only to
print errors before daemonizing.

At the same time, use atexit to ensure that the block device is closed
whenever we exit.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-nbd.c