Error reporting patches for 2020-05-27

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAl7N/xISHGFybWJydUBy
 ZWRoYXQuY29tAAoJEDhwtADrkYZTdJYP/j0mnss0or9ZuchxNpFLTV1lBd0wuKqL
 79279BWsJ8AObmYPs0oXe1cfcq76NA7d6tVYrmz0pZ7BkYmXY0VgbBKeYXozcX5z
 6MJ+7+7wOJ1hO4oSTz9Jo1ZSpr8g0Be4m4DweHSyC9Uz6jCNAw3yJlPNsZ295jvk
 w2QD4ApwaofhF8SkNw5s4DE1piLpr8+IbGhY7YTKASQv3dIqTfjGSoz9MCKI4ZCA
 KHLLLkgV3NvCgxRKP2JclWUSsX6Er8joN2zUGlU1xBm6yTZqjWPLMxSysVkl+vcA
 1qx4GggDZ/zMcfyGBdXW8EAtT1QMfHU6zh9ED9toYbBohWFewTVCqkSaA2yVQZWx
 D69L6Q1KT/RIbrH6zEQaIEYcMmzvZWLy6EumKD9pgOAwDQlHv5QPT5hp6gonF/kI
 D8ZdT0jQ6JQqo42zi4J4hW4eH0r0Kf+79XsVz7wxe26YK762ZVnJLK/q7Fu1vb/u
 bBMJBYh/xdRO1GDE9JsomVq3mdXlz4ywQM+SFUiCj+peiO0C9JdDxE+PII1RaDqV
 wlJ7HW1eoKs4OG0gBjrJM2tn4q3BNpyr2BLSQONBSJEfWi6Z4OnimN45K5cEEJHj
 et2OCQetRt1zXmdrFdvX3Zn87PMZKfPmdaZrxzRvxk/VIP1f4vRgJ3D2FGP+E82H
 S/GWWRkw8pZy
 =b99a
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-05-27' into staging

Error reporting patches for 2020-05-27

# gpg: Signature made Wed 27 May 2020 06:48:02 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-error-2020-05-27:
  i386: Fix x86_cpu_load_model() error API violation
  arm/sabrelite: Consistently use &error_fatal in sabrelite_init()
  mips/boston: Plug memory leak in boston_mach_init()
  mips/boston: Fix boston_mach_init() error handling
  mips/malta: Fix create_cps() error handling
  error: Use error_reportf_err() where appropriate
  tests/migration: Tighten error checking
  s390x/cpumodel: Fix harmless misuse of visit_check_struct()
  xen: Fix and improve handling of device_add usb-host errors
  nvdimm: Plug memory leak in uuid property setter

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-05-28 11:21:30 +01:00
commit aacc7c8be2
14 changed files with 59 additions and 64 deletions

View File

