Error reporting patches for 2017-07-13

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJZZ1/BAAoJEDhwtADrkYZTo7oP+gLj4B4kkp/DJnkzfuMMD1Ce
 ZPddZ8Z9RyXE4fS66sq1ODBQo5U+aQQZO7K234+jf8V4cKWW98lpVzLc3YdAHm2U
 ZF6Z9Rji5K4414ZsUcg92Zlovvdaji+mY0ooINav+4mqlONYrz29ntApWc0e0tGc
 e3tj4XDLhJrOM+mIx8vzixFlgSYj+6HgEiybYwolEK5svQbIQao3Y2omyb+zy0w0
 RDT3XQnAAaZSOQAXcJGkhekkyMe0jMHOF0tULLx1uDQYctg9mUGlAGTZ5oTLgSve
 TCpSJwWCAx8XAJMkXyDRrdRFDLeUh6yGY7NTqAL3OuPSoAw9ygKrHyhTavxBJL+W
 rX7Qit3dmVrlZLviwNFQplAKYb10d08vBoKXmrnW5oVCmPEDvJIQfncbucpA/CNS
 ucdJ3RMLuDbbWdl+5tsL7jfiZAG7oSgAePTjN1rm0bDe5JN7NAU8WzHnKfE83iZq
 R+I3hofqGoiXSByYRLamZb+6nsURAxWPhcqcw7hdMsk7UI6dyZwWl9Fnm72w0BZK
 M5LHLkX0LYc+kZjiLKXlNK7Z50bXY0zKQpPCLH3nHA69iMiwVoozrjwa9iCKIxE+
 7ZlOfsu4ztExuicEyTr8b27CBrHjJjYDuFP0hroEOzqCKXUzegoq3oYMGP0doXxe
 o3xcwXVKT/1PudddyR4z
 =tByN
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2017-07-13' into staging

Error reporting patches for 2017-07-13

# gpg: Signature made Thu 13 Jul 2017 12:55:45 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-error-2017-07-13:
  Convert error_report*_err() to warn_report*_err()
  error: Implement the warn and free Error functions
  char-socket: Report TCP socket waiting as information
  Convert error_report() to warn_report()
  error: Functions to report warnings and informational messages
  util/qemu-error: Rename error_print_loc() to be more generic
  websock: Don't try to set *errp directly
  block: Don't try to set *errp directly
  xilinx: Fix latent error handling bug

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-07-14 09:36:40 +01:00
commit a309b290aa
46 changed files with 275 additions and 148 deletions

View file

@ -4254,11 +4254,9 @@ bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp)
assert((int) op >= 0 && op < BLOCK_OP_TYPE_MAX);
if (!QLIST_EMPTY(&bs->op_blockers[op])) {
blocker = QLIST_FIRST(&bs->op_blockers[op]);
if (errp) {
*errp = error_copy(blocker->reason);
error_prepend(errp, "Node '%s' is busy: ",
bdrv_get_device_or_node_name(bs));
}
error_propagate(errp, error_copy(blocker->reason));
error_prepend(errp, "Node '%s' is busy: ",
bdrv_get_device_or_node_name(bs));
return true;
}
return false;

View file

