From patchwork Tue Oct 16 18:08:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Bryant X-Patchwork-Id: 191841 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 C80BF2C009A for ; Wed, 17 Oct 2012 05:28:47 +1100 (EST) Received: from localhost ([::1]:42947 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOBsj-0000vl-Io for incoming@patchwork.ozlabs.org; Tue, 16 Oct 2012 14:28:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOBsc-0000vg-HE for qemu-devel@nongnu.org; Tue, 16 Oct 2012 14:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOBsb-0006JG-Fk for qemu-devel@nongnu.org; Tue, 16 Oct 2012 14:28:38 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:53898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOBsb-0006J8-Bt for qemu-devel@nongnu.org; Tue, 16 Oct 2012 14:28:37 -0400 Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Oct 2012 14:28:35 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e6.ny.us.ibm.com (192.168.1.106) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Oct 2012 14:25:49 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id B409D38C859C for ; Tue, 16 Oct 2012 14:08:47 -0400 (EDT) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9GI8gnx280026 for ; Tue, 16 Oct 2012 14:08:42 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9GI8fDN014648 for ; Tue, 16 Oct 2012 14:08:42 -0400 Received: from localhost ([9.80.103.101]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9GI8epF014539; Tue, 16 Oct 2012 14:08:41 -0400 From: Corey Bryant To: qemu-devel@nongnu.org Date: Tue, 16 Oct 2012 14:08:32 -0400 Message-Id: <1350410912-2373-1-git-send-email-coreyb@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.11.4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12101618-1976-0000-0000-0000126A2087 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.146 Cc: kwolf@redhat.com, libvir-list@redhat.com, Corey Bryant Subject: [Qemu-devel] [PATCH v3 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) monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 5d5de41..0dae7ac 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);