mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
qemu-timer: introduce timer attributes
Attributes are simple flags, associated with individual timers for their whole lifetime. They intended to be used to mark individual timers for special handling when they fire. New/init functions family in timer interface updated and refactored (new 'attribute' argument added, timer_list replaced with timer_list_group+type combinations, comments improved to avoid info duplication). Also existing aio interface extended with attribute-enabled variants of functions, which create/initialize timers. Signed-off-by: Artem Pisarenko <artem.k.pisarenko@gmail.com> Message-Id: <f47b81dbce734e9806f9516eba8ca588e6321c2f.1539764043.git.artem.k.pisarenko@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
05ff8dc32f
commit
89a603a0c8
4 changed files with 124 additions and 70 deletions
|
@ -387,6 +387,32 @@ struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp);
|
|||
/* Return the LinuxAioState bound to this AioContext */
|
||||
struct LinuxAioState *aio_get_linux_aio(AioContext *ctx);
|
||||
|
||||
/**
|
||||
* aio_timer_new_with_attrs:
|
||||
* @ctx: the aio context
|
||||
* @type: the clock type
|
||||
* @scale: the scale
|
||||
* @attributes: 0, or one to multiple OR'ed QEMU_TIMER_ATTR_<id> values
|
||||
* to assign
|
||||
* @cb: the callback to call on timer expiry
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Allocate a new timer (with attributes) attached to the context @ctx.
|
||||
* The function is responsible for memory allocation.
|
||||
*
|
||||
* The preferred interface is aio_timer_init or aio_timer_init_with_attrs.
|
||||
* Use that unless you really need dynamic memory allocation.
|
||||
*
|
||||
* Returns: a pointer to the new timer
|
||||
*/
|
||||
static inline QEMUTimer *aio_timer_new_with_attrs(AioContext *ctx,
|
||||
QEMUClockType type,
|
||||
int scale, int attributes,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
return timer_new_full(&ctx->tlg, type, scale, attributes, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
* aio_timer_new:
|
||||
* @ctx: the aio context
|
||||
|
@ -396,10 +422,7 @@ struct LinuxAioState *aio_get_linux_aio(AioContext *ctx);
|
|||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Allocate a new timer attached to the context @ctx.
|
||||
* The function is responsible for memory allocation.
|
||||
*
|
||||
* The preferred interface is aio_timer_init. Use that
|
||||
* unless you really need dynamic memory allocation.
|
||||
* See aio_timer_new_with_attrs for details.
|
||||
*
|
||||
* Returns: a pointer to the new timer
|
||||
*/
|
||||
|
@ -407,7 +430,29 @@ static inline QEMUTimer *aio_timer_new(AioContext *ctx, QEMUClockType type,
|
|||
int scale,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
return timer_new_tl(ctx->tlg.tl[type], scale, cb, opaque);
|
||||
return timer_new_full(&ctx->tlg, type, scale, 0, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
* aio_timer_init_with_attrs:
|
||||
* @ctx: the aio context
|
||||
* @ts: the timer
|
||||
* @type: the clock type
|
||||
* @scale: the scale
|
||||
* @attributes: 0, or one to multiple OR'ed QEMU_TIMER_ATTR_<id> values
|
||||
* to assign
|
||||
* @cb: the callback to call on timer expiry
|
||||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Initialise a new timer (with attributes) attached to the context @ctx.
|
||||
* The caller is responsible for memory allocation.
|
||||
*/
|
||||
static inline void aio_timer_init_with_attrs(AioContext *ctx,
|
||||
QEMUTimer *ts, QEMUClockType type,
|
||||
int scale, int attributes,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
timer_init_full(ts, &ctx->tlg, type, scale, attributes, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,14 +465,14 @@ static inline QEMUTimer *aio_timer_new(AioContext *ctx, QEMUClockType type,
|
|||
* @opaque: the opaque pointer to pass to the callback
|
||||
*
|
||||
* Initialise a new timer attached to the context @ctx.
|
||||
* The caller is responsible for memory allocation.
|
||||
* See aio_timer_init_with_attrs for details.
|
||||
*/
|
||||
static inline void aio_timer_init(AioContext *ctx,
|
||||
QEMUTimer *ts, QEMUClockType type,
|
||||
int scale,
|
||||
QEMUTimerCB *cb, void *opaque)
|
||||
{
|
||||
timer_init_tl(ts, ctx->tlg.tl[type], scale, cb, opaque);
|
||||
timer_init_full(ts, &ctx->tlg, type, scale, 0, cb, opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue