[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3] monitor: Add monitor_recv_fd function to work w
From: |
Yury Kotov |
Subject: |
[Qemu-devel] [PATCH 1/3] monitor: Add monitor_recv_fd function to work with sent fds |
Date: |
Fri, 12 Apr 2019 15:20:26 +0300 |
Signed-off-by: Yury Kotov <address@hidden>
---
include/monitor/monitor.h | 1 +
monitor.c | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index c1b40a9cac..9b9e593fb3 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -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);
diff --git a/monitor.c b/monitor.c
index 4807bbe811..3ebbc08e5c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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;
}
--
2.21.0