From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: jan.kiszka@siemens.com, pbonzini@redhat.com, ldoktor@redhat.com,
mreitz@redhat.com, mprivozn@redhat.com, berrange@redhat.com,
ehabkost@redhat.com
Subject: [Qemu-devel] [PATCH] vl.c: make default main_loop_wait() timeout independed of slirp
Date: Mon, 4 Jun 2018 22:14:38 +0200 [thread overview]
Message-ID: <1528143278-247932-1-git-send-email-imammedo@redhat.com> (raw)
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áš Doktor <ldoktor@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
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;
- if (*timeout <= TIMEOUT_FAST) {
- return;
- }
-
- t = MIN(1000, *timeout);
+ assert(*timeout > TIMEOUT_FAST);
/* 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 = MIN(TIMEOUT_SLOW, t);
+ *timeout = MIN(TIMEOUT_SLOW, *timeout);
}
}
- *timeout = t;
}
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 = UINT32_MAX;
int64_t timeout_ns;
+ uint32_t timeout = nonblocking ? 0 : 1000 /* milliseconds */;
- if (nonblocking) {
- timeout = 0;
- }
/* 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);
- if (timeout == UINT32_MAX) {
- timeout_ns = -1;
- } else {
- timeout_ns = (uint64_t)timeout * (int64_t)(SCALE_MS);
- }
-
- timeout_ns = qemu_soonest_timeout(timeout_ns,
+ timeout_ns = qemu_soonest_timeout((uint64_t)timeout * (int64_t)(SCALE_MS),
timerlistgroup_deadline_ns(
&main_loop_tlg));
--
2.7.4
next reply other threads:[~2018-06-04 20:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 20:14 Igor Mammedov [this message]
2018-06-05 1:04 ` [Qemu-devel] [PATCH] vl.c: make default main_loop_wait() timeout independed of slirp Eduardo Habkost
2018-06-05 8:27 ` Igor Mammedov
2018-06-05 8:47 ` Daniel P. Berrangé
2018-06-07 12:37 ` Stefan Hajnoczi
2018-06-05 9:02 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528143278-247932-1-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=ldoktor@redhat.com \
--cc=mprivozn@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).