diff options
author | Laszlo Ersek <lersek@redhat.com> | 2014-04-10 10:24:31 +0200 |
---|---|---|
committer | Luiz Capitulino <lcapitulino@redhat.com> | 2014-05-08 14:19:58 -0400 |
commit | 5906366ef0474691e9cfd9aa54a525d43bd2df43 (patch) | |
tree | cbebda28e251a8741f1c4c10eebac6660f7f6ce1 /monitor.c | |
parent | e9c5c1f40c949c5d2d7e1eeddf3caaed32e1c641 (diff) | |
download | qemu-5906366ef0474691e9cfd9aa54a525d43bd2df43.zip qemu-5906366ef0474691e9cfd9aa54a525d43bd2df43.tar.gz qemu-5906366ef0474691e9cfd9aa54a525d43bd2df43.tar.bz2 |
monitor: add Error-propagating monitor_handle_fd_param2()
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 <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 27 |
1 files changed, 22 insertions, 5 deletions
@@ -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; |