All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	berrange@redhat.com
Subject: Re: [Qemu-devel] [PATCH 0/4] Fix socket chardev regression
Date: Mon, 20 Aug 2018 10:45:04 +0800	[thread overview]
Message-ID: <20180820024504.GA7953@xz-mi> (raw)
In-Reply-To: <20180817135224.22971-1-marcandre.lureau@redhat.com>

On Fri, Aug 17, 2018 at 03:52:20PM +0200, Marc-André Lureau wrote:
> Hi,
> 
> In commit 25679e5d58e "chardev: tcp: postpone async connection setup"
> (and its follow up 99f2f54174a59), Peter moved chardev socket
> connection to machine_done event. However, chardev created later will
> no longer attempt to connect, and chardev created in tests do not have
> machine_done event (breaking some of vhost-user-test).
> 
> The goal was to move the "connect" source to the chardev frontend
> context (the monitor thread context in his case). chr->gcontext is set
> with qemu_chr_fe_set_handlers(). But there is no guarantee that the
> function will be called in general,

Could you hint a case where we didn't use qemu_chr_fe_set_handlers()
upon a chardev backend?  I thought it was always used in chardev
frontends, and what the backend could do if without a frontend?

[1]

> so we can't delay connection until
> then: the chardev should still attempt to connect during open(), using
> the main context.
> 
> An alternative would be to specify the iothread during chardev
> creation. Setting up monitor OOB would be quite different too, it
> would take the same iothread as argument.
> 
> 99f2f54174a595e is also a bit problematic, since it will behave
> differently before and after machine_done (the first case gives a
> chance to use a different context reliably, the second looks racy)
> 
> In the end, I am not sure this is all necessary, as chardev callbacks
> are called after qemu_chr_fe_set_handlers(), at which point the
> context of sources are updated. In "char-socket: update all ioc
> handlers when changing context", I moved also the hup handler to the
> updated context. So unless the main thread is already stuck, we can
> setup a different context for the chardev at that time. Or not?

IMHO the two patches that you reverted are special-cases for reasons.

The TLS handshake is carried out with an TLS internal GSource which is
not owned by the chardev code, so the qemu_chr_fe_set_handlers() won't
update that GSource (please refer to qio_channel_tls_handshake_task).

The async connection is carried out in a standalone thread that calls
connect().  IMHO we'd better not update the gcontext bound to the
async task since otherwise there'll be a race (IIRC I proposed
something before using a mutex to update the gcontext, but Dan would
prefer not to, and I followed with the suggestion which makes sense to
me).

Could we just postpone these machine done tasks into
qemu_chr_fe_set_handlers() (or say, chr_update_read_handler() hook,
just like what I mentioned in the other thread)?  Though we'll be sure
qemu_chr_fe_set_handlers() will be called for all chardev backends
hence I asked question [1] above.

Regards,

-- 
Peter Xu

  parent reply	other threads:[~2018-08-20  2:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 13:52 [Qemu-devel] [PATCH 0/4] Fix socket chardev regression Marc-André Lureau
2018-08-17 13:52 ` [Qemu-devel] [PATCH 1/4] Revert "chardev: tcp: postpone TLS work until machine done" Marc-André Lureau
2018-08-17 13:52 ` [Qemu-devel] [PATCH 2/4] Revert "chardev: tcp: postpone async connection setup" Marc-André Lureau
2018-08-17 13:52 ` [Qemu-devel] [PATCH 3/4] char-socket: update all ioc handlers when changing context Marc-André Lureau
2018-08-17 13:52 ` [Qemu-devel] [PATCH 4/4] test-char: add socket reconnect test Marc-André Lureau
2018-08-20  2:45 ` Peter Xu [this message]
2018-08-20 15:37   ` [Qemu-devel] [PATCH 0/4] Fix socket chardev regression Marc-André Lureau
2018-08-21  6:29     ` Peter Xu
2018-08-21 14:04       ` Marc-André Lureau
2018-08-21 14:14         ` Daniel P. Berrangé
2018-08-21 14:16         ` Paolo Bonzini
2018-08-22  3:46           ` Peter Xu
2018-08-22  6:55             ` Peter Xu

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=20180820024504.GA7953@xz-mi \
    --to=peterx@redhat.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.