@ -138,8 +138,9 @@ static void check_report_connect_error(Chardev *chr,
SocketChardev *s = SOCKET_CHARDEV(chr); SocketChardev *s = SOCKET_CHARDEV(chr);
if (!s->connect_err_reported) { if (!s->connect_err_reported) {
error_report("Unable to connect character device %s: %s", error_reportf_err(err,
chr->label, error_get_pretty(err)); "Unable to connect character device %s: ",
chr->label);
s->connect_err_reported = true; s->connect_err_reported = true;
} }
qemu_chr_socket_restart_timer(chr); qemu_chr_socket_restart_timer(chr);

View File

@ -41,7 +41,6 @@ static void sabrelite_reset_secondary(ARMCPU *cpu,
static void sabrelite_init(MachineState *machine) static void sabrelite_init(MachineState *machine)
{ {
FslIMX6State *s; FslIMX6State *s;
Error *err = NULL;
/* Check the amount of memory is compatible with the SOC */ /* Check the amount of memory is compatible with the SOC */
if (machine->ram_size > FSL_IMX6_MMDC_SIZE) { if (machine->ram_size > FSL_IMX6_MMDC_SIZE) {
@ -52,11 +51,7 @@ static void sabrelite_init(MachineState *machine)
s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
object_property_add_child(OBJECT(machine), "soc", OBJECT(s)); object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
object_property_set_bool(OBJECT(s), true, "realized", &err); object_property_set_bool(OBJECT(s), true, "realized", &error_fatal);
if (err != NULL) {
error_report("%s", error_get_pretty(err));
exit(1);
}
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
machine->ram); machine->ram);

View File

@ -97,7 +97,6 @@ static void nvdimm_set_uuid(Object *obj, Visitor *v, const char *name,
if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) { if (qemu_uuid_parse(value, &nvdimm->uuid) != 0) {
error_setg(errp, "Property '%s.%s' has invalid value", error_setg(errp, "Property '%s.%s' has invalid value",
object_get_typename(obj), name); object_get_typename(obj), name);
goto out;
} }
g_free(value); g_free(value);

View File

@ -426,7 +426,6 @@ static void boston_mach_init(MachineState *machine)
{ {
DeviceState *dev; DeviceState *dev;
BostonState *s; BostonState *s;
Error *err = NULL;
MemoryRegion *flash, *ddr_low_alias, *lcd, *platreg; MemoryRegion *flash, *ddr_low_alias, *lcd, *platreg;
MemoryRegion *sys_mem = get_system_memory(); MemoryRegion *sys_mem = get_system_memory();
XilinxPCIEHost *pcie2; XilinxPCIEHost *pcie2;
@ -458,19 +457,17 @@ static void boston_mach_init(MachineState *machine)
sysbus_init_child_obj(OBJECT(machine), "cps", OBJECT(&s->cps), sysbus_init_child_obj(OBJECT(machine), "cps", OBJECT(&s->cps),
sizeof(s->cps), TYPE_MIPS_CPS); sizeof(s->cps), TYPE_MIPS_CPS);
object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type", object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type",
&err); &error_fatal);
object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp", &err); object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp",
object_property_set_bool(OBJECT(&s->cps), true, "realized", &err); &error_fatal);
object_property_set_bool(OBJECT(&s->cps), true, "realized",
if (err != NULL) { &error_fatal);
error_report("%s", error_get_pretty(err));
exit(1);
}
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
flash = g_new(MemoryRegion, 1); flash = g_new(MemoryRegion, 1);
memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB, &err); memory_region_init_rom(flash, NULL, "boston.flash", 128 * MiB,
&error_fatal);
memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0); memory_region_add_subregion_overlap(sys_mem, 0x18000000, flash, 0);
memory_region_add_subregion_overlap(sys_mem, 0x80000000, machine->ram, 0); memory_region_add_subregion_overlap(sys_mem, 0x80000000, machine->ram, 0);

View File

@ -1183,17 +1183,14 @@ static void create_cpu_without_cps(MachineState *ms,
static void create_cps(MachineState *ms, MaltaState *s, static void create_cps(MachineState *ms, MaltaState *s,
qemu_irq *cbus_irq, qemu_irq *i8259_irq) qemu_irq *cbus_irq, qemu_irq *i8259_irq)
{ {
Error *err = NULL;
sysbus_init_child_obj(OBJECT(s), "cps", OBJECT(&s->cps), sizeof(s->cps), sysbus_init_child_obj(OBJECT(s), "cps", OBJECT(&s->cps), sizeof(s->cps),
TYPE_MIPS_CPS); TYPE_MIPS_CPS);
object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type", &err); object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type",
object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp", &err); &error_fatal);
object_property_set_bool(OBJECT(&s->cps), true, "realized", &err); object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp",
if (err != NULL) { &error_fatal);
error_report("%s", error_get_pretty(err)); object_property_set_bool(OBJECT(&s->cps), true, "realized",
exit(1); &error_fatal);
}
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1); sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);

View File

@ -497,12 +497,12 @@ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD); carddev = qdev_create(qdev_get_child_bus(dev, "sd-bus"), TYPE_SD_CARD);
qdev_prop_set_drive(carddev, "drive", blk, &err); qdev_prop_set_drive(carddev, "drive", blk, &err);
if (err) { if (err) {
error_report("failed to init SD card: %s", error_get_pretty(err)); error_reportf_err(err, "failed to init SD card: ");
return NULL; return NULL;
} }
object_property_set_bool(OBJECT(carddev), true, "realized", &err); object_property_set_bool(OBJECT(carddev), true, "realized", &err);
if (err) { if (err) {
error_report("failed to init SD card: %s", error_get_pretty(err)); error_reportf_err(err, "failed to init SD card: ");
return NULL; return NULL;
} }

View File

