mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
block: add throttle block filter driver
block/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,throttle-group=bar which registers the throttle filter node with the ThrottleGroup 'bar'. The given group must be created beforehand with object-add or -object. Reviewed-by: Alberto Garcia <berto@igalia.com> Signed-off-by: Manos Pitsidianakis <el13635@mail.ntua.gr> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
432d889e55
commit
d8e7d87ec4
6 changed files with 275 additions and 2 deletions
|
@ -101,6 +101,14 @@ static ThrottleGroup *throttle_group_by_name(const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* This function reads throttle_groups and must be called under the global
|
||||
* mutex.
|
||||
*/
|
||||
bool throttle_group_exists(const char *name)
|
||||
{
|
||||
return throttle_group_by_name(name) != NULL;
|
||||
}
|
||||
|
||||
/* Increments the reference count of a ThrottleGroup given its name.
|
||||
*
|
||||
* If no ThrottleGroup is found with the given name a new one is
|
||||
|
@ -543,6 +551,11 @@ void throttle_group_unregister_tgm(ThrottleGroupMember *tgm)
|
|||
ThrottleGroupMember *token;
|
||||
int i;
|
||||
|
||||
if (!ts) {
|
||||
/* Discard already unregistered tgm */
|
||||
return;
|
||||
}
|
||||
|
||||
assert(tgm->pending_reqs[0] == 0 && tgm->pending_reqs[1] == 0);
|
||||
assert(qemu_co_queue_empty(&tgm->throttled_reqs[0]));
|
||||
assert(qemu_co_queue_empty(&tgm->throttled_reqs[1]));
|
||||
|
@ -709,7 +722,7 @@ static void throttle_group_obj_complete(UserCreatable *obj, Error **errp)
|
|||
assert(tg->name);
|
||||
|
||||
/* error if name is duplicate */
|
||||
if (throttle_group_by_name(tg->name) != NULL) {
|
||||
if (throttle_group_exists(tg->name)) {
|
||||
error_setg(errp, "A group with this name already exists");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue