From: Markus Armbruster <armbru@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once
Date: Tue, 15 May 2018 14:02:55 +0200 [thread overview]
Message-ID: <87mux16s9c.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20180515091356.24106-1-peterx@redhat.com> (Peter Xu's message of "Tue, 15 May 2018 17:13:56 +0800")
Peter Xu <peterx@redhat.com> writes:
> I stole the printk_once() macro.
>
> I always wanted to be able to print some error directly if there is a
> buffer to dump, however we can't use error_report() really quite often
> when there can be any DDOS attack.
Got an example?
> To avoid that, we can introduce a
> print-once function for it.
>
> CC: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> We can for sure introduce similar functions for the rest of the
> error_*() functions, it's just an idea to see whether we'd like it
> in general.
> ---
> include/qemu/error-report.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> index e1c8ae1a52..efebb80e2c 100644
> --- a/include/qemu/error-report.h
> +++ b/include/qemu/error-report.h
> @@ -44,6 +44,18 @@ 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);
>
> +#define error_report_once(fmt, ...) \
> + ({ \
> + static bool __print_once; \
> + bool __ret_print_once = !__print_once; \
> + \
> + if (!__print_once) { \
> + __print_once = true; \
> + error_report(fmt, ##__VA_ARGS__); \
> + } \
> + unlikely(__ret_print_once); \
> + })
> +
> const char *error_get_progname(void);
> extern bool enable_timestamp_msg;
Ignorant question: what's the return value's intended use?
next prev parent reply other threads:[~2018-05-15 12:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 9:13 [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once Peter Xu
2018-05-15 9:16 ` no-reply
2018-05-15 12:02 ` Markus Armbruster [this message]
2018-05-15 12:38 ` Peter Xu
2018-05-15 15:56 ` Markus Armbruster
2018-05-15 16:39 ` Eric Blake
2018-05-16 3:08 ` Peter Xu
2018-05-15 15:29 ` Eric Blake
2018-05-16 3:07 ` Peter Xu
2018-05-16 14:02 ` Eric Blake
2018-05-17 2:51 ` Peter Xu
2018-05-31 11:03 ` Stefan Hajnoczi
2018-06-01 3:17 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mux16s9c.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.