mirror of https://github.com/xqemu/xqemu.git
Monitor: Convert do_getfd() to cmd_new_ret()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
ba85d35191
commit
6ad3ebd28e
11
monitor.c
11
monitor.c
|
@ -2403,7 +2403,7 @@ static void do_inject_mce(Monitor *mon, const QDict *qdict)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
{
|
{
|
||||||
const char *fdname = qdict_get_str(qdict, "fdname");
|
const char *fdname = qdict_get_str(qdict, "fdname");
|
||||||
mon_fd_t *monfd;
|
mon_fd_t *monfd;
|
||||||
|
@ -2412,12 +2412,12 @@ static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
fd = qemu_chr_get_msgfd(mon->chr);
|
fd = qemu_chr_get_msgfd(mon->chr);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
qemu_error_new(QERR_FD_NOT_SUPPLIED);
|
qemu_error_new(QERR_FD_NOT_SUPPLIED);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemu_isdigit(fdname[0])) {
|
if (qemu_isdigit(fdname[0])) {
|
||||||
qemu_error_new(QERR_INVALID_PARAMETER, "fdname");
|
qemu_error_new(QERR_INVALID_PARAMETER, "fdname");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
|
@ -2426,7 +2426,7 @@ static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
qemu_error_new(QERR_TOO_MANY_FILES);
|
qemu_error_new(QERR_TOO_MANY_FILES);
|
||||||
else
|
else
|
||||||
qemu_error_new(QERR_UNDEFINED_ERROR);
|
qemu_error_new(QERR_UNDEFINED_ERROR);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLIST_FOREACH(monfd, &mon->fds, next) {
|
QLIST_FOREACH(monfd, &mon->fds, next) {
|
||||||
|
@ -2436,7 +2436,7 @@ static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
|
|
||||||
close(monfd->fd);
|
close(monfd->fd);
|
||||||
monfd->fd = fd;
|
monfd->fd = fd;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
monfd = qemu_mallocz(sizeof(mon_fd_t));
|
monfd = qemu_mallocz(sizeof(mon_fd_t));
|
||||||
|
@ -2444,6 +2444,7 @@ static void do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
monfd->fd = fd;
|
monfd->fd = fd;
|
||||||
|
|
||||||
QLIST_INSERT_HEAD(&mon->fds, monfd, next);
|
QLIST_INSERT_HEAD(&mon->fds, monfd, next);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_closefd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
static void do_closefd(Monitor *mon, const QDict *qdict, QObject **ret_data)
|
||||||
|
|
|
@ -1083,7 +1083,7 @@ ETEXI
|
||||||
.params = "getfd name",
|
.params = "getfd name",
|
||||||
.help = "receive a file descriptor via SCM rights and assign it a name",
|
.help = "receive a file descriptor via SCM rights and assign it a name",
|
||||||
.user_print = monitor_user_noop,
|
.user_print = monitor_user_noop,
|
||||||
.mhandler.cmd_new = do_getfd,
|
.cmd_new_ret = do_getfd,
|
||||||
},
|
},
|
||||||
|
|
||||||
STEXI
|
STEXI
|
||||||
|
|
Loading…
Reference in New Issue