@ -639,12 +639,12 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
ret = bdrv_get_info(target, &bdi);
if (ret == -ENOTSUP && !target->backing) {
/* Cluster size is not defined */
error_report("WARNING: The target block device doesn't provide "
"information about the block size and it doesn't have a "
"backing file. The default block size of %u bytes is "
"used. If the actual block size of the target exceeds "
"this default, the backup may be unusable",
BACKUP_CLUSTER_SIZE_DEFAULT);
warn_report("The target block device doesn't provide "
"information about the block size and it doesn't have a "
"backing file. The default block size of %u bytes is "
"used. If the actual block size of the target exceeds "
"this default, the backup may be unusable",
BACKUP_CLUSTER_SIZE_DEFAULT);
job->cluster_size = BACKUP_CLUSTER_SIZE_DEFAULT;
} else if (ret < 0 && !target->backing) {
error_setg_errno(errp, -ret,

View file

@ -345,8 +345,7 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,
is_unix = true;
} else if (!strcmp(uri->scheme, "gluster+rdma")) {
gsconf->type = SOCKET_ADDRESS_TYPE_INET;
error_report("Warning: rdma feature is not supported, falling "
"back to tcp");
warn_report("rdma feature is not supported, falling back to tcp");
} else {
ret = -EINVAL;
goto out;

View file

@ -1761,9 +1761,9 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
* filename encoded options */
filename = qdict_get_try_str(options, "filename");
if (filename) {
error_report("Warning: 'filename' option specified. "
"This is an unsupported option, and may be deprecated "
"in the future");
warn_report("'filename' option specified. "
"This is an unsupported option, and may be deprecated "
"in the future");
iscsi_parse_filename(filename, options, &local_err);
if (local_err) {
ret = -EINVAL;

View file

@ -558,8 +558,8 @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
}
client->readahead = qemu_opt_get_number(opts, "readahead-size", 0);
if (client->readahead > QEMU_NFS_MAX_READAHEAD_SIZE) {
error_report("NFS Warning: Truncating NFS readahead "
"size to %d", QEMU_NFS_MAX_READAHEAD_SIZE);
warn_report("Truncating NFS readahead size to %d",
QEMU_NFS_MAX_READAHEAD_SIZE);
client->readahead = QEMU_NFS_MAX_READAHEAD_SIZE;
}
nfs_set_readahead(client->context, client->readahead);
@ -579,8 +579,8 @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
}
client->pagecache = qemu_opt_get_number(opts, "page-cache-size", 0);
if (client->pagecache > QEMU_NFS_MAX_PAGECACHE_SIZE) {
error_report("NFS Warning: Truncating NFS pagecache "
"size to %d pages", QEMU_NFS_MAX_PAGECACHE_SIZE);
warn_report("Truncating NFS pagecache size to %d pages",
QEMU_NFS_MAX_PAGECACHE_SIZE);
client->pagecache = QEMU_NFS_MAX_PAGECACHE_SIZE;
}
nfs_set_pagecache(client->context, client->pagecache);
@ -595,8 +595,8 @@ static int64_t nfs_client_open(NFSClient *client, QDict *options,
/* limit the maximum debug level to avoid potential flooding
* of our log files. */
if (client->debug > QEMU_NFS_MAX_DEBUG_LEVEL) {
error_report("NFS Warning: Limiting NFS debug level "
"to %d", QEMU_NFS_MAX_DEBUG_LEVEL);
warn_report("Limiting NFS debug level to %d",
QEMU_NFS_MAX_DEBUG_LEVEL);
client->debug = QEMU_NFS_MAX_DEBUG_LEVEL;
}
nfs_set_debug(client->context, client->debug);

View file

@ -555,9 +555,9 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
* filename encoded options */
filename = qdict_get_try_str(options, "filename");
if (filename) {
error_report("Warning: 'filename' option specified. "
"This is an unsupported option, and may be deprecated "
"in the future");
warn_report("'filename' option specified. "
"This is an unsupported option, and may be deprecated "
"in the future");
qemu_rbd_parse_filename(filename, options, &local_err);
if (local_err) {
r = -EINVAL;

View file

@ -1114,8 +1114,8 @@ static coroutine_fn int ssh_co_writev(BlockDriverState *bs,
static void unsafe_flush_warning(BDRVSSHState *s, const char *what)
{
if (!s->unsafe_flush_warning) {
error_report("warning: ssh server %s does not support fsync",
s->inet->host);
warn_report("ssh server %s does not support fsync",
s->inet->host);
if (what) {
error_report("to support fsync, you need %s", what);
}

View file

@ -910,7 +910,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false);
if (read_only && copy_on_read) {
error_report("warning: disabling copy-on-read on read-only drive");
warn_report("disabling copy-on-read on read-only drive");
copy_on_read = false;
}

View file

@ -765,8 +765,8 @@ static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
* in TLS and telnet cases, only wait for an accepted socket */
while (!s->ioc) {
if (s->is_listen) {
error_report("QEMU waiting for connection on: %s",
chr->filename);
info_report("QEMU waiting for connection on: %s",
chr->filename);
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), true, NULL);
tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);

2
cpus.c
View file

@ -557,7 +557,7 @@ void qemu_start_warp_timer(void)
if (deadline < 0) {
static bool notified;
if (!icount_sleep && !notified) {
error_report("WARNING: icount sleep disabled and no active timers");
warn_report("icount sleep disabled and no active timers");
notified = true;
}
return;

View file

@ -2376,7 +2376,7 @@ static void coroutine_fn v9fs_flush(void *opaque)
trace_v9fs_flush(pdu->tag, pdu->id, tag);
if (pdu->tag == tag) {
error_report("Warning: the guest sent a self-referencing 9P flush request");
warn_report("the guest sent a self-referencing 9P flush request");
} else {
QLIST_FOREACH(cancel_pdu, &s->active_list, next) {
if (cancel_pdu->tag == tag) {

View file

@ -383,9 +383,9 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
highbank_binfo.write_board_setup = hb_write_board_setup;
highbank_binfo.secure_board_setup = true;
} else {
error_report("WARNING: cannot load built-in Monitor support "
"if KVM is enabled. Some guests (such as Linux) "
"may not boot.");
warn_report("cannot load built-in Monitor support "
"if KVM is enabled. Some guests (such as Linux) "
"may not boot.");
}
arm_load_kernel(ARM_CPU(first_cpu), &highbank_binfo);

View file

@ -80,9 +80,9 @@ static void imx25_pdk_init(MachineState *machine)
/* We need to initialize our memory */
if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) {
error_report("WARNING: RAM size " RAM_ADDR_FMT " above max supported, "
"reduced to %x", machine->ram_size,
FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE);
warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
"reduced to %x", machine->ram_size,
FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE);
machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE;
}

View file

@ -79,9 +79,9 @@ static void kzm_init(MachineState *machine)
/* Check the amount of memory is compatible with the SOC */
if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE)) {
error_report("WARNING: RAM size " RAM_ADDR_FMT " above max supported, "
"reduced to %x", machine->ram_size,
FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE);
warn_report("RAM size " RAM_ADDR_FMT " above max supported, "
"reduced to %x", machine->ram_size,
FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE);
machine->ram_size = FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE;
}

View file

@ -741,11 +741,11 @@ static void machine_numa_finish_init(MachineState *machine)
}
}
if (s->len && !qtest_enabled()) {
error_report("warning: CPU(s) not present in any NUMA nodes: %s",
s->str);
error_report("warning: All CPU(s) up to maxcpus should be described "
"in NUMA config, ability to start up with partial NUMA "
"mappings is obsoleted and will be removed in future");
warn_report("CPU(s) not present in any NUMA nodes: %s",
s->str);
warn_report("All CPU(s) up to maxcpus should be described "
"in NUMA config, ability to start up with partial NUMA "
"mappings is obsoleted and will be removed in future");
}
g_string_free(s, true);
}

View file

@ -1132,15 +1132,15 @@ int qdev_prop_check_globals(void)
oc = object_class_by_name(prop->driver);
oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
if (!oc) {
error_report("Warning: global %s.%s has invalid class name",
prop->driver, prop->property);
warn_report("global %s.%s has invalid class name",
prop->driver, prop->property);
ret = 1;
continue;
}
dc = DEVICE_CLASS(oc);
if (!dc->hotpluggable && !prop->used) {
error_report("Warning: global %s.%s=%s not used",
prop->driver, prop->property, prop->value);
warn_report("global %s.%s=%s not used",
prop->driver, prop->property, prop->value);
ret = 1;
continue;
}
@ -1169,7 +1169,7 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
error_propagate(prop->errp, err);
} else {
assert(prop->user_provided);
error_reportf_err(err, "Warning: ");
warn_report_err(err);
}
}
}

