qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>,
	Anthony Liguori <aliguori@redhat.com>,
	Alon Levy <alevy@redhat.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] RFC adding ioctl's to virtserial/virtconsole
Date: Tue, 03 Aug 2010 08:12:28 -0500	[thread overview]
Message-ID: <4C5815BC.6030600@codemonkey.ws> (raw)
In-Reply-To: <4C57D768.20401@redhat.com>

On 08/03/2010 03:46 AM, Gerd Hoffmann wrote:
>   Hi,
>
>> My main objection to ioctls is that you change states based on event
>> delivery. This results in weird things like what happens when you do a
>> chr_write while not ready or not connected.
>>
>> So what I'd rather see is a move to an API that was connection oriented.
>> For instance, we could treat CharDriverState as an established
>> connection. So something like:
>>
>> typedef struct CharServerState
>> {
>> int backlog; /* max simultaneous connections; -1 for unlimited */
>> void (*connect)(CharServerState *s, CharDriverState *session);
>> void (*disconnect)(CharServerState *s, CharDriverState *session);
>> } CharDriverState;
>
> Oh, that is a similar but unrelated issue.
>
> We have open/close events on the *guest* side (i.e. some process 
> inside the guests opens/closes /dev/vmchannel/org.qemu.foo.42).  This 
> is what Alon wants to propagate from the device backend to the chardev.
>
> We also have open/close (or connect/disconnect) events on the *host* 
> side for the devices (or sockets) the chardevs are bound to.  This is 
> what you are talking about.

No, I'm not.  You have a front-end device that's connected to 
virtio-serial.  You're implementing the backend in spice.   The 
front-end needs to communicate to the backend events like connect, 
ready, disconnect.  I don't see what the difference between connect and 
ready is so I'll ignore it for now.

The proposal is to implement this via events.   My concern is that this 
interface is brittle because it leaves a lot of behavior undefined.  
There are three distinct states in the life cycle, DISCONNECTED, 
CONNECTED_BUT_NOT_READY, and CONNECTED_AND_READY.  The entire 
CharDriverState interface is only useful in the CONNECTED_AND_READY 
state so what's the behavior of every function in any of the other states?

My suggestion is to implement a simple CharServerState driver.  This 
interface is connection oriented.  You can have a dummy CharServerState 
that returns a single CharDriverState on connect() and does nothing on 
disconnect().  That's how you bridge virtio-serial to what we have 
today.  But the idea is that virtio-serial no longer takes a 
CharDriverState but a CharServerState.

Spice would then implement it's own CharServerState and would use it to 
understand what state the session is in.  It's a really simple interface 
yet it makes the code much more robust because it eliminates the entire 
class of errors associated with undefined behavior when state != 
CONNECTED_AND_READY.

The problem we've had with host side state is poorly defined semantics.  
For instance, I still think we generate multiple OPENED events as 
opposed to strictly generating CLOSED, followed by OPENED, followed by 
CLOSED.

> Note that we already have events (CHR_EVENT_OPENED,CLOSED) for the 
> host side.  Adding events for the guest side open/close events makes 
> sense to me (and is certainly better than the ioctl patch).

We have the same problem with host side events today but it's even worse 
because the semantics are very subtle.  Ultimately we need something 
like CharServerState and we could probably even use it but that's a 
larger scope than just this patch.

The reason I think it's worth doing it this way is that I anticipate 
future virtio-serial backends in QEMU.  It's a very simple difference too.

Regards,

Anthony Liguori


>
> cheers,
>   Gerd
>

  reply	other threads:[~2010-08-03 13:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <183307416.602861280770002326.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-08-02 17:28 ` [Qemu-devel] RFC adding ioctl's to virtserial/virtconsole Alon Levy
2010-08-02 17:42   ` Anthony Liguori
2010-08-03  8:46     ` Gerd Hoffmann
2010-08-03 13:12       ` Anthony Liguori [this message]
2010-08-03 15:28         ` Gerd Hoffmann
2010-08-03 15:46           ` Anthony Liguori
2010-08-03 16:42             ` Gerd Hoffmann
2010-08-03 16:45               ` Anthony Liguori
2010-08-03 17:02                 ` Gerd Hoffmann
2010-08-03 17:53                   ` Anthony Liguori
2010-08-03 20:41                     ` Gerd Hoffmann
2010-08-03 20:45                       ` Anthony Liguori
     [not found] <391834624.690531280844685997.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-08-03 14:13 ` Alon Levy
     [not found] <2092558519.524651280737489312.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-08-02  8:33 ` Alon Levy
2010-08-02  9:03   ` Amit Shah
2010-08-02 15:04   ` Anthony Liguori

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=4C5815BC.6030600@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=alevy@redhat.com \
    --cc=aliguori@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).