aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-07-22 09:11:41 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-27 08:39:28 -0500
commit7768e04c34c60d99de57ddcc37fcbbe736185430 (patch)
tree9e6dee3b0853989d4d03416033f470c5ace2e26d /monitor.c
parentf07918fdff76ace82b1ca3e53bbcddef069eb314 (diff)
downloadqemu-7768e04c34c60d99de57ddcc37fcbbe736185430.zip
qemu-7768e04c34c60d99de57ddcc37fcbbe736185430.tar.gz
qemu-7768e04c34c60d99de57ddcc37fcbbe736185430.tar.bz2
Add monitor_get_fd() command for fetching named fds
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 817e4b7..6ad2e14 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1774,6 +1774,30 @@ static void do_closefd(Monitor *mon, const char *fdname)
fdname);
}
+int monitor_get_fd(Monitor *mon, const char *fdname)
+{
+ mon_fd_t *monfd;
+
+ LIST_FOREACH(monfd, &mon->fds, next) {
+ int fd;
+
+ if (strcmp(monfd->name, fdname) != 0) {
+ continue;
+ }
+
+ fd = monfd->fd;
+
+ /* caller takes ownership of fd */
+ LIST_REMOVE(monfd, next);
+ qemu_free(monfd->name);
+ qemu_free(monfd);
+
+ return fd;
+ }
+
+ return -1;
+}
+
static const mon_cmd_t mon_cmds[] = {
#include "qemu-monitor.h"
{ NULL, NULL, },