View file

@ -554,9 +554,7 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp)
return;
xilinx_axidma_realize_fail:
if (!*errp) {
*errp = local_err;
}
error_propagate(errp, local_err);
}
static void xilinx_axidma_init(Object *obj)

View file

@ -2766,17 +2766,17 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
ACPI_BUILD_ALIGN_SIZE);
if (tables_blob->len > legacy_table_size) {
/* Should happen only with PCI bridges and -M pc-i440fx-2.0. */
error_report("Warning: migration may not work.");
warn_report("migration may not work.");
}
g_array_set_size(tables_blob, legacy_table_size);
} else {
/* Make sure we have a buffer in case we need to resize the tables. */
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
/* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots. */
error_report("Warning: ACPI tables are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
warn_report("ACPI tables are larger than 64k.");
warn_report("migration may not work.");
warn_report("please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
}

View file

@ -1353,9 +1353,9 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev, Error **errp)
PCI_CAP_ID_EXP);
return -EINVAL;
} else if (size != 0x3c) {
error_report("WARNING, %s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
warn_report("%s: PCIe cap-id 0x%x has "
"non-standard size 0x%x; std size should be 0x3c",
__func__, PCI_CAP_ID_EXP, size);
}
} else if (version == 0) {
uint16_t vid, did;

View file

@ -381,8 +381,8 @@ ISADevice *pc_find_fdc0(void)
}
if (state.multiple) {
error_report("warning: multiple floppy disk controllers with "
"iobase=0x3f0 have been found");
warn_report("multiple floppy disk controllers with "
"iobase=0x3f0 have been found");
error_printf("the one being picked for CMOS setup might not reflect "
"your intent\n");
}
@ -1320,8 +1320,7 @@ void pc_acpi_init(const char *default_dsdt)
acpi_table_add_builtin(opts, &err);
if (err) {
error_reportf_err(err, "WARNING: failed to load %s: ",
filename);
warn_reportf_err(err, "failed to load %s: ", filename);
}
g_free(filename);
}
@ -2087,9 +2086,9 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
}
if (value < (1ULL << 20)) {
error_report("Warning: small max_ram_below_4g(%"PRIu64
") less than 1M. BIOS may not work..",
value);
warn_report("small max_ram_below_4g(%"PRIu64
") less than 1M. BIOS may not work..",
value);
}
pcms->max_ram_below_4g = value;

