From: Laszlo Ersek <lersek@redhat.com>
To: Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, dgilbert@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 7/7] error: On abort, report where the error was created
Date: Fri, 24 Jul 2015 10:14:35 +0200 [thread overview]
Message-ID: <55B1F3EB.8050805@redhat.com> (raw)
In-Reply-To: <55B0FE7A.8070100@redhat.com>
On 07/23/15 16:47, Eric Blake wrote:
> On 07/23/2015 08:01 AM, Markus Armbruster wrote:
>> This is particularly useful when we abort in error_propagate(),
>> because there the stack backtrace doesn't lead to where the error was
>> created. Looks like this:
>>
>> Unexpected error in parse_block_error_action() at /work/armbru/qemu/blockdev.c:322:
>> qemu-system-x86_64: -drive if=none,werror=foo: 'foo' invalid write error action
>> Aborted (core dumped)
>>
>> Note: to get this example output, I monkey-patched drive_new() to pass
>> &error_abort to blockdev_init().
>>
>> To keep the error handling boiler plate from growing even more, all
>> error_setFOO() become macros expanding into error_setFOO_internal()
>> with additional __FILE__, __LINE__, __func__ arguments. Not exactly
>> pretty, but it works.
>>
>> The macro trickery breaks down when you take the address of an
>> error_setFOO(). Fortunately, we do that in just one place: qemu-ga's
>> Windows VSS provider and requester DLL wants to call
>> error_setg_win32() through a function pointer "to avoid linking glib
>> to the DLL". Use error_setg_win32_internal() there. The use of the
>> function pointer is already wrapped in a macro, so the churn isn't
>> bad.
>>
>> Code size increases by some 35KiB for me (0.7%). Tolerable. Could be
>> less if we passed relative rather than absolute source file names to
>> the compiler, or forwent reporting __func__.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> include/qapi/error.h | 43 +++++++++++++++++++++++++++--------
>> qga/vss-win32.c | 2 +-
>> qga/vss-win32/requester.cpp | 5 +++--
>> qga/vss-win32/requester.h | 6 +++--
>> util/error.c | 55 ++++++++++++++++++++++++++++++++-------------
>> 5 files changed, 81 insertions(+), 30 deletions(-)
>>
>
>> +++ b/qga/vss-win32/requester.cpp
>> @@ -23,8 +23,9 @@
>> /* Call QueryStatus every 10 ms while waiting for frozen event */
>> #define VSS_TIMEOUT_EVENT_MSEC 10
>>
>> -#define err_set(e, err, fmt, ...) \
>> - ((e)->error_setg_win32((e)->errp, err, fmt, ## __VA_ARGS__))
>> +#define err_set(e, err, fmt, ...) \
>> + ((e)->error_setg_win32((e)->errp, __FILE__, __LINE__, __func__, \
>> + err, fmt, ## __VA_ARGS__))
>
> Indentation looks odd here, but not fatal.
>
>> -void error_setg_errno(Error **errp, int os_errno, const char *fmt, ...)
>> +void error_setg_errno_internal(Error **errp,
>> + const char *src, int line, const char *func,
>> + int os_errno, const char *fmt, ...)
>
> Indentation off again.
>
> Those are minor, and could be fixed by maintainer.
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
I'm going to freeload in the wake of Eric's review, and just say "thank
you" for including __func__.
Acked-by: Laszlo Ersek <lersek@redhat.com>
next prev parent reply other threads:[~2015-07-24 8:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 14:01 [Qemu-devel] [PATCH v2 0/7] error: On abort, report where the error was created Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 1/7] error: De-duplicate code creating Error objects Markus Armbruster
2015-07-23 14:38 ` Eric Blake
2015-07-24 8:59 ` Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 2/7] error: Make error_setg() a function Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 3/7] qga: Clean up unnecessarily dirty casts Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 4/7] qga/vss-win32: Document the DLL requires non-null errp Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 5/7] error: error_set_errno() is unused, drop Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 6/7] error: Revamp interface documentation Markus Armbruster
2015-07-28 11:31 ` Dr. David Alan Gilbert
2015-07-29 7:23 ` Markus Armbruster
2015-07-29 18:32 ` Dr. David Alan Gilbert
2015-07-30 6:58 ` Markus Armbruster
2015-07-23 14:01 ` [Qemu-devel] [PATCH v2 7/7] error: On abort, report where the error was created Markus Armbruster
2015-07-23 14:47 ` Eric Blake
2015-07-24 8:14 ` Laszlo Ersek [this message]
2015-07-24 9:02 ` Markus Armbruster
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=55B1F3EB.8050805@redhat.com \
--to=lersek@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).