vl.c: make default main_loop_wait() timeout independed of slirp
PATCH 1/1 vl.c: make default main_loop_wait() timeout independed of slirp
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).
---
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(-)
slirp/slirp.c +2 -8
@@ -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)
util/main-loop.c +2 -11
@@ -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));
Signature · 1 line
2.7.4
Quoted 7 lines · Igor Mammedov
Since commit (
047f7038f58cli: add --preconfig option) QEMU is stuck with indefinite timeout inos_host_main_loop_wait()atRUN_STATE_PRECONFIGeven if --preconfig option wasn't used when it's started with -nodefaults CLI option like this:./s390x-softmmu/qemu-system-s390x -nodefaults
Quoted 7 lines
It's caused by the fact that
slirp_pollfds_fill()bails out early andslirp_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.
I don't get this part. Why default infinite timeout doesn't make sense? Why would a 1 second timeout make sense?
Quoted 15 lines
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 ofslirp_pollfds_fill()exited early or not (i.e. -nodefaults won't have any effect onmain_loop_wait()anymore, which would provide more consistent behavior between both variants of startup).Reported-by Lukáš Doktor <[email protected]>Signed-off-by Igor Mammedov <[email protected]>---
PS:
it doesn't fix issue reported by Max where
"echo foo | $QEMU"
is also broken due to commit047f7038f58, but there is antoher fix on the list to fix that (either Michal's or Daniel's).
[...]
Signature · 1 line
Eduardo
Quoted 13 lines · On Mon, 4 Jun 2018 22:04:13 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 12 lines · Igor Mammedov
Since commit (
047f7038f58cli: add --preconfig option) QEMU is stuck with indefinite timeout inos_host_main_loop_wait()atRUN_STATE_PRECONFIGeven 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 andslirp_update_timeout()won't be called to update timeout to a reasonable value (1 sec) so timeout would be left with infinite value (0xFFFFFFFF).
Quoted 5 lines
Quoted 2 lines
Default infinite timeout though doen't make sense and reducing it to 1 second as in
slirp_update_timeout()won't affect host.I don't get this part. Why default infinite timeout doesn't make sense? Why would a 1 second timeout make sense?
I've meant that there is no reason for infinite timeuot, and 1sec is good as any other finite one.
Hence we can unify timeout with/without -nodefaults, by moving 1sec constant from slirp to main_loop_wait() and simplify code a bit.
Quoted 18 lines
Quoted 16 lines
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 ofslirp_pollfds_fill()exited early or not (i.e. -nodefaults won't have any effect onmain_loop_wait()anymore, which would provide more consistent behavior between both variants of startup).Reported-by Lukáš Doktor <[email protected]>Signed-off-by Igor Mammedov <[email protected]>---
PS:
it doesn't fix issue reported by Max where
"echo foo | $QEMU"
is also broken due to commit047f7038f58, but there is antoher fix on the list to fix that (either Michal's or Daniel's).[...]
Quoted 16 lines · Igor Mammedov
Quoted 13 lines · On Mon, 4 Jun 2018 22:04:13 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 12 lines · Igor Mammedov
Since commit (
047f7038f58cli: add --preconfig option) QEMU is stuck with indefinite timeout inos_host_main_loop_wait()atRUN_STATE_PRECONFIGeven 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 andslirp_update_timeout()won't be called to update timeout to a reasonable value (1 sec) so timeout would be left with infinite value (0xFFFFFFFF).
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Default infinite timeout though doen't make sense and reducing it to 1 second as in
slirp_update_timeout()won't affect host.I don't get this part. Why default infinite timeout doesn't make sense? Why would a 1 second timeout make sense?
I've meant that there is no reason for infinite timeuot, and 1sec is good as any other finite one.
I don't really agree - it is better to not wakeup at all if there's no work todo rather than pointlessly wake up once a second, to deal with a hack for the SLIRP feature that's almost never used in most production scenarios..
Quoted 23 lines
Hence we can unify timeout with/without -nodefaults, by moving 1sec constant from slirp to
main_loop_wait()and simplify code a bit.Quoted 18 lines
Quoted 16 lines
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 ofslirp_pollfds_fill()exited early or not (i.e. -nodefaults won't have any effect onmain_loop_wait()anymore, which would provide more consistent behavior between both variants of startup).Reported-by Lukáš Doktor <[email protected]>Signed-off-by Igor Mammedov <[email protected]>---
PS:
it doesn't fix issue reported by Max where
"echo foo | $QEMU"
is also broken due to commit047f7038f58, but there is antoher fix on the list to fix that (either Michal's or Daniel's).[...]
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 22 lines · Daniel P. Berrangé
Quoted 21 lines · Igor Mammedov
Quoted 18 lines · On Mon, 4 Jun 2018 22:04:13 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
Since commit (
047f7038f58cli: add --preconfig option) QEMU is stuck with indefinite timeout inos_host_main_loop_wait()atRUN_STATE_PRECONFIGeven if --preconfig option wasn't used when it's started with -nodefaults CLI option like this:./s390x-softmmu/qemu-system-s390x -nodefaults
Quoted 7 lines
It's caused by the fact that
slirp_pollfds_fill()bails out early andslirp_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.I don't get this part. Why default infinite timeout doesn't make sense? Why would a 1 second timeout make sense?
Quoted 7 lines
Quoted 2 lines
I've meant that there is no reason for infinite timeuot, and 1sec is good as any other finite one.
I don't really agree - it is better to not wakeup at all if there's no work todo rather than pointlessly wake up once a second, to deal with a hack for the SLIRP feature that's almost never used in most production scenarios..
Right, a host with 1000 VMs should experience 1000 wakeups/second for no good reason. QEMU needs to be scalable.
Stefan
Quoted 7 lines · Igor Mammedov
Quoted 2 lines
I don't get this part. Why default infinite timeout doesn't make sense? Why would a 1 second timeout make sense?
I've meant that there is no reason for infinite timeout, and 1sec is good as any other finite one.
Hence we can unify timeout with/without -nodefaults, by moving 1sec constant from slirp tomain_loop_wait()and simplify code a bit.
The event loop is supposed to wake up when there is an event. If there is no event, the timeout should be infinite, otherwise you're just introducing unnecessary BQL contention and/or papering over bugs. So I agree with Eduardo, I'm not sure what you mean when you say that the infinite timeout makes no sense.
In fact, the 1-second limit on the SLIRP timeout was introduced in commit a42e9c4188 ("slirp: set mainloop timeout with more precise value", 2013-09-17) with no justification in the commit message. The desirable fix would be to remove that limit, not to push it up the stack and actrivate it for all executions of QEMU.
Paolo