mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
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>
This commit is contained in:
parent
d8803b1ad0
commit
91cda4e8f3
5 changed files with 37 additions and 20 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue