From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 0/5] qemu-io: Exit with error when a command failed
Date: Sat, 28 Apr 2018 16:41:18 +0200 [thread overview]
Message-ID: <20180428144123.30333-1-mreitz@redhat.com> (raw)
Right now, qemu-io's exit code is rather useless as it is usually 0.
Except sometimes, then it's 1 in case of an error (mostly when you
specify a filename as an argument and it cannot open that).
At the same time, most command functions' return values are rather
useless as they are usually 0 (meaning "continue execution"). There is
only a single function that breaks that pattern, which is "quit". On
one hand, this is pointless because "quit" is in qemu-io.c, so it can
easily signal that fact through a global (yet static) variable. On the
other, it breaks the usual pattern of I/O functions returning error
codes.
This series resolves the overlap between both issues by making the
command functions' return error values instead of whether to continue
execution or not, and thus makes qemu-io return 1 if any of the commands
executed has failed and 0 only if all of them have succeeded.
Patch 5 showcases how that may be useful for iotests.
See also: https://bugzilla.redhat.com/show_bug.cgi?id=1519617
Max Reitz (5):
qemu-io: Drop command functions' return values
qemu-io: Let command functions return error code
qemu-io: Exit with error when a command failed
iotests.py: Add qemu_io_silent
iotests: Let 216 make use of qemu-io's exit code
include/qemu-io.h | 4 +-
qemu-io-cmds.c | 276 ++++++++++++++++++++++++------------------
qemu-io.c | 62 +++++++---
tests/qemu-iotests/216 | 23 ++--
tests/qemu-iotests/216.out | 17 +--
tests/qemu-iotests/iotests.py | 9 ++
6 files changed, 226 insertions(+), 165 deletions(-)
--
2.14.3
next reply other threads:[~2018-04-28 14:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-28 14:41 Max Reitz [this message]
2018-04-28 14:41 ` [Qemu-devel] [PATCH 1/5] qemu-io: Drop command functions' return values Max Reitz
2018-04-30 14:58 ` Eric Blake
2018-04-28 14:41 ` [Qemu-devel] [PATCH 2/5] qemu-io: Let command functions return error code Max Reitz
2018-04-30 15:08 ` Eric Blake
2018-04-30 15:14 ` Max Reitz
2018-04-28 14:41 ` [Qemu-devel] [PATCH 3/5] qemu-io: Exit with error when a command failed Max Reitz
2018-04-30 16:38 ` Eric Blake
2018-04-28 14:41 ` [Qemu-devel] [PATCH 4/5] iotests.py: Add qemu_io_silent Max Reitz
2018-04-30 16:40 ` Eric Blake
2018-04-28 14:41 ` [Qemu-devel] [PATCH 5/5] iotests: Let 216 make use of qemu-io's exit code Max Reitz
2018-04-30 16:44 ` Eric Blake
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=20180428144123.30333-1-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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).