[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd_cleanup |
Date: |
Fri, 2 Nov 2012 18:50:59 +0100 |
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 <address@hidden>
---
migration.c | 19 ++++++++-----------
1 file modificato, 8 inserzioni(+), 11 rimozioni(-)
diff --git a/migration.c b/migration.c
index 300ab75..a63596f 100644
--- a/migration.c
+++ b/migration.c
@@ -243,21 +243,13 @@ 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;
}
- if (s->fd != -1) {
- close(s->fd);
- s->fd = -1;
- }
-
+ migrate_fd_close(s);
return ret;
}
@@ -393,8 +385,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)
--
1.7.12.1
- [Qemu-devel] [PULL 00/12] Incoming migration coroutine, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 03/12] migration: add qemu_get_fd, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 01/12] migration: unify stdio-based QEMUFile operations, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 02/12] migration: consolidate QEMUFile methods in a single QEMUFileOps struct, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 04/12] migration: replace qemu_stdio_fd with qemu_get_fd, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 05/12] migration: clean up server sockets and handlers before invoking process_incoming_migration, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 06/12] migration: use migrate_fd_close in migrate_fd_cleanup,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 07/12] migration: use closesocket, not close, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 08/12] migration: xxx_close will only be called once, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 09/12] migration: close socket QEMUFile from socket_close, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 12/12] migration: move process_incoming_migration to a coroutine, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 10/12] migration: move qemu_fclose to process_incoming_migration, Paolo Bonzini, 2012/11/02
- [Qemu-devel] [PATCH 11/12] migration: handle EAGAIN while reading QEMUFile, Paolo Bonzini, 2012/11/02
- Re: [Qemu-devel] [PULL 00/12] Incoming migration coroutine, Anthony Liguori, 2012/11/02