All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19
@ 2017-01-19 14:53 Markus Armbruster
  2017-01-19 14:53 ` [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved Markus Armbruster
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Armbruster @ 2017-01-19 14:53 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit ab4b92760498e097ff668f0e9c83aa87a2ec1128:

  Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2017-01-17 16:54:09 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/armbru.git tags/pull-error-2017-01-19

for you to fetch changes up to 0d6b50d474090b9085c595e2475c40cfdc092411:

  error: Report certain hints on stderr when no monitor (2017-01-19 15:42:36 +0100)

----------------------------------------------------------------
Error reporting patches for 2017-01-19

----------------------------------------------------------------
Marc-André Lureau (1):
      error: Report certain hints on stderr when no monitor

Sascha Silbe (1):
      error: error_setg_errno(): errno gets preserved

 include/qapi/error.h | 3 +++
 monitor.c            | 2 ++
 2 files changed, 5 insertions(+)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved
  2017-01-19 14:53 [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Markus Armbruster
@ 2017-01-19 14:53 ` Markus Armbruster
  2017-01-19 14:53 ` [Qemu-devel] [PULL 2/2] error: Report certain hints on stderr when no monitor Markus Armbruster
  2017-01-20 14:04 ` [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2017-01-19 14:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sascha Silbe

From: Sascha Silbe <silbe@linux.vnet.ibm.com>

C11 allows errno to be clobbered by pretty much any library function
call, so in general callers need to take care to save errno before
calling other functions.

However, for error reporting functions this is rather awkward and can
make the code on the caller side more complicated than
necessary. error_setg_errno() already takes care of preserving errno
and some functions rely on that, so just promise that we continue to
do so in the future.

Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Message-Id: <1469611466-31574-1-git-send-email-silbe@linux.vnet.ibm.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 include/qapi/error.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 0576659..7e532d0 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -170,6 +170,9 @@ void error_setg_internal(Error **errp,
  * Just like error_setg(), with @os_error info added to the message.
  * If @os_error is non-zero, ": " + strerror(os_error) is appended to
  * the human-readable error message.
+ *
+ * The value of errno (which usually can get clobbered by almost any
+ * function call) will be preserved.
  */
 #define error_setg_errno(errp, os_error, fmt, ...)                      \
     error_setg_errno_internal((errp), __FILE__, __LINE__, __func__,     \
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 2/2] error: Report certain hints on stderr when no monitor
  2017-01-19 14:53 [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Markus Armbruster
  2017-01-19 14:53 ` [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved Markus Armbruster
@ 2017-01-19 14:53 ` Markus Armbruster
  2017-01-20 14:04 ` [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2017-01-19 14:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Hints printed with error_printf_unless_qmp() are suppressed outside
monitor context.  Reproducer:

    $ qemu-system-x86_64 -m 1Z
    qemu-system-x86_64: -m 1Z: Parameter 'size' expects a size

Print to stderr instead.  The reproducer now additionally prints:

    You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170105135957.12003-1-marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/monitor.c b/monitor.c
index 0841d43..90c5baf 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3973,6 +3973,8 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
 {
     if (cur_mon && !monitor_cur_is_qmp()) {
         monitor_vprintf(cur_mon, fmt, ap);
+    } else if (!cur_mon) {
+        vfprintf(stderr, fmt, ap);
     }
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19
  2017-01-19 14:53 [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Markus Armbruster
  2017-01-19 14:53 ` [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved Markus Armbruster
  2017-01-19 14:53 ` [Qemu-devel] [PULL 2/2] error: Report certain hints on stderr when no monitor Markus Armbruster
@ 2017-01-20 14:04 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2017-01-20 14:04 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers

On 19 January 2017 at 14:53, Markus Armbruster <armbru@redhat.com> wrote:
> The following changes since commit ab4b92760498e097ff668f0e9c83aa87a2ec1128:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' into staging (2017-01-17 16:54:09 +0000)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/armbru.git tags/pull-error-2017-01-19
>
> for you to fetch changes up to 0d6b50d474090b9085c595e2475c40cfdc092411:
>
>   error: Report certain hints on stderr when no monitor (2017-01-19 15:42:36 +0100)
>
> ----------------------------------------------------------------
> Error reporting patches for 2017-01-19
>
> ----------------------------------------------------------------
> Marc-André Lureau (1):
>       error: Report certain hints on stderr when no monitor
>
> Sascha Silbe (1):
>       error: error_setg_errno(): errno gets preserved
>
>  include/qapi/error.h | 3 +++
>  monitor.c            | 2 ++
>  2 files changed, 5 insertions(+)

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-01-20 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-19 14:53 [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Markus Armbruster
2017-01-19 14:53 ` [Qemu-devel] [PULL 1/2] error: error_setg_errno(): errno gets preserved Markus Armbruster
2017-01-19 14:53 ` [Qemu-devel] [PULL 2/2] error: Report certain hints on stderr when no monitor Markus Armbruster
2017-01-20 14:04 ` [Qemu-devel] [PULL 0/2] Error reporting patches for 2017-01-19 Peter Maydell

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.