accel: cleanup error output
PATCH 1/1 accel: cleanup error output
Only emit "XXX accelerator not found", if there are not further accelerators listed. eg
accel=kvm:tcg
doesn't print a "KVM accelerator not found" warning when it falls back to tcg, but a
accel=kvm
prints a warning, since no fallback is given.
--- accel/accel.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
accel/accel.c +7 -6
@@ -69,19 +69,20 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)void configure_accelerator (MachineState *ms) { -const char *p; +const char *accel, *p;char buf[10 ];int ret;bool accel_initialised = false;bool init_failed = false;AccelClass *acc =NULL ; - p =qemu_opt_get (qemu_get_machine_opts (),"accel" ); -if (p ==NULL ) { + accel =qemu_opt_get (qemu_get_machine_opts (),"accel" ); +if (accel ==NULL ) {/* Use the default "accelerator", tcg */ - p ="tcg" ; + accel ="tcg" ; } + p = accel;while (!accel_initialised && *p !='\0' ) {if (*p ==':' ) { p++;
@@ -89,7 +90,6 @@ void configure_accelerator(MachineState *ms) p =get_opt_name (buf,sizeof (buf), p,':' ); acc =accel_find (buf);if (!acc) { -fprintf (stderr,"\"%s\" accelerator not found.\n" , buf);continue ; }if (acc->available && !acc->available ()) {
@@ -110,7 +110,8 @@ void configure_accelerator(MachineState *ms)if (!accel_initialised) {if (!init_failed) { -fprintf (stderr,"No accelerator found!\n" ); +fprintf (stderr,"-machine accel=%s: No accelerator found!\n" , + accel); }exit (1 ); }
Signature · 1 line
2.9.4
Quoted 21 lines · Laurent Vivier
Only emit "XXX accelerator not found", if there are not further accelerators listed. eg
accel=kvm:tcg
doesn't print a "KVM accelerator not found" warning when it falls back to tcg, but a
accel=kvm
prints a warning, since no fallback is given.
Suggested-by Daniel P. Berrange <[email protected]>Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- accel/accel.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
accel/accel.c void configure_accelerator(MachineState *ms) · line 113
Quoted 5 lines
accel/accel.c +1
-1@@ -110,7 +110,8 @@ void configure_accelerator(MachineState *ms)if (!accel_initialised) {if (!init_failed) { -fprintf (stderr,"No accelerator found!\n" ); + fprintf(stderr, "-machine accel=%s: No accelerator found!\n",
It may be worth dropping the '!', as we tend not to shout at the user; but whether or not you tweak that,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 57 lines · Laurent Vivier
Only emit "XXX accelerator not found", if there are not further accelerators listed. eg
accel=kvm:tcg
doesn't print a "KVM accelerator not found" warning when it falls back to tcg, but a
accel=kvm
prints a warning, since no fallback is given.
Suggested-by Daniel P. Berrange <[email protected]>Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- accel/accel.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)accel/accel.c +5
-5@@ -69,19 +69,20 @@ static int accel_init_machine(AccelClass *acc, MachineState *ms)void configure_accelerator (MachineState *ms) { -const char *p; +const char *accel, *p;char buf[10 ];int ret;bool accel_initialised = false;bool init_failed = false;AccelClass *acc =NULL ; - p =qemu_opt_get (qemu_get_machine_opts (),"accel" ); -if (p ==NULL ) { + accel =qemu_opt_get (qemu_get_machine_opts (),"accel" ); +if (accel ==NULL ) {/* Use the default "accelerator", tcg */ - p ="tcg" ; + accel ="tcg" ; } + p = accel;while (!accel_initialised && *p !='\0' ) {if (*p ==':' ) { p++;@@ -89,7 +90,6 @@ void configure_accelerator(MachineState *ms) p =get_opt_name (buf,sizeof (buf), p,':' ); acc =accel_find (buf);if (!acc) { -fprintf (stderr,"\"%s\" accelerator not found.\n" , buf);continue ; }if (acc->available && !acc->available ()) {
accel/accel.c void configure_accelerator(MachineState *ms) · line 117
Quoted 9 lines
accel/accel.c +2
-1@@ -110,7 +110,8 @@ void configure_accelerator(MachineState *ms)if (!accel_initialised) {if (!init_failed) { -fprintf (stderr,"No accelerator found!\n" ); +fprintf (stderr,"-machine accel=%s: No accelerator found!\n" , + accel); }exit (1 ); }
Maybe use error_report() instead of fprintf(stderr, ...) ?
Apart from that, looks fine to me, so feel free to add my: