Skip to content

Commit

Permalink
aio / timers: Switch entire codebase to the new timer API
Browse files Browse the repository at this point in the history
This is an autogenerated patch using scripts/switch-timer-api.

Switch the entire code base to using the new timer API.

Note this patch may introduce some line length issues.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
abligh authored and stefanhaRH committed Aug 22, 2013
1 parent fe10ab5 commit bc72ad6
Show file tree
Hide file tree
Showing 121 changed files with 678 additions and 678 deletions.
12 changes: 6 additions & 6 deletions arch_init.c
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions audio/audio.c
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions audio/noaudio.c
Expand Up @@ -46,7 +46,7 @@ static int no_run_out (HWVoiceOut *hw, int live)
int64_t ticks;
int64_t bytes;

now = qemu_get_clock_ns (vm_clock);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ticks = now - no->old_ticks;
bytes = muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
bytes = audio_MIN (bytes, INT_MAX);
Expand Down Expand Up @@ -102,7 +102,7 @@ static int no_run_in (HWVoiceIn *hw)
int samples = 0;

if (dead) {
int64_t now = qemu_get_clock_ns (vm_clock);
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
int64_t ticks = now - no->old_ticks;
int64_t bytes =
muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
Expand Down
4 changes: 2 additions & 2 deletions audio/spiceaudio.c
Expand Up @@ -81,7 +81,7 @@ static void spice_audio_fini (void *opaque)
static void rate_start (SpiceRateCtl *rate)
{
memset (rate, 0, sizeof (*rate));
rate->start_ticks = qemu_get_clock_ns (vm_clock);
rate->start_ticks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
}

static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)
Expand All @@ -91,7 +91,7 @@ static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)
int64_t bytes;
int64_t samples;

now = qemu_get_clock_ns (vm_clock);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
ticks = now - rate->start_ticks;
bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ());
samples = (bytes - rate->bytes_sent) >> info->shift;
Expand Down
2 changes: 1 addition & 1 deletion audio/wavaudio.c
Expand Up @@ -52,7 +52,7 @@ static int wav_run_out (HWVoiceOut *hw, int live)
int rpos, decr, samples;
uint8_t *dst;
struct st_sample *src;
int64_t now = qemu_get_clock_ns (vm_clock);
int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
int64_t ticks = now - wav->old_ticks;
int64_t bytes =
muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
Expand Down
12 changes: 6 additions & 6 deletions backends/baum.c
Expand Up @@ -315,7 +315,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
if (*cur++ != ESC) { \
DPRINTF("Broken packet %#2x, tossing\n", req); \
if (timer_pending(baum->cellCount_timer)) { \
qemu_del_timer(baum->cellCount_timer); \
timer_del(baum->cellCount_timer); \
baum_cellCount_timer_cb(baum); \
} \
return (cur - 2 - buf); \
Expand All @@ -334,7 +334,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
int i;

/* Allow 100ms to complete the DisplayData packet */
qemu_mod_timer(baum->cellCount_timer, qemu_get_clock_ns(vm_clock) +
timer_mod(baum->cellCount_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
get_ticks_per_sec() / 10);
for (i = 0; i < baum->x * baum->y ; i++) {
EAT(c);
Expand All @@ -348,7 +348,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len)
c = '?';
text[i] = c;
}
qemu_del_timer(baum->cellCount_timer);
timer_del(baum->cellCount_timer);

memset(zero, 0, sizeof(zero));

Expand Down Expand Up @@ -553,7 +553,7 @@ static void baum_close(struct CharDriverState *chr)
{
BaumDriverState *baum = chr->opaque;

qemu_free_timer(baum->cellCount_timer);
timer_free(baum->cellCount_timer);
if (baum->brlapi) {
brlapi__closeConnection(baum->brlapi);
g_free(baum->brlapi);
Expand Down Expand Up @@ -588,7 +588,7 @@ CharDriverState *chr_baum_init(void)
goto fail_handle;
}

baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum);
baum->cellCount_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, baum_cellCount_timer_cb, baum);

if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) {
brlapi_perror("baum_init: brlapi_getDisplaySize");
Expand All @@ -614,7 +614,7 @@ CharDriverState *chr_baum_init(void)
return chr;

fail:
qemu_free_timer(baum->cellCount_timer);
timer_free(baum->cellCount_timer);
brlapi__closeConnection(handle);
fail_handle:
g_free(handle);
Expand Down
14 changes: 7 additions & 7 deletions block.c
Expand Up @@ -130,8 +130,8 @@ void bdrv_io_limits_disable(BlockDriverState *bs)
do {} while (qemu_co_enter_next(&bs->throttled_reqs));

if (bs->block_timer) {
qemu_del_timer(bs->block_timer);
qemu_free_timer(bs->block_timer);
timer_del(bs->block_timer);
timer_free(bs->block_timer);
bs->block_timer = NULL;
}

Expand All @@ -148,7 +148,7 @@ static void bdrv_block_timer(void *opaque)

void bdrv_io_limits_enable(BlockDriverState *bs)
{
bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs);
bs->block_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, bdrv_block_timer, bs);
bs->io_limits_enabled = true;
}

Expand Down Expand Up @@ -180,8 +180,8 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
*/

while (bdrv_exceed_io_limits(bs, nb_sectors, is_write, &wait_time)) {
qemu_mod_timer(bs->block_timer,
wait_time + qemu_get_clock_ns(vm_clock));
timer_mod(bs->block_timer,
wait_time + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
qemu_co_queue_wait_insert_head(&bs->throttled_reqs);
}

Expand Down Expand Up @@ -3747,7 +3747,7 @@ static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors,
double elapsed_time;
int bps_ret, iops_ret;

now = qemu_get_clock_ns(vm_clock);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (now > bs->slice_end) {
bs->slice_start = now;
bs->slice_end = now + BLOCK_IO_SLICE_TIME;
Expand All @@ -3767,7 +3767,7 @@ static bool bdrv_exceed_io_limits(BlockDriverState *bs, int nb_sectors,
*wait = max_wait;
}

now = qemu_get_clock_ns(vm_clock);
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
if (bs->slice_end < now + max_wait) {
bs->slice_end = now + max_wait;
}
Expand Down
14 changes: 7 additions & 7 deletions block/iscsi.c
Expand Up @@ -960,7 +960,7 @@ static void iscsi_nop_timed_event(void *opaque)
return;
}

qemu_mod_timer(iscsilun->nop_timer, qemu_get_clock_ms(rt_clock) + NOP_INTERVAL);
timer_mod(iscsilun->nop_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL);
iscsi_set_events(iscsilun);
}
#endif
Expand Down Expand Up @@ -1173,8 +1173,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags)

#if defined(LIBISCSI_FEATURE_NOP_COUNTER)
/* Set up a timer for sending out iSCSI NOPs */
iscsilun->nop_timer = qemu_new_timer_ms(rt_clock, iscsi_nop_timed_event, iscsilun);
qemu_mod_timer(iscsilun->nop_timer, qemu_get_clock_ms(rt_clock) + NOP_INTERVAL);
iscsilun->nop_timer = timer_new_ms(QEMU_CLOCK_REALTIME, iscsi_nop_timed_event, iscsilun);
timer_mod(iscsilun->nop_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL);
#endif

out:
Expand Down Expand Up @@ -1204,8 +1204,8 @@ static void iscsi_close(BlockDriverState *bs)
struct iscsi_context *iscsi = iscsilun->iscsi;

if (iscsilun->nop_timer) {
qemu_del_timer(iscsilun->nop_timer);
qemu_free_timer(iscsilun->nop_timer);
timer_del(iscsilun->nop_timer);
timer_free(iscsilun->nop_timer);
}
qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), NULL, NULL, NULL);
iscsi_destroy_context(iscsi);
Expand Down Expand Up @@ -1267,8 +1267,8 @@ static int iscsi_create(const char *filename, QEMUOptionParameter *options)
goto out;
}
if (iscsilun->nop_timer) {
qemu_del_timer(iscsilun->nop_timer);
qemu_free_timer(iscsilun->nop_timer);
timer_del(iscsilun->nop_timer);
timer_free(iscsilun->nop_timer);
}
if (iscsilun->type != TYPE_DISK) {
ret = -ENODEV;
Expand Down
6 changes: 3 additions & 3 deletions block/mirror.c
Expand Up @@ -356,7 +356,7 @@ static void coroutine_fn mirror_run(void *opaque)
}

bdrv_dirty_iter_init(bs, &s->hbi);
last_pause_ns = qemu_get_clock_ns(rt_clock);
last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
for (;;) {
uint64_t delay_ns;
int64_t cnt;
Expand All @@ -374,7 +374,7 @@ static void coroutine_fn mirror_run(void *opaque)
* We do so every SLICE_TIME nanoseconds, or when there is an error,
* or when the source is clean, whichever comes first.
*/
if (qemu_get_clock_ns(rt_clock) - last_pause_ns < SLICE_TIME &&
if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME &&
s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) {
if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 ||
(cnt == 0 && s->in_flight > 0)) {
Expand Down Expand Up @@ -454,7 +454,7 @@ static void coroutine_fn mirror_run(void *opaque)
s->common.cancelled = false;
break;
}
last_pause_ns = qemu_get_clock_ns(rt_clock);
last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
}

