]> Git Repo - qemu.git/commitdiff
monitor: add Error-propagating monitor_handle_fd_param2()
authorLaszlo Ersek <[email protected]>
Thu, 10 Apr 2014 08:24:31 +0000 (10:24 +0200)
committerLuiz Capitulino <[email protected]>
Thu, 8 May 2014 18:19:58 +0000 (14:19 -0400)
and rebase monitor_handle_fd_param() to it. (Note that this will slightly
change the behavior when the qemu_parse_fd() branch is selected and it
fails: we now report (and in case of QMP, set) the error immediately,
rather than allowing the caller to set its own error message (if any)).

Signed-off-by: Laszlo Ersek <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Luiz Capitulino <[email protected]>
include/monitor/monitor.h
monitor.c

index 42d867155bc939f82ea74199d045df5baced440b..1c1f56f36b17f4032773e0a39e44f569c8ab5534 100644 (file)
@@ -75,6 +75,7 @@ int monitor_read_block_device_key(Monitor *mon, const char *device,
 
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
 int monitor_handle_fd_param(Monitor *mon, const char *fdname);
+int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp);
 
 void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
     GCC_FMT_ATTR(2, 0);
index 2d3fb3f0efed35887997f3f4b1adc880c14a8ad6..9af6b0ad6663ca6834220bc2af83019308bff3e8 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -2611,16 +2611,33 @@ int monitor_handle_fd_param(Monitor *mon, const char *fdname)
     int fd;
     Error *local_err = NULL;
 
-    if (!qemu_isdigit(fdname[0]) && mon) {
+    fd = monitor_handle_fd_param2(mon, fdname, &local_err);
+    if (local_err) {
+        qerror_report_err(local_err);
+        error_free(local_err);
+    }
+    return fd;
+}
+
+int monitor_handle_fd_param2(Monitor *mon, const char *fdname, Error **errp)
+{
+    int fd;
+    Error *local_err = NULL;
 
+    if (!qemu_isdigit(fdname[0]) && mon) {
         fd = monitor_get_fd(mon, fdname, &local_err);
+    } else {
+        fd = qemu_parse_fd(fdname);
         if (fd == -1) {
-            qerror_report_err(local_err);
-            error_free(local_err);
-            return -1;
+            error_setg(&local_err, "Invalid file descriptor number '%s'",
+                       fdname);
         }
+    }
+    if (local_err) {
+        error_propagate(errp, local_err);
+        assert(fd == -1);
     } else {
-        fd = qemu_parse_fd(fdname);
+        assert(fd != -1);
     }
 
     return fd;
This page took 0.034715 seconds and 4 git commands to generate.