aboutsummaryrefslogtreecommitdiff
path: root/net/vhost-user.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-06-09 10:05:29 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-06-09 10:05:29 +0100
commitb781a60b1054e06de6733b75dd1489afff9c3276 (patch)
tree17e34ae3ddbf174a94e9e6b94988ee5e43724cf5 /net/vhost-user.c
parentee09f84e6bf5383a23c9624115c26b72aa1e076c (diff)
parent8190483196148f765c65785876f7b893d64b6cdd (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2015-06-09' into staging
Error reporting patches # gpg: Signature made Tue Jun 9 06:42:15 2015 BST using RSA key ID EB918653 # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" * remotes/armbru/tags/pull-error-2015-06-09: vhost-user: Improve -netdev/netdev_add/-net/... error reporting QemuOpts: Convert qemu_opt_foreach() to Error QemuOpts: Drop qemu_opt_foreach() parameter abort_on_failure blkdebug: Simplify passing of Error through qemu_opts_foreach() QemuOpts: Convert qemu_opts_foreach() to Error QemuOpts: Drop qemu_opts_foreach() parameter abort_on_failure vl: Fail right after first bad -object vl: Print -device help at most once vl: Report failure to sandbox at most once Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'net/vhost-user.c')
-rw-r--r--net/vhost-user.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 8d2672846f..3930741fb6 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -157,8 +157,9 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
return 0;
}
-static int net_vhost_chardev_opts(const char *name, const char *value,
- void *opaque)
+static int net_vhost_chardev_opts(void *opaque,
+ const char *name, const char *value,
+ Error **errp)
{
VhostUserChardevProps *props = opaque;
@@ -169,33 +170,34 @@ static int net_vhost_chardev_opts(const char *name, const char *value,
} else if (strcmp(name, "server") == 0) {
props->is_server = true;
} else {
- error_report("vhost-user does not support a chardev"
- " with the following option:\n %s = %s",
- name, value);
+ error_setg(errp,
+ "vhost-user does not support a chardev with option %s=%s",
+ name, value);
return -1;
}
return 0;
}
-static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts)
+static CharDriverState *net_vhost_parse_chardev(
+ const NetdevVhostUserOptions *opts, Error **errp)
{
CharDriverState *chr = qemu_chr_find(opts->chardev);
VhostUserChardevProps props;
if (chr == NULL) {
- error_report("chardev \"%s\" not found", opts->chardev);
+ error_setg(errp, "chardev \"%s\" not found", opts->chardev);
return NULL;
}
/* inspect chardev opts */
memset(&props, 0, sizeof(props));
- if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, true) != 0) {
+ if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, errp)) {
return NULL;
}
if (!props.is_socket || !props.is_unix) {
- error_report("chardev \"%s\" is not a unix socket",
- opts->chardev);
+ error_setg(errp, "chardev \"%s\" is not a unix socket",
+ opts->chardev);
return NULL;
}
@@ -204,7 +206,7 @@ static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *op
return chr;
}
-static int net_vhost_check_net(QemuOpts *opts, void *opaque)
+static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp)
{
const char *name = opaque;
const char *driver, *netdev;
@@ -219,7 +221,7 @@ static int net_vhost_check_net(QemuOpts *opts, void *opaque)
if (strcmp(netdev, name) == 0 &&
strncmp(driver, virtio_name, strlen(virtio_name)) != 0) {
- error_report("vhost-user requires frontend driver virtio-net-*");
+ error_setg(errp, "vhost-user requires frontend driver virtio-net-*");
return -1;
}
@@ -229,7 +231,6 @@ static int net_vhost_check_net(QemuOpts *opts, void *opaque)
int net_init_vhost_user(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
- /* FIXME error_setg(errp, ...) on failure */
uint32_t queues;
const NetdevVhostUserOptions *vhost_user_opts;
CharDriverState *chr;
@@ -237,15 +238,14 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name,
assert(opts->kind == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
vhost_user_opts = opts->vhost_user;
- chr = net_vhost_parse_chardev(vhost_user_opts);
+ chr = net_vhost_parse_chardev(vhost_user_opts, errp);
if (!chr) {
- error_report("No suitable chardev found");
return -1;
}
/* verify net frontend */
if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net,
- (char *)name, true) == -1) {
+ (char *)name, errp)) {
return -1;
}