From patchwork Thu Oct 18 19:19:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Bryant X-Patchwork-Id: 192422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CE58A2C0092 for ; Fri, 19 Oct 2012 06:23:17 +1100 (EST) Received: from localhost ([::1]:50050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOvdn-0000Pa-6C for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 15:20:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOvdP-00009X-Il for qemu-devel@nongnu.org; Thu, 18 Oct 2012 15:20:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOvdL-00050J-E5 for qemu-devel@nongnu.org; Thu, 18 Oct 2012 15:19:59 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:48579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOvdL-000506-5I for qemu-devel@nongnu.org; Thu, 18 Oct 2012 15:19:55 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Oct 2012 13:19:52 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 18 Oct 2012 13:19:49 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id EE6D319D805C for ; Thu, 18 Oct 2012 13:19:47 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9IJJlV5223674 for ; Thu, 18 Oct 2012 13:19:47 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9IJJhWV021359 for ; Thu, 18 Oct 2012 13:19:44 -0600 Received: from localhost ([9.80.110.233]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9IJJgYM021292; Thu, 18 Oct 2012 13:19:43 -0600 From: Corey Bryant To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 15:19:33 -0400 Message-Id: <1350587974-6378-4-git-send-email-coreyb@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1350587974-6378-1-git-send-email-coreyb@linux.vnet.ibm.com> References: <1350587974-6378-1-git-send-email-coreyb@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12101819-2398-0000-0000-00000C91322D X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000294; HX=3.00000196; KW=3.00000007; PH=3.00000001; SC=3.00000008; SDB=6.00183503; UDB=6.00041591; UTC=2012-10-18 19:19:50 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.110.151 Cc: kwolf@redhat.com, libvir-list@redhat.com, Corey Bryant Subject: [Qemu-devel] [PATCH v4 3/4] monitor: Prevent removing fd from set during init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- v3: - This patch was split into it's own patch in v3 (eblake@redhat.com, kwolf@redhat.com) v4: - No changes monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index d8f66ca..928e3ae 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);