Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-reques…
Browse files Browse the repository at this point in the history
…t' into staging

Pull request

v2:
 * Dropped Fam's git-publish series because there is still ongoing discussion

# gpg: Signature made Thu 15 Feb 2018 09:42:03 GMT
# gpg:                using RSA key 9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha/tags/block-pull-request:
  misc: fix spelling
  ratelimit: don't align wait time with slices
  vl: pause vcpus before stopping iothreads

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Feb 15, 2018
2 parents 8c5e7bd + d2f668b commit f003d07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 5 additions & 6 deletions include/qemu/ratelimit.h
Expand Up @@ -36,7 +36,7 @@ typedef struct {
static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
{
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
uint64_t delay_slices;
double delay_slices;

assert(limit->slice_quota && limit->slice_ns);

Expand All @@ -55,12 +55,11 @@ static inline int64_t ratelimit_calculate_delay(RateLimit *limit, uint64_t n)
return 0;
}

/* Quota exceeded. Calculate the next time slice we may start
* sending data again. */
delay_slices = (limit->dispatched + limit->slice_quota - 1) /
limit->slice_quota;
/* Quota exceeded. Wait based on the excess amount and then start a new
* slice. */
delay_slices = (double)limit->dispatched / limit->slice_quota;
limit->slice_end_time = limit->slice_start_time +
delay_slices * limit->slice_ns;
(uint64_t)(delay_slices * limit->slice_ns);
return limit->slice_end_time - now;
}

Expand Down
2 changes: 1 addition & 1 deletion util/qemu-coroutine-lock.c
Expand Up @@ -89,7 +89,7 @@ void qemu_co_queue_run_restart(Coroutine *co)
* invalid memory. Therefore, use a temporary queue and do not touch
* the "co" coroutine as soon as you enter another one.
*
* In its turn resumed "co" can pupulate "co_queue_wakeup" queue with
* In its turn resumed "co" can populate "co_queue_wakeup" queue with
* new coroutines to be woken up. The caller, who has resumed "co",
* will be responsible for traversing the same queue, which may cause
* a different wakeup order but not any missing wakeups.
Expand Down
10 changes: 9 additions & 1 deletion vl.c
Expand Up @@ -4767,10 +4767,18 @@ int main(int argc, char **argv, char **envp)

main_loop();
replay_disable_events();
iothread_stop_all();

/* The ordering of the following is delicate. Stop vcpus to prevent new
* I/O requests being queued by the guest. Then stop IOThreads (this
* includes a drain operation and completes all request processing). At
* this point emulated devices are still associated with their IOThreads
* (if any) but no longer have any work to do. Only then can we close
* block devices safely because we know there is no more I/O coming.
*/
pause_all_vcpus();
iothread_stop_all();
bdrv_close_all();

res_free();

/* vhost-user must be cleaned up before chardevs. */
Expand Down

0 comments on commit f003d07

Please sign in to comment.