[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 3/4] trace: forbid use of %m in trace event f
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v3 3/4] trace: forbid use of %m in trace event format strings |
Date: |
Tue, 22 Jan 2019 11:25:55 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 1/22/19 10:49 AM, Daniel P. Berrangé wrote:
> The '%m' format specifier instructs glibc's printf() implementation to
> insert the contents of strerror(errno). Since this is a glibc extension
> it should generally be avoided in QEMU due to need for portability to a
> variety of platforms.
Up to you if you want to mention that syslog() portably supports %m, but
not all trace backends use syslog().
>
> Even though vfio is Linux-only code that could otherwise use "%m", it
> must still be avoided in trace-events files because several of the
> backends do not use the format string and so this error information is
> invisible to them.
>
> The errno string value should be given as an explicit trace argument
> instead, making it accessible to all backends. This also allows it to
> work correctly with future patches that use the format string with
> systemtap's simple printf code.
>
> Signed-off-by: Daniel P. Berrangé <address@hidden>
> ---
> hw/vfio/pci.c | 2 +-
> hw/vfio/trace-events | 2 +-
> scripts/tracetool/__init__.py | 4 ++++
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature