|
Justin M. Forbes |
252f3a |
>From c8cb28f0791ab38945c7facb5a63e445b4b6f41f Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
252f3a |
From: Hans de Goede <hdegoede@redhat.com>
|
|
Justin M. Forbes |
252f3a |
Date: Fri, 18 Mar 2011 15:23:21 +0100
|
|
Justin M. Forbes |
252f3a |
Subject: [PATCH 15/17] chardev: Allow frontends to notify backends of guest open / close
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Some frontends know when the guest has opened the "channel" and is actively
|
|
Justin M. Forbes |
252f3a |
listening to it, for example virtio-serial. This patch adds 2 new qemu-chardev
|
|
Justin M. Forbes |
252f3a |
functions which can be used by frontends to signal guest open / close, and
|
|
Justin M. Forbes |
252f3a |
allows interested backends to listen to this.
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Justin M. Forbes |
252f3a |
---
|
|
Justin M. Forbes |
252f3a |
qemu-char.c | 17 +++++++++++++++++
|
|
Justin M. Forbes |
252f3a |
qemu-char.h | 4 ++++
|
|
Justin M. Forbes |
252f3a |
2 files changed, 21 insertions(+), 0 deletions(-)
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
diff --git a/qemu-char.c b/qemu-char.c
|
|
Justin M. Forbes |
252f3a |
index 2ef972f..d52eb51 100644
|
|
Justin M. Forbes |
252f3a |
--- a/qemu-char.c
|
|
Justin M. Forbes |
252f3a |
+++ b/qemu-char.c
|
|
Justin M. Forbes |
252f3a |
@@ -507,6 +507,9 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
|
|
Justin M. Forbes |
252f3a |
chr->chr_write = mux_chr_write;
|
|
Justin M. Forbes |
252f3a |
chr->chr_update_read_handler = mux_chr_update_read_handler;
|
|
Justin M. Forbes |
252f3a |
chr->chr_accept_input = mux_chr_accept_input;
|
|
Justin M. Forbes |
252f3a |
+ /* Frontend guest-open / -close notification is not support with muxes */
|
|
Justin M. Forbes |
252f3a |
+ chr->chr_guest_open = NULL;
|
|
Justin M. Forbes |
252f3a |
+ chr->chr_guest_close = NULL;
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
/* Muxes are always open on creation */
|
|
Justin M. Forbes |
252f3a |
qemu_chr_generic_open(chr);
|
|
Justin M. Forbes |
252f3a |
@@ -2712,6 +2715,20 @@ void qemu_chr_set_echo(struct CharDriverState *chr, bool echo)
|
|
Justin M. Forbes |
252f3a |
}
|
|
Justin M. Forbes |
252f3a |
}
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
+void qemu_chr_guest_open(struct CharDriverState *chr)
|
|
Justin M. Forbes |
252f3a |
+{
|
|
Justin M. Forbes |
252f3a |
+ if (chr->chr_guest_open) {
|
|
Justin M. Forbes |
252f3a |
+ chr->chr_guest_open(chr);
|
|
Justin M. Forbes |
252f3a |
+ }
|
|
Justin M. Forbes |
252f3a |
+}
|
|
Justin M. Forbes |
252f3a |
+
|
|
Justin M. Forbes |
252f3a |
+void qemu_chr_guest_close(struct CharDriverState *chr)
|
|
Justin M. Forbes |
252f3a |
+{
|
|
Justin M. Forbes |
252f3a |
+ if (chr->chr_guest_close) {
|
|
Justin M. Forbes |
252f3a |
+ chr->chr_guest_close(chr);
|
|
Justin M. Forbes |
252f3a |
+ }
|
|
Justin M. Forbes |
252f3a |
+}
|
|
Justin M. Forbes |
252f3a |
+
|
|
Justin M. Forbes |
252f3a |
void qemu_chr_close(CharDriverState *chr)
|
|
Justin M. Forbes |
252f3a |
{
|
|
Justin M. Forbes |
252f3a |
QTAILQ_REMOVE(&chardevs, chr, next);
|
|
Justin M. Forbes |
252f3a |
diff --git a/qemu-char.h b/qemu-char.h
|
|
Justin M. Forbes |
252f3a |
index bf06da0..f3b9bf4 100644
|
|
Justin M. Forbes |
252f3a |
--- a/qemu-char.h
|
|
Justin M. Forbes |
252f3a |
+++ b/qemu-char.h
|
|
Justin M. Forbes |
252f3a |
@@ -69,6 +69,8 @@ struct CharDriverState {
|
|
Justin M. Forbes |
252f3a |
void (*chr_close)(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
void (*chr_accept_input)(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
void (*chr_set_echo)(struct CharDriverState *chr, bool echo);
|
|
Justin M. Forbes |
252f3a |
+ void (*chr_guest_open)(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
+ void (*chr_guest_close)(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
void *opaque;
|
|
Justin M. Forbes |
252f3a |
QEMUBH *bh;
|
|
Justin M. Forbes |
252f3a |
char *label;
|
|
Justin M. Forbes |
252f3a |
@@ -91,6 +93,8 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts,
|
|
Justin M. Forbes |
252f3a |
void (*init)(struct CharDriverState *s));
|
|
Justin M. Forbes |
252f3a |
CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
|
|
Justin M. Forbes |
252f3a |
void qemu_chr_set_echo(struct CharDriverState *chr, bool echo);
|
|
Justin M. Forbes |
252f3a |
+void qemu_chr_guest_open(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
+void qemu_chr_guest_close(struct CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
void qemu_chr_close(CharDriverState *chr);
|
|
Justin M. Forbes |
252f3a |
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...)
|
|
Justin M. Forbes |
252f3a |
GCC_FMT_ATTR(2, 3);
|
|
Justin M. Forbes |
252f3a |
--
|
|
Justin M. Forbes |
252f3a |
1.7.3.2
|
|
Justin M. Forbes |
252f3a |
|