qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] 9p: Print error hints if option parsing fails
@ 2019-09-13 16:36 Greg Kurz
  2019-09-14 18:59 ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kurz @ 2019-09-13 16:36 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel

Option parsing fonctions are called with &error_fatal, which
causes error_setg() to call exit() and the hints are never
printed.

Use an intermediate error object so that exit() happens in
error_propagate() after error_append_hint() could be called.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p-local.c |   11 +++++++----
 hw/9pfs/9p-proxy.c |   11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 6f7309f4e691..2c80d2ac30f5 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1486,8 +1486,9 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
     Error *local_err = NULL;
 
     if (!sec_model) {
-        error_setg(errp, "security_model property not set");
-        error_append_security_model_hint(errp);
+        error_setg(&local_err, "security_model property not set");
+        error_append_security_model_hint(&local_err);
+        error_propagate(errp, local_err);
         return -1;
     }
 
@@ -1501,8 +1502,10 @@ static int local_parse_opts(QemuOpts *opts, FsDriverEntry *fse, Error **errp)
     } else if (!strcmp(sec_model, "mapped-file")) {
         fse->export_flags |= V9FS_SM_MAPPED_FILE;
     } else {
-        error_setg(errp, "invalid security_model property '%s'", sec_model);
-        error_append_security_model_hint(errp);
+        error_setg(&local_err, "invalid security_model property '%s'",
+                   sec_model);
+        error_append_security_model_hint(&local_err);
+        error_propagate(errp, local_err);
         return -1;
     }
 
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 97ab9c58a573..5de5e53702f7 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -1126,15 +1126,18 @@ 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");
+    Error *local_err = NULL;
 
     if (!socket && !sock_fd) {
-        error_setg(errp, "both socket and sock_fd properties are missing");
-        error_append_socket_sockfd_hint(errp);
+        error_setg(&local_err, "both socket and sock_fd properties are missing");
+        error_append_socket_sockfd_hint(&local_err);
+        error_propagate(errp, local_err);
         return -1;
     }
     if (socket && sock_fd) {
-        error_setg(errp, "both socket and sock_fd properties are set");
-        error_append_socket_sockfd_hint(errp);
+        error_setg(&local_err, "both socket and sock_fd properties are set");
+        error_append_socket_sockfd_hint(&local_err);
+        error_propagate(errp, local_err);
         return -1;
     }
     if (socket) {



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-15 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-13 16:36 [Qemu-devel] [PATCH] 9p: Print error hints if option parsing fails Greg Kurz
2019-09-14 18:59 ` Markus Armbruster
2019-09-15 18:50   ` Greg Kurz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).