From 248337e178fbcf1c20132d4f3d1033cb0dde7638 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 9 Feb 2015 11:49:08 +0100 Subject: vhost-scsi: Improve error reporting for invalid vhostfd 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 Acked-by: Paolo Bonzini --- hw/scsi/vhost-scsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'hw/scsi') 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 { -- cgit v1.1 From 1677f4c66cf2228eb14f1b0571d0e3b38d0d6606 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 9 Feb 2015 14:03:19 +0100 Subject: monitor: Clean up around monitor_handle_fd_param() monitor_handle_fd_param() is a wrapper around monitor_handle_fd_param2() that feeds errors to qerror_report_err() instead of returning them. qerror_report_err() is inappropriate in many contexts. monitor_handle_fd_param() looks simpler than monitor_handle_fd_param2(), which tempts use. Remove the temptation: drop the wrapper and open-code the (trivial) error handling instead. Replace the open-coded qerror_report_err() by error_report_err() in places that already use error_report(). Turns out that's everywhere. While there, rename monitor_handle_fd_param2() to monitor_fd_param(). Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- hw/scsi/vhost-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/scsi') diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 567f350..484f4a8 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -214,7 +214,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) } if (vs->conf.vhostfd) { - vhostfd = monitor_handle_fd_param2(cur_mon, vs->conf.vhostfd, &err); + vhostfd = monitor_fd_param(cur_mon, vs->conf.vhostfd, &err); if (vhostfd == -1) { error_setg(errp, "vhost-scsi: unable to parse vhostfd: %s", error_get_pretty(err)); -- cgit v1.1