From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSPSw-0000rB-4m for qemu-devel@nongnu.org; Sun, 28 Oct 2012 05:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSPSv-0003JV-2k for qemu-devel@nongnu.org; Sun, 28 Oct 2012 05:47:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31293) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSPSu-0003JL-R0 for qemu-devel@nongnu.org; Sun, 28 Oct 2012 05:47:33 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9S9lVNb010509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 28 Oct 2012 05:47:32 -0400 Message-ID: <508CFF2F.9060400@redhat.com> Date: Sun, 28 Oct 2012 11:47:27 +0200 From: Orit Wasserman MIME-Version: 1.0 References: <1350555758-29988-1-git-send-email-pbonzini@redhat.com> <1350555758-29988-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1350555758-29988-7-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd_cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, quintela@redhat.com On 10/18/2012 12:22 PM, Paolo Bonzini wrote: > migrate_fd_cleanup will usually close the file descriptor via > buffered_file_close's call to migrate_fd_close. However, in the case > of s->file == NULL it is "inlining" migrate_fd_close (almost: there is a > direct close() instead of using s->close(s)). To fix the inconsistency > and clean up the code, allow multiple calls to migrate_fd_close and use > the function in migrate_fd_cleanup. > > Signed-off-by: Paolo Bonzini > --- > migration.c | 20 ++++++++------------ > 1 file modificato, 8 inserzioni(+), 12 rimozioni(-) > > diff --git a/migration.c b/migration.c > index 62e0304..c1807e0 100644 > --- a/migration.c > +++ b/migration.c > @@ -246,21 +246,12 @@ static int migrate_fd_cleanup(MigrationState *s) > { > int ret = 0; > > - if (s->fd != -1) { > - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > - } > - > if (s->file) { > DPRINTF("closing file\n"); > ret = qemu_fclose(s->file); > - s->file = NULL; why remove this line? > - } > - > - if (s->fd != -1) { > - close(s->fd); > - s->fd = -1; > } > > + migrate_fd_close(s); > return ret; > } > > @@ -396,8 +387,13 @@ int migrate_fd_wait_for_unfreeze(MigrationState *s) > > int migrate_fd_close(MigrationState *s) > { > - qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > - return s->close(s); > + int rc = 0; > + if (s->fd != -1) { > + qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL); > + rc = s->close(s); > + s->fd = -1; > + } > + return rc; > } > > void add_migration_state_change_notifier(Notifier *notify) >