All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vhost-scsi: Improve error reporting for invalid vhostfd
@ 2015-02-09 10:52 Markus Armbruster
  2015-02-10 16:46 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Armbruster @ 2015-02-09 10:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

We get two error messages: one from monitor_handle_fd_param2(), and
another one from vhost_scsi_realize().  The second one gets suppressed
in QMP context.

That's because monitor_handle_fd_param() calls qerror_report_err().
Calling qerror_report_err() is always inappropriate in realize
methods, because it doesn't return the Error object.  It either
reports the error to stderr or the human monitor, or it stores it in
the QMP monitor, where it makes the QMP command fail even when the
realize method ignores the error and succeeds.  Fortunately,
vhost_scsi_realize() doesn't do that.

Fix by switching to monitor_handle_fd_param2().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/scsi/vhost-scsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index dcb2bc5..567f350 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -214,9 +214,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     }
 
     if (vs->conf.vhostfd) {
-        vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd);
+        vhostfd = monitor_handle_fd_param2(cur_mon, vs->conf.vhostfd, &err);
         if (vhostfd == -1) {
-            error_setg(errp, "vhost-scsi: unable to parse vhostfd");
+            error_setg(errp, "vhost-scsi: unable to parse vhostfd: %s",
+                       error_get_pretty(err));
+            error_free(err);
             return;
         }
     } else {
-- 
1.9.3

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

* Re: [Qemu-devel] [PATCH] vhost-scsi: Improve error reporting for invalid vhostfd
  2015-02-09 10:52 [Qemu-devel] [PATCH] vhost-scsi: Improve error reporting for invalid vhostfd Markus Armbruster
@ 2015-02-10 16:46 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-02-10 16:46 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: mst



On 09/02/2015 11:52, Markus Armbruster wrote:
> We get two error messages: one from monitor_handle_fd_param2(), and
> another one from vhost_scsi_realize().  The second one gets suppressed
> in QMP context.
> 
> That's because monitor_handle_fd_param() calls qerror_report_err().
> Calling qerror_report_err() is always inappropriate in realize
> methods, because it doesn't return the Error object.  It either
> reports the error to stderr or the human monitor, or it stores it in
> the QMP monitor, where it makes the QMP command fail even when the
> realize method ignores the error and succeeds.  Fortunately,
> vhost_scsi_realize() doesn't do that.
> 
> Fix by switching to monitor_handle_fd_param2().
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/scsi/vhost-scsi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
> index dcb2bc5..567f350 100644
> --- a/hw/scsi/vhost-scsi.c
> +++ b/hw/scsi/vhost-scsi.c
> @@ -214,9 +214,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
>      }
>  
>      if (vs->conf.vhostfd) {
> -        vhostfd = monitor_handle_fd_param(cur_mon, vs->conf.vhostfd);
> +        vhostfd = monitor_handle_fd_param2(cur_mon, vs->conf.vhostfd, &err);
>          if (vhostfd == -1) {
> -            error_setg(errp, "vhost-scsi: unable to parse vhostfd");
> +            error_setg(errp, "vhost-scsi: unable to parse vhostfd: %s",
> +                       error_get_pretty(err));
> +            error_free(err);
>              return;
>          }
>      } else {
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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

end of thread, other threads:[~2015-02-10 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09 10:52 [Qemu-devel] [PATCH] vhost-scsi: Improve error reporting for invalid vhostfd Markus Armbruster
2015-02-10 16:46 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.