From nobody Sat May 4 20:35:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498586244599430.6208572096923; Tue, 27 Jun 2017 10:57:24 -0700 (PDT) Received: from localhost ([::1]:57564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPujr-0002xj-5r for importer@patchew.org; Tue, 27 Jun 2017 13:57:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPuMC-0000Vc-1f for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:32:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPuMB-0002SD-Aa for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:32:56 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dPuMB-0002R8-3m for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:32:55 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dPuM6-0000Ns-SU; Tue, 27 Jun 2017 18:32:50 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 27 Jun 2017 18:32:48 +0100 Message-Id: <1498584769-12439-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498584769-12439-1-git-send-email-peter.maydell@linaro.org> References: <1498584769-12439-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH v3 1/2] tests/test-char.c: Don't use main_loop_wait()'s return value 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In QEMU's main_loop() we used to check whether we should do a nonblocking call to main_loop(); this was deleted in commit e330c118f2a5, because now that vCPUs always drop the I/O thread lock it is an unnecessary optimization. The loop in test-char.c copied the old QEMU main_loop() code, but here the nonblocking check has never been necessary because this standalone test case doesn't hold the I/O lock anyway. Remove it, so we can drop the main_loop_wait() return value. Signed-off-by: Peter Maydell Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/test-char.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/test-char.c b/tests/test-char.c index 9e361c8..94ef708 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -20,13 +20,9 @@ typedef struct FeHandler { =20 static void main_loop(void) { - bool nonblocking; - int last_io =3D 0; - quit =3D false; do { - nonblocking =3D last_io > 0; - last_io =3D main_loop_wait(nonblocking); + main_loop_wait(false); } while (!quit); } =20 --=20 2.7.4 From nobody Sat May 4 20:35:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498585624629573.143447920751; Tue, 27 Jun 2017 10:47:04 -0700 (PDT) Received: from localhost ([::1]:57447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPuZq-0004EY-6I for importer@patchew.org; Tue, 27 Jun 2017 13:47:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPuMO-0000eM-0L for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPuMI-0002XS-C2 for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:33:08 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dPuMI-0002VF-4k for qemu-devel@nongnu.org; Tue, 27 Jun 2017 13:33:02 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dPuM7-0000O3-Ce; Tue, 27 Jun 2017 18:32:51 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 27 Jun 2017 18:32:49 +0100 Message-Id: <1498584769-12439-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498584769-12439-1-git-send-email-peter.maydell@linaro.org> References: <1498584769-12439-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH v3 2/2] main_loop: Make main_loop_wait() return void 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 , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 The last users of main_loop_wait() that cared about the return value have now been changed to no longer use it. Drop the now-useless return value and make the function return void. We avoid the awkwardness of ifdeffery to handle the 'ret' variable in main_loop_wait() only being wanted if CONFIG_SLIRP by simply dropping all the ifdefs. There are stub implementations of slirp_pollfds_poll() and slirp_pollfds_fill() already in stubs/slirp.c which do nothing, as required. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- This will coincidentally satisfy Coverity, which currently complains in CID 1372464 that we call main_loop_wait() in vl.c and ignore the return value which may be reporting a poll() syscall failure. Essentially we don't expect poll() to fail, except perhaps with a transient EINTR -- if it ever did we'd spin retrying endlessly I think. --- include/qemu/main-loop.h | 2 +- util/main-loop.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index d7e24af..6b4b60b 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -79,7 +79,7 @@ int qemu_init_main_loop(Error **errp); * * @nonblocking: Whether the caller should block until an event occurs. */ -int main_loop_wait(int nonblocking); +void main_loop_wait(int nonblocking); =20 /** * qemu_get_aio_context: Return the main loop's AioContext diff --git a/util/main-loop.c b/util/main-loop.c index 19cad6b..2f48f41 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -487,7 +487,7 @@ static int os_host_main_loop_wait(int64_t timeout) } #endif =20 -int main_loop_wait(int nonblocking) +void main_loop_wait(int nonblocking) { int ret; uint32_t timeout =3D UINT32_MAX; @@ -500,9 +500,7 @@ int main_loop_wait(int nonblocking) /* poll any events */ g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ -#ifdef CONFIG_SLIRP slirp_pollfds_fill(gpollfds, &timeout); -#endif =20 if (timeout =3D=3D UINT32_MAX) { timeout_ns =3D -1; @@ -515,16 +513,12 @@ int main_loop_wait(int nonblocking) &main_loop_tlg)); =20 ret =3D os_host_main_loop_wait(timeout_ns); -#ifdef CONFIG_SLIRP slirp_pollfds_poll(gpollfds, (ret < 0)); -#endif =20 /* CPU thread can infinitely wait for event after missing the warp */ qemu_start_warp_timer(); qemu_clock_run_all_timers(); - - return ret; } =20 /* Functions to operate on the main QEMU AioContext. */ --=20 2.7.4