From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, kwolf@redhat.com
Subject: [PATCH 2/3] block: do not check bdrv_file_open
Date: Mon, 12 Dec 2022 14:16:59 +0100 [thread overview]
Message-ID: <20221212131700.250209-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20221212131700.250209-1-pbonzini@redhat.com>
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>
---
block.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 0a625a489a6e..7a66cc2ea23a 100644
--- a/block.c
+++ b/block.c
@@ -911,7 +911,6 @@ BlockDriver *bdrv_find_protocol(const char *filename,
int i;
GLOBAL_STATE_CODE();
- /* TODO Drivers without bdrv_file_open must be specified explicitly */
/*
* XXX(hch): we really should not let host device detection
@@ -1618,7 +1617,7 @@ static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv,
bs->opaque = g_malloc0(drv->instance_size);
assert(!drv->bdrv_needs_filename || bs->filename[0]);
- if (drv->bdrv_file_open) {
+ if (drv->bdrv_open) {
ret = drv->bdrv_file_open(bs, options, open_flags, &local_err);
} else if (drv->bdrv_open) {
ret = drv->bdrv_open(bs, options, open_flags, &local_err);
@@ -1930,7 +1929,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file,
open_flags = bdrv_open_flags(bs, bs->open_flags);
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);
if (ret < 0) {
goto fail_opts;
@@ -2030,7 +2029,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
}
/* If the user has explicitly specified the driver, this choice should
* override the BDRV_O_PROTOCOL flag */
- protocol = drv->bdrv_file_open;
+ protocol = drv->protocol_name;
}
if (protocol) {
@@ -3932,7 +3931,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
}
/* 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
* (the inverse results in an error message from bdrv_open_common()) */
assert(!(flags & BDRV_O_PROTOCOL) || !file);
@@ -5671,7 +5670,7 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
return drv->bdrv_get_allocated_file_size(bs);
}
- if (drv->bdrv_file_open) {
+ if (drv->protocol_name) {
/*
* Protocol drivers default to -ENOTSUP (most of their data is
* not stored in any of their children (if they even have any),
@@ -7772,7 +7771,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)
* Both of these conditions are represented by generate_json_filename.
*/
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)
{
strcpy(bs->exact_filename, primary_child_bs->exact_filename);
--
2.38.1
next prev parent reply other threads:[~2022-12-12 13:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-12 13:16 [PATCH 0/3] block: remove separate bdrv_file_open callback Paolo Bonzini
2022-12-12 13:16 ` [PATCH 1/3] block: apply assertion more widely Paolo Bonzini
2022-12-12 13:16 ` Paolo Bonzini [this message]
2023-01-19 13:17 ` [PATCH 2/3] block: do not check bdrv_file_open Kevin Wolf
2023-04-21 9:35 ` Paolo Bonzini
2022-12-12 13:17 ` [PATCH 3/3] block: remove separate bdrv_file_open callback Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2023-03-09 8:50 [PATCH 0/3] " Paolo Bonzini
2023-03-09 8:50 ` [PATCH 2/3] block: do not check bdrv_file_open Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221212131700.250209-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).