From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, aliguori@us.ibm.com,
stefanha@linux.vnet.ibm.com, libvir-list@redhat.com,
Corey Bryant <coreyb@linux.vnet.ibm.com>,
lcapitulino@redhat.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH v6 3/6] monitor: Clean up fd sets on monitor disconnect
Date: Fri, 3 Aug 2012 13:28:06 -0400 [thread overview]
Message-ID: <1344014889-12390-4-git-send-email-coreyb@linux.vnet.ibm.com> (raw)
In-Reply-To: <1344014889-12390-1-git-send-email-coreyb@linux.vnet.ibm.com>
Each fd set has a boolean that keeps track of whether or not the
fd set is in use by a monitor connection. When a monitor
disconnects, all fds that are members of an fd set with refcount
of zero are closed. This prevents any fd leakage associated with
a client disconnect prior to using a passed fd.
v5:
-This patch is new in v5.
-This support addresses concerns from v4 regarding fd leakage
if the client disconnects unexpectedly. (eblake@redhat.com,
kwolf@redhat.com, dberrange@redhat.com)
v6:
-No changes
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
---
monitor.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/monitor.c b/monitor.c
index 9aa9f7e..a46ef8d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2559,6 +2559,19 @@ FdsetInfoList *qmp_query_fdsets(Error **errp)
return fdset_list;
}
+static void monitor_fdsets_set_in_use(Monitor *mon, bool in_use)
+{
+ mon_fdset_t *mon_fdset;
+ mon_fdset_t *mon_fdset_next;
+
+ QLIST_FOREACH_SAFE(mon_fdset, &mon->fdsets, next, mon_fdset_next) {
+ mon_fdset->in_use = in_use;
+ if (!in_use) {
+ monitor_fdset_cleanup(mon_fdset);
+ }
+ }
+}
+
/* mon_cmds and info_cmds would be sorted at runtime */
static mon_cmd_t mon_cmds[] = {
#include "hmp-commands.h"
@@ -4763,9 +4776,11 @@ static void monitor_control_event(void *opaque, int event)
data = get_qmp_greeting();
monitor_json_emitter(mon, data);
qobject_decref(data);
+ monitor_fdsets_set_in_use(mon, true);
break;
case CHR_EVENT_CLOSED:
json_message_parser_destroy(&mon->mc->parser);
+ monitor_fdsets_set_in_use(mon, false);
break;
}
}
--
1.7.10.4
next prev parent reply other threads:[~2012-08-03 17:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 17:28 [Qemu-devel] [PATCH v6 0/6] file descriptor passing using fd sets Corey Bryant
2012-08-03 17:28 ` [Qemu-devel] [PATCH v6 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg Corey Bryant
2012-08-03 17:33 ` Corey Bryant
2012-08-03 17:28 ` [Qemu-devel] [PATCH v6 2/6] qapi: Introduce add-fd, remove-fd, query-fdsets Corey Bryant
2012-08-07 18:16 ` Stefan Hajnoczi
2012-08-07 19:59 ` Corey Bryant
2012-08-08 8:52 ` Stefan Hajnoczi
2012-08-08 13:40 ` Corey Bryant
2012-08-03 17:28 ` Corey Bryant [this message]
2012-08-07 17:32 ` [Qemu-devel] [PATCH v6 3/6] monitor: Clean up fd sets on monitor disconnect Stefan Hajnoczi
2012-08-07 19:36 ` Corey Bryant
2012-08-03 17:28 ` [Qemu-devel] [PATCH v6 4/6] block: Convert open calls to qemu_open Corey Bryant
2012-08-03 17:28 ` [Qemu-devel] [PATCH v6 5/6] block: Convert close calls to qemu_close Corey Bryant
2012-08-03 17:28 ` [Qemu-devel] [PATCH v6 6/6] block: Enable qemu_open/close to work with fd sets Corey Bryant
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=1344014889-12390-4-git-send-email-coreyb@linux.vnet.ibm.com \
--to=coreyb@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=libvir-list@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/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).