View file

@ -131,10 +131,10 @@ static void pc_init1(MachineState *machine,
lowmem = 0xc0000000;
}
if (lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g "
"(%" PRIu64 ") not a multiple of 1G; "
"possible bad performance.",
pcms->max_ram_below_4g);
warn_report("Large machine and max_ram_below_4g "
"(%" PRIu64 ") not a multiple of 1G; "
"possible bad performance.",
pcms->max_ram_below_4g);
}
}
}

View file

@ -101,9 +101,9 @@ static void pc_q35_init(MachineState *machine)
lowmem = pcms->max_ram_below_4g;
if (machine->ram_size - lowmem > lowmem &&
lowmem & ((1ULL << 30) - 1)) {
error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
pcms->max_ram_below_4g);
warn_report("Large machine and max_ram_below_4g(%"PRIu64
") not a multiple of 1G; possible bad performance.",
pcms->max_ram_below_4g);
}
}

View file

@ -157,8 +157,8 @@ static int ast2400_rambits(AspeedSDMCState *s)
}
/* use a common default */
error_report("warning: Invalid RAM size 0x%" PRIx64
". Using default 256M", s->ram_size);
warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 256M",
s->ram_size);
s->ram_size = 256 << 20;
return ASPEED_SDMC_DRAM_256MB;
}
@ -179,8 +179,8 @@ static int ast2500_rambits(AspeedSDMCState *s)
}
/* use a common default */
error_report("warning: Invalid RAM size 0x%" PRIx64
". Using default 512M", s->ram_size);
warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 512M",
s->ram_size);
s->ram_size = 512 << 20;
return ASPEED_SDMC_AST2500_512MB;
}

View file

@ -981,9 +981,7 @@ static void xilinx_enet_realize(DeviceState *dev, Error **errp)
return;
xilinx_enet_realize_fail:
if (!*errp) {
*errp = local_err;
}
error_propagate(errp, local_err);
}
static void xilinx_enet_init(Object *obj)

View file

@ -781,7 +781,7 @@ static int get_fw_cfg_order(FWCfgState *s, const char *name)
}
/* Stick unknown stuff at the end. */
error_report("warning: Unknown firmware file in legacy mode: %s", name);
warn_report("Unknown firmware file in legacy mode: %s", name);
return FW_CFG_ORDER_OVERRIDE_LAST;
}

View file

