From: Luiz Capitulino <lcapitulino@redhat.com>
To: aliguori@us.ibm.com
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <1272296853-30285-10-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1272296853-30285-1-git-send-email-lcapitulino@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
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 <pbonzini@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
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
next prev parent reply other threads:[~2010-04-26 15:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 15:47 [Qemu-devel] [PATCH 0/9][PULL]: QMP/Monitor queue Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 1/9] QError: New QERR_QMP_BAD_INPUT_OBJECT_MEMBER Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 2/9] QMP: Use QERR_QMP_BAD_INPUT_OBJECT_MEMBER Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 3/9] QError: Improve QERR_QMP_BAD_INPUT_OBJECT desc Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 4/9] QMP: Check "arguments" member's type Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 5/9] Monitor: Return before exiting with 'quit' Luiz Capitulino
2010-04-26 17:49 ` Anthony Liguori
2010-04-26 18:22 ` Luiz Capitulino
2010-04-26 18:25 ` Anthony Liguori
2010-04-26 18:53 ` Luiz Capitulino
2010-04-26 19:00 ` Anthony Liguori
2010-04-26 19:10 ` [Qemu-devel] " Jan Kiszka
2010-04-26 19:13 ` Anthony Liguori
2010-04-26 19:44 ` Luiz Capitulino
2010-04-27 11:52 ` Paolo Bonzini
2010-04-27 13:20 ` Luiz Capitulino
2010-04-27 13:52 ` Paolo Bonzini
2010-04-26 15:47 ` [Qemu-devel] [PATCH 6/9] monitor: Cleanup ID assignment for compat switch Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 7/9] monitor: Reorder intialization to drop initial mux focus Luiz Capitulino
2010-04-26 15:47 ` [Qemu-devel] [PATCH 8/9] chardev: Document mux option Luiz Capitulino
2010-04-26 15:47 ` Luiz Capitulino [this message]
2010-04-26 21:32 ` [Qemu-devel] [PATCH 0/9][PULL]: QMP/Monitor queue Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272296853-30285-10-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).