diff mbox

[24/38] char: move fe_open in CharBackend

Message ID 20161022100951.19562-1-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Oct. 22, 2016, 10:09 a.m. UTC
The fe_open state belongs to front end.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qemu-char.c           | 7 ++++---
 include/sysemu/char.h | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/qemu-char.c b/qemu-char.c
index e52c3af..81a593b 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -921,6 +921,7 @@  bool qemu_chr_fe_init(CharBackend *b, CharDriverState *s, Error **errp)
         s->be = b;
     }
 
+    b->fe_open = false;
     b->tag = tag;
     b->chr = s;
 
@@ -4221,10 +4222,10 @@  void qemu_chr_fe_set_open(CharBackend *be, int fe_open)
         return;
     }
 
-    if (chr->fe_open == fe_open) {
+    if (be->fe_open == fe_open) {
         return;
     }
-    chr->fe_open = fe_open;
+    be->fe_open = fe_open;
     if (chr->chr_set_fe_open) {
         chr->chr_set_fe_open(chr, fe_open);
     }
@@ -4309,7 +4310,7 @@  ChardevInfoList *qmp_query_chardev(Error **errp)
         info->value = g_malloc0(sizeof(*info->value));
         info->value->label = g_strdup(chr->label);
         info->value->filename = g_strdup(chr->filename);
-        info->value->frontend_open = chr->fe_open;
+        info->value->frontend_open = chr->be && chr->be->fe_open;
 
         info->next = chr_list;
         chr_list = info;
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index ae32e1c..2c3060c 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -81,6 +81,7 @@  typedef struct CharBackend {
     IOReadHandler *chr_read;
     void *opaque;
     int tag;
+    int fe_open;
 } CharBackend;
 
 struct CharDriverState {
@@ -108,7 +109,6 @@  struct CharDriverState {
     char *filename;
     int logfd;
     int be_open;
-    int fe_open;
     int explicit_be_open;
     int avail_connections;
     int is_mux;