@ -307,7 +307,7 @@ static void i440fx_realize(PCIDevice *dev, Error **errp)
dev->config[I440FX_SMRAM] = 0x02;
if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
error_report("warning: i440fx doesn't support emulated iommu");
warn_report("i440fx doesn't support emulated iommu");
}
}

View file

@ -160,13 +160,13 @@ static void powernv_create_core_node(PnvChip *chip, PnvCore *pc, void *fdt)
_FDT((fdt_setprop_cell(fdt, offset, "d-cache-size",
pcc->l1_dcache_size)));
} else {
error_report("Warning: Unknown L1 dcache size for cpu");
warn_report("Unknown L1 dcache size for cpu");
}
if (pcc->l1_icache_size) {
_FDT((fdt_setprop_cell(fdt, offset, "i-cache-size",
pcc->l1_icache_size)));
} else {
error_report("Warning: Unknown L1 icache size for cpu");
warn_report("Unknown L1 icache size for cpu");
}
_FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq)));
@ -556,7 +556,7 @@ static void ppc_powernv_init(MachineState *machine)
/* allocate RAM */
if (machine->ram_size < (1 * G_BYTE)) {
error_report("Warning: skiboot may not work with < 1GB of RAM");
warn_report("skiboot may not work with < 1GB of RAM");
}
ram = g_new(MemoryRegion, 1);

View file

@ -534,13 +534,13 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
_FDT((fdt_setprop_cell(fdt, offset, "d-cache-size",
pcc->l1_dcache_size)));
} else {
error_report("Warning: Unknown L1 dcache size for cpu");
warn_report("Unknown L1 dcache size for cpu");
}
if (pcc->l1_icache_size) {
_FDT((fdt_setprop_cell(fdt, offset, "i-cache-size",
pcc->l1_icache_size)));
} else {
error_report("Warning: Unknown L1 icache size for cpu");
warn_report("Unknown L1 icache size for cpu");
}
_FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq)));

View file

@ -334,7 +334,7 @@ void spapr_tce_table_enable(sPAPRTCETable *tcet,
uint32_t nb_table)
{
if (tcet->nb_table) {
error_report("Warning: trying to enable already enabled TCE table");
warn_report("trying to enable already enabled TCE table");
return;
}

View file

@ -282,9 +282,9 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated)
continue; /* claimed */
}
if (!dinfo->is_default) {
error_report("warning: bus=%d,unit=%d is deprecated with this"
" machine type",
bus->busnr, unit);
warn_report("bus=%d,unit=%d is deprecated with this"
" machine type",
bus->busnr, unit);
}
}
scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),

View file

@ -1314,12 +1314,12 @@ static int ccid_card_init(DeviceState *qdev)
int ret = 0;
if (card->slot != 0) {
error_report("Warning: usb-ccid supports one slot, can't add %d",
card->slot);
warn_report("usb-ccid supports one slot, can't add %d",
card->slot);
return -1;
}
if (s->card != NULL) {
error_report("Warning: usb-ccid card already full, not adding");
warn_report("usb-ccid card already full, not adding");
return -1;
}
ret = ccid_card_initfn(card);

View file

