Patchwork [03/11] qemu-char: Add fe_open tracking

login
register
mail settings
Submitter Hans de Goede
Date March 26, 2013, 10:07 a.m.
Message ID <1364292483-16564-4-git-send-email-hdegoede@redhat.com>
Download mbox | patch
Permalink /patch/231145/
State New
Headers show

Comments

Hans de Goede - March 26, 2013, 10:07 a.m.
Add tracking of the fe_open state to struct CharDriverState.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 include/char/char.h | 1 +
 qemu-char.c         | 8 ++++++++
 2 files changed, 9 insertions(+)

Patch

diff --git a/include/char/char.h b/include/char/char.h
index dd8f39a..3174575 100644
--- a/include/char/char.h
+++ b/include/char/char.h
@@ -75,6 +75,7 @@  struct CharDriverState {
     char *label;
     char *filename;
     int be_open;
+    int fe_open;
     int avail_connections;
     QemuOpts *opts;
     QTAILQ_ENTRY(CharDriverState) next;
diff --git a/qemu-char.c b/qemu-char.c
index 55795d7..2f35504 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3385,6 +3385,10 @@  void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo)
 
 void qemu_chr_fe_open(struct CharDriverState *chr)
 {
+    if (chr->fe_open) {
+        return;
+    }
+    chr->fe_open = 1;
     if (chr->chr_guest_open) {
         chr->chr_guest_open(chr);
     }
@@ -3392,6 +3396,10 @@  void qemu_chr_fe_open(struct CharDriverState *chr)
 
 void qemu_chr_fe_close(struct CharDriverState *chr)
 {
+    if (!chr->fe_open) {
+        return;
+    }
+    chr->fe_open = 0;
     if (chr->chr_guest_close) {
         chr->chr_guest_close(chr);
     }