From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block/create: Do not abort if a block driver is not available
Date: Wed, 11 Sep 2019 17:12:47 -0500 [thread overview]
Message-ID: <0cf09644-2da1-adda-3691-74206ab13dfd@redhat.com> (raw)
In-Reply-To: <20190911220849.30840-1-philmd@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1671 bytes --]
On 9/11/19 5:08 PM, Philippe Mathieu-Daudé wrote:
> The 'blockdev-create' QMP command was introduced as experimental
> feature in commit b0292b851b8, using the assert() debug call.
> It got promoted to 'stable' command in 3fb588a0f2c, but the
> assert call was not removed.
>
> Some block drivers are optional, and bdrv_find_format() might
> return a NULL value, triggering the assertion.
>
> Stable code is not expected to abort, so return an error instead.
>
>
> Reported-by: Xu Tian <xutian@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> block/create.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/block/create.c b/block/create.c
> index 1bd00ed5f8..89812669df 100644
> --- a/block/create.c
> +++ b/block/create.c
> @@ -64,9 +64,13 @@ void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
> const char *fmt = BlockdevDriver_str(options->driver);
> BlockDriver *drv = bdrv_find_format(fmt);
>
> + if (!drv) {
> + error_setg(errp, "Block driver '%s' not found or not supported", fmt);
> + return;
> + }
> +
> /* If the driver is in the schema, we know that it exists. But it may not
> * be whitelisted. */
> - assert(drv);
> if (bdrv_uses_whitelist() && !bdrv_is_whitelisted(drv, false)) {
> error_setg(errp, "Driver is not whitelisted");
Matches that we error for not being on the whitelist.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-09-11 22:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 22:08 [Qemu-devel] [PATCH] block/create: Do not abort if a block driver is not available Philippe Mathieu-Daudé
2019-09-11 22:12 ` Eric Blake [this message]
2019-09-11 22:46 ` [Qemu-devel] [Qemu-block] " John Snow
2019-09-12 8:03 ` [Qemu-devel] " Kevin Wolf
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=0cf09644-2da1-adda-3691-74206ab13dfd@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@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).