nbd: Fix filename generation
commitec0de76874462c745a1600911bd81ee0253c0c23
authorMax Reitz <mreitz@redhat.com>
Wed, 8 Oct 2014 17:55:15 +0000 (8 19:55 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 20 Oct 2014 11:41:26 +0000 (20 13:41 +0200)
tree01616a1295932a8eb18b4326dbdd01f8caf1228a
parent7c15903789953ead14a417882657d52dc0c19a24
nbd: Fix filename generation

Export names may be used with nbd+unix, too, fix nbd_refresh_filename()
accordingly. Also, for nbd+tcp, the documented path schema is
"nbd://host[:port]/export", so use it. Furthermore, as can be seen from
that schema, the port is optional.

That makes six single cases for how the filename can be formatted; it is
not easy to generalize these cases without the resulting statement being
completely unreadable, thus there is simply one snprintf() per case.

Finally, taking the options from BDRVNBDState::socket_opts is wrong,
because those will not contain the export name. Just use
BlockDriverState::options instead.

Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/nbd.c