* [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation
@ 2011-03-22 13:15 Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-22 13:15 UTC (permalink / raw)
To: qemu-devel
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.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close
2011-03-22 13:15 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Hans de Goede
@ 2011-03-22 13:15 ` Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 2/3] virtio-console: notify backend " Hans de Goede
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-22 13:15 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-22 13:15 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
@ 2011-03-22 13:15 ` Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend " Hans de Goede
2011-03-22 14:05 ` [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Amit Shah
3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-22 13:15 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..a23ef5a 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);
+
+ return 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);
+
+ return 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-22 13:15 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 2/3] virtio-console: notify backend " Hans de Goede
@ 2011-03-22 13:15 ` Hans de Goede
2011-03-22 14:05 ` [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Amit Shah
3 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2011-03-22 13:15 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 517f337..fa15a71 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -131,6 +131,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;
@@ -183,6 +195,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 notifcation
2011-03-22 13:15 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Hans de Goede
` (2 preceding siblings ...)
2011-03-22 13:15 ` [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend " Hans de Goede
@ 2011-03-22 14:05 ` Amit Shah
3 siblings, 0 replies; 6+ messages in thread
From: Amit Shah @ 2011-03-22 14:05 UTC (permalink / raw)
To: Hans de Goede; +Cc: qemu-devel
On (Tue) 22 Mar 2011 [14:15:20], 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.
ACK series
Amit
^ permalink raw reply [flat|nested] 6+ messages in thread
* [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
0 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
end of thread, other threads:[~2011-03-24 10:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-22 13:15 [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 1/3] chardev: Allow frontends to notify backends of guest open / close Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 2/3] virtio-console: notify backend " Hans de Goede
2011-03-22 13:15 ` [Qemu-devel] [PATCH 3/3] spice-chardev: listen to frontend " Hans de Goede
2011-03-22 14:05 ` [Qemu-devel] [PATCH 0/3] spicevmc -> chardev: restore guest open / close notifcation Amit Shah
-- strict thread matches above, loose matches on Subject: below --
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
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).