17.01.2019 22:36, Eric Blake wrote: > We want to be able to detect whether a given qemu NBD server is > exposing the right export(s) and dirty bitmaps, at least for > regression testing. We could use 'nbd-client -l' from the upstream > NBD project to list exports, but it's annoying to rely on > out-of-tree binaries; furthermore, nbd-client doesn't necessarily > know about all of the qemu NBD extensions. Thus, it is time to add > a new mode to qemu-nbd that merely sniffs all possible information > from the server during handshake phase, then disconnects and dumps > the information.
[..] (hm, first time I do it for commit message) > Not done here, but maybe worth future experiments: capture > the meat of NBDExportInfo into a QAPI struct, and use the > generated QAPI pretty-printers instead of hand-rolling our > output loop. It would also permit us to add a JSON output > mode for machine parsing. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > Reviewed-by: Richard W.M. Jones <rjo...@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > @@ -816,6 +940,11 @@ int main(int argc, char **argv) > } > } > > + if (list) { > + saddr = nbd_build_socket_address(sockpath, bindto, port); > + return qemu_nbd_client_list(saddr, tlscreds, bindto); note, that this main() prefers to use exit() instead of return, even for last exit(EXIT_SUCCESS). (but it has already one return, so this is not the first, and for me return looks better) -- Best regards, Vladimir