mirror of https://github.com/xemu-project/xemu.git
block: drop unused permission update functions
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20210428151804.439460-32-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
72373e40fb
commit
058acc4708
103
block.c
103
block.c
|
@ -1987,11 +1987,6 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q,
|
|
||||||
uint64_t new_used_perm,
|
|
||||||
uint64_t new_shared_perm,
|
|
||||||
Error **errp);
|
|
||||||
|
|
||||||
typedef struct BlockReopenQueueEntry {
|
typedef struct BlockReopenQueueEntry {
|
||||||
bool prepared;
|
bool prepared;
|
||||||
bool perms_checked;
|
bool perms_checked;
|
||||||
|
@ -2426,56 +2421,12 @@ static int bdrv_check_perm_common(GSList *list, BlockReopenQueue *q,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q,
|
|
||||||
uint64_t cumulative_perms,
|
|
||||||
uint64_t cumulative_shared_perms, Error **errp)
|
|
||||||
{
|
|
||||||
g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs);
|
|
||||||
return bdrv_check_perm_common(list, q, true, cumulative_perms,
|
|
||||||
cumulative_shared_perms, NULL, errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bdrv_list_refresh_perms(GSList *list, BlockReopenQueue *q,
|
static int bdrv_list_refresh_perms(GSList *list, BlockReopenQueue *q,
|
||||||
Transaction *tran, Error **errp)
|
Transaction *tran, Error **errp)
|
||||||
{
|
{
|
||||||
return bdrv_check_perm_common(list, q, false, 0, 0, tran, errp);
|
return bdrv_check_perm_common(list, q, false, 0, 0, tran, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Notifies drivers that after a previous bdrv_check_perm() call, the
|
|
||||||
* permission update is not performed and any preparations made for it (e.g.
|
|
||||||
* taken file locks) need to be undone.
|
|
||||||
*/
|
|
||||||
static void bdrv_node_abort_perm_update(BlockDriverState *bs)
|
|
||||||
{
|
|
||||||
BlockDriver *drv = bs->drv;
|
|
||||||
BdrvChild *c;
|
|
||||||
|
|
||||||
if (!drv) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bdrv_drv_set_perm_abort(bs);
|
|
||||||
|
|
||||||
QLIST_FOREACH(c, &bs->children, next) {
|
|
||||||
bdrv_child_set_perm_abort(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bdrv_list_abort_perm_update(GSList *list)
|
|
||||||
{
|
|
||||||
for ( ; list; list = list->next) {
|
|
||||||
bdrv_node_abort_perm_update((BlockDriverState *)list->data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__((unused))
|
|
||||||
static void bdrv_abort_perm_update(BlockDriverState *bs)
|
|
||||||
{
|
|
||||||
g_autoptr(GSList) list = bdrv_topological_dfs(NULL, NULL, bs);
|
|
||||||
return bdrv_list_abort_perm_update(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bdrv_node_set_perm(BlockDriverState *bs)
|
static void bdrv_node_set_perm(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
|
@ -2557,60 +2508,6 @@ char *bdrv_perm_names(uint64_t perm)
|
||||||
return g_string_free(result, FALSE);
|
return g_string_free(result, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Checks whether a new reference to @bs can be added if the new user requires
|
|
||||||
* @new_used_perm/@new_shared_perm as its permissions. If @ignore_children is
|
|
||||||
* set, the BdrvChild objects in this list are ignored in the calculations;
|
|
||||||
* this allows checking permission updates for an existing reference.
|
|
||||||
*
|
|
||||||
* Needs to be followed by a call to either bdrv_set_perm() or
|
|
||||||
* bdrv_abort_perm_update(). */
|
|
||||||
__attribute__((unused))
|
|
||||||
static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *q,
|
|
||||||
uint64_t new_used_perm,
|
|
||||||
uint64_t new_shared_perm,
|
|
||||||
Error **errp)
|
|
||||||
{
|
|
||||||
BdrvChild *c;
|
|
||||||
uint64_t cumulative_perms = new_used_perm;
|
|
||||||
uint64_t cumulative_shared_perms = new_shared_perm;
|
|
||||||
|
|
||||||
|
|
||||||
/* There is no reason why anyone couldn't tolerate write_unchanged */
|
|
||||||
assert(new_shared_perm & BLK_PERM_WRITE_UNCHANGED);
|
|
||||||
|
|
||||||
QLIST_FOREACH(c, &bs->parents, next_parent) {
|
|
||||||
if ((new_used_perm & c->shared_perm) != new_used_perm) {
|
|
||||||
char *user = bdrv_child_user_desc(c);
|
|
||||||
char *perm_names = bdrv_perm_names(new_used_perm & ~c->shared_perm);
|
|
||||||
|
|
||||||
error_setg(errp, "Conflicts with use by %s as '%s', which does not "
|
|
||||||
"allow '%s' on %s",
|
|
||||||
user, c->name, perm_names, bdrv_get_node_name(c->bs));
|
|
||||||
g_free(user);
|
|
||||||
g_free(perm_names);
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((c->perm & new_shared_perm) != c->perm) {
|
|
||||||
char *user = bdrv_child_user_desc(c);
|
|
||||||
char *perm_names = bdrv_perm_names(c->perm & ~new_shared_perm);
|
|
||||||
|
|
||||||
error_setg(errp, "Conflicts with use by %s as '%s', which uses "
|
|
||||||
"'%s' on %s",
|
|
||||||
user, c->name, perm_names, bdrv_get_node_name(c->bs));
|
|
||||||
g_free(user);
|
|
||||||
g_free(perm_names);
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
cumulative_perms |= c->perm;
|
|
||||||
cumulative_shared_perms &= c->shared_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bdrv_check_perm(bs, q, cumulative_perms, cumulative_shared_perms,
|
|
||||||
errp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bdrv_refresh_perms(BlockDriverState *bs, Error **errp)
|
static int bdrv_refresh_perms(BlockDriverState *bs, Error **errp)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue