block: Add BdrvChildRole to BdrvChild

For now, it is always set to 0.  Later patches in this series will
ensure that all callers pass an appropriate combination of flags.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200513110544.176672-6-mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Max Reitz 2020-05-13 13:05:15 +02:00 committed by Kevin Wolf
parent 3284bcf430
commit 258b776515
31 changed files with 62 additions and 49 deletions

11
block.c
View File

@ -2571,6 +2571,7 @@ static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs)
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const char *child_name, const char *child_name,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
AioContext *ctx, AioContext *ctx,
uint64_t perm, uint64_t shared_perm, uint64_t perm, uint64_t shared_perm,
void *opaque, Error **errp) void *opaque, Error **errp)
@ -2592,6 +2593,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
.bs = NULL, .bs = NULL,
.name = g_strdup(child_name), .name = g_strdup(child_name),
.klass = child_class, .klass = child_class,
.role = child_role,
.perm = perm, .perm = perm,
.shared_perm = shared_perm, .shared_perm = shared_perm,
.opaque = opaque, .opaque = opaque,
@ -2644,6 +2646,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
BlockDriverState *child_bs, BlockDriverState *child_bs,
const char *child_name, const char *child_name,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
Error **errp) Error **errp)
{ {
BdrvChild *child; BdrvChild *child;
@ -2656,7 +2659,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
perm, shared_perm, &perm, &shared_perm); perm, shared_perm, &perm, &shared_perm);
child = bdrv_root_attach_child(child_bs, child_name, child_class, child = bdrv_root_attach_child(child_bs, child_name, child_class,
bdrv_get_aio_context(parent_bs), child_role, bdrv_get_aio_context(parent_bs),
perm, shared_perm, parent_bs, errp); perm, shared_perm, parent_bs, errp);
if (child == NULL) { if (child == NULL) {
return NULL; return NULL;
@ -2774,7 +2777,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
} }
bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_backing, bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_backing,
errp); 0, errp);
/* If backing_hd was already part of bs's backing chain, and /* If backing_hd was already part of bs's backing chain, and
* inherits_from pointed recursively to bs then let's update it to * inherits_from pointed recursively to bs then let's update it to
* point directly to bs (else it will become NULL). */ * point directly to bs (else it will become NULL). */
@ -2965,6 +2968,7 @@ BdrvChild *bdrv_open_child(const char *filename,
QDict *options, const char *bdref_key, QDict *options, const char *bdref_key,
BlockDriverState *parent, BlockDriverState *parent,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
bool allow_none, Error **errp) bool allow_none, Error **errp)
{ {
BlockDriverState *bs; BlockDriverState *bs;
@ -2975,7 +2979,8 @@ BdrvChild *bdrv_open_child(const char *filename,
return NULL; return NULL;
} }
return bdrv_attach_child(parent, bs, bdref_key, child_class, errp); return bdrv_attach_child(parent, bs, bdref_key, child_class, child_role,
errp);
} }
/* /*

View File

@ -214,7 +214,8 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
source->supported_zero_flags); source->supported_zero_flags);
bdrv_ref(target); bdrv_ref(target);
state->target = bdrv_attach_child(top, target, "target", &child_file, errp); state->target = bdrv_attach_child(top, target, "target", &child_file, 0,
errp);
if (!state->target) { if (!state->target) {
bdrv_unref(target); bdrv_unref(target);
bdrv_unref(top); bdrv_unref(top);

View File

@ -497,7 +497,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the image file */ /* Open the image file */
bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image",
bs, &child_file, false, &local_err); bs, &child_file, 0, false, &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
error_propagate(errp, local_err); error_propagate(errp, local_err);

View File

@ -157,7 +157,7 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
} }
/* Open the file */ /* Open the file */
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
&local_err); &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
@ -166,8 +166,8 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
} }
/* Open the log file */ /* Open the log file */
s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false, s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, 0,
&local_err); false, &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
error_propagate(errp, local_err); error_propagate(errp, local_err);

View File

@ -28,7 +28,7 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the image file */ /* Open the image file */
bs->file = bdrv_open_child(NULL, options, "image", bs->file = bdrv_open_child(NULL, options, "image",
bs, &child_file, false, &local_err); bs, &child_file, 0, false, &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
error_propagate(errp, local_err); error_propagate(errp, local_err);

View File

@ -125,7 +125,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the raw file */ /* Open the raw file */
bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw", bs->file = bdrv_open_child(qemu_opt_get(opts, "x-raw"), options, "raw",
bs, &child_file, false, &local_err); bs, &child_file, 0, false, &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
error_propagate(errp, local_err); error_propagate(errp, local_err);
@ -134,7 +134,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
/* Open the test file */ /* Open the test file */
s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, s->test_file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options,
"test", bs, &child_format, false, "test", bs, &child_format, 0, false,
&local_err); &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;

