diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-07-22 09:11:41 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2009-07-29 11:47:09 -0500 |
commit | 9bab7711ca7c3a0daaaaf7d645caa9722bfe7be1 (patch) | |
tree | 8ec6b2cf9038374dd6855d9fd79d67cb302ee5a5 | |
parent | dedd9ecaf96a3b35491bf24e55aafe04a69ec863 (diff) |
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>
-rw-r--r-- | monitor.c | 24 | ||||
-rw-r--r-- | monitor.h | 2 |
2 files changed, 26 insertions, 0 deletions
@@ -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, }, @@ -20,6 +20,8 @@ void monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, BlockDriverCompletionFunc *completion_cb, void *opaque); +int monitor_get_fd(Monitor *mon, const char *fdname); + void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap); void monitor_printf(Monitor *mon, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); |