tap: Improve -netdev/netdev_add/-net/... tap error reporting
commita308817743be5cc051d3379477f54027deb0befb
authorMarkus Armbruster <armbru@redhat.com>
Fri, 15 May 2015 11:59:03 +0000 (15 13:59 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 27 May 2015 09:34:07 +0000 (27 10:34 +0100)
tree4cfc02673f57ec41f135e94abe7ea5c903f99107
parent95c35a74fea51e307f6a3967e465a22776056b7e
tap: Improve -netdev/netdev_add/-net/... tap error reporting

When -netdev tap fails, it first reports a specific error, then a
generic one, like this:

    $ qemu-system-x86_64 -netdev tap,id=foo
    qemu-system-x86_64: -netdev tap,id=foo: could not configure /dev/net/tun: Operation not permitted
    qemu-system-x86_64: -netdev tap,id=foo: Device 'tap' could not be initialized

With the command line, the messages go to stderr.  In HMP, they go to
the monitor.  In QMP, the second one becomes the error reply, and the
first one goes to stderr.

Convert net_init_tap() to Error.  This suppresses the unwanted second
message, and makes the specific error the QMP error reply.

[Dropped duplicate "and" from error message as suggested by Eric Blake:
"ifname=, script=, downscript=, and vnet_hdr=, "
"queues=, and vhostfds= are invalid with helper="
--Stefan]

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1431691143-1015-16-git-send-email-armbru@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
net/tap.c