* Returns the options and flags that bs->file should get if a protocol driver
* is expected, based on the given options and flags for the parent BDS
*/
-static void bdrv_inherited_options(BdrvChildRole role,
+static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_format,
int *child_flags, QDict *child_options,
int parent_flags, QDict *parent_options)
{
* flags for the parent BDS
*/
static void bdrv_inherited_fmt_options(BdrvChildRole role,
+ bool parent_is_format,
int *child_flags, QDict *child_options,
int parent_flags, QDict *parent_options)
{
- child_file.inherit_options(role, child_flags, child_options,
+ child_file.inherit_options(role, parent_is_format,
+ child_flags, child_options,
parent_flags, parent_options);
*child_flags &= ~(BDRV_O_PROTOCOL | BDRV_O_NO_IO);
* Returns the options and flags that bs->backing should get, based on the
* given options and flags for the parent BDS
*/
-static void bdrv_backing_options(BdrvChildRole role,
+static void bdrv_backing_options(BdrvChildRole role, bool parent_is_format,
int *child_flags, QDict *child_options,
int parent_flags, QDict *parent_options)
{
bs->explicit_options = qdict_clone_shallow(options);
if (child_class) {
+ bool parent_is_format;
+
+ if (parent->drv) {
+ parent_is_format = parent->drv->is_format;
+ } else {
+ /*
+ * parent->drv is not set yet because this node is opened for
+ * (potential) format probing. That means that @parent is going
+ * to be a format node.
+ */
+ parent_is_format = true;
+ }
+
bs->inherits_from = parent;
- child_class->inherit_options(child_role, &flags, options,
+ child_class->inherit_options(child_role, parent_is_format,
+ &flags, options,
parent->open_flags, parent->options);
}
flags, options);
/* Let bdrv_backing_options() override "read-only" */
qdict_del(options, BDRV_OPT_READ_ONLY);
- bdrv_backing_options(0, &flags, options, flags, options);
+ bdrv_backing_options(0, true, &flags, options, flags, options);
}
bs->open_flags = flags;
QDict *options,
const BdrvChildClass *klass,
BdrvChildRole role,
+ bool parent_is_format,
QDict *parent_options,
int parent_flags,
bool keep_old_opts)
/* Inherit from parent node */
if (parent_options) {
flags = 0;
- klass->inherit_options(role, &flags, options,
+ klass->inherit_options(role, parent_is_format, &flags, options,
parent_flags, parent_options);
} else {
flags = bdrv_get_flags(bs);
}
bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options,
- child->klass, child->role, options, flags,
- child_keep_old);
+ child->klass, child->role, bs->drv->is_format,
+ options, flags, child_keep_old);
}
return bs_queue;
BlockDriverState *bs,
QDict *options, bool keep_old_opts)
{
- return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, 0, NULL, 0,
- keep_old_opts);
+ return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, 0, false,
+ NULL, 0, keep_old_opts);
}
/*