aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-03-26 11:07:56 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-27 10:26:49 -0500
commit190832289fe670f764fb277e4dcaf00f94ca6553 (patch)
treea8ba5e23991ffb6f2c229f52dd553677e14f1906 /qemu-char.c
parentc0c4bd2cfae0fb83696000f1bfc355f22e2b41cb (diff)
qemu-char: Automatically do fe_open / fe_close on qemu_chr_add_handlers
Most frontends can't really determine if the guest actually has the frontend side open. So lets automatically generate fe_open / fe_close as soon as a frontend becomes ready (as signalled by calling qemu_chr_add_handlers) / becomes non ready (as signalled by setting all handlers to NULL). And allow frontends which can actually determine if the guest is listening to opt-out of this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Message-id: 1364292483-16564-5-git-send-email-hdegoede@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/qemu-char.c b/qemu-char.c
index c9890ad20f..947541a559 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -221,9 +221,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
IOEventHandler *fd_event,
void *opaque)
{
+ int fe_open;
+
if (!opaque && !fd_can_read && !fd_read && !fd_event) {
/* chr driver being released. */
++s->avail_connections;
+ fe_open = 0;
+ } else {
+ fe_open = 1;
}
s->chr_can_read = fd_can_read;
s->chr_read = fd_read;
@@ -232,6 +237,14 @@ void qemu_chr_add_handlers(CharDriverState *s,
if (s->chr_update_read_handler)
s->chr_update_read_handler(s);
+ if (!s->explicit_fe_open) {
+ if (fe_open) {
+ qemu_chr_fe_open(s);
+ } else {
+ qemu_chr_fe_close(s);
+ }
+ }
+
/* We're connecting to an already opened device, so let's make sure we
also get the open event */
if (s->be_open) {