aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/monitor.c b/monitor.c
index 2d3fb3f0ef..9af6b0ad66 100644
--- 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;