qemu-nbd: drop old-style negotiation

Use new-style negotiation always, with default "" (empty) export name
if it is not specified with '-x' option.

qemu as client can manage either style since 2.6.0, commit 69b49502d8

For comparison:

nbd 3.10 dropped oldstyle long ago (Mar 2015):
https://github.com/NetworkBlockDevice/nbd/commit/36940193

nbdkit 1.3 switched its default to newstyle (Jan 2018):
https://github.com/libguestfs/nbdkit/commit/b2a8aecc
https://github.com/libguestfs/nbdkit/commit/8158e773

Furthermore, if a client that only speaks oldstyle still needs to
communicate to qemu, nbdkit remains available to perform the
translation between the two protocols.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20181003170228.95973-2-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: enhance commit message]
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2018-10-03 20:02:27 +03:00 committed by Eric Blake
parent f7812df77d
commit f5cd0bb517
1 changed files with 6 additions and 19 deletions

View File

@ -56,7 +56,6 @@
#define MBR_SIZE 512 #define MBR_SIZE 512
static NBDExport *exp; static NBDExport *exp;
static bool newproto;
static int verbose; static int verbose;
static char *srcpath; static char *srcpath;
static SocketAddress *saddr; static SocketAddress *saddr;
@ -84,8 +83,8 @@ static void usage(const char *name)
" -e, --shared=NUM device can be shared by NUM clients (default '1')\n" " -e, --shared=NUM device can be shared by NUM clients (default '1')\n"
" -t, --persistent don't exit on the last connection\n" " -t, --persistent don't exit on the last connection\n"
" -v, --verbose display extra debugging information\n" " -v, --verbose display extra debugging information\n"
" -x, --export-name=NAME expose export by name\n" " -x, --export-name=NAME expose export by name (default is empty string)\n"
" -D, --description=TEXT with -x, also export a human-readable description\n" " -D, --description=TEXT export a human-readable description\n"
"\n" "\n"
"Exposing part of the image:\n" "Exposing part of the image:\n"
" -o, --offset=OFFSET offset into the image\n" " -o, --offset=OFFSET offset into the image\n"
@ -355,8 +354,7 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
nb_fds++; nb_fds++;
nbd_update_server_watch(); nbd_update_server_watch();
nbd_client_new(newproto ? NULL : exp, cioc, nbd_client_new(NULL, cioc, tlscreds, NULL, nbd_client_closed);
tlscreds, NULL, nbd_client_closed);
} }
static void nbd_update_server_watch(void) static void nbd_update_server_watch(void)
@ -550,7 +548,7 @@ int main(int argc, char **argv)
Error *local_err = NULL; Error *local_err = NULL;
BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF; BlockdevDetectZeroesOptions detect_zeroes = BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
QDict *options = NULL; QDict *options = NULL;
const char *export_name = NULL; const char *export_name = ""; /* Default export name */
const char *export_description = NULL; const char *export_description = NULL;
const char *tlscredsid = NULL; const char *tlscredsid = NULL;
bool imageOpts = false; bool imageOpts = false;
@ -809,11 +807,6 @@ int main(int argc, char **argv)
error_report("TLS is not supported with a host device"); error_report("TLS is not supported with a host device");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (!export_name) {
/* Set the default NBD protocol export name, since
* we *must* use new style protocol for TLS */
export_name = "";
}
tlscreds = nbd_get_tls_creds(tlscredsid, &local_err); tlscreds = nbd_get_tls_creds(tlscredsid, &local_err);
if (local_err) { if (local_err) {
error_report("Failed to get TLS creds %s", error_report("Failed to get TLS creds %s",
@ -1014,14 +1007,8 @@ int main(int argc, char **argv)
error_report_err(local_err); error_report_err(local_err);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (export_name) { nbd_export_set_name(exp, export_name);
nbd_export_set_name(exp, export_name); nbd_export_set_description(exp, export_description);
nbd_export_set_description(exp, export_description);
newproto = true;
} else if (export_description) {
error_report("Export description requires an export name");
exit(EXIT_FAILURE);
}
if (device) { if (device) {
int ret; int ret;