vhost-user: Improve -netdev/netdev_add/-net/... error reporting
commit8190483196148f765c65785876f7b893d64b6cdd
authorMarkus Armbruster <armbru@redhat.com>
Fri, 13 Mar 2015 13:17:16 +0000 (13 14:17 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 9 Jun 2015 05:40:24 +0000 (9 07:40 +0200)
tree17e34ae3ddbf174a94e9e6b94988ee5e43724cf5
parent71df1d833776647fc12f5bbcd6d6fe4c5e931094
vhost-user: Improve -netdev/netdev_add/-net/... error reporting

When -netdev vhost-user fails, it first reports a specific error, then
one or more generic ones, like this:

    $ qemu-system-x86_64 -netdev vhost-user,id=foo,chardev=xxx
    qemu-system-x86_64: -netdev vhost-user,id=foo,chardev=xxx: chardev "xxx" not found
    qemu-system-x86_64: -netdev vhost-user,id=foo,chardev=xxx: No suitable chardev found
    qemu-system-x86_64: -netdev vhost-user,id=foo,chardev=xxx: Device 'vhost-user' could not be initialized

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

Convert net_init_vhost_user() and its helpers to Error.  This
suppresses the unwanted unspecific error messages, and makes the
specific error the QMP error reply.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
net/vhost-user.c