mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
qapi: block-stream: add "bottom" argument
The code already don't freeze base node and we try to make it prepared for the situation when base node is changed during the operation. In other words, block-stream doesn't own base node. Let's introduce a new interface which should replace the current one, which will in better relations with the code. Specifying bottom node instead of base, and requiring it to be non-filter gives us the following benefits: - drop difference between above_base and base_overlay, which will be renamed to just bottom, when old interface dropped - clean way to work with parallel streams/commits on the same backing chain, which otherwise become a problem when we introduce a filter for stream job - cleaner interface. Nobody will surprised the fact that base node may disappear during block-stream, when there is no word about "base" in the interface. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20201216061703.70908-11-vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
000e5a1cda
commit
7f4a396d76
5 changed files with 94 additions and 31 deletions
|
@ -221,6 +221,7 @@ static const BlockJobDriver stream_job_driver = {
|
|||
|
||||
void stream_start(const char *job_id, BlockDriverState *bs,
|
||||
BlockDriverState *base, const char *backing_file_str,
|
||||
BlockDriverState *bottom,
|
||||
int creation_flags, int64_t speed,
|
||||
BlockdevOnError on_error,
|
||||
const char *filter_node_name,
|
||||
|
@ -230,25 +231,42 @@ void stream_start(const char *job_id, BlockDriverState *bs,
|
|||
BlockDriverState *iter;
|
||||
bool bs_read_only;
|
||||
int basic_flags = BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED;
|
||||
BlockDriverState *base_overlay = bdrv_find_overlay(bs, base);
|
||||
BlockDriverState *base_overlay;
|
||||
BlockDriverState *above_base;
|
||||
|
||||
if (!base_overlay) {
|
||||
error_setg(errp, "'%s' is not in the backing chain of '%s'",
|
||||
base->node_name, bs->node_name);
|
||||
return;
|
||||
}
|
||||
assert(!(base && bottom));
|
||||
assert(!(backing_file_str && bottom));
|
||||
|
||||
/*
|
||||
* Find the node directly above @base. @base_overlay is a COW overlay, so
|
||||
* it must have a bdrv_cow_child(), but it is the immediate overlay of
|
||||
* @base, so between the two there can only be filters.
|
||||
*/
|
||||
above_base = base_overlay;
|
||||
if (bdrv_cow_bs(above_base) != base) {
|
||||
above_base = bdrv_cow_bs(above_base);
|
||||
while (bdrv_filter_bs(above_base) != base) {
|
||||
above_base = bdrv_filter_bs(above_base);
|
||||
if (bottom) {
|
||||
/*
|
||||
* New simple interface. The code is written in terms of old interface
|
||||
* with @base parameter (still, it doesn't freeze link to base, so in
|
||||
* this mean old code is correct for new interface). So, for now, just
|
||||
* emulate base_overlay and above_base. Still, when old interface
|
||||
* finally removed, we should refactor code to use only "bottom", but
|
||||
* not "*base*" things.
|
||||
*/
|
||||
assert(!bottom->drv->is_filter);
|
||||
base_overlay = above_base = bottom;
|
||||
} else {
|
||||
base_overlay = bdrv_find_overlay(bs, base);
|
||||
if (!base_overlay) {
|
||||
error_setg(errp, "'%s' is not in the backing chain of '%s'",
|
||||
base->node_name, bs->node_name);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the node directly above @base. @base_overlay is a COW overlay,
|
||||
* so it must have a bdrv_cow_child(), but it is the immediate overlay
|
||||
* of @base, so between the two there can only be filters.
|
||||
*/
|
||||
above_base = base_overlay;
|
||||
if (bdrv_cow_bs(above_base) != base) {
|
||||
above_base = bdrv_cow_bs(above_base);
|
||||
while (bdrv_filter_bs(above_base) != base) {
|
||||
above_base = bdrv_filter_bs(above_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue