From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.co, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 04/15] net/dump: Improve -net/host_net_add dump error reporting
Date: Fri, 15 May 2015 13:58:52 +0200 [thread overview]
Message-ID: <1431691143-1015-5-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1431691143-1015-1-git-send-email-armbru@redhat.com>
When -net dump fails, it first reports a specific error, then a
generic one, like this:
$ qemu-system-x86_64 -net dump,id=foo,file=/eperm
qemu-system-x86_64: -net dump,id=foo,file=/eperm: -net dump: can't open /eperm
qemu-system-x86_64: -net dump,id=foo,file=/eperm: Device 'dump' could not be initialized
Convert net_init_tap() to Error. This suppresses the unwanted second
message.
Improve the error messages to include strerror(errno) where
appropriate.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
net/dump.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/dump.c b/net/dump.c
index 214e88a..02c8064 100644
--- a/net/dump.c
+++ b/net/dump.c
@@ -101,7 +101,8 @@ static NetClientInfo net_dump_info = {
};
static int net_dump_init(NetClientState *peer, const char *device,
- const char *name, const char *filename, int len)
+ const char *name, const char *filename, int len,
+ Error **errp)
{
struct pcap_file_hdr hdr;
NetClientState *nc;
@@ -111,7 +112,7 @@ static int net_dump_init(NetClientState *peer, const char *device,
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
if (fd < 0) {
- error_report("-net dump: can't open %s", filename);
+ error_setg_errno(errp, errno, "-net dump: can't open %s", filename);
return -1;
}
@@ -124,7 +125,7 @@ static int net_dump_init(NetClientState *peer, const char *device,
hdr.linktype = 1;
if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {
- error_report("-net dump write error: %s", strerror(errno));
+ error_setg_errno(errp, errno, "-net dump write error");
close(fd);
return -1;
}
@@ -148,7 +149,6 @@ static int net_dump_init(NetClientState *peer, const char *device,
int net_init_dump(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
- /* FIXME error_setg(errp, ...) on failure */
int len;
const char *file;
char def_file[128];
@@ -174,7 +174,7 @@ int net_init_dump(const NetClientOptions *opts, const char *name,
if (dump->has_len) {
if (dump->len > INT_MAX) {
- error_report("invalid length: %"PRIu64, dump->len);
+ error_setg(errp, "invalid length: %"PRIu64, dump->len);
return -1;
}
len = dump->len;
@@ -182,5 +182,5 @@ int net_init_dump(const NetClientOptions *opts, const char *name,
len = 65536;
}
- return net_dump_init(peer, "dump", name, file, len);
+ return net_dump_init(peer, "dump", name, file, len, errp);
}
--
1.9.3
next prev parent reply other threads:[~2015-05-15 11:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 11:58 [Qemu-devel] [PATCH v2 00/15] net: Improve error reporting Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 01/15] net: Improve error message for -net hubport a bit Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 02/15] net: Permit incremental conversion of init functions to Error Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 03/15] net: Improve -net nic error reporting Markus Armbruster
2015-05-15 11:58 ` Markus Armbruster [this message]
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 05/15] tap: net_tap_fd_init() can't fail, drop dead error handling Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 06/15] tap: Improve -netdev/netdev_add/-net/... bridge error reporting Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 07/15] tap: Convert tap_set_sndbuf() to Error Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 08/15] tap: Convert net_init_tap_one() " Markus Armbruster
2015-05-19 12:52 ` Stefan Hajnoczi
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 09/15] tap: Convert launch_script() " Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 10/15] tap: Permit incremental conversion of tap_open() " Markus Armbruster
2015-05-15 11:58 ` [Qemu-devel] [PATCH v2 11/15] tap-linux: Convert " Markus Armbruster
2015-05-15 11:59 ` [Qemu-devel] [PATCH v2 12/15] tap-bsd: " Markus Armbruster
2015-05-15 14:36 ` Eric Blake
2015-05-15 11:59 ` [Qemu-devel] [PATCH v2 13/15] tap-solaris: " Markus Armbruster
2015-05-15 11:59 ` [Qemu-devel] [PATCH v2 14/15] tap: Finish conversion of " Markus Armbruster
2015-05-15 11:59 ` [Qemu-devel] [PATCH v2 15/15] tap: Improve -netdev/netdev_add/-net/... tap error reporting Markus Armbruster
2015-05-15 14:38 ` Eric Blake
2015-05-19 13:15 ` [Qemu-devel] [PATCH v2 00/15] net: Improve " Stefan Hajnoczi
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=1431691143-1015-5-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=eblake@redhat.co \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).