BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const char *child_name,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
AioContext *ctx,
uint64_t perm, uint64_t shared_perm,
void *opaque, Error **errp)
.bs = NULL,
.name = g_strdup(child_name),
.klass = child_class,
+ .role = child_role,
.perm = perm,
.shared_perm = shared_perm,
.opaque = opaque,
BlockDriverState *child_bs,
const char *child_name,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
Error **errp)
{
BdrvChild *child;
perm, shared_perm, &perm, &shared_perm);
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);
if (child == NULL) {
return NULL;
}
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
* inherits_from pointed recursively to bs then let's update it to
* point directly to bs (else it will become NULL). */
QDict *options, const char *bdref_key,
BlockDriverState *parent,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
bool allow_none, Error **errp)
{
BlockDriverState *bs;
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);
}
/*
source->supported_zero_flags);
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) {
bdrv_unref(target);
bdrv_unref(top);
/* Open the image file */
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) {
ret = -EINVAL;
error_propagate(errp, local_err);
}
/* 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);
if (local_err) {
ret = -EINVAL;
}
/* Open the log file */
- s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, false,
- &local_err);
+ s->log_file = bdrv_open_child(NULL, options, "log", bs, &child_file, 0,
+ false, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
/* Open the image file */
bs->file = bdrv_open_child(NULL, options, "image",
- bs, &child_file, false, &local_err);
+ bs, &child_file, 0, false, &local_err);
if (local_err) {
ret = -EINVAL;
error_propagate(errp, local_err);
/* Open the raw file */
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) {
ret = -EINVAL;
error_propagate(errp, local_err);
/* Open the test file */
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);
if (local_err) {
ret = -EINVAL;
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);
if (!blk->root) {
blk_unref(blk);
{
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
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);
if (blk->root == NULL) {
return -EPERM;
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);
if (!bs->file) {
return -EINVAL;
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);
if (!bs->file) {
return -EINVAL;
static int cor_open(BlockDriverState *bs, QDict *options, int flags,
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);
if (!bs->file) {
return -EINVAL;
unsigned int cflags = 0;
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);
if (!bs->file) {
return -EINVAL;
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);
if (!bs->file) {
return -EINVAL;
static int compress_open(BlockDriverState *bs, QDict *options, int flags,
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);
if (!bs->file) {
return -EINVAL;
Error *local_err = NULL;
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);
if (!bs->file) {
return -EINVAL;
qdict_extract_subqdict(options, &encryptopts, "encrypt.");
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);
if (!bs->file) {
ret = -EINVAL;
/* Open external data file */
s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file,
- true, &local_err);
+ 0, true, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
if (!s->data_file && s->image_data_file) {
s->data_file = bdrv_open_child(s->image_data_file, options,
- "data-file", bs, &child_file,
+ "data-file", bs, &child_file, 0,
false, errp);
if (!s->data_file) {
ret = -EINVAL;
.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);
if (!bs->file) {
return -EINVAL;
.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);
if (!bs->file) {
return -EINVAL;
assert(ret < 32);
s->children[i] = bdrv_open_child(NULL, options, indexstr, bs,
- &child_format, false, &local_err);
+ &child_format, 0, false, &local_err);
if (local_err) {
ret = -EINVAL;
goto close_exit;
/* We can safely add the child now */
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) {
s->next_child_index--;
goto out;
BDRVRawState *s = bs->opaque;
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);
if (!bs->file) {
return -EINVAL;
const char *mode;
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);
if (!bs->file) {
return -EINVAL;
int ret;
bs->file = bdrv_open_child(NULL, options, "file", bs,
- &child_file, false, errp);
+ &child_file, 0, false, errp);
if (!bs->file) {
return -EINVAL;
}
Error *local_err = NULL;
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);
if (!bs->file) {
return -EINVAL;
uint64_t signature;
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);
if (!bs->file) {
return -EINVAL;
assert(ret < 32);
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);
if (local_err) {
error_propagate(errp, local_err);
uint32_t magic;
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);
if (!bs->file) {
return -EINVAL;
int ret;
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);
if (!bs->file) {
return -EINVAL;
options = qdict_new();
qdict_put_str(options, "write-target.driver", "qcow");
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);
if (!s->qcow) {
ret = -EINVAL;
if (job->job.aio_context != qemu_get_aio_context()) {
aio_context_release(job->job.aio_context);
}
- c = bdrv_root_attach_child(bs, name, &child_job, job->job.aio_context,
- perm, shared_perm, job, errp);
+ c = bdrv_root_attach_child(bs, name, &child_job, 0,
+ job->job.aio_context, perm, shared_perm, job,
+ errp);
if (job->job.aio_context != qemu_get_aio_context()) {
aio_context_acquire(job->job.aio_context);
}
QDict *options, const char *bdref_key,
BlockDriverState* parent,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
bool allow_none, Error **errp);
BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
BlockDriverState *child_bs,
const char *child_name,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
Error **errp);
bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);
BlockDriverState *bs;
char *name;
const BdrvChildClass *klass;
+ BdrvChildRole role;
void *opaque;
/**
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
const char *child_name,
const BdrvChildClass *child_class,
+ BdrvChildRole child_role,
AioContext *ctx,
uint64_t perm, uint64_t shared_perm,
void *opaque, Error **errp);
null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
&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
* it will stall until a drain occurs */
child_bs->total_sectors = 65536 >> BDRV_SECTOR_BITS;
/* Takes our reference to child_bs */
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
* (for detach_instead_of_delete == true) */
null_bs = bdrv_open("null-co://", NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL,
&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_insert_bs(blk, bs, &error_abort);
bdrv_ref(data->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)
/* Set child relationships */
bdrv_ref(b);
bdrv_ref(a);
- child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, &error_abort);
- child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, &error_abort);
+ child_b = bdrv_attach_child(parent_b, b, "PB-B", &child_file, 0,
+ &error_abort);
+ child_a = bdrv_attach_child(parent_b, a, "PB-A", &child_backing, 0,
+ &error_abort);
bdrv_ref(a);
bdrv_attach_child(parent_a, a, "PA-A",
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_b->refcnt, ==, 1);
/* Takes the reference to chain[i - 1] */
chain[i]->backing = bdrv_attach_child(chain[i], chain[i - 1],
"chain", &chain_child_class,
- &error_abort);
+ 0, &error_abort);
}
}
bdrv_ref(old_child_bs);
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++) {
bdrv_drained_begin(old_child_bs);
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_set_backing_hd(target, bs, &error_abort);
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);
g_assert(target->backing->bs == bs);