mirror of https://github.com/xemu-project/xemu.git
block: Convert throttle_group_get_name() to BlockBackend
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
31dce3ccca
commit
49d2165d7d
|
@ -1525,7 +1525,7 @@ void blk_update_root_state(BlockBackend *blk)
|
||||||
throttle_group_unref(blk->root_state.throttle_state);
|
throttle_group_unref(blk->root_state.throttle_state);
|
||||||
}
|
}
|
||||||
if (blk->root->bs->throttle_state) {
|
if (blk->root->bs->throttle_state) {
|
||||||
const char *name = throttle_group_get_name(blk->root->bs);
|
const char *name = throttle_group_get_name(blk);
|
||||||
blk->root_state.throttle_group = g_strdup(name);
|
blk->root_state.throttle_group = g_strdup(name);
|
||||||
blk->root_state.throttle_state = throttle_group_incref(name);
|
blk->root_state.throttle_state = throttle_group_incref(name);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -89,7 +89,7 @@ void bdrv_io_limits_update_group(BlockDriverState *bs, const char *group)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this bs is a part of the same group than the one we want */
|
/* this bs is a part of the same group than the one we want */
|
||||||
if (!g_strcmp0(throttle_group_get_name(bs), group)) {
|
if (!g_strcmp0(throttle_group_get_name(bs->blk), group)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk,
|
||||||
info->iops_size = cfg.op_size;
|
info->iops_size = cfg.op_size;
|
||||||
|
|
||||||
info->has_group = true;
|
info->has_group = true;
|
||||||
info->group = g_strdup(throttle_group_get_name(bs));
|
info->group = g_strdup(throttle_group_get_name(bs->blk));
|
||||||
}
|
}
|
||||||
|
|
||||||
info->write_threshold = bdrv_write_threshold_get(bs);
|
info->write_threshold = bdrv_write_threshold_get(bs);
|
||||||
|
|
|
@ -133,16 +133,16 @@ void throttle_group_unref(ThrottleState *ts)
|
||||||
qemu_mutex_unlock(&throttle_groups_lock);
|
qemu_mutex_unlock(&throttle_groups_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the name from a BlockDriverState's ThrottleGroup. The name (and
|
/* Get the name from a BlockBackend's ThrottleGroup. The name (and the pointer)
|
||||||
* the pointer) is guaranteed to remain constant during the lifetime
|
* is guaranteed to remain constant during the lifetime of the group.
|
||||||
* of the group.
|
|
||||||
*
|
*
|
||||||
* @bs: a BlockDriverState that is member of a throttling group
|
* @blk: a BlockBackend that is member of a throttling group
|
||||||
* @ret: the name of the group.
|
* @ret: the name of the group.
|
||||||
*/
|
*/
|
||||||
const char *throttle_group_get_name(BlockDriverState *bs)
|
const char *throttle_group_get_name(BlockBackend *blk)
|
||||||
{
|
{
|
||||||
ThrottleGroup *tg = container_of(bs->throttle_state, ThrottleGroup, ts);
|
ThrottleGroup *tg = container_of(blk_bs(blk)->throttle_state,
|
||||||
|
ThrottleGroup, ts);
|
||||||
return tg->name;
|
return tg->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "qemu/throttle.h"
|
#include "qemu/throttle.h"
|
||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
|
|
||||||
const char *throttle_group_get_name(BlockDriverState *bs);
|
const char *throttle_group_get_name(BlockBackend *blk);
|
||||||
|
|
||||||
ThrottleState *throttle_group_incref(const char *name);
|
ThrottleState *throttle_group_incref(const char *name);
|
||||||
void throttle_group_unref(ThrottleState *ts);
|
void throttle_group_unref(ThrottleState *ts);
|
||||||
|
|
|
@ -598,8 +598,8 @@ static void test_groups(void)
|
||||||
g_assert(bdrv2->throttle_state != NULL);
|
g_assert(bdrv2->throttle_state != NULL);
|
||||||
g_assert(bdrv3->throttle_state != NULL);
|
g_assert(bdrv3->throttle_state != NULL);
|
||||||
|
|
||||||
g_assert(!strcmp(throttle_group_get_name(bdrv1), "bar"));
|
g_assert(!strcmp(throttle_group_get_name(blk1), "bar"));
|
||||||
g_assert(!strcmp(throttle_group_get_name(bdrv2), "foo"));
|
g_assert(!strcmp(throttle_group_get_name(blk2), "foo"));
|
||||||
g_assert(bdrv1->throttle_state == bdrv3->throttle_state);
|
g_assert(bdrv1->throttle_state == bdrv3->throttle_state);
|
||||||
|
|
||||||
/* Setting the config of a group member affects the whole group */
|
/* Setting the config of a group member affects the whole group */
|
||||||
|
|
Loading…
Reference in New Issue