View File

@ -423,7 +423,7 @@ BlockBackend *blk_new_open(const char *filename, const char *reference,
return NULL; return NULL;
} }
blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx, blk->root = bdrv_root_attach_child(bs, "root", &child_root, 0, blk->ctx,
perm, BLK_PERM_ALL, blk, errp); perm, BLK_PERM_ALL, blk, errp);
if (!blk->root) { if (!blk->root) {
blk_unref(blk); blk_unref(blk);
@ -834,7 +834,7 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp)
{ {
ThrottleGroupMember *tgm = &blk->public.throttle_group_member; ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
bdrv_ref(bs); bdrv_ref(bs);
blk->root = bdrv_root_attach_child(bs, "root", &child_root, blk->ctx, blk->root = bdrv_root_attach_child(bs, "root", &child_root, 0, blk->ctx,
blk->perm, blk->shared_perm, blk, errp); blk->perm, blk->shared_perm, blk, errp);
if (blk->root == NULL) { if (blk->root == NULL) {
return -EPERM; return -EPERM;

View File

@ -110,7 +110,7 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
return ret; return ret;
} }
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -71,7 +71,7 @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
return ret; return ret;
} }
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -28,7 +28,7 @@
static int cor_open(BlockDriverState *bs, QDict *options, int flags, static int cor_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
{ {
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
errp); errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -218,7 +218,7 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
unsigned int cflags = 0; unsigned int cflags = 0;
QDict *cryptoopts = NULL; QDict *cryptoopts = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -439,7 +439,7 @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
return ret; return ret;
} }
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -30,7 +30,7 @@
static int compress_open(BlockDriverState *bs, QDict *options, int flags, static int compress_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp) Error **errp)
{ {
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0, false,
errp); errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -739,7 +739,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
Error *local_err = NULL; Error *local_err = NULL;
char *buf; char *buf;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -130,7 +130,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
qdict_extract_subqdict(options, &encryptopts, "encrypt."); qdict_extract_subqdict(options, &encryptopts, "encrypt.");
encryptfmt = qdict_get_try_str(encryptopts, "format"); encryptfmt = qdict_get_try_str(encryptopts, "format");
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
ret = -EINVAL; ret = -EINVAL;

View File

@ -1591,7 +1591,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
/* Open external data file */ /* Open external data file */
s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file, s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file,
true, &local_err); 0, true, &local_err);
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
ret = -EINVAL; ret = -EINVAL;
@ -1601,7 +1601,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) { if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
if (!s->data_file && s->image_data_file) { if (!s->data_file && s->image_data_file) {
s->data_file = bdrv_open_child(s->image_data_file, options, s->data_file = bdrv_open_child(s->image_data_file, options,
"data-file", bs, &child_file, "data-file", bs, &child_file, 0,
false, errp); false, errp);
if (!s->data_file) { if (!s->data_file) {
ret = -EINVAL; ret = -EINVAL;
@ -1863,7 +1863,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
.ret = -EINPROGRESS .ret = -EINPROGRESS
}; };
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -547,7 +547,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
.ret = -EINPROGRESS .ret = -EINPROGRESS
}; };
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -977,7 +977,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
assert(ret < 32); assert(ret < 32);
s->children[i] = bdrv_open_child(NULL, options, indexstr, bs, s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
&child_format, false, &local_err); &child_format, 0, false, &local_err);
if (local_err) { if (local_err) {
ret = -EINVAL; ret = -EINVAL;
goto close_exit; goto close_exit;
@ -1053,7 +1053,7 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
/* We can safely add the child now */ /* We can safely add the child now */
bdrv_ref(child_bs); bdrv_ref(child_bs);
child = bdrv_attach_child(bs, child_bs, indexstr, &child_format, errp); child = bdrv_attach_child(bs, child_bs, indexstr, &child_format, 0, errp);
if (child == NULL) { if (child == NULL) {
s->next_child_index--; s->next_child_index--;
goto out; goto out;

View File

@ -428,7 +428,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags,
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
int ret; int ret;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -90,7 +90,7 @@ static int replication_open(BlockDriverState *bs, QDict *options,
const char *mode; const char *mode;
const char *top_id; const char *top_id;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -82,7 +82,7 @@ static int throttle_open(BlockDriverState *bs, QDict *options,
int ret; int ret;
bs->file = bdrv_open_child(NULL, options, "file", bs, bs->file = bdrv_open_child(NULL, options, "file", bs,
&child_file, false, errp); &child_file, 0, false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;
} }

View File

@ -378,7 +378,7 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
Error *local_err = NULL; Error *local_err = NULL;
QemuUUID uuid_link, uuid_parent; QemuUUID uuid_link, uuid_parent;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -996,7 +996,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags,
uint64_t signature; uint64_t signature;
Error *local_err = NULL; Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -1152,7 +1152,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
assert(ret < 32); assert(ret < 32);
extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix, extent_file = bdrv_open_child(extent_path, options, extent_opt_prefix,
bs, &child_file, false, &local_err); bs, &child_file, 0, false, &local_err);
g_free(extent_path); g_free(extent_path);
if (local_err) { if (local_err) {
error_propagate(errp, local_err); error_propagate(errp, local_err);
@ -1257,7 +1257,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags,
uint32_t magic; uint32_t magic;
Error *local_err = NULL; Error *local_err = NULL;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -228,7 +228,7 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
int ret; int ret;
int64_t bs_size; int64_t bs_size;
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, 0,
false, errp); false, errp);
if (!bs->file) { if (!bs->file) {
return -EINVAL; return -EINVAL;

View File

@ -3183,7 +3183,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp)
options = qdict_new(); options = qdict_new();
qdict_put_str(options, "write-target.driver", "qcow"); qdict_put_str(options, "write-target.driver", "qcow");
s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs, s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs,
&child_vvfat_qcow, false, errp); &child_vvfat_qcow, 0, false, errp);
qobject_unref(options); qobject_unref(options);
if (!s->qcow) { if (!s->qcow) {
ret = -EINVAL; ret = -EINVAL;

View File

@ -217,8 +217,9 @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
if (job->job.aio_context != qemu_get_aio_context()) { if (job->job.aio_context != qemu_get_aio_context()) {
aio_context_release(job->job.aio_context); aio_context_release(job->job.aio_context);
} }
c = bdrv_root_attach_child(bs, name, &child_job, job->job.aio_context, c = bdrv_root_attach_child(bs, name, &child_job, 0,
perm, shared_perm, job, errp); job->job.aio_context, perm, shared_perm, job,
errp);
if (job->job.aio_context != qemu_get_aio_context()) { if (job->job.aio_context != qemu_get_aio_context()) {
aio_context_acquire(job->job.aio_context); aio_context_acquire(job->job.aio_context);
} }

View File

@ -353,6 +353,7 @@ BdrvChild *bdrv_open_child(const char *filename,
QDict *options, const char *bdref_key, QDict *options, const char *bdref_key,
BlockDriverState* parent, BlockDriverState* parent,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
bool allow_none, Error **errp); bool allow_none, Error **errp);
BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
@ -598,6 +599,7 @@ BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
BlockDriverState *child_bs, BlockDriverState *child_bs,
const char *child_name, const char *child_name,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
Error **errp); Error **errp);
bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);

View File

@ -746,6 +746,7 @@ struct BdrvChild {
BlockDriverState *bs; BlockDriverState *bs;
char *name; char *name;
const BdrvChildClass *klass; const BdrvChildClass *klass;
BdrvChildRole role;
void *opaque; void *opaque;
/** /**
@ -1233,6 +1234,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs, BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const char *child_name, const char *child_name,
const BdrvChildClass *child_class, const BdrvChildClass *child_class,
BdrvChildRole child_role,
AioContext *ctx, AioContext *ctx,
uint64_t perm, uint64_t shared_perm, uint64_t perm, uint64_t shared_perm,
void *opaque, Error **errp); void *opaque, Error **errp);

View File

@ -1202,7 +1202,7 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
&error_abort); &error_abort);
bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort); bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_abort);
/* This child will be the one to pass to requests through to, and /* This child will be the one to pass to requests through to, and
* it will stall until a drain occurs */ * it will stall until a drain occurs */
@ -1211,13 +1211,13 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
child_bs->total_sectors = 65536 >> BDRV_SECTOR_BITS; child_bs->total_sectors = 65536 >> BDRV_SECTOR_BITS;
/* Takes our reference to child_bs */ /* Takes our reference to child_bs */
tts->wait_child = bdrv_attach_child(bs, child_bs, "wait-child", &child_file, tts->wait_child = bdrv_attach_child(bs, child_bs, "wait-child", &child_file,
&error_abort); 0, &error_abort);
/* This child is just there to be deleted /* This child is just there to be deleted
* (for detach_instead_of_delete == true) */ * (for detach_instead_of_delete == true) */
null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
&error_abort); &error_abort);
bdrv_attach_child(bs, null_bs, "null-child", &child_file, &error_abort); bdrv_attach_child(bs, null_bs, "null-child", &child_file, 0, &error_abort);
blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); blk = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
blk_insert_bs(blk, bs, &error_abort); blk_insert_bs(blk, bs, &error_abort);
@ -1314,7 +1314,7 @@ static void detach_indirect_bh(void *opaque)
bdrv_ref(data->c); bdrv_ref(data->c);
data->child_c = bdrv_attach_child(data->parent_b, data->c, "PB-C", data->child_c = bdrv_attach_child(data->parent_b, data->c, "PB-C",
&child_file, &error_abort); &child_file, 0, &error_abort);
} }
static void detach_by_parent_aio_cb(void *opaque, int ret) static void detach_by_parent_aio_cb(void *opaque, int ret)
@ -1396,13 +1396,15 @@ static void test_detach_indirect(bool by_parent_cb)
/* Set child relationships */ /* Set child relationships */
bdrv_ref(b); bdrv_ref(b);
bdrv_ref(a); bdrv_ref(a);
child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, &error_abort); child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0,
child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, &error_abort); &error_abort);
child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, 0,
&error_abort);
bdrv_ref(a); bdrv_ref(a);
bdrv_attach_child(parent_a, a, "PA-A", bdrv_attach_child(parent_a, a, "PA-A",
by_parent_cb ? &child_file : &detach_by_driver_cb_class, by_parent_cb ? &child_file : &detach_by_driver_cb_class,
&error_abort); 0, &error_abort);
g_assert_cmpint(parent_a->refcnt, ==, 1); g_assert_cmpint(parent_a->refcnt, ==, 1);
g_assert_cmpint(parent_b->refcnt, ==, 1); g_assert_cmpint(parent_b->refcnt, ==, 1);
@ -1813,7 +1815,7 @@ static void test_drop_intermediate_poll(void)
/* Takes the reference to chain[i - 1] */ /* Takes the reference to chain[i - 1] */
chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1], chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1],
"chain", &chain_child_class, "chain", &chain_child_class,
&error_abort); 0, &error_abort);
} }
} }
@ -2031,7 +2033,7 @@ static void do_test_replace_child_mid_drain(int old_drain_count,
bdrv_ref(old_child_bs); bdrv_ref(old_child_bs);
parent_bs->backing = bdrv_attach_child(parent_bs, old_child_bs, "child", parent_bs->backing = bdrv_attach_child(parent_bs, old_child_bs, "child",
&child_backing, &error_abort); &child_backing, 0, &error_abort);
for (i = 0; i < old_drain_count; i++) { for (i = 0; i < old_drain_count; i++) {
bdrv_drained_begin(old_child_bs); bdrv_drained_begin(old_child_bs);

View File

@ -111,7 +111,7 @@ static void test_update_perm_tree(void)
blk_insert_bs(root, bs, &error_abort); blk_insert_bs(root, bs, &error_abort);
bdrv_attach_child(filter, bs, "child", &child_file, &error_abort); bdrv_attach_child(filter, bs, "child", &child_file, 0, &error_abort);
bdrv_append(filter, bs, &local_err); bdrv_append(filter, bs, &local_err);
@ -177,7 +177,7 @@ static void test_should_update_child(void)
bdrv_set_backing_hd(target, bs, &error_abort); bdrv_set_backing_hd(target, bs, &error_abort);
g_assert(target->backing->bs == bs); g_assert(target->backing->bs == bs);
bdrv_attach_child(filter, target, "target", &child_file, &error_abort); bdrv_attach_child(filter, target, "target", &child_file, 0, &error_abort);
bdrv_append(filter, bs, &error_abort); bdrv_append(filter, bs, &error_abort);
g_assert(target->backing->bs == bs); g_assert(target->backing->bs == bs);