All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: amit.shah@redhat.com, Alon Levy <alevy@redhat.com>,
	qemu-devel@nongnu.org, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] char: add qemu_chr_be_is_fe_connected
Date: Sun, 24 Mar 2013 13:37:47 +0100	[thread overview]
Message-ID: <514EF39B.1000904@redhat.com> (raw)
In-Reply-To: <87wqsz2wbv.fsf@codemonkey.ws>

Hi,

On 03/22/2013 06:11 PM, Anthony Liguori wrote:
> Hans de Goede <hdegoede@redhat.com> writes:

<snip>

> If the qemu-char.c code did:
>
> int qemu_chr_fe_write(...) {
>      if (!s->fe_open) {
>          qemu_chr_fe_open(s);
>      }
>      ...
> }
>
> That would be one thing.  It's a hack, but a more reasonable hack than
> doing this in the backend like we do today.

Agreed.

> And in fact, herein lies exactly what the problem is.  There is no
> "s->fe_open".  And if such a thing did exist, we would note that this is
> in fact guest state and that it needs to be taken care of during
> migration.

Agreed too, I've prepared a patch set adding fe_open and cleaning up the
whole existing code around the fe_open stuff. I'll send it directly after
this mail.

<snip>

>> We could do the same and have a qemu_fe_generic_open for frontends which
>> does the qemu_chr_fe_open call.
>
> You mean, in qemu_chr_fe_write()?  Yes, I think not doing this bit in
> the backend and making it part of qemu-char would be a significant
> improvement and would also guide in solving this problem correctly.

I believe that qemu_chr_fe_write is too late, this assumes that the
frontend is always the first one to do a write (assuming fe_open aware
backends won't do anything until the fe_open happens). But what if the
protocol going over the chardev expects the backend to do the first
write? Then the backend will just sit there waiting for the fe_open,
and the frontend will just sit there waiting for the first write before
sending this fe_open.

I believe that your previous comments on qemu_chr_add_handlers being
the closest thing to a fe_open for many frontends is correct, esp. since
some frontends and hw/qdev-properties-system.c do a NULL
qemu_chr_add_handlers when a frontend is being unregistered / removed /
closed. Which gives us a central place to detect frontend closes too.

So this is what I've used in my patch-set.

> Also, you can get reset handling for free by unconditionally clearly
> s->fe_open with a reset handler.  That would also simplify the
> virtio-serial code since it would no longer need the reset logic.
>
>>> And for me, the most logical thing is to call qemu_chr_fe_open() in
>>> post_load for the device.
>>
>> With the device I assume you mean the frontend? That is what we originally
>> suggested and submitted a patch for (for virtio-console) but Amit didn't
>> like it.
>
> As Avi would say, this is "derived guest state" and derived guest state
> has to be recomputed in post_load handlers.

Agreed, which brings us back to the original patch posted a long time
ago which Amit did not like:
http://lists.gnu.org/archive/html/qemu-devel/2012-11/msg02721.html

Amit can you take a second look at this? Note that after the cleanup patchset
which I'll send right after this mail, it will look slightly different, something
like:

@@ -653,6 +654,10 @@ static void virtio_serial_post_load_timer_cb(void *opaque)
              send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN,
                                 port->host_connected);
          }
+        vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
+        if (vsc->set_guest_connected) {
+            vsc->set_guest_connected(port, port->guest_connected);
+        }
      }
      g_free(s->post_load.connected);
      s->post_load.connected = NULL;

Which to me looks like a reasonable thing to do on post-load.

Regards,

Hans

  reply	other threads:[~2013-03-24 12:34 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20  9:55 [Qemu-devel] [PATCH v2 0/4] for spice post load char device hook Alon Levy
2013-03-20  9:55 ` [Qemu-devel] [PATCH 1/4] char: add a post_load callback Alon Levy
2013-03-20 13:08   ` Anthony Liguori
2013-03-20 16:59     ` Alon Levy
2013-03-21  6:53       ` Gerd Hoffmann
2013-03-21  8:54         ` Alon Levy
2013-03-20 17:05     ` Alon Levy
2013-03-20 18:59       ` Anthony Liguori
2013-03-21  8:27         ` Hans de Goede
2013-03-21  8:36           ` Hans de Goede
2013-03-21 16:35         ` [Qemu-devel] [PATCH v3 0/2] spice-qemu-char fix agent mouse after migration Alon Levy
2013-03-21 16:35           ` [Qemu-devel] [PATCH 1/2] char: add qemu_chr_be_is_fe_connected Alon Levy
2013-03-21 18:18             ` Anthony Liguori
2013-03-21 18:35               ` Alon Levy
2013-03-21 19:24                 ` Anthony Liguori
2013-03-21 21:55                   ` Alon Levy
2013-03-21 22:05                     ` Alon Levy
2013-03-22  7:56               ` Hans de Goede
2013-03-22 13:50                 ` Anthony Liguori
2013-03-22 15:53                   ` Gerd Hoffmann
2013-03-22 16:50                   ` Hans de Goede
2013-03-22 17:11                     ` Anthony Liguori
2013-03-24 12:37                       ` Hans de Goede [this message]
2013-03-22  8:25               ` Gerd Hoffmann
2013-03-22  8:58                 ` Hans de Goede
2013-03-22 13:33                 ` Anthony Liguori
2013-03-21 16:35           ` [Qemu-devel] [PATCH 2/2] spice-qemu-char: register interface on post load Alon Levy
2013-03-22  8:07             ` Hans de Goede
2013-03-22  8:16               ` Alon Levy
2013-03-22  8:55                 ` Hans de Goede
2013-03-20  9:55 ` [Qemu-devel] [PATCH 2/4] virtio-serial: add a post_load callback implemented by port Alon Levy
2013-03-20  9:55 ` [Qemu-devel] [PATCH 3/4] virtio-console: implement post_load to call to qemu_chr_fe_post_load Alon Levy
2013-03-20  9:55 ` [Qemu-devel] [PATCH 4/4] spice-qemu-char: register interface on post load Alon Levy

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=514EF39B.1000904@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=alevy@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=amit.shah@redhat.com \
    --cc=kraxel@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.