migration: use migrate_fd_close in migrate_fd_cleanup
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 <pbonzini@redhat.com>
This commit is contained in:
parent
a6ef29096b
commit
8dc592e620
19
migration.c
19
migration.c
|
@ -243,21 +243,13 @@ static int migrate_fd_cleanup(MigrationState *s)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (s->fd != -1) {
|
|
||||||
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s->file) {
|
if (s->file) {
|
||||||
DPRINTF("closing file\n");
|
DPRINTF("closing file\n");
|
||||||
ret = qemu_fclose(s->file);
|
ret = qemu_fclose(s->file);
|
||||||
s->file = NULL;
|
s->file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->fd != -1) {
|
migrate_fd_close(s);
|
||||||
close(s->fd);
|
|
||||||
s->fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,8 +385,13 @@ int migrate_fd_wait_for_unfreeze(MigrationState *s)
|
||||||
|
|
||||||
int migrate_fd_close(MigrationState *s)
|
int migrate_fd_close(MigrationState *s)
|
||||||
{
|
{
|
||||||
qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
|
int rc = 0;
|
||||||
return s->close(s);
|
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)
|
void add_migration_state_change_notifier(Notifier *notify)
|
||||||
|
|
Loading…
Reference in a new issue