@ -193,7 +193,7 @@ static void usbredir_handle_status(USBRedirDevice *dev, USBPacket *p,
#define WARNING(...) \
do { \
if (dev->debug >= usbredirparser_warning) { \
error_report("usb-redir warning: " __VA_ARGS__); \
warn_report("" __VA_ARGS__); \
} \
} while (0)
#define INFO(...) \

View file

@ -265,11 +265,22 @@ void error_free(Error *err);
*/
void error_free_or_abort(Error **errp);
/*
* Convenience function to warn_report() and free @err.
*/
void warn_report_err(Error *err);
/*
* Convenience function to error_report() and free @err.
*/
void error_report_err(Error *err);
/*
* Convenience function to error_prepend(), warn_report() and free @err.
*/
void warn_reportf_err(Error *err, const char *fmt, ...)
GCC_FMT_ATTR(2, 3);
/*
* Convenience function to error_prepend(), error_report() and free @err.
*/

View file

@ -35,8 +35,15 @@ void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_set_progname(const char *argv0);
void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void info_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
const char *error_get_progname(void);
extern bool enable_timestamp_msg;

View file

@ -856,7 +856,7 @@ static ssize_t qio_channel_websock_readv(QIOChannel *ioc,
ssize_t ret;
if (wioc->io_err) {
*errp = error_copy(wioc->io_err);
error_propagate(errp, error_copy(wioc->io_err));
return -1;
}
@ -902,7 +902,7 @@ static ssize_t qio_channel_websock_writev(QIOChannel *ioc,
ssize_t ret;
if (wioc->io_err) {
*errp = error_copy(wioc->io_err);
error_propagate(errp, error_copy(wioc->io_err));
return -1;
}

View file

@ -55,7 +55,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (ioctl(fd, TUNGETFEATURES, &features) == -1) {
error_report("warning: TUNGETFEATURES failed: %s", strerror(errno));
warn_report("TUNGETFEATURES failed: %s", strerror(errno));
features = 0;
}

View file

@ -2533,9 +2533,14 @@ sub process {
error_setg_file_open|
error_set|
error_prepend|
warn_reportf_err|
error_reportf_err|
error_vreport|
error_report}x;
warn_vreport|
info_vreport|
error_report|
warn_report|
info_report}x;
if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(.*\".*\\n/) {
ERROR("Error messages should not contain newlines\n" . $herecurr);

View file

@ -2060,15 +2060,15 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
name = featurestr;
if (g_list_find_custom(plus_features, name, compare_string)) {
error_report("warning: Ambiguous CPU model string. "
"Don't mix both \"+%s\" and \"%s=%s\"",
name, name, val);
warn_report("Ambiguous CPU model string. "
"Don't mix both \"+%s\" and \"%s=%s\"",
name, name, val);
ambiguous = true;
}
if (g_list_find_custom(minus_features, name, compare_string)) {
error_report("warning: Ambiguous CPU model string. "
"Don't mix both \"-%s\" and \"%s=%s\"",
name, name, val);
warn_report("Ambiguous CPU model string. "
"Don't mix both \"-%s\" and \"%s=%s\"",
name, name, val);
ambiguous = true;
}
@ -2096,8 +2096,8 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
}
if (ambiguous) {
error_report("warning: Compatibility of ambiguous CPU model "
"strings won't be kept on future QEMU versions");
warn_report("Compatibility of ambiguous CPU model "
"strings won't be kept on future QEMU versions");
}
}
@ -3547,9 +3547,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
*/
if (cpu->phys_bits != host_phys_bits && cpu->phys_bits != 0 &&
!warned) {
error_report("Warning: Host physical bits (%u)"
" does not match phys-bits property (%u)",
host_phys_bits, cpu->phys_bits);
warn_report("Host physical bits (%u)"
" does not match phys-bits property (%u)",
host_phys_bits, cpu->phys_bits);
warned = true;
}

View file

@ -600,10 +600,10 @@ static int kvm_arch_set_tsc_khz(CPUState *cs)
kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ) :
-ENOTSUP;
if (cur_freq <= 0 || cur_freq != env->tsc_khz) {
error_report("warning: TSC frequency mismatch between "
"VM (%" PRId64 " kHz) and host (%d kHz), "
"and TSC scaling unavailable",
env->tsc_khz, cur_freq);
warn_report("TSC frequency mismatch between "
"VM (%" PRId64 " kHz) and host (%d kHz), "
"and TSC scaling unavailable",
env->tsc_khz, cur_freq);
return r;
}
}
@ -919,8 +919,8 @@ int kvm_arch_init_vcpu(CPUState *cs)
error_report("kvm: LMCE not supported");
return -ENOTSUP;
}
error_report("warning: Unsupported MCG_CAP bits: 0x%" PRIx64,
unsupported_caps);
warn_report("Unsupported MCG_CAP bits: 0x%" PRIx64,
unsupported_caps);
}
env->mcg_cap &= mcg_cap | MCG_CAP_BANKS_MASK;

View file

@ -677,9 +677,9 @@ static void check_consistency(const S390CPUModel *model)
for (i = 0; i < ARRAY_SIZE(dep); i++) {
if (test_bit(dep[i][0], model->features) &&
!test_bit(dep[i][1], model->features)) {
error_report("Warning: \'%s\' requires \'%s\'.",
s390_feat_def(dep[i][0])->name,
s390_feat_def(dep[i][1])->name);
warn_report("\'%s\' requires \'%s\'.",
s390_feat_def(dep[i][0])->name,
s390_feat_def(dep[i][1])->name);
}
}
}

