qtest: fix qtest log fd should be initialized before qtest chardev
PATCH 1/1 qtest: fix qtest log fd should be initialized before qtest chardev
From: Li Liu <[email protected]>
qtest_log_fp should be inited before qemu_chr_add_handlers. If not the log dumped from callback functions may be lost.
easy to reproduce it by command:
"QTEST_LOG=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 gtester -k --verbose -m=quick tests/qdev-monitor-test"
The log "[I xxxxxx] OPENED" should be printed out by qtest_event, but does not.
--- qtest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
qtest.c +4 -5
@@ -537,11 +537,6 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)return ; } -qemu_chr_add_handlers (chr, qtest_can_read, qtest_read, qtest_event, chr); -qemu_chr_fe_set_echo (chr, true); - - inbuf =g_string_new ("" ); -if (qtest_log) {if (strcmp (qtest_log,"none" ) !=0 ) { qtest_log_fp =fopen (qtest_log,"w+" );
@@ -550,6 +545,10 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) qtest_log_fp = stderr; } +qemu_chr_add_handlers (chr, qtest_can_read, qtest_read, qtest_event, chr); +qemu_chr_fe_set_echo (chr, true); + + inbuf =g_string_new ("" ); qtest_chr = chr; }
Signature · 1 line
1.7.9.5
Quoted 36 lines · john.liuli
From: Li Liu <[email protected]>
qtest_log_fpshould be inited beforeqemu_chr_add_handlers. If not the log dumped from callback functions may be lost.easy to reproduce it by command:
"QTEST_LOG=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 gtester -k --verbose -m=quick tests/qdev-monitor-test"The log "[I xxxxxx] OPENED" should be printed out by
qtest_event, but does not.Signed-off-by Li Liu <[email protected]>Reviewed-by Stefan Hajnoczi <[email protected]>--- qtest.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)qtest.c +0
-5@@ -537,11 +537,6 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp)return ; } -qemu_chr_add_handlers (chr, qtest_can_read, qtest_read, qtest_event, chr); -qemu_chr_fe_set_echo (chr, true); - - inbuf =g_string_new ("" ); -if (qtest_log) {if (strcmp (qtest_log,"none" ) !=0 ) { qtest_log_fp =fopen (qtest_log,"w+" );
qtest.c void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) · line 554
Quoted 10 lines
qtest.c +4
-0@@ -550,6 +545,10 @@ void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) qtest_log_fp = stderr; } +qemu_chr_add_handlers (chr, qtest_can_read, qtest_read, qtest_event, chr); +qemu_chr_fe_set_echo (chr, true); + + inbuf =g_string_new ("" ); qtest_chr = chr; }
Thanks, applying.
Paolo