immediate_exit:
Expand Down
10 changes: 5 additions & 5 deletions block/qed.c
Expand Up @@ -353,18 +353,18 @@ static void qed_start_need_check_timer(BDRVQEDState *s)
{
trace_qed_start_need_check_timer(s);

/* Use vm_clock so we don't alter the image file while suspended for
/* Use QEMU_CLOCK_VIRTUAL so we don't alter the image file while suspended for
* migration.
*/
qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(vm_clock) +
timer_mod(s->need_check_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
get_ticks_per_sec() * QED_NEED_CHECK_TIMEOUT);
}

/* It's okay to call this multiple times or when no timer is started */
static void qed_cancel_need_check_timer(BDRVQEDState *s)
{
trace_qed_cancel_need_check_timer(s);
qemu_del_timer(s->need_check_timer);
timer_del(s->need_check_timer);
}

static void bdrv_qed_rebind(BlockDriverState *bs)
Expand Down Expand Up @@ -494,7 +494,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags)
}
}

s->need_check_timer = qemu_new_timer_ns(vm_clock,
s->need_check_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
qed_need_check_timer_cb, s);

out:
Expand All @@ -518,7 +518,7 @@ static void bdrv_qed_close(BlockDriverState *bs)
BDRVQEDState *s = bs->opaque;

qed_cancel_need_check_timer(s);
qemu_free_timer(s->need_check_timer);
timer_free(s->need_check_timer);

/* Ensure writes reach stable storage */
bdrv_flush(bs->file);
Expand Down
2 changes: 1 addition & 1 deletion blockdev.c
Expand Up @@ -1299,7 +1299,7 @@ void qmp_block_set_io_throttle(const char *device, int64_t bps, int64_t bps_rd,
bdrv_io_limits_disable(bs);
} else {
if (bs->block_timer) {
qemu_mod_timer(bs->block_timer, qemu_get_clock_ns(vm_clock));
timer_mod(bs->block_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions hmp.c
Expand Up @@ -1195,13 +1195,13 @@ static void hmp_migrate_status_cb(void *opaque)
monitor_flush(status->mon);
}

qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock) + 1000);
timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000);
} else {
if (status->is_block_migration) {
monitor_printf(status->mon, "\n");
}
monitor_resume(status->mon);
qemu_del_timer(status->timer);
timer_del(status->timer);
g_free(status);
}

Expand Down Expand Up @@ -1235,9 +1235,9 @@ void hmp_migrate(Monitor *mon, const QDict *qdict)
status = g_malloc0(sizeof(*status));
status->mon = mon;
status->is_block_migration = blk || inc;
status->timer = qemu_new_timer_ms(rt_clock, hmp_migrate_status_cb,
status->timer = timer_new_ms(QEMU_CLOCK_REALTIME, hmp_migrate_status_cb,
status);
qemu_mod_timer(status->timer, qemu_get_clock_ms(rt_clock));
timer_mod(status->timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
}
}

Expand Down
8 changes: 4 additions & 4 deletions hw/acpi/core.c
Expand Up @@ -433,9 +433,9 @@ void acpi_pm_tmr_update(ACPIREGS *ar, bool enable)
if (enable) {
expire_time = muldiv64(ar->tmr.overflow_time, get_ticks_per_sec(),
PM_TIMER_FREQUENCY);
qemu_mod_timer(ar->tmr.timer, expire_time);
timer_mod(ar->tmr.timer, expire_time);
} else {
qemu_del_timer(ar->tmr.timer);
timer_del(ar->tmr.timer);
}
}

Expand Down Expand Up @@ -481,7 +481,7 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
MemoryRegion *parent)
{
ar->tmr.update_sci = update_sci;
ar->tmr.timer = qemu_new_timer_ns(vm_clock, acpi_pm_tmr_timer, ar);
ar->tmr.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, acpi_pm_tmr_timer, ar);
memory_region_init_io(&ar->tmr.io, memory_region_owner(parent),
&acpi_pm_tmr_ops, ar, "acpi-tmr", 4);
memory_region_add_subregion(parent, 8, &ar->tmr.io);
Expand All @@ -490,7 +490,7 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci,
void acpi_pm_tmr_reset(ACPIREGS *ar)
{
ar->tmr.overflow_time = 0;
qemu_del_timer(ar->tmr.timer);
timer_del(ar->tmr.timer);
}

/* ACPI PM1aCNT */
Expand Down

0 comments on commit bc72ad6

Please sign in to comment.