From nobody Mon Apr 29 11:20:10 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528143381349177.39899976056654; Mon, 4 Jun 2018 13:16:21 -0700 (PDT) Received: from localhost ([::1]:41783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPvts-0001UP-J0 for importer@patchew.org; Mon, 04 Jun 2018 16:16:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPvsx-0001AD-Lv for qemu-devel@nongnu.org; Mon, 04 Jun 2018 16:15:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPvsu-0002n9-E7 for qemu-devel@nongnu.org; Mon, 04 Jun 2018 16:15:23 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42292 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPvst-0002mn-W5 for qemu-devel@nongnu.org; Mon, 04 Jun 2018 16:15:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4438A4075390; Mon, 4 Jun 2018 20:15:19 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2078111AF04; Mon, 4 Jun 2018 20:15:17 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 4 Jun 2018 22:14:38 +0200 Message-Id: <1528143278-247932-1-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 04 Jun 2018 20:15:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 04 Jun 2018 20:15:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] vl.c: make default main_loop_wait() timeout independed of slirp 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: ldoktor@redhat.com, ehabkost@redhat.com, jan.kiszka@siemens.com, mreitz@redhat.com, mprivozn@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since commit (047f7038f58 cli: add --preconfig option) QEMU is stuck with indefinite timeout in os_host_main_loop_wait() at RUN_STATE_PRECONFIG even if --preconfig option wasn't used when it's started with -nodefaults CLI option like this: ./s390x-softmmu/qemu-system-s390x -nodefaults It's caused by the fact that slirp_pollfds_fill() bails out early and slirp_update_timeout() won't be called to update timeout to a reasonable value (1 sec) so timeout would be left with infinite value (0xFFFFFFFF). Default infinite timeout though doen't make sense and reducing it to 1 second as in slirp_update_timeout() won't affect host. Fix issue by simplifying default timeout to the same 1sec as it is in slirp_update_timeout() and cleanup the later. It makes default timeout the same regardless of slirp_pollfds_fill() exited early or not (i.e. -nodefaults won't have any effect on main_loop_wait() anymore, which would provide more consistent behavior between both variants of startup). Reported-by: Luk=C3=A1=C5=A1 Doktor Signed-off-by: Igor Mammedov --- PS: it doesn't fix issue reported by Max where "echo foo | $QEMU" is also broken due to commit 047f7038f58, but there is antoher fix on the list to fix that (either Michal's or Daniel's). --- slirp/slirp.c | 10 ++-------- util/main-loop.c | 13 ++----------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/slirp/slirp.c b/slirp/slirp.c index 1cb6b07..1112f86 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -358,13 +358,8 @@ void slirp_cleanup(Slirp *slirp) static void slirp_update_timeout(uint32_t *timeout) { Slirp *slirp; - uint32_t t; =20 - if (*timeout <=3D TIMEOUT_FAST) { - return; - } - - t =3D MIN(1000, *timeout); + assert(*timeout > TIMEOUT_FAST); =20 /* If we have tcp timeout with slirp, then we will fill @timeout with * more precise value. @@ -375,10 +370,9 @@ static void slirp_update_timeout(uint32_t *timeout) return; } if (slirp->do_slowtimo) { - t =3D MIN(TIMEOUT_SLOW, t); + *timeout =3D MIN(TIMEOUT_SLOW, *timeout); } } - *timeout =3D t; } =20 void slirp_pollfds_fill(GArray *pollfds, uint32_t *timeout) diff --git a/util/main-loop.c b/util/main-loop.c index 992f9b0..fd23166 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -497,25 +497,16 @@ static int os_host_main_loop_wait(int64_t timeout) void main_loop_wait(int nonblocking) { int ret; - uint32_t timeout =3D UINT32_MAX; int64_t timeout_ns; + uint32_t timeout =3D nonblocking ? 0 : 1000 /* milliseconds */; =20 - if (nonblocking) { - timeout =3D 0; - } =20 /* poll any events */ g_array_set_size(gpollfds, 0); /* reset for new iteration */ /* XXX: separate device handlers from system ones */ slirp_pollfds_fill(gpollfds, &timeout); =20 - if (timeout =3D=3D UINT32_MAX) { - timeout_ns =3D -1; - } else { - timeout_ns =3D (uint64_t)timeout * (int64_t)(SCALE_MS); - } - - timeout_ns =3D qemu_soonest_timeout(timeout_ns, + timeout_ns =3D qemu_soonest_timeout((uint64_t)timeout * (int64_t)(SCAL= E_MS), timerlistgroup_deadline_ns( &main_loop_tlg)); =20 --=20 2.7.4