mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
block: Add Error parameter to bdrv_find_protocol()
The argument given to bdrv_find_protocol() is just a file name, which makes it difficult for the caller to reconstruct what protocol bdrv_find_protocol() was hoping to find. This patch adds an Error parameter to that function to solve this issue. Suggested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1423162705-32065-4-git-send-email-mreitz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
ca49a4fdb3
commit
b65a5e12a4
5 changed files with 19 additions and 15 deletions
14
block.c
14
block.c
|
@ -508,9 +508,8 @@ int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp)
|
|||
Error *local_err = NULL;
|
||||
int ret;
|
||||
|
||||
drv = bdrv_find_protocol(filename, true);
|
||||
drv = bdrv_find_protocol(filename, true, errp);
|
||||
if (drv == NULL) {
|
||||
error_setg(errp, "Could not find protocol for file '%s'", filename);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
@ -628,7 +627,8 @@ static BlockDriver *find_hdev_driver(const char *filename)
|
|||
}
|
||||
|
||||
BlockDriver *bdrv_find_protocol(const char *filename,
|
||||
bool allow_protocol_prefix)
|
||||
bool allow_protocol_prefix,
|
||||
Error **errp)
|
||||
{
|
||||
BlockDriver *drv1;
|
||||
char protocol[128];
|
||||
|
@ -666,6 +666,8 @@ BlockDriver *bdrv_find_protocol(const char *filename,
|
|||
return drv1;
|
||||
}
|
||||
}
|
||||
|
||||
error_setg(errp, "Unknown protocol '%s'", protocol);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1136,9 +1138,8 @@ static int bdrv_fill_options(QDict **options, const char **pfilename, int flags,
|
|||
} else {
|
||||
if (!drvname && protocol) {
|
||||
if (filename) {
|
||||
drv = bdrv_find_protocol(filename, parse_filename);
|
||||
drv = bdrv_find_protocol(filename, parse_filename, errp);
|
||||
if (!drv) {
|
||||
error_setg(errp, "Unknown protocol");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -5623,9 +5624,8 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
|||
return;
|
||||
}
|
||||
|
||||
proto_drv = bdrv_find_protocol(filename, true);
|
||||
proto_drv = bdrv_find_protocol(filename, true, errp);
|
||||
if (!proto_drv) {
|
||||
error_setg(errp, "Unknown protocol '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue