mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
blockdev: Convert drive_new() to Error
Calling error_report() from within a function that takes an Error ** argument is suspicious. drive_new() calls error_report() even though it can run within drive_init_func(), which takes an Error ** argument. drive_init_func()'s caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway: * Convert drive_new() to Error * Update add_init_drive() to report the error received from drive_new() * Make main() pass &error_fatal through qemu_opts_foreach(), drive_init_func() to drive_new() * Make default_drive() pass &error_abort through qemu_opts_foreach(), drive_init_func() to drive_new() Cc: Kevin Wolf <kwolf@redhat.com> Cc: Max Reitz <mreitz@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20181017082702.5581-34-armbru@redhat.com>
This commit is contained in:
parent
f881ca19f1
commit
c4f26c9f37
4 changed files with 24 additions and 19 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "sysemu/block-backend.h"
|
||||
#include "sysemu/blockdev.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/config-file.h"
|
||||
#include "qemu/option.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
|
@ -36,6 +37,7 @@
|
|||
|
||||
static DriveInfo *add_init_drive(const char *optstr)
|
||||
{
|
||||
Error *err = NULL;
|
||||
DriveInfo *dinfo;
|
||||
QemuOpts *opts;
|
||||
MachineClass *mc;
|
||||
|
@ -45,8 +47,9 @@ static DriveInfo *add_init_drive(const char *optstr)
|
|||
return NULL;
|
||||
|
||||
mc = MACHINE_GET_CLASS(current_machine);
|
||||
dinfo = drive_new(opts, mc->block_default_type);
|
||||
dinfo = drive_new(opts, mc->block_default_type, &err);
|
||||
if (!dinfo) {
|
||||
error_report_err(err);
|
||||
qemu_opts_del(opts);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue