mirror of https://github.com/xemu-project/xemu.git
nbd/server: drop old-style negotiation
After the previous commit, nbd_client_new's first parameter is always NULL. Let's drop it with all corresponding old-style negotiation code path which is unreachable now. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20181003170228.95973-3-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> [eblake: re-wrap short line] Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
f5cd0bb517
commit
7f7dfe2a53
|
@ -36,8 +36,7 @@ static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
|
||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
|
||||||
nbd_client_new(NULL, cioc,
|
nbd_client_new(cioc, nbd_server->tlscreds, NULL,
|
||||||
nbd_server->tlscreds, NULL,
|
|
||||||
nbd_blockdev_client_closed);
|
nbd_blockdev_client_closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,8 +308,7 @@ void nbd_export_set_name(NBDExport *exp, const char *name);
|
||||||
void nbd_export_set_description(NBDExport *exp, const char *description);
|
void nbd_export_set_description(NBDExport *exp, const char *description);
|
||||||
void nbd_export_close_all(void);
|
void nbd_export_close_all(void);
|
||||||
|
|
||||||
void nbd_client_new(NBDExport *exp,
|
void nbd_client_new(QIOChannelSocket *sioc,
|
||||||
QIOChannelSocket *sioc,
|
|
||||||
QCryptoTLSCreds *tlscreds,
|
QCryptoTLSCreds *tlscreds,
|
||||||
const char *tlsaclname,
|
const char *tlsaclname,
|
||||||
void (*close_fn)(NBDClient *, bool));
|
void (*close_fn)(NBDClient *, bool));
|
||||||
|
|
53
nbd/server.c
53
nbd/server.c
|
@ -1253,7 +1253,6 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
|
||||||
const uint16_t myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
|
const uint16_t myflags = (NBD_FLAG_HAS_FLAGS | NBD_FLAG_SEND_TRIM |
|
||||||
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA |
|
NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA |
|
||||||
NBD_FLAG_SEND_WRITE_ZEROES | NBD_FLAG_SEND_CACHE);
|
NBD_FLAG_SEND_WRITE_ZEROES | NBD_FLAG_SEND_CACHE);
|
||||||
bool oldStyle;
|
|
||||||
|
|
||||||
/* Old style negotiation header, no room for options
|
/* Old style negotiation header, no room for options
|
||||||
[ 0 .. 7] passwd ("NBDMAGIC")
|
[ 0 .. 7] passwd ("NBDMAGIC")
|
||||||
|
@ -1274,33 +1273,19 @@ static coroutine_fn int nbd_negotiate(NBDClient *client, Error **errp)
|
||||||
trace_nbd_negotiate_begin();
|
trace_nbd_negotiate_begin();
|
||||||
memcpy(buf, "NBDMAGIC", 8);
|
memcpy(buf, "NBDMAGIC", 8);
|
||||||
|
|
||||||
oldStyle = client->exp != NULL && !client->tlscreds;
|
stq_be_p(buf + 8, NBD_OPTS_MAGIC);
|
||||||
if (oldStyle) {
|
stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
|
||||||
trace_nbd_negotiate_old_style(client->exp->size,
|
|
||||||
client->exp->nbdflags | myflags);
|
|
||||||
stq_be_p(buf + 8, NBD_CLIENT_MAGIC);
|
|
||||||
stq_be_p(buf + 16, client->exp->size);
|
|
||||||
stl_be_p(buf + 24, client->exp->nbdflags | myflags);
|
|
||||||
|
|
||||||
if (nbd_write(client->ioc, buf, sizeof(buf), errp) < 0) {
|
if (nbd_write(client->ioc, buf, 18, errp) < 0) {
|
||||||
error_prepend(errp, "write failed: ");
|
error_prepend(errp, "write failed: ");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
} else {
|
ret = nbd_negotiate_options(client, myflags, errp);
|
||||||
stq_be_p(buf + 8, NBD_OPTS_MAGIC);
|
if (ret != 0) {
|
||||||
stw_be_p(buf + 16, NBD_FLAG_FIXED_NEWSTYLE | NBD_FLAG_NO_ZEROES);
|
if (ret < 0) {
|
||||||
|
error_prepend(errp, "option negotiation failed: ");
|
||||||
if (nbd_write(client->ioc, buf, 18, errp) < 0) {
|
|
||||||
error_prepend(errp, "write failed: ");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
ret = nbd_negotiate_options(client, myflags, errp);
|
|
||||||
if (ret != 0) {
|
|
||||||
if (ret < 0) {
|
|
||||||
error_prepend(errp, "option negotiation failed: ");
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!client->optlen);
|
assert(!client->optlen);
|
||||||
|
@ -2396,13 +2381,8 @@ static void nbd_client_receive_next_request(NBDClient *client)
|
||||||
static coroutine_fn void nbd_co_client_start(void *opaque)
|
static coroutine_fn void nbd_co_client_start(void *opaque)
|
||||||
{
|
{
|
||||||
NBDClient *client = opaque;
|
NBDClient *client = opaque;
|
||||||
NBDExport *exp = client->exp;
|
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
if (exp) {
|
|
||||||
nbd_export_get(exp);
|
|
||||||
QTAILQ_INSERT_TAIL(&exp->clients, client, next);
|
|
||||||
}
|
|
||||||
qemu_co_mutex_init(&client->send_lock);
|
qemu_co_mutex_init(&client->send_lock);
|
||||||
|
|
||||||
if (nbd_negotiate(client, &local_err)) {
|
if (nbd_negotiate(client, &local_err)) {
|
||||||
|
@ -2417,13 +2397,11 @@ static coroutine_fn void nbd_co_client_start(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new client listener on the given export @exp, using the
|
* Create a new client listener using the given channel @sioc.
|
||||||
* given channel @sioc. Begin servicing it in a coroutine. When the
|
* Begin servicing it in a coroutine. When the connection closes, call
|
||||||
* connection closes, call @close_fn with an indication of whether the
|
* @close_fn with an indication of whether the client completed negotiation.
|
||||||
* client completed negotiation.
|
|
||||||
*/
|
*/
|
||||||
void nbd_client_new(NBDExport *exp,
|
void nbd_client_new(QIOChannelSocket *sioc,
|
||||||
QIOChannelSocket *sioc,
|
|
||||||
QCryptoTLSCreds *tlscreds,
|
QCryptoTLSCreds *tlscreds,
|
||||||
const char *tlsaclname,
|
const char *tlsaclname,
|
||||||
void (*close_fn)(NBDClient *, bool))
|
void (*close_fn)(NBDClient *, bool))
|
||||||
|
@ -2433,7 +2411,6 @@ void nbd_client_new(NBDExport *exp,
|
||||||
|
|
||||||
client = g_new0(NBDClient, 1);
|
client = g_new0(NBDClient, 1);
|
||||||
client->refcount = 1;
|
client->refcount = 1;
|
||||||
client->exp = exp;
|
|
||||||
client->tlscreds = tlscreds;
|
client->tlscreds = tlscreds;
|
||||||
if (tlscreds) {
|
if (tlscreds) {
|
||||||
object_ref(OBJECT(client->tlscreds));
|
object_ref(OBJECT(client->tlscreds));
|
||||||
|
|
|
@ -354,7 +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(NULL, cioc, tlscreds, NULL, nbd_client_closed);
|
nbd_client_new(cioc, tlscreds, NULL, nbd_client_closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nbd_update_server_watch(void)
|
static void nbd_update_server_watch(void)
|
||||||
|
|
Loading…
Reference in New Issue