From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQxcQ-0001S8-KV for qemu-devel@nongnu.org; Wed, 24 Oct 2012 05:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQxcK-0006lP-7g for qemu-devel@nongnu.org; Wed, 24 Oct 2012 05:51:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQxcJ-0006lH-Vh for qemu-devel@nongnu.org; Wed, 24 Oct 2012 05:51:16 -0400 From: Kevin Wolf Date: Wed, 24 Oct 2012 11:50:38 +0200 Message-Id: <1351072256-6112-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1351072256-6112-1-git-send-email-kwolf@redhat.com> References: <1351072256-6112-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 14/32] monitor: Prevent removing fd from set during init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Corey Bryant If an fd is added to an fd set via the command line, and it is not referenced by another command line option (ie. -drive), then clean it up after QEMU initialization is complete. Signed-off-by: Corey Bryant Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- monitor.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 6e99049..1d3dd9a 100644 --- a/monitor.c +++ b/monitor.c @@ -2105,8 +2105,9 @@ static void monitor_fdset_cleanup(MonFdset *mon_fdset) MonFdsetFd *mon_fdset_fd_next; QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_next) { - if (mon_fdset_fd->removed || - (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount == 0)) { + if ((mon_fdset_fd->removed || + (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount == 0)) && + runstate_is_running()) { close(mon_fdset_fd->fd); g_free(mon_fdset_fd->opaque); QLIST_REMOVE(mon_fdset_fd, next); -- 1.7.6.5