@@ -25,6 +25,7 @@ void monitor_cleanup(void);
int monitor_suspend(Monitor *mon);
void monitor_resume(Monitor *mon);
+int monitor_recv_fd(Monitor *mon, Error **errp);
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
@@ -2206,9 +2206,8 @@ void qmp_getfd(const char *fdname, Error **errp)
mon_fd_t *monfd;
int fd, tmp_fd;
- fd = qemu_chr_fe_get_msgfd(&cur_mon->chr);
+ fd = monitor_recv_fd(cur_mon, errp);
if (fd == -1) {
- error_setg(errp, QERR_FD_NOT_SUPPLIED);
return;
}
@@ -2266,6 +2265,15 @@ void qmp_closefd(const char *fdname, Error **errp)
error_setg(errp, QERR_FD_NOT_FOUND, fdname);
}
+int monitor_recv_fd(Monitor *mon, Error **errp)
+{
+ int fd = qemu_chr_fe_get_msgfd(&cur_mon->chr);
+ if (fd == -1) {
+ error_setg(errp, QERR_FD_NOT_SUPPLIED);
+ }
+ return fd;
+}
+
int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
{
mon_fd_t *monfd;
@@ -2335,9 +2343,8 @@ AddfdInfo *qmp_add_fd(bool has_fdset_id, int64_t fdset_id, bool has_opaque,
Monitor *mon = cur_mon;
AddfdInfo *fdinfo;
- fd = qemu_chr_fe_get_msgfd(&mon->chr);
+ fd = monitor_recv_fd(mon, errp);
if (fd == -1) {
- error_setg(errp, QERR_FD_NOT_SUPPLIED);
goto error;
}
Signed-off-by: Yury Kotov <yury-kotov@yandex-team.ru> --- include/monitor/monitor.h | 1 + monitor.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)