Commit f7ad538e authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Merge remote-tracking branch 'stefanha/block' into staging



# By Alex Bligh (32) and others
# Via Stefan Hajnoczi
* stefanha/block: (42 commits)
  win32-aio: drop win32_aio_flush_cb()
  aio-win32: replace incorrect AioHandler->opaque usage with ->e
  aio / timers: remove dummy_io_handler_flush from tests/test-aio.c
  aio / timers: Remove legacy interface
  aio / timers: Switch entire codebase to the new timer API
  aio / timers: Add scripts/switch-timer-api
  aio / timers: Add test harness for AioContext timers
  aio / timers: convert block_job_sleep_ns and co_sleep_ns to new API
  aio / timers: Convert rtc_clock to be a QEMUClockType
  aio / timers: Remove main_loop_timerlist
  aio / timers: Rearrange timer.h & make legacy functions call non-legacy
  aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms
  aio / timers: Remove legacy qemu_clock_deadline & qemu_timerlist_deadline
  aio / timers: Remove alarm timers
  aio / timers: Add documentation and new format calls
  aio / timers: Use all timerlists in icount warp calculations
  aio / timers: Introduce new API timer_new and friends
  aio / timers: On timer modification, qemu_notify or aio_notify
  aio / timers: Convert mainloop to use timeout
  aio / timers: Convert aio_poll to use AioContext timers' deadline
  ...

Message-id: 1377202298-22896-1-git-send-email-stefanha@redhat.com
Signed-off-by: default avatarAnthony Liguori <anthony@codemonkey.ws>
parents e3f024ae b10577df
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@ static bool aio_dispatch(AioContext *ctx)
            g_free(tmp);
        }
    }

    /* Run our timers */
    progress |= timerlistgroup_run_timers(&ctx->tlg);

    return progress;
}

@@ -219,9 +223,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
    }

    /* wait until next event */
    ret = g_poll((GPollFD *)ctx->pollfds->data,
    ret = qemu_poll_ns((GPollFD *)ctx->pollfds->data,
                         ctx->pollfds->len,
                 blocking ? -1 : 0);
                         blocking ? timerlistgroup_deadline_ns(&ctx->tlg) : 0);

    /* if we have any readable fds, dispatch event */
    if (ret > 0) {
@@ -232,10 +236,12 @@ bool aio_poll(AioContext *ctx, bool blocking)
                node->pfd.revents = pfd->revents;
            }
        }
    }

    /* Run dispatch even if there were no readable fds to run timers */
    if (aio_dispatch(ctx)) {
        progress = true;
    }
    }

    return progress;
}
+20 −4
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
    HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
    bool progress;
    int count;
    int timeout;

    progress = false;

@@ -108,6 +109,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
        progress = true;
    }

    /* Run timers */
    progress |= timerlistgroup_run_timers(&ctx->tlg);

    /*
     * Then dispatch any pending callbacks from the GSource.
     *
@@ -125,7 +129,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
            node->io_notify(node->e);

            /* aio_notify() does not count as progress */
            if (node->opaque != &ctx->notifier) {
            if (node->e != &ctx->notifier) {
                progress = true;
            }
        }
@@ -164,8 +168,11 @@ bool aio_poll(AioContext *ctx, bool blocking)

    /* wait until next event */
    while (count > 0) {
        int timeout = blocking ? INFINITE : 0;
        int ret = WaitForMultipleObjects(count, events, FALSE, timeout);
        int ret;

        timeout = blocking ?
            qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(&ctx->tlg)) : 0;
        ret = WaitForMultipleObjects(count, events, FALSE, timeout);

        /* if we have any signaled events, dispatch event */
        if ((DWORD) (ret - WAIT_OBJECT_0) >= count) {
@@ -188,7 +195,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
                node->io_notify(node->e);

                /* aio_notify() does not count as progress */
                if (node->opaque != &ctx->notifier) {
                if (node->e != &ctx->notifier) {
                    progress = true;
                }
            }
@@ -208,5 +215,14 @@ bool aio_poll(AioContext *ctx, bool blocking)
        events[ret - WAIT_OBJECT_0] = events[--count];
    }

    if (blocking) {
        /* Run the timers a second time. We do this because otherwise aio_wait
         * will not note progress - and will stop a drain early - if we have
         * a timer that was not ready to run entering g_poll but is ready
         * after g_poll. This will only do anything if a timer has expired.
         */
        progress |= timerlistgroup_run_timers(&ctx->tlg);
    }

    return progress;
}
+6 −6
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ static void migration_bitmap_sync(void)
    }

    if (!start_time) {
        start_time = qemu_get_clock_ms(rt_clock);
        start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
    }

    trace_migration_bitmap_sync_start();
