Received: from eggs.gnu.org ([208.118.235.92]:56095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG5EC-0008Dp-Bo for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TG5EB-0003gR-Au for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:45:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45157) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG5EB-0003f7-1V for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:45:23 -0400 From: Markus Armbruster References: <1348411747-29804-1-git-send-email-owasserm@redhat.com> <1348411747-29804-5-git-send-email-owasserm@redhat.com> Date: Mon, 24 Sep 2012 11:45:19 +0200 In-Reply-To: <1348411747-29804-5-git-send-email-owasserm@redhat.com> (Orit Wasserman's message of "Sun, 23 Sep 2012 16:49:07 +0200") Message-ID: <87d31bsqj4.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 4/4] Clear handler only for valid fd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Orit Wasserman Cc: kwolf@redhat.com, aliguori@us.ibm.com, akong@redhat.com, mst@redhat.com, quintela@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, pbonzini@redhat.com, lcapitulino@redhat.com Orit Wasserman writes: > Signed-off-by: Orit Wasserman > --- > migration.c | 3 +-- > 1 files changed, 1 insertions(+), 2 deletions(-) > > diff --git a/migration.c b/migration.c > index 1edeec5..c20a2fe 100644 > --- a/migration.c > +++ b/migration.c > @@ -240,8 +240,6 @@ static int migrate_fd_cleanup(MigrationState *s) > { > int ret = 0; > > - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > - > if (s->file) { > DPRINTF("closing file\n"); > ret = qemu_fclose(s->file); > @@ -249,6 +247,7 @@ static int migrate_fd_cleanup(MigrationState *s) > } > > if (s->fd != -1) { > + qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > close(s->fd); > s->fd = -1; > } As far as I can see, qemu_set_fd_handler2() treats invalid file descriptor -1 just like any other. If it's in io_handlers, it gets deleted, else it's a nop. Thus, the old code works. But I agree passing invalid file descriptors is abusing the interface. I'm not sufficiently familiar with the migration code to judge whether moving the handler reset down is safe.