From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIHmX-00086e-V2 for qemu-devel@nongnu.org; Thu, 23 Jul 2015 10:47:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIHmO-0002MO-Tm for qemu-devel@nongnu.org; Thu, 23 Jul 2015 10:47:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIHmO-0002MH-Mb for qemu-devel@nongnu.org; Thu, 23 Jul 2015 10:47:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3F3C32DC426 for ; Thu, 23 Jul 2015 14:47:24 +0000 (UTC) References: <1437660098-4584-1-git-send-email-armbru@redhat.com> <1437660098-4584-8-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <55B0FE7A.8070100@redhat.com> Date: Thu, 23 Jul 2015 08:47:22 -0600 MIME-Version: 1.0 In-Reply-To: <1437660098-4584-8-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5gb8E3LPwpguRjDMw1s1muCBwbIRlBGQe" Subject: Re: [Qemu-devel] [PATCH v2 7/7] error: On abort, report where the error was created List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, lersek@redhat.com, dgilbert@redhat.com, mst@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5gb8E3LPwpguRjDMw1s1muCBwbIRlBGQe Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: >=20 > Unexpected error in parse_block_error_action() at /work/armbru/qemu= /blockdev.c:322: > qemu-system-x86_64: -drive if=3Dnone,werror=3Dfoo: 'foo' invalid wr= ite error action > Aborted (core dumped) >=20 > Note: to get this example output, I monkey-patched drive_new() to pass > &error_abort to blockdev_init(). >=20 > 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. >=20 > 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. >=20 > 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__. >=20 > Signed-off-by: Markus Armbruster > --- > 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(-) >=20 > +++ 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 > =20 > -#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 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --5gb8E3LPwpguRjDMw1s1muCBwbIRlBGQe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVsP56AAoJEKeha0olJ0NqOk4H/iCPoBj7hslurhrxZwGP1Cr4 LGGgKY2m4LGFkiAVfN8x0G351J9YZOFy3M0fenrh7nPq9MiIeUtC3KNliGDPNLi6 dEsIihi35+iOhndkbnXJPKjio0sA2tCL5IMYMGmDXQoOF63dSJiY6ld42w6kQoVZ v1RKkA7RGxipfI+Mkwvatl4/WQx7gAF1JyQYkRNZzgOMSISHVuBzmdFCeHwU+yhI OSbOKjWt5DAw222difHfGWsjhkqnHA7y9kQVIe35hct9O7br+yT4/cPWoGs8NWZt VTrIT1SvrKA2CVR1QOp6Va3iAEExpHgfQpBVgzdNWncQWwRH8ITQ8kzGPjpSoB4= =8dU4 -----END PGP SIGNATURE----- --5gb8E3LPwpguRjDMw1s1muCBwbIRlBGQe--