From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgpU0-0006SY-UJ for qemu-devel@nongnu.org; Wed, 22 Oct 2014 02:33:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgpTv-00007M-HX for qemu-devel@nongnu.org; Wed, 22 Oct 2014 02:33:20 -0400 Received: from mail-wg0-x22c.google.com ([2a00:1450:400c:c00::22c]:63141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgpTv-00007F-Ba for qemu-devel@nongnu.org; Wed, 22 Oct 2014 02:33:15 -0400 Received: by mail-wg0-f44.google.com with SMTP id y10so2909784wgg.3 for ; Tue, 21 Oct 2014 23:33:14 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <54474FA7.5020009@redhat.com> Date: Wed, 22 Oct 2014 08:33:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1413944807-12112-1-git-send-email-john.liuli@huawei.com> In-Reply-To: <1413944807-12112-1-git-send-email-john.liuli@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v1 repost] qtest: fix qtest log fd should be initialized before qtest chardev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "john.liuli" , qemu-devel@nongnu.org Cc: stefanha@redhat.com, mst@redhat.com On 10/22/2014 04:26 AM, john.liuli wrote: > From: Li Liu > > 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. > > Signed-off-by: Li Liu > Reviewed-by: Stefan Hajnoczi > --- > qtest.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/qtest.c b/qtest.c > index ef0d991..2a33d98 100644 > --- a/qtest.c > +++ b/qtest.c > @@ -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; > } > > Thanks, applying. Paolo