[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH] block/create: Do not abort if a block driver is
From: |
Eric Blake |
Subject: |
Re: [Qemu-block] [PATCH] block/create: Do not abort if a block driver is not available |
Date: |
Wed, 11 Sep 2019 17:12:47 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
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 <address@hidden>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> 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 <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature