qemu-patch-raspberry4/include/qemu
Peter Xu bc6a69dd4b qemu-error: introduce {error|warn}_report_once
There are many error_report()s that can be used in frequently called
functions, especially on IO paths.  That can be unideal in that
malicious guest can try to trigger the error tons of time which might
use up the log space on the host (e.g., libvirt can capture the stderr
of QEMU and put it persistently onto disk).  In VT-d emulation code, we
have trace_vtd_error() tracer.  AFAIU all those places can be replaced
by something like error_report() but trace points are mostly used to
avoid the DDOS attack that mentioned above.  However using trace points
mean that errors are not dumped if trace not enabled.

It's not a big deal in most modern server managements since we have
things like logrotate to maintain the logs and make sure the quota is
expected.  However it'll still be nice that we just provide another way
to restrict message generations.  In most cases, this kind of
error_report()s will only provide valid information on the first message
sent, and all the rest of similar messages will be mostly talking about
the same thing.  This patch introduces *_report_once() helpers to allow
a message to be dumped only once during one QEMU process's life cycle.
It will make sure: (1) it's on by deffault, so we can even get something
without turning the trace on and reproducing, and (2) it won't be
affected by DDOS attack.

To implement it, I stole the printk_once() macro from Linux.

CC: Eric Blake <eblake@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180815095328.32414-2-peterx@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Whitespace adjusted, comments improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2018-08-27 06:38:45 +02:00
..
acl.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
atomic.h atomic.h: Work around gcc spurious "unused value" warning 2018-05-10 18:10:57 +01:00
base64.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
bcd.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
bitmap.h bitmap: provide to_le/from_le helpers 2017-09-22 14:11:25 +02:00
bitops.h vnc: replace hweight_long() with ctpopl() 2017-05-12 12:36:02 +02:00
bswap.h bswap: Add new stn_*_p() and ldn_*_p() memory access functions 2018-06-15 15:23:34 +01:00
buffer.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
compiler.h compiler: add a sizeof_field() macro 2018-06-27 13:01:40 +01:00
config-file.h Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
coroutine.h coroutine-lock: make qemu_co_enter_next thread-safe 2018-02-08 09:22:03 +08:00
coroutine_int.h coroutine: avoid co_queue_wakeup recursion 2018-03-27 13:05:28 +01:00
cpuid.h util: Introduce include/qemu/cpuid.h 2017-07-24 12:42:55 +01:00
crc32c.h include/qemu/crc32c.h: Rename include guards to match filename 2014-02-26 17:20:07 +00:00
cutils.h cutils: Do not include "qemu/units.h" directly 2018-07-02 15:41:17 +02:00
envlist.h misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
error-report.h qemu-error: introduce {error|warn}_report_once 2018-08-27 06:38:45 +02:00
event_notifier.h Revert "qemu: add a cleanup callback function to EventNotifier" 2018-01-24 19:20:19 +02:00
fifo8.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
fifo32.h hw: Clean up includes 2016-06-07 18:19:23 +03:00
fprintf-fn.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
futex.h futex: add missing header guards 2017-10-16 20:57:13 +03:00
hbitmap.h hbitmap: Add @advance param to hbitmap_iter_next() 2018-06-18 17:04:55 +02:00
help_option.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
host-utils.h pci/shpc: Move function to generic header file 2018-01-18 21:52:38 +02:00
id.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
int128.h tcg: Add atomic128 helpers 2016-10-26 08:29:01 -07:00
iov.h tests: Use real size for iov tests 2017-09-05 22:34:40 +02:00
iova-tree.h util: remove redundant include of glib.h and add osdep.h 2018-06-29 12:22:28 +01:00
jhash.h Jhash: add linux kernel jhashtable in qemu 2016-09-27 17:54:21 +08:00
job.h job: Add job_progress_increase_remaining() 2018-06-18 17:05:11 +02:00
lockable.h lockable: workaround GCC link issue with ASAN 2018-03-06 14:01:27 +01:00
log-for-trace.h log-for-trace.h: Split out parts of log.h used by trace.h 2018-03-12 11:10:20 +00:00
log.h tcg: Optionally log FPU state in TCG -d cpu logging 2018-05-15 14:58:44 +01:00
main-loop.h qsp: track BQL callers explicitly 2018-08-23 18:46:25 +02:00
memfd.h memfd: fix vhost-user-test on non-memfd capable host 2018-04-09 12:57:06 +02:00
mmap-alloc.h exec, kvm, target-ppc: Move getrampagesize() to common code 2017-03-03 11:30:59 +11:00
module.h audio: add module loading support 2018-03-12 11:18:26 +01:00
notify.h notify: add NotiferWithReturn so notifier list can abort 2013-06-28 09:20:26 +02:00
option.h opts: don't silently truncate long option values 2018-05-09 00:13:39 +02:00
option_int.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
osdep.h osdep: work around Coverity parsing errors 2018-06-28 19:05:34 +02:00
path.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
pmem.h migration/ram: ensure write persistence on loading all data to PMEM. 2018-08-10 13:29:39 +03:00
processor.h Drop remaining bits of ia64 host support 2018-02-05 18:09:45 +01:00
qdist.h clean-includes: run it once more 2016-06-16 18:39:03 +02:00
qht.h qsp: QEMU's Synchronization Profiler 2018-08-23 18:46:25 +02:00
qsp.h qsp: support call site coalescing 2018-08-23 18:46:25 +02:00
queue.h migration: hold the lock only if it is really needed 2018-08-22 12:36:18 +02:00
range.h range: Replace internal representation of Range 2016-07-04 16:49:33 +03:00
ratelimit.h ratelimit: don't align wait time with slices 2018-02-15 09:39:49 +00:00
rcu.h membarrier: introduce qemu/sys_membarrier.h 2018-03-12 16:12:47 +01:00
rcu_queue.h rcu_queue: add RCU QTAILQ 2018-08-23 18:46:25 +02:00
readline.h readline: add a free function 2018-01-16 14:54:50 +01:00
seqlock.h seqlock: add QemuLockable support 2018-08-23 18:46:25 +02:00
sockets.h sockets: move fd_is_socket() into common sockets code 2018-03-13 18:06:06 +00:00
stats64.h util: add stats64 module 2017-06-16 07:55:00 +08:00
sys_membarrier.h membarrier: add --enable-membarrier 2018-03-12 16:12:47 +01:00
systemd.h qemu-ga: obey LISTEN_PID when using systemd socket activation 2017-03-19 11:12:12 +01:00
thread-posix.h qsp: QEMU's Synchronization Profiler 2018-08-23 18:46:25 +02:00
thread-win32.h qsp: QEMU's Synchronization Profiler 2018-08-23 18:46:25 +02:00
thread.h qsp: track BQL callers explicitly 2018-08-23 18:46:25 +02:00
throttle-options.h block: add throttle block filter driver 2017-09-06 10:12:02 +02:00
throttle.h Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
timed-average.h include: Clean up includes 2016-02-23 12:43:05 +00:00
timer.h replay: save prior value of the host clock 2018-03-12 16:12:50 +01:00
typedefs.h typedefs: add QJSON 2018-06-15 14:40:56 +01:00
unicode.h json: Reject invalid UTF-8 sequences 2018-08-24 20:26:37 +02:00
units.h include: Add IEC binary prefixes in "qemu/units.h" 2018-07-02 14:45:23 +02:00
uri.h Remove unused function declarations 2016-09-15 15:32:22 +03:00
uuid.h util: add is_equal to UUID API 2017-12-20 22:01:24 +08:00
vfio-helpers.h util: Introduce vfio helpers 2018-02-08 09:22:03 +08:00
xattr.h include: Fix typos found by codespell 2017-01-24 23:26:52 +03:00