@ -703,13 +703,13 @@ SDState *sd_init(BlockBackend *blk, bool is_spi)
dev = DEVICE(obj); dev = DEVICE(obj);
qdev_prop_set_drive(dev, "drive", blk, &err); qdev_prop_set_drive(dev, "drive", blk, &err);
if (err) { if (err) {
error_report("sd_init failed: %s", error_get_pretty(err)); error_reportf_err(err, "sd_init failed: ");
return NULL; return NULL;
} }
qdev_prop_set_bit(dev, "spi", is_spi); qdev_prop_set_bit(dev, "spi", is_spi);
object_property_set_bool(obj, true, "realized", &err); object_property_set_bool(obj, true, "realized", &err);
if (err) { if (err) {
error_report("sd_init failed: %s", error_get_pretty(err)); error_reportf_err(err, "sd_init failed: ");
return NULL; return NULL;
} }

View File

@ -631,8 +631,9 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
int64_t id = qemu_file_monitor_add_watch(s->file_monitor, o->path, NULL, int64_t id = qemu_file_monitor_add_watch(s->file_monitor, o->path, NULL,
file_monitor_event, s, &err); file_monitor_event, s, &err);
if (id == -1) { if (id == -1) {
error_report("usb-mtp: failed to add watch for %s: %s", o->path, error_reportf_err(err,
error_get_pretty(err)); "usb-mtp: failed to add watch for %s: ",
o->path);
error_free(err); error_free(err);
} else { } else {
trace_usb_mtp_file_monitor_event(s->dev.addr, o->path, trace_usb_mtp_file_monitor_event(s->dev.addr, o->path,
@ -1276,8 +1277,8 @@ static void usb_mtp_command(MTPState *s, MTPControl *c)
s->file_monitor = qemu_file_monitor_new(&err); s->file_monitor = qemu_file_monitor_new(&err);
if (err) { if (err) {
error_report("usb-mtp: file monitoring init failed: %s", error_reportf_err(err,
error_get_pretty(err)); "usb-mtp: file monitoring init failed: ");
error_free(err); error_free(err);
} else { } else {
QTAILQ_INIT(&s->events); QTAILQ_INIT(&s->events);

View File

@ -30,6 +30,7 @@
#include "hw/usb.h" #include "hw/usb.h"
#include "hw/xen/xen-legacy-backend.h" #include "hw/xen/xen-legacy-backend.h"
#include "monitor/qdev.h" #include "monitor/qdev.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h" #include "qapi/qmp/qstring.h"
@ -755,13 +756,16 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
qdict_put_int(qdict, "port", port); qdict_put_int(qdict, "port", port);
qdict_put_int(qdict, "hostbus", atoi(busid)); qdict_put_int(qdict, "hostbus", atoi(busid));
qdict_put_str(qdict, "hostport", portname); qdict_put_str(qdict, "hostport", portname);
opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err); opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict,
if (local_err) { &error_abort);
goto err;
}
usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err)); usbif->ports[port - 1].dev = USB_DEVICE(qdev_device_add(opts, &local_err));
if (!usbif->ports[port - 1].dev) { if (!usbif->ports[port - 1].dev) {
goto err; qobject_unref(qdict);
xen_pv_printf(&usbif->xendev, 0,
"device %s could not be opened: %s\n",
busid, error_get_pretty(local_err));
error_free(local_err);
return;
} }
qobject_unref(qdict); qobject_unref(qdict);
speed = usbif->ports[port - 1].dev->speed; speed = usbif->ports[port - 1].dev->speed;
@ -793,11 +797,6 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
usbback_hotplug_enq(usbif, port); usbback_hotplug_enq(usbif, port);
TR_BUS(&usbif->xendev, "port %d attached\n", port); TR_BUS(&usbif->xendev, "port %d attached\n", port);
return;
err:
qobject_unref(qdict);
xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
} }
static void usbback_process_port(struct usbback_info *usbif, unsigned port) static void usbback_process_port(struct usbback_info *usbif, unsigned port)

View File

