* [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close
2011-03-24 10:12 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Hans de Goede
@ 2011-03-24 10:12 ` Hans de Goede
2011-03-24 10:12 ` [Qemu-devel] [PATCH 2/3] virtio-console: notify backend " Hans de Goede
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-24 10:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Hans de Goede
Some frontends know when the guest has opened the "channel" and is actively
listening to it, for example virtio-serial. This patch adds 2 new qemu-chardev
functions which can be used by frontends to signal guest open / close, and
allows interested backends to listen to this.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
qemu-char.c | 17 +++++++++++++++++
qemu-char.h | 4 ++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 31c9e79..7ec7196 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -476,6 +476,9 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
chr->chr_write = mux_chr_write;
chr->chr_update_read_handler = mux_chr_update_read_handler;
chr->chr_accept_input = mux_chr_accept_input;
+ /* Frontend guest-open / -close notification is not support with muxes */
+ chr->chr_guest_open = NULL;
+ chr->chr_guest_close = NULL;
/* Muxes are always open on creation */
qemu_chr_generic_open(chr);
@@ -2575,6 +2578,20 @@ void qemu_chr_set_echo(struct CharDriverState *chr, bool echo)
}
}
+void qemu_chr_guest_open(struct CharDriverState *chr)
+{
+ if (chr->chr_guest_open) {
+ chr->chr_guest_open(chr);
+ }
+}
+
+void qemu_chr_guest_close(struct CharDriverState *chr)
+{
+ if (chr->chr_guest_close) {
+ chr->chr_guest_close(chr);
+ }
+}
+
void qemu_chr_close(CharDriverState *chr)
{
QTAILQ_REMOVE(&chardevs, chr, next);
diff --git a/qemu-char.h b/qemu-char.h
index 56d9954..d2f5e5f 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -65,6 +65,8 @@ struct CharDriverState {
void (*chr_close)(struct CharDriverState *chr);
void (*chr_accept_input)(struct CharDriverState *chr);
void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
+ void (*chr_guest_open)(struct CharDriverState *chr);
+ void (*chr_guest_close)(struct CharDriverState *chr);
void *opaque;
QEMUBH *bh;
char *label;
@@ -78,6 +80,8 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
void (*init)(struct CharDriverState *s));
CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
void qemu_chr_set_echo(struct CharDriverState *chr, bool echo);
+void qemu_chr_guest_open(struct CharDriverState *chr);
+void qemu_chr_guest_close(struct CharDriverState *chr);
void qemu_chr_close(CharDriverState *chr);
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/3] virtio-console: notify backend of guest open / close
2011-03-24 10:12 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Hans de Goede
2011-03-24 10:12 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
@ 2011-03-24 10:12 ` Hans de Goede
2011-03-24 10:12 ` [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend " Hans de Goede
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-24 10:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Hans de Goede
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
hw/virtio-console.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index c235b27..e635771 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -27,6 +27,22 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
return qemu_chr_write(vcon->chr, buf, len);
}
+/* Callback function that's called when the guest opens the port */
+static void guest_open(VirtIOSerialPort *port)
+{
+ VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+ qemu_chr_guest_open(vcon->chr);
+}
+
+/* Callback function that's called when the guest closes the port */
+static void guest_close(VirtIOSerialPort *port)
+{
+ VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+ qemu_chr_guest_close(vcon->chr);
+}
+
/* Readiness of the guest to accept data on a port */
static int chr_can_read(void *opaque)
{
@@ -63,6 +79,8 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)
qemu_chr_add_handlers(vcon->chr, chr_can_read, chr_read, chr_event,
vcon);
vcon->port.info->have_data = flush_buf;
+ vcon->port.info->guest_open = guest_open;
+ vcon->port.info->guest_close = guest_close;
}
return 0;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend guest open / close
2011-03-24 10:12 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Hans de Goede
2011-03-24 10:12 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
2011-03-24 10:12 ` [Qemu-devel] [PATCH 2/3] virtio-console: notify backend " Hans de Goede
@ 2011-03-24 10:12 ` Hans de Goede
2011-03-24 10:44 ` [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Alon Levy
2011-04-25 10:25 ` Amit Shah
4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-24 10:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Hans de Goede
Note the vmc_register_interface() in spice_chr_write is left in place
in case someone uses spice-chardev with a frontend which does not have
guest open / close notification.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
spice-qemu-char.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 6134fe9..605c241 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -130,6 +130,18 @@ static void spice_chr_close(struct CharDriverState *chr)
qemu_free(s);
}
+static void spice_chr_guest_open(struct CharDriverState *chr)
+{
+ SpiceCharDriver *s = chr->opaque;
+ vmc_register_interface(s);
+}
+
+static void spice_chr_guest_close(struct CharDriverState *chr)
+{
+ SpiceCharDriver *s = chr->opaque;
+ vmc_unregister_interface(s);
+}
+
static void print_allowed_subtypes(void)
{
const char** psubtype;
@@ -182,6 +194,8 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
chr->opaque = s;
chr->chr_write = spice_chr_write;
chr->chr_close = spice_chr_close;
+ chr->chr_guest_open = spice_chr_guest_open;
+ chr->chr_guest_close = spice_chr_guest_close;
qemu_chr_generic_open(chr);
--
1.7.3.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2)
2011-03-24 10:12 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Hans de Goede
` (2 preceding siblings ...)
2011-03-24 10:12 ` [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend " Hans de Goede
@ 2011-03-24 10:44 ` Alon Levy
2011-04-25 10:25 ` Amit Shah
4 siblings, 0 replies; 6+ messages in thread
From: Alon Levy @ 2011-03-24 10:44 UTC (permalink / raw)
To: Hans de Goede; +Cc: qemu-devel
On Thu, Mar 24, 2011 at 11:12:01AM +0100, Hans de Goede wrote:
> Hi All,
>
> When we moved from the spicevmc device (which directly implemented a virtio
> serial port) to doing spicevmc as a chardev backend we lost the notification
> of the guest opening / closing the port to spice server. This causes the
> server to not fall back to server mouse mode when the agent inside the
> guest stops / dies (for what ever reason). Which causes the mouse to
> stop working in this scenario. This patch set fixes this regression.
Reviewed-by: Alon Levy <alevy@redhat.com>
>
> Changes since v1:
> -Replace "return qemu_chr_guest_open(vcon->chr);" with just
> "qemu_chr_guest_open(vcon->chr);", since this is a void func. idem for close.
>
> Regards,
>
> Hans
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2)
2011-03-24 10:12 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Hans de Goede
` (3 preceding siblings ...)
2011-03-24 10:44 ` [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close (v2) Alon Levy
@ 2011-04-25 10:25 ` Amit Shah
4 siblings, 0 replies; 6+ messages in thread
From: Amit Shah @ 2011-04-25 10:25 UTC (permalink / raw)
To: Hans de Goede; +Cc: qemu-devel
On (Thu) 24 Mar 2011 [11:12:01], Hans de Goede wrote:
> Hi All,
>
> When we moved from the spicevmc device (which directly implemented a virtio
> serial port) to doing spicevmc as a chardev backend we lost the notification
> of the guest opening / closing the port to spice server. This causes the
> server to not fall back to server mouse mode when the agent inside the
> guest stops / dies (for what ever reason). Which causes the mouse to
> stop working in this scenario. This patch set fixes this regression.
>
> Changes since v1:
> -Replace "return qemu_chr_guest_open(vcon->chr);" with just
> "qemu_chr_guest_open(vcon->chr);", since this is a void func. idem for close.
I've picked this up in the virtio-serial branch; will do a pull
request shortly.
Amit
^ permalink raw reply [flat|nested] 6+ messages in thread