[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 9/9] stash away SCM_RIGHTS fd until a getfd command
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 9/9] stash away SCM_RIGHTS fd until a getfd command arrives |
Date: |
Mon, 26 Apr 2010 12:47:33 -0300 |
From: Paolo Bonzini <address@hidden>
If there is already a fd in s->msgfd before recvmsg it is
closed by parts that this patch does not touch. So, only
one descriptor can be "leaked" by attaching it to a command
other than getfd.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 9 ---------
qemu-char.c | 9 +++------
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/monitor.c b/monitor.c
index 611cbe9..814b7dc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2414,15 +2414,6 @@ static int do_getfd(Monitor *mon, const QDict *qdict,
QObject **ret_data)
return -1;
}
- fd = dup(fd);
- if (fd == -1) {
- if (errno == EMFILE)
- qerror_report(QERR_TOO_MANY_FILES);
- else
- qerror_report(QERR_UNDEFINED_ERROR);
- return -1;
- }
-
QLIST_FOREACH(monfd, &mon->fds, next) {
if (strcmp(monfd->name, fdname) != 0) {
continue;
diff --git a/qemu-char.c b/qemu-char.c
index 05df971..ac65a1c 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2000,8 +2000,9 @@ static void tcp_chr_process_IAC_bytes(CharDriverState
*chr,
static int tcp_get_msgfd(CharDriverState *chr)
{
TCPCharDriver *s = chr->opaque;
-
- return s->msgfd;
+ int fd = s->msgfd;
+ s->msgfd = -1;
+ return fd;
}
#ifndef _WIN32
@@ -2089,10 +2090,6 @@ static void tcp_chr_read(void *opaque)
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
if (size > 0)
qemu_chr_read(chr, buf, size);
- if (s->msgfd != -1) {
- close(s->msgfd);
- s->msgfd = -1;
- }
}
}
--
1.7.1.rc1.12.ga6018
- Re: [Qemu-devel] [PATCH 5/9] Monitor: Return before exiting with 'quit', (continued)
- Re: [Qemu-devel] [PATCH 5/9] Monitor: Return before exiting with 'quit', Anthony Liguori, 2010/04/26
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Jan Kiszka, 2010/04/26
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Anthony Liguori, 2010/04/26
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Luiz Capitulino, 2010/04/26
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Paolo Bonzini, 2010/04/27
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Luiz Capitulino, 2010/04/27
- [Qemu-devel] Re: [PATCH 5/9] Monitor: Return before exiting with 'quit', Paolo Bonzini, 2010/04/27
[Qemu-devel] [PATCH 6/9] monitor: Cleanup ID assignment for compat switch, Luiz Capitulino, 2010/04/26
[Qemu-devel] [PATCH 7/9] monitor: Reorder intialization to drop initial mux focus, Luiz Capitulino, 2010/04/26
[Qemu-devel] [PATCH 8/9] chardev: Document mux option, Luiz Capitulino, 2010/04/26
[Qemu-devel] [PATCH 9/9] stash away SCM_RIGHTS fd until a getfd command arrives,
Luiz Capitulino <=
Re: [Qemu-devel] [PATCH 0/9][PULL]: QMP/Monitor queue, Anthony Liguori, 2010/04/26