@ -856,8 +856,7 @@ int main(int argc, char **argv)
} }
tlscreds = nbd_get_tls_creds(tlscredsid, list, &local_err); tlscreds = nbd_get_tls_creds(tlscredsid, list, &local_err);
if (local_err) { if (local_err) {
error_report("Failed to get TLS creds %s", error_reportf_err(local_err, "Failed to get TLS creds: ");
error_get_pretty(local_err));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else { } else {
@ -983,8 +982,8 @@ int main(int argc, char **argv)
&local_err); &local_err);
if (sioc == NULL) { if (sioc == NULL) {
object_unref(OBJECT(server)); object_unref(OBJECT(server));
error_report("Failed to use socket activation: %s", error_reportf_err(local_err,
error_get_pretty(local_err)); "Failed to use socket activation: ");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
qio_net_listener_add(server, sioc); qio_net_listener_add(server, sioc);

View File

@ -1030,8 +1030,8 @@ int main(int argc, char **argv)
server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD, server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
&local_err); &local_err);
if (server_ioc == NULL) { if (server_ioc == NULL) {
error_report("Failed to use socket activation: %s", error_reportf_err(local_err,
error_get_pretty(local_err)); "Failed to use socket activation: ");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }

View File

@ -5078,7 +5078,7 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model)
/* Load data from X86CPUDefinition into a X86CPU object /* Load data from X86CPUDefinition into a X86CPU object
*/ */
static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp) static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)
{ {
X86CPUDefinition *def = model->cpudef; X86CPUDefinition *def = model->cpudef;
CPUX86State *env = &cpu->env; CPUX86State *env = &cpu->env;
@ -5092,13 +5092,19 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp)
*/ */
/* CPU models only set _minimum_ values for level/xlevel: */ /* CPU models only set _minimum_ values for level/xlevel: */
object_property_set_uint(OBJECT(cpu), def->level, "min-level", errp); object_property_set_uint(OBJECT(cpu), def->level, "min-level",
object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel", errp); &error_abort);
object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel",
&error_abort);
object_property_set_int(OBJECT(cpu), def->family, "family", errp); object_property_set_int(OBJECT(cpu), def->family, "family",
object_property_set_int(OBJECT(cpu), def->model, "model", errp); &error_abort);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp); object_property_set_int(OBJECT(cpu), def->model, "model",
object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp); &error_abort);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping",
&error_abort);
object_property_set_str(OBJECT(cpu), def->model_id, "model-id",
&error_abort);
for (w = 0; w < FEATURE_WORDS; w++) { for (w = 0; w < FEATURE_WORDS; w++) {
env->features[w] = def->features[w]; env->features[w] = def->features[w];
} }
@ -5135,7 +5141,8 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **errp)
vendor = host_vendor; vendor = host_vendor;
} }
object_property_set_str(OBJECT(cpu), vendor, "vendor", errp); object_property_set_str(OBJECT(cpu), vendor, "vendor",
&error_abort);
x86_cpu_apply_version_props(cpu, model); x86_cpu_apply_version_props(cpu, model);
} }
@ -6975,7 +6982,7 @@ static void x86_cpu_initfn(Object *obj)
object_property_add_alias(obj, "sse4_2", obj, "sse4.2"); object_property_add_alias(obj, "sse4_2", obj, "sse4.2");
if (xcc->model) { if (xcc->model) {
x86_cpu_load_model(cpu, xcc->model, &error_abort); x86_cpu_load_model(cpu, xcc->model);
} }
} }

View File

@ -524,7 +524,7 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
} }
} }
if (!err) { if (!err) {
visit_check_struct(visitor, errp); visit_check_struct(visitor, &err);
} }
visit_end_struct(visitor, NULL); visit_end_struct(visitor, NULL);
visit_free(visitor); visit_free(visitor);

View File

@ -13,6 +13,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "libqtest.h" #include "libqtest.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qemu/module.h" #include "qemu/module.h"
#include "qemu/option.h" #include "qemu/option.h"
@ -301,7 +302,6 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
{ {
QDict *rsp; QDict *rsp;
char *result; char *result;
Error *local_err = NULL;
SocketAddressList *addrs; SocketAddressList *addrs;
Visitor *iv = NULL; Visitor *iv = NULL;
QObject *object; QObject *object;
@ -310,7 +310,7 @@ static char *migrate_get_socket_address(QTestState *who, const char *parameter)
object = qdict_get(rsp, parameter); object = qdict_get(rsp, parameter);
iv = qobject_input_visitor_new(object); iv = qobject_input_visitor_new(object);
visit_type_SocketAddressList(iv, NULL, &addrs, &local_err); visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort);
visit_free(iv); visit_free(iv);
/* we are only using a single address */ /* we are only using a single address */