View file

@ -2675,8 +2675,8 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)
/* enable CMM via CMMA - disable on hugetlbfs */
if (test_bit(S390_FEAT_CMM, model->features)) {
if (mem_path) {
error_report("Warning: CMM will not be enabled because it is not "
"compatible to hugetlbfs.");
warn_report("CMM will not be enabled because it is not "
"compatible to hugetlbfs.");
} else {
kvm_s390_enable_cmma();
}

View file

@ -232,10 +232,10 @@ static void test_dynamic_globalprop(void)
g_test_trap_assert_passed();
g_test_trap_assert_stderr_unmatched("*prop1*");
g_test_trap_assert_stderr_unmatched("*prop2*");
g_test_trap_assert_stderr("*Warning: global dynamic-prop-type-bad.prop3 has invalid class name\n*");
g_test_trap_assert_stderr("*warning: global dynamic-prop-type-bad.prop3 has invalid class name\n*");
g_test_trap_assert_stderr_unmatched("*prop4*");
g_test_trap_assert_stderr("*Warning: global nohotplug-type.prop5=105 not used\n*");
g_test_trap_assert_stderr("*Warning: global nondevice-type.prop6 has invalid class name\n*");
g_test_trap_assert_stderr("*warning: global nohotplug-type.prop5=105 not used\n*");
g_test_trap_assert_stderr("*warning: global nondevice-type.prop6 has invalid class name\n*");
g_test_trap_assert_stdout("");
}

View file

@ -171,8 +171,8 @@ static void do_trace_enable_events(const char *line_buf)
while ((ev = trace_event_iter_next(&iter)) != NULL) {
if (!trace_event_get_state_static(ev)) {
if (!is_pattern) {
error_report("WARNING: trace event '%s' is not traceable",
line_ptr);
warn_report("trace event '%s' is not traceable",
line_ptr);
return;
}
continue;
@ -186,8 +186,8 @@ static void do_trace_enable_events(const char *line_buf)
}
if (!is_pattern) {
error_report("WARNING: trace event '%s' does not exist",
line_ptr);
warn_report("trace event '%s' does not exist",
line_ptr);
}
}

View file

