add throttle block driver filter
v2 cover add throttle block driver filter
This series adds a throttle block driver filter. Currently throttling is done at the BlockBackend level. Using block driver interfaces we can move the throttling to any point in the BDS graph using a throttle node which uses the existing throttling code. This allows for potentially more complex configurations (throttling at any point in the graph, chained filters)
There's also the question of how filter drivers affect the rest of the block layer, especially live block jobs. This won't be tackled in this series though.
v2:
change QOM throttle group object name
print valid ranges for uint on error
move frees in throttle_group_obj_finalize()
split throttle_group_{set,get}()
add throttle_recurse_is_first_non_filter()
Manos Pitsidianakis (7):
block: move ThrottleGroup membership to ThrottleGroupMember
block: add aio_context field in ThrottleGroupMember
block: tidy ThrottleGroupMember initializations
block: convert ThrottleGroup to object with QOM
block: add throttle block filter driver
block: add BlockDevOptionsThrottle to QAPI
block: add throttle block filter driver interface tests
block/Makefile.objs | 1 + block/block-backend.c | 61 ++-- block/qapi.c | 8 +- block/throttle-groups.c | 715 ++++++++++++++++++++++++++++++---------- block/throttle.c | 395 ++++++++++++++++++++++ blockdev.c | 4 +- include/block/throttle-groups.h | 47 ++- include/qemu/throttle-options.h | 60 ++-- include/qemu/throttle.h | 3 + include/sysemu/block-backend.h | 20 +- qapi/block-core.json | 68 +++- tests/qemu-iotests/184 | 237 +++++++++++++ tests/qemu-iotests/184.out | 319 ++++++++++++++++++ tests/qemu-iotests/group | 1 + tests/test-throttle.c | 111 ++++--- util/throttle.c | 151 +++++++++ 16 files changed, 1891 insertions(+), 310 deletions(-) create mode 100644 block/throttle.c create mode 100755 tests/qemu-iotests/184 create mode 100644 tests/qemu-iotests/184.out
Signature · 1 line
2.11.0
PATCH v2 1/7 block: move ThrottleGroup membership to ThrottleGroupMember
This commit eliminates the 1:1 relationship between BlockBackend and throttle group state. Users will be able to create multiple throttle nodes, each with its own throttle group state, in the future. The throttle group state cannot be per-BlockBackend anymore, it must be per-throttle node. This is done by gathering ThrottleGroup membership details from BlockBackendPublic into ThrottleGroupMember and refactoring existing code to use the structure.
--- block/block-backend.c | 66 +++++---- block/qapi.c | 8 +- block/throttle-groups.c | 288 ++++++++++++++++++++-------------------- blockdev.c | 4 +- include/block/throttle-groups.h | 39 +++++- include/sysemu/block-backend.h | 20 +-- tests/test-throttle.c | 53 ++++---- 7 files changed, 252 insertions(+), 226 deletions(-)
block/block-backend.c +37 -29
@@ -215,9 +215,9 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm) blk->shared_perm = shared_perm;blk_set_enable_write_cache (blk, true); -qemu_co_mutex_init (&blk->public.throttled_reqs_lock); -qemu_co_queue_init (&blk->public.throttled_reqs[0 ]); -qemu_co_queue_init (&blk->public.throttled_reqs[1 ]); +qemu_co_mutex_init (&blk->public.throttle_group_member.throttled_reqs_lock); +qemu_co_queue_init (&blk->public.throttle_group_member.throttled_reqs[0 ]); +qemu_co_queue_init (&blk->public.throttle_group_member.throttled_reqs[1 ]);block_acct_init (&blk->stats);notifier_list_init (&blk->remove_bs_notifiers);
@@ -285,7 +285,7 @@ static void blk_delete(BlockBackend *blk)assert (!blk->refcnt);assert (!blk->name);assert (!blk->dev); -if (blk->public.throttle_state) { +if (blk->public.throttle_group_member.throttle_state) {blk_io_limits_disable (blk); }if (blk->root) {
@@ -596,9 +596,12 @@ BlockBackend *blk_by_public(BlockBackendPublic *public)*/ void blk_remove_bs (BlockBackend *blk) { +ThrottleTimers *tt; +notifier_list_notify (&blk->remove_bs_notifiers, blk); -if (blk->public.throttle_state) { -throttle_timers_detach_aio_context (&blk->public.throttle_timers); +if (blk->public.throttle_group_member.throttle_state) { + tt = &blk->public.throttle_group_member.throttle_timers; +throttle_timers_detach_aio_context (tt); }blk_update_root_state (blk);
@@ -620,9 +623,10 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)bdrv_ref (bs);notifier_list_notify (&blk->insert_bs_notifiers, blk); -if (blk->public.throttle_state) { +if (blk->public.throttle_group_member.throttle_state) {throttle_timers_attach_aio_context ( - &blk->public.throttle_timers,bdrv_get_aio_context (bs)); + &blk->public.throttle_group_member.throttle_timers, +bdrv_get_aio_context (bs)); }return 0 ;
@@ -984,8 +988,9 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,bdrv_inc_in_flight (bs);/* throttling disk I/O */ -if (blk->public.throttle_state) { -throttle_group_co_io_limits_intercept (blk, bytes, false); +if (blk->public.throttle_group_member.throttle_state) { +throttle_group_co_io_limits_intercept (&blk->public.throttle_group_member, + bytes, false); } ret =bdrv_co_preadv (blk->root, offset, bytes, qiov, flags);
@@ -1008,10 +1013,10 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, }bdrv_inc_in_flight (bs); -/* throttling disk I/O */ -if (blk->public.throttle_state) { -throttle_group_co_io_limits_intercept (blk, bytes, true); +if (blk->public.throttle_group_member.throttle_state) { +throttle_group_co_io_limits_intercept (&blk->public.throttle_group_member, + bytes, true); }if (!blk->enable_write_cache) {
@@ -1680,15 +1685,17 @@ static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)void blk_set_aio_context (BlockBackend *blk,AioContext *new_context) {BlockDriverState *bs =blk_bs (blk); +ThrottleTimers *tt;if (bs) { -if (blk->public.throttle_state) { -throttle_timers_detach_aio_context (&blk->public.throttle_timers); +if (blk->public.throttle_group_member.throttle_state) { + tt = &blk->public.throttle_group_member.throttle_timers; +throttle_timers_detach_aio_context (tt); }bdrv_set_aio_context (bs, new_context); -if (blk->public.throttle_state) { -throttle_timers_attach_aio_context (&blk->public.throttle_timers, - new_context); +if (blk->public.throttle_group_member.throttle_state) { + tt = &blk->public.throttle_group_member.throttle_timers; +throttle_timers_attach_aio_context (tt, new_context); } } }
@@ -1907,33 +1914,34 @@ int blk_commit_all(void)/* throttling disk I/O limits */ void blk_set_io_limits (BlockBackend *blk,ThrottleConfig *cfg) { -throttle_group_config (blk, cfg); +throttle_group_config (&blk->public.throttle_group_member, cfg); }void blk_io_limits_disable (BlockBackend *blk) { -assert (blk->public.throttle_state); +assert (blk->public.throttle_group_member.throttle_state);bdrv_drained_begin (blk_bs (blk)); -throttle_group_unregister_blk (blk); +throttle_group_unregister_tgm (&blk->public.throttle_group_member);bdrv_drained_end (blk_bs (blk)); }/* should be called before blk_set_io_limits if a limit is set */ void blk_io_limits_enable (BlockBackend *blk,const char *group) { -assert (!blk->public.throttle_state); -throttle_group_register_blk (blk, group); +assert (!blk->public.throttle_group_member.throttle_state); +throttle_group_register_tgm (&blk->public.throttle_group_member, group); }void blk_io_limits_update_group (BlockBackend *blk,const char *group) {/* this BB is not part of any group */ -if (!blk->public.throttle_state) { +if (!blk->public.throttle_group_member.throttle_state) {return ; }/* this BB is a part of the same group than the one we want */ -if (!g_strcmp0 (throttle_group_get_name (blk), group)) { +if (!g_strcmp0 (throttle_group_get_name (&blk->public.throttle_group_member), + group)) {return ; }
@@ -1955,8 +1963,8 @@ static void blk_root_drained_begin(BdrvChild *child)/* Note that blk->root may not be accessible here yet if we are just * attaching to a BlockDriverState that is drained. Use child instead. */ -if (atomic_fetch_inc (&blk->public.io_limits_disabled) ==0 ) { -throttle_group_restart_blk (blk); +if (atomic_fetch_inc (&blk->public.throttle_group_member.io_limits_disabled) ==0 ) { +throttle_group_restart_tgm (&blk->public.throttle_group_member); } }
@@ -1965,8 +1973,8 @@ static void blk_root_drained_end(BdrvChild *child)BlockBackend *blk = child->opaque;assert (blk->quiesce_counter); -assert (blk->public.io_limits_disabled); -atomic_dec (&blk->public.io_limits_disabled); +assert (blk->public.throttle_group_member.io_limits_disabled); +atomic_dec (&blk->public.throttle_group_member.io_limits_disabled);if (--blk->quiesce_counter ==0 ) {if (blk->dev_ops && blk->dev_ops->drained_end) {
block/qapi.c +5 -3
@@ -66,10 +66,11 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, info->detect_zeroes = bs->detect_zeroes; -if (blk &&blk_get_public (blk)->throttle_state) { +if (blk &&blk_get_public (blk)->throttle_group_member.throttle_state) {ThrottleConfig cfg; +BlockBackendPublic *blkp =blk_get_public (blk); -throttle_group_get_config (blk, &cfg); +throttle_group_get_config (&blkp->throttle_group_member, &cfg); info->bps = cfg.buckets[THROTTLE_BPS_TOTAL ].avg; info->bps_rd = cfg.buckets[THROTTLE_BPS_READ ].avg;
@@ -117,7 +118,8 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, info->iops_size = cfg.op_size; info->has_group = true; - info->group =g_strdup (throttle_group_get_name (blk)); + info->group = +g_strdup (throttle_group_get_name (&blkp->throttle_group_member)); } info->write_threshold =bdrv_write_threshold_get (bs);
block/throttle-groups.c +144 -144
564 lines not on this page · raw message
blockdev.c +2 -2
@@ -2688,7 +2688,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) if (throttle_enabled(&cfg)) { /* Enable I/O limits if they're not enabled yet, otherwise * just update the throttling group. */ - if (!blk_get_public(blk)->throttle_state) { + if (!blk_get_public(blk)->throttle_group_member.throttle_state) { blk_io_limits_enable(blk, arg->has_group ? arg->group : arg->has_device ? arg->device :
@@ -2698,7 +2698,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp) }/* Set the new throttling configuration */ blk_set_io_limits (blk, &cfg); - }else if (blk_get_public (blk)->throttle_state) { + }else if (blk_get_public (blk)->throttle_group_member.throttle_state) {/* If all throttling settings are set to 0, disable I/O limits */ blk_io_limits_disable (blk); }
include/block/throttle-groups.h +32 -7
@@ -28,19 +28,44 @@#include "qemu/throttle.h" #include "block/block_int.h" -const char *throttle_group_get_name (BlockBackend *blk); +/* The ThrottleGroupMember structure indicates membership in a ThrottleGroup +* and holds related data. +*/ + +typedef struct ThrottleGroupMember { +/* throttled_reqs_lock protects the CoQueues for throttled requests. */ +CoMutex throttled_reqs_lock; +CoQueue throttled_reqs[2 ]; + +/* Nonzero if the I/O limits are currently being ignored; generally +* it is zero. Accessed with atomic operations. +*/ +unsigned int io_limits_disabled; + +/* The following fields are protected by the ThrottleGroup lock. +* See the ThrottleGroup documentation for details. +* throttle_state tells us if I/O limits are configured. */ +ThrottleState *throttle_state; +ThrottleTimers throttle_timers; +unsigned pending_reqs[2 ]; +QLIST_ENTRY (ThrottleGroupMember) round_robin; + +}ThrottleGroupMember ; + +const char *throttle_group_get_name (ThrottleGroupMember *tgm);ThrottleState *throttle_group_incref (const char *name);void throttle_group_unref (ThrottleState *ts); -void throttle_group_config (BlockBackend *blk,ThrottleConfig *cfg); -void throttle_group_get_config (BlockBackend *blk,ThrottleConfig *cfg); +void throttle_group_config (ThrottleGroupMember *tgm,ThrottleConfig *cfg); +void throttle_group_get_config (ThrottleGroupMember *tgm,ThrottleConfig *cfg); -void throttle_group_register_blk (BlockBackend *blk,const char *groupname); -void throttle_group_unregister_blk (BlockBackend *blk); -void throttle_group_restart_blk (BlockBackend *blk); +void throttle_group_register_tgm (ThrottleGroupMember *tgm, +const char *groupname); +void throttle_group_unregister_tgm (ThrottleGroupMember *tgm); +void throttle_group_restart_tgm (ThrottleGroupMember *tgm); -void coroutine_fn throttle_group_co_io_limits_intercept(BlockBackend *blk, +void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm,unsigned int bytes,bool is_write);
include/sysemu/block-backend.h +3 -17
@@ -70,24 +70,10 @@ typedef struct BlockDevOps {/* This struct is embedded in (the private) BlockBackend struct and contains * fields that must be public. This is in particular for QLIST_ENTRY() and -* friends so that BlockBackends can be kept in lists outside block-backend.c */ +* friends so that BlockBackends can be kept in lists outside block-backend.c +* */ typedef struct BlockBackendPublic { -/* throttled_reqs_lock protects the CoQueues for throttled requests. */ -CoMutex throttled_reqs_lock; -CoQueue throttled_reqs[2 ]; - -/* Nonzero if the I/O limits are currently being ignored; generally -* it is zero. Accessed with atomic operations. -*/ -unsigned int io_limits_disabled; - -/* The following fields are protected by the ThrottleGroup lock. -* See the ThrottleGroup documentation for details. -* throttle_state tells us if I/O limits are configured. */ -ThrottleState *throttle_state; -ThrottleTimers throttle_timers; -unsigned pending_reqs[2 ]; -QLIST_ENTRY (BlockBackendPublic) round_robin; +ThrottleGroupMember throttle_group_member; }BlockBackendPublic ;BlockBackend *blk_new (uint64_t perm,uint64_t shared_perm);
tests/test-throttle.c +29 -24
85 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 2/7 block: add aio_context field in ThrottleGroupMember
In reply to Manos Pitsidianakistimer_cb() needs to know about the current Aio context of the throttle request that is woken up. In order to make ThrottleGroupMember backend agnostic, this information is stored in an aio_context field instead of accessing it from BlockBackend.
--- block/block-backend.c | 14 ++++----- block/throttle-groups.c | 38 ++++++++++++++++--------- include/block/throttle-groups.h | 7 ++++- tests/test-throttle.c | 63 +++++++++++++++++++++-------------------- 4 files changed, 69 insertions(+), 53 deletions(-)
block/block-backend.c +6 -8
@@ -1685,17 +1685,15 @@ static AioContext *blk_aiocb_get_aio_context(BlockAIOCB *acb)void blk_set_aio_context (BlockBackend *blk,AioContext *new_context) {BlockDriverState *bs =blk_bs (blk); -ThrottleTimers *tt; +ThrottleGroupMember *tgm = &blk->public.throttle_group_member;if (bs) { -if (blk->public.throttle_group_member.throttle_state) { - tt = &blk->public.throttle_group_member.throttle_timers; -throttle_timers_detach_aio_context (tt); +if (tgm->throttle_state) { +throttle_group_detach_aio_context (tgm); }bdrv_set_aio_context (bs, new_context); -if (blk->public.throttle_group_member.throttle_state) { - tt = &blk->public.throttle_group_member.throttle_timers; -throttle_timers_attach_aio_context (tt, new_context); +if (tgm->throttle_state) { +throttle_group_attach_aio_context (tgm, new_context); } } }
@@ -1929,7 +1927,7 @@ void blk_io_limits_disable(BlockBackend *blk)void blk_io_limits_enable (BlockBackend *blk,const char *group) {assert (!blk->public.throttle_group_member.throttle_state); -throttle_group_register_tgm (&blk->public.throttle_group_member, group); +throttle_group_register_tgm (&blk->public.throttle_group_member, group,blk_get_aio_context (blk)); }void blk_io_limits_update_group (BlockBackend *blk,const char *group)
block/throttle-groups.c +24 -14
@@ -391,9 +391,6 @@ static void coroutine_fn throttle_group_restart_queue_entry(void *opaque)static void throttle_group_restart_queue (ThrottleGroupMember *tgm,bool is_write) { -BlockBackendPublic *blkp =container_of (tgm, BlockBackendPublic, - throttle_group_member); -BlockBackend *blk =blk_by_public (blkp);Coroutine *co;RestartData rd = { .tgm = tgm,
@@ -401,7 +398,7 @@ static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write }; co =qemu_coroutine_create (throttle_group_restart_queue_entry, &rd); -aio_co_enter (blk_get_aio_context (blk), co); +aio_co_enter (tgm->aio_context, co); }void throttle_group_restart_tgm (ThrottleGroupMember *tgm)
@@ -449,13 +446,11 @@ void throttle_group_get_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg)/* ThrottleTimers callback. This wakes up a request that was waiting * because it had been throttled. * -* @blk: the BlockBackend whose request had been throttled +* @tgm: the ThrottleGroupMember whose request had been throttled * @is_write: the type of operation (read/write) */ -static void timer_cb (BlockBackend *blk,bool is_write) +static void timer_cb (ThrottleGroupMember *tgm,bool is_write) { -BlockBackendPublic *blkp =blk_get_public (blk); -ThrottleGroupMember *tgm = &blkp->throttle_group_member;ThrottleState *ts = tgm->throttle_state;ThrottleGroup *tg =container_of (ts, ThrottleGroup, ts);
@@ -484,18 +479,18 @@ static void write_timer_cb(void *opaque)* * @tgm: the ThrottleGroupMember to insert * @groupname: the name of the group +* @ctx: the AioContext to use */ void throttle_group_register_tgm (ThrottleGroupMember *tgm, -const char *groupname) +const char *groupname, +AioContext *ctx) {int i; -BlockBackendPublic *blkp =container_of (tgm, BlockBackendPublic, - throttle_group_member); -BlockBackend *blk =blk_by_public (blkp);ThrottleState *ts =throttle_group_incref (groupname);ThrottleGroup *tg =container_of (ts, ThrottleGroup, ts); tgm->throttle_state = ts; + tgm->aio_context = ctx;qemu_mutex_lock (&tg->lock);/* If the ThrottleGroup is new set this ThrottleGroupMember as the token */
@@ -508,11 +503,11 @@ void throttle_group_register_tgm(ThrottleGroupMember *tgm,QLIST_INSERT_HEAD (&tg->head, tgm, round_robin);throttle_timers_init (&tgm->throttle_timers, -blk_get_aio_context (blk), + tgm->aio_context, tg->clock_type, read_timer_cb, write_timer_cb, - blk); + tgm);qemu_mutex_unlock (&tg->lock); }
@@ -559,6 +554,21 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *tgm) tgm->throttle_state =NULL ; } +void throttle_group_attach_aio_context (ThrottleGroupMember *tgm, +AioContext *new_context) +{ +ThrottleTimers *tt = &tgm->throttle_timers; +throttle_timers_attach_aio_context (tt, new_context); + tgm->aio_context = new_context; +} + +void throttle_group_detach_aio_context (ThrottleGroupMember *tgm) +{ + tgm->aio_context =NULL ; +ThrottleTimers *tt = &tgm->throttle_timers; +throttle_timers_detach_aio_context (tt); +} +static void throttle_groups_init (void ) {qemu_mutex_init (&throttle_groups_lock);
include/block/throttle-groups.h +6 -1
@@ -33,6 +33,7 @@*/ typedef struct ThrottleGroupMember { + AioContext *aio_context; /* throttled_reqs_lock protects the CoQueues for throttled requests. */ CoMutex throttled_reqs_lock; CoQueue throttled_reqs[2];
@@ -61,12 +62,16 @@ void throttle_group_config(ThrottleGroupMember *tgm, ThrottleConfig *cfg);void throttle_group_get_config (ThrottleGroupMember *tgm,ThrottleConfig *cfg);void throttle_group_register_tgm (ThrottleGroupMember *tgm, -const char *groupname); +const char *groupname, +AioContext *ctx);void throttle_group_unregister_tgm (ThrottleGroupMember *tgm);void throttle_group_restart_tgm (ThrottleGroupMember *tgm); void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm,unsigned int bytes,bool is_write); +void throttle_group_attach_aio_context (ThrottleGroupMember *tgm, +AioContext *new_context); +void throttle_group_detach_aio_context (ThrottleGroupMember *tgm);#endif
tests/test-throttle.c +33 -30
160 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 3/7 block: tidy ThrottleGroupMember initializations
In reply to Manos PitsidianakisMove the CoMutex and CoQueue inits inside throttle_group_register_tgm() which is called whenever a ThrottleGroupMember is initialized. There's no need for them to be separate.
--- block/block-backend.c | 3 --- block/throttle-groups.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
block/block-backend.c +0 -3
@@ -215,9 +215,6 @@ BlockBackend *blk_new(uint64_t perm, uint64_t shared_perm) blk->shared_perm = shared_perm;blk_set_enable_write_cache (blk, true); -qemu_co_mutex_init (&blk->public.throttle_group_member.throttled_reqs_lock); -qemu_co_queue_init (&blk->public.throttle_group_member.throttled_reqs[0 ]); -qemu_co_queue_init (&blk->public.throttle_group_member.throttled_reqs[1 ]);block_acct_init (&blk->stats);notifier_list_init (&blk->remove_bs_notifiers);
block/throttle-groups.c +3 -0
@@ -508,6 +508,9 @@ void throttle_group_register_tgm(ThrottleGroupMember *tgm, read_timer_cb, write_timer_cb, tgm); +qemu_co_mutex_init (&tgm->throttled_reqs_lock); +qemu_co_queue_init (&tgm->throttled_reqs[0 ]); +qemu_co_queue_init (&tgm->throttled_reqs[1 ]);qemu_mutex_unlock (&tg->lock); }
Signature · 1 line
2.11.0
PATCH v2 4/7 block: convert ThrottleGroup to object with QOM
In reply to Manos PitsidianakisThrottleGroup is converted to an object. This will allow the future throttle block filter drive easy creation and configuration of throttle groups in QMP and cli.
A new QAPI struct, ThrottleLimits, is introduced to provide a shared struct for all throttle configuration needs in QMP.
ThrottleGroups can be created via CLI as
-object throttle-group,id=foo,x-iops-total=100,x-..
where x-* are individual limit properties. Since we can't add non-scalar properties in -object this interface must be used instead. However, setting these properties must be disabled after initialization because certain combinations of limits are forbidden and thus configuration changes should be done in one transaction. The individual properties will go away when support for non-scalar values in CLI is implemented and thus are marked as experimental.
ThrottleGroup also has a limits property that uses the ThrottleLimits struct. It can be used to create ThrottleGroups or set the configuration in existing groups as follows:
{ "execute": "object-add",
"arguments": {
"qom-type": "throttle-group",
"id": "foo",
"props" : {
"limits": {
"iops-total": 100
}
}
}
}
{ "execute" : "qom-set",
"arguments" : {
"path" : "foo",
"property" : "limits",
"value" : {
"iops-total" : 99
}
}
}This also means a group's configuration can be fetched with qom-get.
ThrottleGroups can be anonymous which means they can't get accessed by other users ie they will always be units instead of group (Because they have one ThrottleGroupMember).
---
Notes:
Note: I tested Markus Armbruster's patch in <[email protected]> on master and I can use this syntax successfuly:
-object '{ "qom-type" : "throttle-group", "id" : "foo", "props" : { "limits" \
: { "iops-total" : 1000 } } }'
If this gets merged using -object will be a little more verbose but at least we won't have seperate properties, which is a good thing, so the x-* should be dropped.
block/throttle-groups.c | 402 ++++++++++++++++++++++++++++++++++++---- include/block/throttle-groups.h | 3 + include/qemu/throttle-options.h | 59 ++++-- include/qemu/throttle.h | 3 + qapi/block-core.json | 48 +++++ tests/test-throttle.c | 1 + util/throttle.c | 151 +++++++++++++++ 7 files changed, 617 insertions(+), 50 deletions(-)
block/throttle-groups.c +371 -31
@@ -25,9 +25,17 @@#include "qemu/osdep.h" #include "sysemu/block-backend.h" #include "block/throttle-groups.h" +#include "qemu/throttle-options.h" #include "qemu/queue.h" #include "qemu/thread.h" #include "sysemu/qtest.h" +#include "qapi/error.h" +#include "qapi-visit.h" +#include "qom/object.h" +#include "qom/object_interfaces.h" + +static void throttle_group_obj_init (Object *obj); +static void throttle_group_obj_complete (UserCreatable *obj,Error **errp);/* The ThrottleGroup structure (with its ThrottleState) is shared * among different ThrottleGroupMembers and it's independent from
@@ -54,6 +62,10 @@* that ThrottleGroupMember has throttled requests in the queue. */ typedef struct ThrottleGroup { + Object parent_obj; + + /* refuse individual property change if initialization is complete */ + bool is_initialized; char *name; /* This is constant during the lifetime of the group */ QemuMutex lock; /* This lock protects the following four fields */
@@ -63,8 +75,7 @@ typedef struct ThrottleGroup {bool any_timer_armed[2 ];QEMUClockType clock_type; -/* These two are protected by the global throttle_groups_lock */ -unsigned refcount; +/* This is protected by the global throttle_groups_lock */ QTAILQ_ENTRY (ThrottleGroup) list; } ThrottleGroup;
@@ -77,7 +88,8 @@ static QTAILQ_HEAD(, ThrottleGroup) throttle_groups =* If no ThrottleGroup is found with the given name a new one is * created. * -* @name: the name of the ThrottleGroup +* @name: the name of the ThrottleGroup, NULL means a new anonymous group will +* be created. * @ret: the ThrottleState member of the ThrottleGroup */ ThrottleState *throttle_group_incref (const char *name)
@@ -87,32 +99,30 @@ ThrottleState *throttle_group_incref(const char *name)qemu_mutex_lock (&throttle_groups_lock); -/* Look for an existing group with that name */ - QTAILQ_FOREACH(iter, &throttle_groups, list) { -if (!strcmp (name, iter->name)) { - tg = iter; -break ; +if (name) { +/* Look for an existing group with that name */ + QTAILQ_FOREACH(iter, &throttle_groups, list) { +if (!g_strcmp0 (name, iter->name)) { + tg = iter; +break ; + } } }/* Create a new one if not found */ if (!tg) { - tg =g_new0 (ThrottleGroup,1 ); +/* new ThrottleGroup obj will have a refcnt = 1 */ + tg =THROTTLE_GROUP (object_new (TYPE_THROTTLE_GROUP )); tg->name =g_strdup (name); - tg->clock_type =QEMU_CLOCK_REALTIME ; - -if (qtest_enabled ()) { -/* For testing block IO throttling only */ - tg->clock_type =QEMU_CLOCK_VIRTUAL ; - } -qemu_mutex_init (&tg->lock); -throttle_init (&tg->ts); -QLIST_INIT (&tg->head); - -QTAILQ_INSERT_TAIL (&throttle_groups, tg, list); +throttle_group_obj_complete ((UserCreatable *)tg, &error_abort); } - tg->refcount++; +qemu_mutex_lock (&tg->lock); +if (!QLIST_EMPTY (&tg->head)) { +/* only ref if the group is not empty */ +object_ref (OBJECT (tg)); + } +qemu_mutex_unlock (&tg->lock);qemu_mutex_unlock (&throttle_groups_lock);
@@ -129,15 +139,7 @@ ThrottleState *throttle_group_incref(const char *name)void throttle_group_unref (ThrottleState *ts) {ThrottleGroup *tg =container_of (ts, ThrottleGroup, ts); - -qemu_mutex_lock (&throttle_groups_lock); -if (--tg->refcount ==0 ) { -QTAILQ_REMOVE (&throttle_groups, tg, list); -qemu_mutex_destroy (&tg->lock); -g_free (tg->name); -g_free (tg); - } -qemu_mutex_unlock (&throttle_groups_lock); +object_unref (OBJECT (tg)); }/* Get the name from a ThrottleGroupMember's group. The name (and the pointer)
@@ -572,9 +574,347 @@ void throttle_group_detach_aio_context(ThrottleGroupMember *tgm)throttle_timers_detach_aio_context (tt); } +#undef THROTTLE_OPT_PREFIX +#define THROTTLE_OPT_PREFIX "x-" +#define DOUBLE 0 +#define UINT64 1 +#define UNSIGNED 2 + +typedef struct { +const char *name; +BucketType type; +int data_type; +const ptrdiff_t offset;/* offset in LeakyBucket struct. */ +}ThrottleParamInfo ; + +static ThrottleParamInfo properties[] = { +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL, +THROTTLE_OPS_TOTAL ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL_MAX, +THROTTLE_OPS_TOTAL ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL_MAX_LENGTH, +THROTTLE_OPS_TOTAL ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ, +THROTTLE_OPS_READ ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ_MAX, +THROTTLE_OPS_READ ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_READ_MAX_LENGTH, +THROTTLE_OPS_READ ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE, +THROTTLE_OPS_WRITE ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE_MAX, +THROTTLE_OPS_WRITE ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE_MAX_LENGTH, +THROTTLE_OPS_WRITE ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL, +THROTTLE_BPS_TOTAL ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL_MAX, +THROTTLE_BPS_TOTAL ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_TOTAL_MAX_LENGTH, +THROTTLE_BPS_TOTAL ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ, +THROTTLE_BPS_READ ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ_MAX, +THROTTLE_BPS_READ ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_READ_MAX_LENGTH, +THROTTLE_BPS_READ ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE, +THROTTLE_BPS_WRITE ,DOUBLE , offsetof(LeakyBucket , avg), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE_MAX, +THROTTLE_BPS_WRITE ,DOUBLE , offsetof(LeakyBucket , max), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_BPS_WRITE_MAX_LENGTH, +THROTTLE_BPS_WRITE ,UNSIGNED , offsetof(LeakyBucket , burst_length), +}, +{ + THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_SIZE, +0 ,UINT64 , offsetof(ThrottleConfig , op_size), +} +}; + +static void throttle_group_obj_init (Object *obj) +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); + + tg->clock_type =QEMU_CLOCK_REALTIME ; +if (qtest_enabled ()) { +/* For testing block IO throttling only */ + tg->clock_type =QEMU_CLOCK_VIRTUAL ; + } + tg->is_initialized = false; +QTAILQ_INSERT_TAIL (&throttle_groups, tg, list); +qemu_mutex_init (&tg->lock); +throttle_init (&tg->ts); +QLIST_INIT (&tg->head); +} + +static void throttle_group_obj_complete (UserCreatable *obj,Error **errp) +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj), *iter; +ThrottleConfig *cfg = &tg->ts.cfg; + +/* set group name to object id if it exists */ +if (!tg->name && tg->parent_obj.parent) { + tg->name =object_get_canonical_path_component (OBJECT (obj)); + } + +if (tg->name) { +/* error if name is duplicate */ + QTAILQ_FOREACH(iter, &throttle_groups, list) { +if (!g_strcmp0 (tg->name, iter->name) && tg != iter) { +error_setg (errp,"A group with this name already exists" ); +return ; + } + } + } + +/* unfix buckets to check validity */ +throttle_get_config (&tg->ts, cfg); +if (!throttle_is_valid (cfg, errp)) { +return ; + } +/* fix buckets again */ +throttle_config (&tg->ts, tg->clock_type, cfg); + + tg->is_initialized = true; +} + +static void throttle_group_obj_finalize (Object *obj) +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); +qemu_mutex_lock (&throttle_groups_lock); +QTAILQ_REMOVE (&throttle_groups, tg, list); +qemu_mutex_unlock (&throttle_groups_lock); +qemu_mutex_destroy (&tg->lock); +g_free (tg->name); +} + +static void throttle_group_set (Object *obj,Visitor *v,const char * name, +void *opaque,Error **errp) + +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); +ThrottleConfig cfg; +ThrottleParamInfo *info = opaque; +ThrottleLimits *arg =NULL ; +Error *local_err =NULL ; +int64_t value; + +/* If we have finished initialization, don't accept individual property +* changes through QOM. Throttle configuration limits must be set in one +* transaction, as certain combinations are invalid. +*/ +if (tg->is_initialized) { +error_setg (&local_err,"Property cannot be set after initialization" ); + goto fail; + } + +visit_type_int64 (v, name, &value, &local_err); +if (local_err) { + goto fail; + } +if (value <0 ) { +error_setg (&local_err,"Property values cannot be negative" ); + goto fail; + } + + cfg = tg->ts.cfg; +switch (info->data_type) { +case UINT64 : + { +uint64_t *field = (void *)&cfg.buckets[info->type] + info->offset; + *field = value; + } +break ; +case DOUBLE : + { +double *field = (void *)&cfg.buckets[info->type] + info->offset; + *field = value; + } +break ; +case UNSIGNED : + { +if (value >UINT_MAX ) { +error_setg (&local_err,"%s value must be in the" +"range [0, %u]" , info->name,UINT_MAX ); + goto fail; + } +unsigned *field = (void *)&cfg.buckets[info->type] + info->offset; + *field = value; + } + } + + tg->ts.cfg = cfg; + goto ret; + +fail: +error_propagate (errp, local_err); +ret: +g_free (arg); +return ; + +} + +static void throttle_group_get (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); +ThrottleConfig cfg; +ThrottleParamInfo *info = opaque; +int64_t value; + + cfg = tg->ts.cfg; +switch (info->data_type) { +case UINT64 : + { +uint64_t *field = (void *)&cfg.buckets[info->type] + info->offset; + value = *field; + } +break ; +case DOUBLE : + { +double *field = (void *)&cfg.buckets[info->type] + info->offset; + value = *field; + } +break ; +case UNSIGNED : + { +unsigned *field = (void *)&cfg.buckets[info->type] + info->offset; + value = *field; + } + } + +visit_type_int64 (v, name, &value, errp); +} + +static void throttle_group_set_limits (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) + +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); +ThrottleConfig cfg; +ThrottleLimits *arg =NULL ; +Error *local_err =NULL ; + + arg =g_new0 (ThrottleLimits,1 ); +visit_type_ThrottleLimits (v, name, &arg, &local_err); +if (local_err) { + goto fail; + } +qemu_mutex_lock (&tg->lock); +throttle_get_config (&tg->ts, &cfg); +throttle_limits_to_config (arg, &cfg, &local_err); +if (local_err) { +qemu_mutex_unlock (&tg->lock); + goto fail; + } +throttle_config (&tg->ts, tg->clock_type, &cfg); +qemu_mutex_unlock (&tg->lock); + + goto ret; + +fail: +error_propagate (errp, local_err); +ret: +g_free (arg); +return ; +} + +static void throttle_group_get_limits (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ThrottleGroup *tg =THROTTLE_GROUP (obj); +ThrottleConfig cfg; +ThrottleLimits *arg =NULL ; + + arg =g_new0 (ThrottleLimits,1 ); +qemu_mutex_lock (&tg->lock); +throttle_get_config (&tg->ts, &cfg); +qemu_mutex_unlock (&tg->lock); +throttle_config_to_throttle_limits (&cfg, arg); +visit_type_ThrottleLimits (v, name, &arg, errp); +g_free (arg); +} + +static void throttle_group_obj_class_init (ObjectClass *klass,void *class_data) +{ +size_t i =0 ; +UserCreatableClass *ucc =USER_CREATABLE_CLASS (klass); + + ucc->complete = throttle_group_obj_complete; +/* individual properties */ +for (i =0 ; i <sizeof (properties) /sizeof (ThrottleParamInfo); i++) { +object_class_property_add (klass, + properties[i].name, +"int" , + throttle_group_get, + throttle_group_set, +NULL , &properties[i], + &error_abort); + } + +/* ThrottleLimits */ +object_class_property_add (klass, +"limits" ,"ThrottleLimits" , + throttle_group_get_limits, + throttle_group_set_limits, +NULL ,NULL , + &error_abort); +} + +static const TypeInfo throttle_group_info = { + .name =TYPE_THROTTLE_GROUP , + .parent =TYPE_OBJECT , + .class_init = throttle_group_obj_class_init, + .instance_size =sizeof (ThrottleGroup), + .instance_init = throttle_group_obj_init, + .instance_finalize = throttle_group_obj_finalize, + .interfaces = (InterfaceInfo []) { + {TYPE_USER_CREATABLE }, + { } + }, +}; +static void throttle_groups_init (void ) {qemu_mutex_init (&throttle_groups_lock); +type_register_static (&throttle_group_info); } -block_init (throttle_groups_init); +type_init (throttle_groups_init);
include/block/throttle-groups.h +3 -0
@@ -53,6 +53,9 @@ typedef struct ThrottleGroupMember { } ThrottleGroupMember; +#define TYPE_THROTTLE_GROUP "throttle-group" +#define THROTTLE_GROUP (obj) OBJECT_CHECK(ThrottleGroup, (obj), TYPE_THROTTLE_GROUP) +const char *throttle_group_get_name (ThrottleGroupMember *tgm);ThrottleState *throttle_group_incref (const char *name);
include/qemu/throttle-options.h +40 -19
121 lines not on this page · raw message
include/qemu/throttle.h +3 -0
@@ -152,5 +152,8 @@ bool throttle_schedule_timer(ThrottleState *ts, bool is_write);void throttle_account (ThrottleState *ts,bool is_write,uint64_t size); +void throttle_limits_to_config (ThrottleLimits *arg,ThrottleConfig *cfg, +Error **errp); +void throttle_config_to_throttle_limits (ThrottleConfig *cfg,ThrottleLimits *var);#endif
qapi/block-core.json +48 -0
54 lines not on this page · raw message
tests/test-throttle.c +1 -0
@@ -662,6 +662,7 @@ int main(int argc, char **argv)qemu_init_main_loop (&error_fatal); ctx =qemu_get_aio_context ();bdrv_init (); +module_call_init (MODULE_INIT_QOM );do {}while (g_main_context_iteration (NULL , false));
util/throttle.c +151 -0
154 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 5/7 block: add throttle block filter driver
In reply to Manos Pitsidianakisblock/throttle.c uses existing I/O throttle infrastructure inside a block filter driver. I/O operations are intercepted in the filter's read/write coroutines, and referred to block/throttle-groups.c
The driver can be used with the syntax
-drive driver=throttle,file.filename=foo.qcow2, \
limits.iops-total=...,throttle-group=bar
The configuration flags and their semantics are identical to the hardcoded throttling ones.
A node can be created referring to an existing group, and will overwrite its limits if any are specified, otherwise they are retained.
--- block/Makefile.objs | 1 + block/throttle.c | 395 ++++++++++++++++++++++++++++++++++++++++ include/qemu/throttle-options.h | 1 + 3 files changed, 397 insertions(+) create mode 100644 block/throttle.c
block/Makefile.objs +1 -0
@@ -25,6 +25,7 @@ block-obj-y += accounting.o dirty-bitmap.o block-obj-y += write-threshold.o block-obj-y += backup.o block-obj-$(CONFIG_REPLICATION) += replication.o +block-obj-y += throttle.o block-obj-y += crypto.o
block/throttle.c new file +395 -0
395 lines not on this page · raw message
include/qemu/throttle-options.h +1 -0
@@ -29,6 +29,7 @@#define QEMU_OPT_BPS_WRITE_MAX "bps-write-max"#define QEMU_OPT_BPS_WRITE_MAX_LENGTH "bps-write-max-length"#define QEMU_OPT_IOPS_SIZE "iops-size" +#define QEMU_OPT_THROTTLE_GROUP_NAME "throttle-group"#define THROTTLE_OPT_PREFIX "throttling."#define THROTTLE_OPTS \
Signature · 1 line
2.11.0
PATCH v2 6/7 block: add BlockDevOptionsThrottle to QAPI
In reply to Manos PitsidianakisThis is needed to configure throttle filter driver nodes with QAPI.
--- qapi/block-core.json | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
qapi/block-core.json +19 -1
@@ -2222,6 +2222,7 @@ # Drivers that are supported in block device operations. # # @vxhs: Since 2.10 +# @throttle: Since 2.11 # # Since: 2.9 ##
@@ -2231,7 +2232,7 @@ 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh', - 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } + 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } ## # @BlockdevOptionsFile:
@@ -3095,6 +3096,22 @@ '*tls-creds': 'str' } } ## +# @BlockdevOptionsThrottle: +# +# Driver specific block device options for the throttle driver +# +# @throttle-group: the name of the throttle-group object to use. It will be +# created if it doesn't already exist +# @file: reference to or definition of the data source block device +# @limits: ThrottleLimits options +# Since: 2.11 +## +{ 'struct': 'BlockdevOptionsThrottle', + 'data': { '*throttle-group': 'str', + 'file' : 'BlockdevRef', + '*limits' : 'ThrottleLimits' + } } +## # @BlockdevOptions: # # Options for creating a block device. Many options are available for all
@@ -3155,6 +3172,7 @@ 'replication':'BlockdevOptionsReplication', 'sheepdog': 'BlockdevOptionsSheepdog', 'ssh': 'BlockdevOptionsSsh', + 'throttle': 'BlockdevOptionsThrottle', 'vdi': 'BlockdevOptionsGenericFormat', 'vhdx': 'BlockdevOptionsGenericFormat', 'vmdk': 'BlockdevOptionsGenericCOWFormat',
Signature · 1 line
2.11.0
PATCH v2 7/7 block: add throttle block filter driver interface tests
In reply to Manos Pitsidianakis--- tests/qemu-iotests/184 | 237 +++++++++++++++++++++++++++++++++ tests/qemu-iotests/184.out | 319 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 557 insertions(+) create mode 100755 tests/qemu-iotests/184 create mode 100644 tests/qemu-iotests/184.out
tests/qemu-iotests/184 new file +237 -0
@@ -0,0 +1,237 @@ +#!/bin/bash +# +# Test I/O throttle block filter driver interface +# +# Copyright (C) 2017 Manos Pitsidianakis +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +# creator +owner="Manos Pitsidianakis" + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +function do_run_qemu() +{ + echo Testing: "$@" | _filter_imgfmt + $QEMU -nographic -qmp-pretty stdio -serial none "$@" + echo +} + +function run_qemu() +{ + do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp\ + | _filter_qemu_io | _filter_generated_node_ids +} + +_make_test_img 64M +test_throttle=$($QEMU_IMG --help|grep throttle) +[ "$test_throttle" = "" ] && _supported_fmt throttle + +echo +echo "== checking interface ==" + +run_qemu <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "blockdev-add", + "arguments": { + "driver": "$IMGFMT", + "node-name": "disk0", + "file": { + "driver": "file", + "filename": "$TEST_IMG" + } + } +} +{ "execute": "object-add", + "arguments": { + "qom-type": "throttle-group", + "id": "group0", + "props": { + "limits" : { + "iops-total": 1000 + } + } + } +} +{ "execute": "blockdev-add", + "arguments": { + "driver": "throttle", + "node-name": "throttle0", + "throttle-group": "group0", + "file": "disk0" + } +} +{ "execute": "query-named-block-nodes" } +{ "execute": "query-block" } +{ "execute": "quit" } +EOF + +echo +echo "== create anonymous group ==" + +run_qemu <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "blockdev-add", + "arguments": { + "driver": "$IMGFMT", + "node-name": "disk0", + "file": { + "driver": "file", + "filename": "$TEST_IMG" + } + } +} +{ "execute": "blockdev-add", + "arguments": { + "driver": "throttle", + "node-name": "throttle-anonymous", + "limits" : { + "iops-total" : 1000 + }, + "file": "disk0" + } +} +{ "execute": "quit" } +EOF + +echo +echo "== property changes in ThrottleGroup ==" + +run_qemu <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "object-add", + "arguments": { + "qom-type": "throttle-group", + "id": "group0", + "props" : { + "limits": { + "iops-total": 1000 + } + } + } +} +{ "execute" : "qom-get", + "arguments" : { + "path" : "group0", + "property" : "limits" + } +} +{ "execute" : "qom-set", + "arguments" : { + "path" : "group0", + "property" : "limits", + "value" : { + "iops-total" : 0 + } + } +} +{ "execute" : "qom-get", + "arguments" : { + "path" : "group0", + "property" : "limits" + } +} +{ "execute": "blockdev-add", + "arguments": { + "driver": "$IMGFMT", + "node-name": "disk0", + "file": { + "driver": "file", + "filename": "$TEST_IMG" + } + } +} +{ "execute": "blockdev-add", + "arguments": { + "driver": "throttle", + "node-name": "throttle0", + "throttle-group": "group0", + "limits" : { + "iops-total" : 128, + "iops-total-max" : 256, + "iops-total-max-length" : 60 + }, + "file": "disk0" + } +} +{ "execute" : "qom-get", + "arguments" : { + "path" : "group0", + "property" : "limits" + } +} +{ "execute": "quit" } +EOF + +echo +echo "== object creation/set errors ==" + +run_qemu <<EOF +{ "execute": "qmp_capabilities" } +{ "execute": "object-add", + "arguments": { + "qom-type": "throttle-group", + "id": "group0", + "props" : { + "limits": { + "iops-total": 1000 + } + } + } +} +{ "execute" : "qom-set", + "arguments" : { + "path" : "group0", + "property" : "x-iops-total", + "value" : 0 + } +} +{ "execute" : "qom-set", + "arguments" : { + "path" : "group0", + "property" : "limits", + "value" : { + "iops-total" : 10, + "iops-read" : 10 + } + } +} +{ "execute": "quit" } +EOF + +echo +# success, all done +echo "*** done" +rm -f $seq.full +status=0
tests/qemu-iotests/184.out new file +319 -0
319 lines not on this page · raw message
tests/qemu-iotests/group +1 -0
@@ -180,6 +180,7 @@ 181 rw auto migration 182 rw auto quick 183 rw auto migration +184 rw auto quick 185 rw auto 186 rw auto 188 rw auto quick
Signature · 1 line
2.11.0
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Subject: [Qemu-devel] [PATCH v2 0/7] add throttle block driver filter
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
4ff41cf block: add throttle block filter driver interface tests ccf2294 block: add BlockDevOptionsThrottle to QAPI c00da39 block: add throttle block filter driver
c216db8 block: convert ThrottleGroup to object with QOM 92e1316 block: tidy ThrottleGroupMember initializations a3f8bf3 block: add aio_context field in ThrottleGroupMember 88f37da block: move ThrottleGroup membership to ThrottleGroupMember
=== OUTPUT BEGIN ===
Checking PATCH 1/7: block: move ThrottleGroup membership to ThrottleGroupMember...
WARNING: line over 80 characters
#79: FILE: block/block-backend.c:992:
+ throttle_group_co_io_limits_intercept(&blk->public.throttle_group_member,
WARNING: line over 80 characters
#93: FILE: block/block-backend.c:1018:
+ throttle_group_co_io_limits_intercept(&blk->public.throttle_group_member,
WARNING: line over 80 characters
#169: FILE: block/block-backend.c:1966:
+ if (atomic_fetch_inc(&blk->public.throttle_group_member.io_limits_disabled) == 0) {
WARNING: line over 80 characters
#444: FILE: block/throttle-groups.c:274:
+static bool coroutine_fn throttle_group_co_restart_queue(ThrottleGroupMember *tgm,
WARNING: line over 80 characters
#513: FILE: block/throttle-groups.c:333:
+void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm,
WARNING: line over 80 characters
#593: FILE: block/throttle-groups.c:392:
+static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write)
WARNING: line over 80 characters
#868: FILE: include/block/throttle-groups.h:68:
+void coroutine_fn throttle_group_co_io_limits_intercept(ThrottleGroupMember *tgm,
total: 0 errors, 7 warnings, 918 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 2/7: block: add aio_context field in ThrottleGroupMember...
ERROR: line over 90 characters
#47: FILE: block/block-backend.c:1930:
+ throttle_group_register_tgm(&blk->public.throttle_group_member, group, blk_get_aio_context(blk));
total: 1 errors, 0 warnings, 302 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 3/7: block: tidy ThrottleGroupMember initializations... Checking PATCH 4/7: block: convert ThrottleGroup to object with QOM...
WARNING: line over 80 characters
#534: FILE: include/block/throttle-groups.h:57:
+#define THROTTLE_GROUP(obj) OBJECT_CHECK(ThrottleGroup, (obj), TYPE_THROTTLE_GROUP)
WARNING: line over 80 characters
#675: FILE: include/qemu/throttle.h:157:
+void throttle_config_to_throttle_limits(ThrottleConfig *cfg, ThrottleLimits *var);
WARNING: line over 80 characters
#811: FILE: util/throttle.c:559:
+ cfg->buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_total_max_length;
WARNING: line over 80 characters
#827: FILE: util/throttle.c:575:
+ cfg->buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_write_max_length;
WARNING: line over 80 characters
#835: FILE: util/throttle.c:583:
+ cfg->buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_total_max_length;
WARNING: line over 80 characters
#843: FILE: util/throttle.c:591:
+ cfg->buckets[THROTTLE_OPS_READ].burst_length = arg->iops_read_max_length;
WARNING: line over 80 characters
#851: FILE: util/throttle.c:599:
+ cfg->buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_write_max_length;
WARNING: line over 80 characters
#866: FILE: util/throttle.c:614:
+void throttle_config_to_throttle_limits(ThrottleConfig *cfg, ThrottleLimits *var)
WARNING: line over 80 characters
#880: FILE: util/throttle.c:628:
+ var->bps_total_max_length = cfg->buckets[THROTTLE_BPS_TOTAL].burst_length;
WARNING: line over 80 characters
#882: FILE: util/throttle.c:630:
+ var->bps_write_max_length = cfg->buckets[THROTTLE_BPS_WRITE].burst_length;
WARNING: line over 80 characters
#883: FILE: util/throttle.c:631:
+ var->iops_total_max_length = cfg->buckets[THROTTLE_OPS_TOTAL].burst_length;
WARNING: line over 80 characters
#885: FILE: util/throttle.c:633:
+ var->iops_write_max_length = cfg->buckets[THROTTLE_OPS_WRITE].burst_length;
total: 0 errors, 12 warnings, 810 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 5/7: block: add throttle block filter driver...
WARNING: line over 80 characters
#183: FILE: block/throttle.c:143:
+ if (qemu_opt_get(opts, THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_TOTAL_MAX_LENGTH)) {
WARNING: line over 80 characters
#207: FILE: block/throttle.c:167:
+ if (qemu_opt_get(opts, THROTTLE_OPT_PREFIX QEMU_OPT_IOPS_WRITE_MAX_LENGTH)) {
WARNING: line over 80 characters
#418: FILE: block/throttle.c:378:
+ .bdrv_recurse_is_first_non_filter = throttle_recurse_is_first_non_filter,
total: 0 errors, 3 warnings, 409 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 6/7: block: add BlockDevOptionsThrottle to QAPI... Checking PATCH 7/7: block: add throttle block filter driver interface tests... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]