From patchwork Tue Oct 18 09:54:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 9381789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C1FEA60487 for ; Tue, 18 Oct 2016 09:54:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B298029561 for ; Tue, 18 Oct 2016 09:54:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6FF529563; Tue, 18 Oct 2016 09:54:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_HK_NAME_DR autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E5F3729561 for ; Tue, 18 Oct 2016 09:54:27 +0000 (UTC) Received: from localhost ([::1]:39963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwR6I-0007Ju-Iq for patchwork-qemu-devel@patchwork.kernel.org; Tue, 18 Oct 2016 05:54:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwR62-0007Jc-7t for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:54:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwR5y-0006o6-6g for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:54:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51128) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bwR5x-0006nz-Vi for qemu-devel@nongnu.org; Tue, 18 Oct 2016 05:54:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 169BD61E7C; Tue, 18 Oct 2016 09:54:05 +0000 (UTC) Received: from work-vm ([10.33.36.2]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9I9s1xh003028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Oct 2016 05:54:03 -0400 Date: Tue, 18 Oct 2016 10:54:01 +0100 From: "Dr. David Alan Gilbert" To: Markus Armbruster Message-ID: <20161018095400.GD2190@work-vm> References: <20161017185126.GD12934@work-vm> <20161017191550.GG12934@work-vm> <87h98a3wyd.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87h98a3wyd.fsf@dusky.pond.sub.org> User-Agent: Mutt/1.7.1 (2016-10-04) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 18 Oct 2016 09:54:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] qemu master tests/vmstate prints "Failed to load simple/primitive:b_1" etc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , QEMU Developers , Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP * Markus Armbruster (armbru@redhat.com) wrote: > Paolo Bonzini writes: > > > On 17/10/2016 21:15, Dr. David Alan Gilbert wrote: > >> * Peter Maydell (peter.maydell@linaro.org) wrote: > >>> On 17 October 2016 at 19:51, Dr. David Alan Gilbert wrote: > >>>> * Peter Maydell (peter.maydell@linaro.org) wrote: > >>>>> I've just noticed that qemu master running 'make check' prints > >>>>> GTESTER tests/test-vmstate > >>>>> Failed to load simple/primitive:b_1 > >>>>> Failed to load simple/primitive:i64_2 > >>>>> Failed to load simple/primitive:i32_1 > >>>>> Failed to load simple/primitive:i32_1 > >>>>> > >>>>> but the test doesn't fail. > >>>>> > >>>>> Can we either (a) silence this output if it's spurious or (b) have > >>>>> it cause the test to fail if it's real (and fix the cause of the > >>>>> failure ;-)), please? > >>>> > >>>> The test (has always) tried loading truncated versions of the migration > >>>> stream and made sure that it receives an error from vmstate_load_state. > >>>> > >>>> However I just added an error so we can see which field fails to load > >>>> in a migration where we just used to get a 'migration has failed with -22' > >>>> > >>>> Is there a way to silence error_report's that's already in use in tests? > >>> > >>> We have some nasty hacks (like check for 'qtest_enabled()' before > >>> calling error_report()) but we don't have anything in the > >>> tree today that's a more coherent approach to the "test > >>> deliberately provoked this error" problem. > > I guess the "more coherent approach" would be some way to run a piece of > code with error reporting suppressed. > > For unit tests, a need to supress error reporting indicates the code > under test should perhaps error_setg() instead of error_report(). > Unlikely to completely eliminate the need to suppress error reporting, > though. > > >> Errors go to either the current monitor (if it's non-qmp) or > >> stderr; so could we create a dummy monitor to eat the errors > >> and make it current around that part? > > > > I guess you could reimplement the functions of stubs/mon-printf.c and > > stubs/mon-is-qmp.c. > > qemu-error.c does all its output via error_vprintf(): > > void error_vprintf(const char *fmt, va_list ap) > { > if (cur_mon && !monitor_cur_is_qmp()) { > monitor_vprintf(cur_mon, fmt, ap); > } else { > vfprintf(stderr, fmt, ap); > } > } > > Thus, custom monitor_cur_is_qmp() and monitor_vprintf() let you capture > its output. > > Using (or rather abusing) this to suppress error reporting for an entire > program would be easy enough. But I doubt it's a convenient way to > suppress more narrowly. > > I figure a monitor connected to a "null" chardev would work better > there. If we need that anyway, using it for the "entire program" case > as well is probably easiest. I've not quite figured it out but we're linked against the stubs/ monitor code rather than the real monitor code; and the stubs monitor_vprintf discards and the stubs monitor_cur_is_qmp() always returns false, so to silence things we just have to make cur_mon non-NULL. Unfortunately cur_mon is of type Monitor * and Monitor isn't defined publicly, so we can't know it's size. The following evil hack does silence things for anyone desperate, but I do need to find a neater way; perhaps the right thing is just to link against monitor and create a dummy "null" chardev as you say. Dave --- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index d8da26f..c39d3dc 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -27,6 +27,7 @@ #include "qemu-common.h" #include "migration/migration.h" #include "migration/vmstate.h" +#include "monitor/monitor.h" #include "qemu/coroutine.h" #include "io/channel-file.h" @@ -134,6 +135,11 @@ static int load_vmstate(const VMStateDescription *desc, { /* We test with zero size */ obj_copy(obj_clone, obj); + /* NASTY HACK! Silence error_report - relies on the fact we're using the + * stubs code rather than the real monitor. As long as cur_mon is + * non-null error_report won't print. + */ + cur_mon = g_malloc(1); FAILURE(load_vmstate_one(desc, obj, version, wire, 0)); /* Stream ends with QEMU_EOF, so we need at least 3 bytes to be @@ -154,6 +160,9 @@ static int load_vmstate(const VMStateDescription *desc, FAILURE(load_vmstate_one(desc, obj, version, wire + (size/2), size/2)); } + /* Unsilence error-report - we shouldn't get any errors here */ + g_free(cur_mon); + cur_mon = NULL; obj_copy(obj, obj_clone); return load_vmstate_one(desc, obj, version, wire, size); }