diff options
author | Greg Kurz <groug@kaod.org> | 2018-01-08 11:18:23 +0100 |
---|---|---|
committer | Greg Kurz <groug@kaod.org> | 2018-01-08 11:18:23 +0100 |
commit | 91cda4e8f372602795e3a2f4bd2e3adaf9f82255 (patch) | |
tree | 115dc65d98c40f424f805483ea3ce15e091e3916 /hw/9pfs/9p-proxy.c | |
parent | d8803b1ad06734d36878645328011dc86108af9f (diff) |
fsdev: improve error handling of backend opts parsing
This patch changes some error messages in the backend opts parsing
code and convert backends to propagate QEMU Error objects instead
of calling error_report().
Signed-off-by: Greg Kurz <groug@kaod.org>
Diffstat (limited to 'hw/9pfs/9p-proxy.c')
-rw-r--r-- | hw/9pfs/9p-proxy.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 652940726e..f6fb7a408f 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -1111,17 +1111,27 @@ static int connect_namedsocket(const char *path) return sockfd; } -static int proxy_parse_opts(QemuOpts *opts, FsDriverEntry *fs) +static void error_append_socket_sockfd_hint(Error **errp) +{ + error_append_hint(errp, "Either specify socket=/some/path where /some/path" + " points to a listening AF_UNIX socket or sock_fd=fd" + " where fd is a file descriptor to a connected AF_UNIX" + " socket\n"); +} + +static int proxy_parse_opts(QemuOpts *opts, FsDriverEntry *fs, Error **errp) { const char *socket = qemu_opt_get(opts, "socket"); const char *sock_fd = qemu_opt_get(opts, "sock_fd"); if (!socket && !sock_fd) { - error_report("Must specify either socket or sock_fd"); + error_setg(errp, "both socket and sock_fd properties are missing"); + error_append_socket_sockfd_hint(errp); return -1; } if (socket && sock_fd) { - error_report("Both socket and sock_fd options specified"); + error_setg(errp, "both socket and sock_fd properties are set"); + error_append_socket_sockfd_hint(errp); return -1; } if (socket) { |