block: do not check bdrv_file_open
The set of BlockDrivers that have .bdrv_file_open coincides with those that have .protocol_name and guess what---checking drv->bdrv_file_open is done to see if the driver is a protocol. So check drv->protocol_name instead. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
ae8b45d293
commit
41770f6e6f
11
block.c
11
block.c
@ -926,7 +926,6 @@ BlockDriver *bdrv_find_protocol(const char *filename,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
GLOBAL_STATE_CODE();
|
GLOBAL_STATE_CODE();
|
||||||
/* TODO Drivers without bdrv_file_open must be specified explicitly */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX(hch): we really should not let host device detection
|
* XXX(hch): we really should not let host device detection
|
||||||
@ -1983,7 +1982,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
|
|||||||
open_flags = bdrv_open_flags(bs, bs->open_flags);
|
open_flags = bdrv_open_flags(bs, bs->open_flags);
|
||||||
node_name = qemu_opt_get(opts, "node-name");
|
node_name = qemu_opt_get(opts, "node-name");
|
||||||
|
|
||||||
assert(!drv->bdrv_file_open || file == NULL);
|
assert(!drv->protocol_name || file == NULL);
|
||||||
ret = bdrv_open_driver(bs, drv, node_name, options, open_flags, errp);
|
ret = bdrv_open_driver(bs, drv, node_name, options, open_flags, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail_opts;
|
goto fail_opts;
|
||||||
@ -2084,7 +2083,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
|||||||
}
|
}
|
||||||
/* If the user has explicitly specified the driver, this choice should
|
/* If the user has explicitly specified the driver, this choice should
|
||||||
* override the BDRV_O_PROTOCOL flag */
|
* override the BDRV_O_PROTOCOL flag */
|
||||||
protocol = drv->bdrv_file_open;
|
protocol = drv->protocol_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocol) {
|
if (protocol) {
|
||||||
@ -4123,7 +4122,7 @@ bdrv_open_inherit(const char *filename, const char *reference, QDict *options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* BDRV_O_PROTOCOL must be set iff a protocol BDS is about to be created */
|
/* BDRV_O_PROTOCOL must be set iff a protocol BDS is about to be created */
|
||||||
assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->bdrv_file_open);
|
assert(!!(flags & BDRV_O_PROTOCOL) == !!drv->protocol_name);
|
||||||
/* file must be NULL if a protocol BDS is about to be created
|
/* file must be NULL if a protocol BDS is about to be created
|
||||||
* (the inverse results in an error message from bdrv_open_common()) */
|
* (the inverse results in an error message from bdrv_open_common()) */
|
||||||
assert(!(flags & BDRV_O_PROTOCOL) || !file);
|
assert(!(flags & BDRV_O_PROTOCOL) || !file);
|
||||||
@ -5971,7 +5970,7 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs)
|
|||||||
return drv->bdrv_co_get_allocated_file_size(bs);
|
return drv->bdrv_co_get_allocated_file_size(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drv->bdrv_file_open) {
|
if (drv->protocol_name) {
|
||||||
/*
|
/*
|
||||||
* Protocol drivers default to -ENOTSUP (most of their data is
|
* Protocol drivers default to -ENOTSUP (most of their data is
|
||||||
* not stored in any of their children (if they even have any),
|
* not stored in any of their children (if they even have any),
|
||||||
@ -8030,7 +8029,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
|
|||||||
* Both of these conditions are represented by generate_json_filename.
|
* Both of these conditions are represented by generate_json_filename.
|
||||||
*/
|
*/
|
||||||
if (primary_child_bs->exact_filename[0] &&
|
if (primary_child_bs->exact_filename[0] &&
|
||||||
primary_child_bs->drv->bdrv_file_open &&
|
primary_child_bs->drv->protocol_name &&
|
||||||
!drv->is_filter && !generate_json_filename)
|
!drv->is_filter && !generate_json_filename)
|
||||||
{
|
{
|
||||||
strcpy(bs->exact_filename, primary_child_bs->exact_filename);
|
strcpy(bs->exact_filename, primary_child_bs->exact_filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user