@@ -410,7 +410,7 @@ static void migration_bitmap_sync(void)
    trace_migration_bitmap_sync_end(migration_dirty_pages
                                    - num_dirty_pages_init);
    num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init;
    end_time = qemu_get_clock_ms(rt_clock);
    end_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);

    /* more than 1 second = 1000 millisecons */
    if (end_time > start_time + 1000) {
@@ -672,7 +672,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)

    ram_control_before_iterate(f, RAM_CONTROL_ROUND);

    t0 = qemu_get_clock_ns(rt_clock);
    t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
    i = 0;
    while ((ret = qemu_file_rate_limit(f)) == 0) {
        int bytes_sent;
@@ -691,7 +691,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
           iterations
        */
        if ((i & 63) == 0) {
            uint64_t t1 = (qemu_get_clock_ns(rt_clock) - t0) / 1000000;
            uint64_t t1 = (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - t0) / 1000000;
            if (t1 > MAX_WAIT) {
                DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n",
                        t1, i);
@@ -1217,11 +1217,11 @@ static void check_guest_throttling(void)
    }

    if (!t0)  {
        t0 = qemu_get_clock_ns(rt_clock);
        t0 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
        return;
    }

    t1 = qemu_get_clock_ns(rt_clock);
    t1 = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);

    /* If it has been more than 40 ms since the last time the guest
     * was throttled then do it again.
+19 −1
Original line number Diff line number Diff line
@@ -150,7 +150,10 @@ aio_ctx_prepare(GSource *source, gint *timeout)
{
    AioContext *ctx = (AioContext *) source;
    QEMUBH *bh;
    int deadline;

    /* We assume there is no timeout already supplied */
    *timeout = -1;
    for (bh = ctx->first_bh; bh; bh = bh->next) {
        if (!bh->deleted && bh->scheduled) {
            if (bh->idle) {
@@ -166,6 +169,14 @@ aio_ctx_prepare(GSource *source, gint *timeout)
        }
    }

    deadline = qemu_timeout_ns_to_ms(timerlistgroup_deadline_ns(&ctx->tlg));
    if (deadline == 0) {
        *timeout = 0;
        return true;
    } else {
        *timeout = qemu_soonest_timeout(*timeout, deadline);
    }

    return false;
}

@@ -180,7 +191,7 @@ aio_ctx_check(GSource *source)
            return true;
	}
    }
    return aio_pending(ctx);
    return aio_pending(ctx) || (timerlistgroup_deadline_ns(&ctx->tlg) == 0);
}

static gboolean
@@ -205,6 +216,7 @@ aio_ctx_finalize(GSource *source)
    event_notifier_cleanup(&ctx->notifier);
    qemu_mutex_destroy(&ctx->bh_lock);
    g_array_free(ctx->pollfds, TRUE);
    timerlistgroup_deinit(&ctx->tlg);
}

static GSourceFuncs aio_source_funcs = {
@@ -233,6 +245,11 @@ void aio_notify(AioContext *ctx)
    event_notifier_set(&ctx->notifier);
}

static void aio_timerlist_notify(void *opaque)
{
    aio_notify(opaque);
}

AioContext *aio_context_new(void)
{
    AioContext *ctx;
@@ -244,6 +261,7 @@ AioContext *aio_context_new(void)
    aio_set_event_notifier(ctx, &ctx->notifier, 
                           (EventNotifierHandler *)
                           event_notifier_test_and_clear);
    timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx);

    return ctx;
}
+3 −3
Original line number Diff line number Diff line
@@ -1124,10 +1124,10 @@ static int audio_is_timer_needed (void)
static void audio_reset_timer (AudioState *s)
{
    if (audio_is_timer_needed ()) {
        qemu_mod_timer (s->ts, qemu_get_clock_ns (vm_clock) + 1);
        timer_mod (s->ts, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1);
    }
    else {
        qemu_del_timer (s->ts);
        timer_del (s->ts);
    }
}

@@ -1834,7 +1834,7 @@ static void audio_init (void)
    QLIST_INIT (&s->cap_head);
    atexit (audio_atexit);

    s->ts = qemu_new_timer_ns (vm_clock, audio_timer, s);
    s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s);
    if (!s->ts) {
        hw_error("Could not create audio timer\n");
    }
Loading