Commit 2970a6c9435a4857ead2120313d1b1ba4be06d5d

Authored by aliguori
1 parent b36d24b6

char: Fix initial reset (Jan Kiszka)

Recent changes to the graphical console initialization broke the initial
CHR_EVENT_RESET distribution. The reset BHs generated on char device
initialization are now already consumed during machine init (ide init
... -> qemu_aio_wait -> qemu_bh_poll). Therefore, this patch moves the
initial qemu_chr_reset calls into a separate funtion which is called
after machine init.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6700 c046a42c-6fe2-441c-8c8c-71466251a162
qemu-char.c
@@ -101,6 +101,10 @@ @@ -101,6 +101,10 @@
101 /***********************************************************/ 101 /***********************************************************/
102 /* character device */ 102 /* character device */
103 103
  104 +static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs =
  105 + TAILQ_HEAD_INITIALIZER(chardevs);
  106 +static int initial_reset_issued;
  107 +
104 static void qemu_chr_event(CharDriverState *s, int event) 108 static void qemu_chr_event(CharDriverState *s, int event)
105 { 109 {
106 if (!s->chr_event) 110 if (!s->chr_event)
@@ -118,12 +122,23 @@ static void qemu_chr_reset_bh(void *opaque) @@ -118,12 +122,23 @@ static void qemu_chr_reset_bh(void *opaque)
118 122
119 void qemu_chr_reset(CharDriverState *s) 123 void qemu_chr_reset(CharDriverState *s)
120 { 124 {
121 - if (s->bh == NULL) { 125 + if (s->bh == NULL && initial_reset_issued) {
122 s->bh = qemu_bh_new(qemu_chr_reset_bh, s); 126 s->bh = qemu_bh_new(qemu_chr_reset_bh, s);
123 qemu_bh_schedule(s->bh); 127 qemu_bh_schedule(s->bh);
124 } 128 }
125 } 129 }
126 130
  131 +void qemu_chr_initial_reset(void)
  132 +{
  133 + CharDriverState *chr;
  134 +
  135 + initial_reset_issued = 1;
  136 +
  137 + TAILQ_FOREACH(chr, &chardevs, next) {
  138 + qemu_chr_reset(chr);
  139 + }
  140 +}
  141 +
127 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len) 142 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len)
128 { 143 {
129 return s->chr_write(s, buf, len); 144 return s->chr_write(s, buf, len);
@@ -2076,9 +2091,6 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str, @@ -2076,9 +2091,6 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
2076 return NULL; 2091 return NULL;
2077 } 2092 }
2078 2093
2079 -static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs  
2080 -= TAILQ_HEAD_INITIALIZER(chardevs);  
2081 -  
2082 CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s)) 2094 CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s))
2083 { 2095 {
2084 const char *p; 2096 const char *p;
qemu-char.h
@@ -74,6 +74,7 @@ void qemu_chr_add_handlers(CharDriverState *s, @@ -74,6 +74,7 @@ void qemu_chr_add_handlers(CharDriverState *s,
74 void *opaque); 74 void *opaque);
75 int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); 75 int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
76 void qemu_chr_reset(CharDriverState *s); 76 void qemu_chr_reset(CharDriverState *s);
  77 +void qemu_chr_initial_reset(void);
77 int qemu_chr_can_read(CharDriverState *s); 78 int qemu_chr_can_read(CharDriverState *s);
78 void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len); 79 void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
79 void qemu_chr_accept_input(CharDriverState *s); 80 void qemu_chr_accept_input(CharDriverState *s);
@@ -5693,6 +5693,7 @@ int main(int argc, char **argv, char **envp) @@ -5693,6 +5693,7 @@ int main(int argc, char **argv, char **envp)
5693 } 5693 }
5694 5694
5695 text_consoles_set_display(display_state); 5695 text_consoles_set_display(display_state);
  5696 + qemu_chr_initial_reset();
5696 5697
5697 if (monitor_device && monitor_hd) 5698 if (monitor_device && monitor_hd)
5698 monitor_init(monitor_hd, !nographic); 5699 monitor_init(monitor_hd, !nographic);