@ -232,6 +232,15 @@ void error_report_err(Error *err)
error_free(err);
}
void warn_report_err(Error *err)
{
warn_report("%s", error_get_pretty(err));
if (err->hint) {
error_printf_unless_qmp("%s", err->hint->str);
}
error_free(err);
}
void error_reportf_err(Error *err, const char *fmt, ...)
{
va_list ap;
@ -242,6 +251,17 @@ void error_reportf_err(Error *err, const char *fmt, ...)
error_report_err(err);
}
void warn_reportf_err(Error *err, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
error_vprepend(&err, fmt, ap);
va_end(ap);
warn_report_err(err);
}
void error_free(Error *err)
{
if (err) {

View file

@ -14,6 +14,16 @@
#include "monitor/monitor.h"
#include "qemu/error-report.h"
/*
* @report_type is the type of message: error, warning or
* informational.
*/
typedef enum {
REPORT_TYPE_ERROR,
REPORT_TYPE_WARNING,
REPORT_TYPE_INFO,
} report_type;
void error_printf(const char *fmt, ...)
{
va_list ap;
@ -146,7 +156,7 @@ const char *error_get_progname(void)
/*
* Print current location to current monitor if we have one, else to stderr.
*/
static void error_print_loc(void)
static void print_loc(void)
{
const char *sep = "";
int i;
@ -179,17 +189,29 @@ static void error_print_loc(void)
bool enable_timestamp_msg;
/*
* Print an error message to current monitor if we have one, else to stderr.
* Print a message to current monitor if we have one, else to stderr.
* @report_type is the type of message: error, warning or informational.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void error_vreport(const char *fmt, va_list ap)
static void vreport(report_type type, const char *fmt, va_list ap)
{
GTimeVal tv;
gchar *timestr;
switch (type) {
case REPORT_TYPE_ERROR:
break;
case REPORT_TYPE_WARNING:
error_printf("warning: ");
break;
case REPORT_TYPE_INFO:
error_printf("info: ");
break;
}
if (enable_timestamp_msg && !cur_mon) {
g_get_current_time(&tv);
timestr = g_time_val_to_iso8601(&tv);
@ -197,15 +219,52 @@ void error_vreport(const char *fmt, va_list ap)
g_free(timestr);
}
error_print_loc();
print_loc();
error_vprintf(fmt, ap);
error_printf("\n");
}
/*
* Print an error message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void error_vreport(const char *fmt, va_list ap)
{
vreport(REPORT_TYPE_ERROR, fmt, ap);
}
/*
* Print a warning message to current monitor if we have one, else to stderr.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void warn_vreport(const char *fmt, va_list ap)
{
vreport(REPORT_TYPE_WARNING, fmt, ap);
}
/*
* Print an information message to current monitor if we have one, else to
* stderr.
* Format arguments like vsprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void info_vreport(const char *fmt, va_list ap)
{
vreport(REPORT_TYPE_INFO, fmt, ap);
}
/*
* Print an error message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be
* a single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
@ -214,6 +273,39 @@ void error_report(const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
error_vreport(fmt, ap);
vreport(REPORT_TYPE_ERROR, fmt, ap);
va_end(ap);
}
/*
* Print a warning message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void warn_report(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vreport(REPORT_TYPE_WARNING, fmt, ap);
va_end(ap);
}
/*
* Print an information message to current monitor if we have one, else to
* stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
* Prepend the current location and append a newline.
* It's wrong to call this in a QMP monitor. Use error_setg() there.
*/
void info_report(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vreport(REPORT_TYPE_INFO, fmt, ap);
va_end(ap);
}

20
vl.c
View file

@ -952,8 +952,8 @@ static void bt_vhci_add(int vlan_id)
struct bt_scatternet_s *vlan = qemu_find_bt_vlan(vlan_id);
if (!vlan->slave)
error_report("warning: adding a VHCI to an empty scatternet %i",
vlan_id);
warn_report("adding a VHCI to an empty scatternet %i",
vlan_id);
bt_vhci_init(bt_new_hci(vlan));
}
@ -979,8 +979,8 @@ static struct bt_device_s *bt_device_add(const char *opt)
vlan = qemu_find_bt_vlan(vlan_id);
if (!vlan->slave)
error_report("warning: adding a slave device to an empty scatternet %i",
vlan_id);
warn_report("adding a slave device to an empty scatternet %i",
vlan_id);
if (!strcmp(devname, "keyboard"))
return bt_keyboard_init(vlan);
@ -2302,8 +2302,8 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
return -1;
}
if (strncmp(name, "opt/", 4) != 0) {
error_report("warning: externally provided fw_cfg item names "
"should be prefixed with \"opt/\"");
warn_report("externally provided fw_cfg item names "
"should be prefixed with \"opt/\"");
}
if (nonempty_str(str)) {
size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
@ -3760,7 +3760,7 @@ int main(int argc, char **argv, char **envp)
qemu_opts_parse_noisily(olist, "accel=tcg", false);
break;
case QEMU_OPTION_no_kvm_pit: {
error_report("warning: ignoring deprecated option");
warn_report("ignoring deprecated option");
break;
}
case QEMU_OPTION_no_kvm_pit_reinjection: {
@ -3770,8 +3770,8 @@ int main(int argc, char **argv, char **envp)
.value = "discard",
};
error_report("warning: deprecated, replaced by "
"-global kvm-pit.lost_tick_policy=discard");
warn_report("deprecated, replaced by "
"-global kvm-pit.lost_tick_policy=discard");
qdev_prop_register_global(&kvm_pit_lost_tick_policy);
break;
}
@ -3896,7 +3896,7 @@ int main(int argc, char **argv, char **envp)
}
break;
case QEMU_OPTION_tdf:
error_report("warning: ignoring deprecated option");
warn_report("ignoring deprecated option");
break;
case QEMU_OPTION_name:
opts = qemu_opts_parse_noisily(qemu_find_opts("name"),