From: Lukas Straub <lukasstraub2@web.de>
To: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-block <qemu-block@nongnu.org>,
"Juan Quintela" <quintela@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Max Reitz" <mreitz@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PATCH 3/5] block/nbd.c: Add yank feature
Date: Mon, 11 May 2020 19:05:24 +0200 [thread overview]
Message-ID: <20200511190524.3681e58c@luklap> (raw)
In-Reply-To: <20200511161909.GJ2811@work-vm>
[-- Attachment #1: Type: text/plain, Size: 4966 bytes --]
On Mon, 11 May 2020 17:19:09 +0100
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Lukas Straub (lukasstraub2@web.de) wrote:
> > Add yank option, pass it to the socket-channel and register a yank
> > function which sets s->state = NBD_CLIENT_QUIT. This is the same
> > behaviour as if an error occured.
> >
> > Signed-off-by: Lukas Straub <lukasstraub2@web.de>
>
> > +static void nbd_yank(void *opaque)
> > +{
> > + BlockDriverState *bs = opaque;
> > + BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
> > +
> > + atomic_set(&s->state, NBD_CLIENT_QUIT);
>
> I think I was expecting a shutdown on the socket here - why doesn't it
> have one?
For nbd, we register two yank functions: This one and we enable the yank feature on the qio channel (see function nbd_establish_connection below).
Regards,
Lukas Straub
> Dave
>
> > +}
> > +
> > static void nbd_client_close(BlockDriverState *bs)
> > {
> > BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
> > @@ -1407,14 +1421,17 @@ static void nbd_client_close(BlockDriverState *bs)
> > nbd_teardown_connection(bs);
> > }
> >
> > -static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
> > +static QIOChannelSocket *nbd_establish_connection(BlockDriverState *bs,
> > + SocketAddress *saddr,
> > Error **errp)
> > {
> > + BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
> > QIOChannelSocket *sioc;
> > Error *local_err = NULL;
> >
> > sioc = qio_channel_socket_new();
> > qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
> > + qio_channel_set_yank(QIO_CHANNEL(sioc), s->yank);
> >
> > qio_channel_socket_connect_sync(sioc, saddr, &local_err);
> > if (local_err) {
> > @@ -1438,7 +1455,7 @@ static int nbd_client_connect(BlockDriverState *bs, Error **errp)
> > * establish TCP connection, return error if it fails
> > * TODO: Configurable retry-until-timeout behaviour.
> > */
> > - QIOChannelSocket *sioc = nbd_establish_connection(s->saddr, errp);
> > + QIOChannelSocket *sioc = nbd_establish_connection(bs, s->saddr, errp);
> >
> > if (!sioc) {
> > return -ECONNREFUSED;
> > @@ -1829,6 +1846,12 @@ static QemuOptsList nbd_runtime_opts = {
> > "future requests before a successful reconnect will "
> > "immediately fail. Default 0",
> > },
> > + {
> > + .name = "yank",
> > + .type = QEMU_OPT_BOOL,
> > + .help = "Forcibly close the connection and don't attempt to "
> > + "reconnect when the 'yank' qmp command is executed.",
> > + },
> > { /* end of list */ }
> > },
> > };
> > @@ -1888,6 +1911,8 @@ static int nbd_process_options(BlockDriverState *bs, QDict *options,
> >
> > s->reconnect_delay = qemu_opt_get_number(opts, "reconnect-delay", 0);
> >
> > + s->yank = qemu_opt_get_bool(opts, "yank", false);
> > +
> > ret = 0;
> >
> > error:
> > @@ -1921,6 +1946,10 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
> > /* successfully connected */
> > s->state = NBD_CLIENT_CONNECTED;
> >
> > + if (s->yank) {
> > + yank_register_function(nbd_yank, bs);
> > + }
> > +
> > s->connection_co = qemu_coroutine_create(nbd_connection_entry, s);
> > bdrv_inc_in_flight(bs);
> > aio_co_schedule(bdrv_get_aio_context(bs), s->connection_co);
> > @@ -1972,6 +2001,11 @@ static void nbd_close(BlockDriverState *bs)
> > BDRVNBDState *s = bs->opaque;
> >
> > nbd_client_close(bs);
> > +
> > + if (s->yank) {
> > + yank_unregister_function(nbd_yank, bs);
> > + }
> > +
> > nbd_clear_bdrvstate(s);
> > }
> >
> > diff --git a/qapi/block-core.json b/qapi/block-core.json
> > index 943df1926a..1c1578160e 100644
> > --- a/qapi/block-core.json
> > +++ b/qapi/block-core.json
> > @@ -3862,6 +3862,8 @@
> > # reconnect. After that time, any delayed requests and all
> > # future requests before a successful reconnect will
> > # immediately fail. Default 0 (Since 4.2)
> > +# @yank: Forcibly close the connection and don't attempt to reconnect when
> > +# the 'yank' qmp command is executed. (Since: 5.1)
> > #
> > # Since: 2.9
> > ##
> > @@ -3870,7 +3872,8 @@
> > '*export': 'str',
> > '*tls-creds': 'str',
> > '*x-dirty-bitmap': 'str',
> > - '*reconnect-delay': 'uint32' } }
> > + '*reconnect-delay': 'uint32',
> > + 'yank': 'bool' } }
> >
> > ##
> > # @BlockdevOptionsRaw:
> > --
> > 2.20.1
> >
>
>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-05-11 17:09 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 11:14 [PATCH 0/5] Introduce 'yank' oob qmp command to recover from hanging qemu Lukas Straub
2020-05-11 11:14 ` [PATCH 1/5] Introduce yank feature Lukas Straub
2020-05-11 11:14 ` [PATCH 2/5] io/channel.c,io/channel-socket.c: Add " Lukas Straub
2020-05-11 11:51 ` Daniel P. Berrangé
2020-05-11 20:00 ` Lukas Straub
2020-05-12 8:52 ` Daniel P. Berrangé
2020-05-11 11:14 ` [PATCH 3/5] block/nbd.c: " Lukas Straub
2020-05-11 16:19 ` Dr. David Alan Gilbert
2020-05-11 17:05 ` Lukas Straub [this message]
2020-05-11 17:24 ` Dr. David Alan Gilbert
2020-05-12 8:54 ` Daniel P. Berrangé
2020-05-15 9:48 ` Lukas Straub
2020-05-15 10:04 ` Daniel P. Berrangé
2020-05-15 10:14 ` Lukas Straub
2020-05-15 10:26 ` Daniel P. Berrangé
2020-05-15 13:03 ` Lukas Straub
2020-05-15 13:45 ` Daniel P. Berrangé
2020-05-11 11:14 ` [PATCH 4/5] chardev/char-socket.c: " Lukas Straub
2020-05-12 8:56 ` Daniel P. Berrangé
2020-05-11 11:14 ` [PATCH 5/5] migration: " Lukas Straub
2020-05-11 11:49 ` [PATCH 0/5] Introduce 'yank' oob qmp command to recover from hanging qemu Daniel P. Berrangé
2020-05-11 12:07 ` Dr. David Alan Gilbert
2020-05-11 12:17 ` Daniel P. Berrangé
2020-05-11 15:46 ` Dr. David Alan Gilbert
2020-05-12 9:32 ` Lukas Straub
2020-05-12 9:43 ` Daniel P. Berrangé
2020-05-12 18:58 ` Dr. David Alan Gilbert
2020-05-13 8:41 ` Daniel P. Berrangé
2020-05-12 19:42 ` Lukas Straub
2020-05-13 10:32 ` Kevin Wolf
2020-05-13 10:53 ` Dr. David Alan Gilbert
2020-05-13 11:13 ` Kevin Wolf
2020-05-13 11:26 ` Daniel P. Berrangé
2020-05-13 11:58 ` Paolo Bonzini
2020-05-13 12:25 ` Dr. David Alan Gilbert
2020-05-13 12:32 ` Kevin Wolf
2020-05-13 12:18 ` Kevin Wolf
2020-05-13 12:56 ` Dr. David Alan Gilbert
2020-05-13 13:08 ` Daniel P. Berrangé
2020-05-13 13:48 ` Dr. David Alan Gilbert
2020-05-13 13:57 ` Eric Blake
2020-05-13 14:06 ` Kevin Wolf
2020-05-13 14:18 ` Eric Blake
2020-09-01 10:35 ` Markus Armbruster
2020-05-11 19:41 ` Lukas Straub
2020-05-11 18:12 ` Lukas Straub
2020-05-12 9:03 ` Daniel P. Berrangé
2020-05-12 9:06 ` Dr. David Alan Gilbert
2020-05-12 9:09 ` Dr. David Alan Gilbert
2020-05-13 19:12 ` Lukas Straub
2020-05-14 10:41 ` Kevin Wolf
2020-05-14 11:01 ` Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200511190524.3681e58c@luklap \
--to=lukasstraub2@web.de \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.