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 <xut...@redhat.com> > Signed-off-by: Philippe Mathieu-Daudé <phi...@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 <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature