qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

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.

Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20170717144527.24534-1-lvivier@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Laurent Vivier and committed by
Paolo Bonzini
d73f0247 f70d3451

+10 -10
+10 -10
accel/accel.c
··· 33 33 #include "sysemu/qtest.h" 34 34 #include "hw/xen/xen.h" 35 35 #include "qom/object.h" 36 + #include "qemu/error-report.h" 36 37 37 38 static const TypeInfo accel_type = { 38 39 .name = TYPE_ACCEL, ··· 69 70 70 71 void configure_accelerator(MachineState *ms) 71 72 { 72 - const char *p; 73 + const char *accel, *p; 73 74 char buf[10]; 74 75 int ret; 75 76 bool accel_initialised = false; 76 77 bool init_failed = false; 77 78 AccelClass *acc = NULL; 78 79 79 - p = qemu_opt_get(qemu_get_machine_opts(), "accel"); 80 - if (p == NULL) { 80 + accel = qemu_opt_get(qemu_get_machine_opts(), "accel"); 81 + if (accel == NULL) { 81 82 /* Use the default "accelerator", tcg */ 82 - p = "tcg"; 83 + accel = "tcg"; 83 84 } 84 85 86 + p = accel; 85 87 while (!accel_initialised && *p != '\0') { 86 88 if (*p == ':') { 87 89 p++; ··· 89 91 p = get_opt_name(buf, sizeof(buf), p, ':'); 90 92 acc = accel_find(buf); 91 93 if (!acc) { 92 - fprintf(stderr, "\"%s\" accelerator not found.\n", buf); 93 94 continue; 94 95 } 95 96 if (acc->available && !acc->available()) { ··· 100 101 ret = accel_init_machine(acc, ms); 101 102 if (ret < 0) { 102 103 init_failed = true; 103 - fprintf(stderr, "failed to initialize %s: %s\n", 104 - acc->name, 105 - strerror(-ret)); 104 + error_report("failed to initialize %s: %s", 105 + acc->name, strerror(-ret)); 106 106 } else { 107 107 accel_initialised = true; 108 108 } ··· 110 110 111 111 if (!accel_initialised) { 112 112 if (!init_failed) { 113 - fprintf(stderr, "No accelerator found!\n"); 113 + error_report("-machine accel=%s: No accelerator found", accel); 114 114 } 115 115 exit(1); 116 116 } 117 117 118 118 if (init_failed) { 119 - fprintf(stderr, "Back to %s accelerator.\n", acc->name); 119 + error_report("Back to %s accelerator", acc->name); 120 120 } 121 121 } 122 122