migration: eliminate s->migration_file
The indirection is useless now. Backends can open s->file directly. Reviewed-by: Orit Wasserman <owasserm@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
404a7c05bc
commit
b352365f5a
@ -36,9 +36,7 @@ struct MigrationState
|
|||||||
size_t xfer_limit;
|
size_t xfer_limit;
|
||||||
QemuThread thread;
|
QemuThread thread;
|
||||||
QEMUBH *cleanup_bh;
|
QEMUBH *cleanup_bh;
|
||||||
|
|
||||||
QEMUFile *file;
|
QEMUFile *file;
|
||||||
QEMUFile *migration_file;
|
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
MigrationParams params;
|
MigrationParams params;
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
|
|
||||||
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
|
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
|
||||||
{
|
{
|
||||||
s->migration_file = qemu_popen_cmd(command, "w");
|
s->file = qemu_popen_cmd(command, "w");
|
||||||
if (s->migration_file == NULL) {
|
if (s->file == NULL) {
|
||||||
error_setg_errno(errp, errno, "failed to popen the migration target");
|
error_setg_errno(errp, errno, "failed to popen the migration target");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **
|
|||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s->migration_file = qemu_fdopen(fd, "wb");
|
s->file = qemu_fdopen(fd, "wb");
|
||||||
|
|
||||||
migrate_fd_connect(s);
|
migrate_fd_connect(s);
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ static void tcp_wait_for_connect(int fd, void *opaque)
|
|||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
DPRINTF("migrate connect error\n");
|
DPRINTF("migrate connect error\n");
|
||||||
s->migration_file = NULL;
|
s->file = NULL;
|
||||||
migrate_fd_error(s);
|
migrate_fd_error(s);
|
||||||
} else {
|
} else {
|
||||||
DPRINTF("migrate connect success\n");
|
DPRINTF("migrate connect success\n");
|
||||||
s->migration_file = qemu_fopen_socket(fd, "wb");
|
s->file = qemu_fopen_socket(fd, "wb");
|
||||||
migrate_fd_connect(s);
|
migrate_fd_connect(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,11 @@ static void unix_wait_for_connect(int fd, void *opaque)
|
|||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
DPRINTF("migrate connect error\n");
|
DPRINTF("migrate connect error\n");
|
||||||
s->migration_file = NULL;
|
s->file = NULL;
|
||||||
migrate_fd_error(s);
|
migrate_fd_error(s);
|
||||||
} else {
|
} else {
|
||||||
DPRINTF("migrate connect success\n");
|
DPRINTF("migrate connect success\n");
|
||||||
s->migration_file = qemu_fopen_socket(fd, "wb");
|
s->file = qemu_fopen_socket(fd, "wb");
|
||||||
migrate_fd_connect(s);
|
migrate_fd_connect(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
51
migration.c
51
migration.c
@ -270,9 +270,6 @@ static void migrate_fd_cleanup(void *opaque)
|
|||||||
|
|
||||||
if (s->file) {
|
if (s->file) {
|
||||||
DPRINTF("closing file\n");
|
DPRINTF("closing file\n");
|
||||||
qemu_fclose(s->file);
|
|
||||||
s->file = NULL;
|
|
||||||
|
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
qemu_thread_join(&s->thread);
|
qemu_thread_join(&s->thread);
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
@ -280,7 +277,7 @@ static void migrate_fd_cleanup(void *opaque)
|
|||||||
migrate_fd_close(s);
|
migrate_fd_close(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(s->migration_file == NULL);
|
assert(s->file == NULL);
|
||||||
assert(s->state != MIG_STATE_ACTIVE);
|
assert(s->state != MIG_STATE_ACTIVE);
|
||||||
|
|
||||||
if (s->state != MIG_STATE_COMPLETED) {
|
if (s->state != MIG_STATE_COMPLETED) {
|
||||||
@ -317,9 +314,9 @@ static void migrate_fd_cancel(MigrationState *s)
|
|||||||
int migrate_fd_close(MigrationState *s)
|
int migrate_fd_close(MigrationState *s)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
if (s->migration_file != NULL) {
|
if (s->file != NULL) {
|
||||||
rc = qemu_fclose(s->migration_file);
|
rc = qemu_fclose(s->file);
|
||||||
s->migration_file = NULL;
|
s->file = NULL;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -506,39 +503,6 @@ int64_t migrate_xbzrle_cache_size(void)
|
|||||||
|
|
||||||
/* migration thread support */
|
/* migration thread support */
|
||||||
|
|
||||||
static int migration_put_buffer(void *opaque, const uint8_t *buf,
|
|
||||||
int64_t pos, int size)
|
|
||||||
{
|
|
||||||
MigrationState *s = opaque;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
|
|
||||||
|
|
||||||
if (size <= 0) {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_put_buffer(s->migration_file, buf, size);
|
|
||||||
ret = qemu_file_get_error(s->migration_file);
|
|
||||||
if (ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int migration_close(void *opaque)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int migration_get_fd(void *opaque)
|
|
||||||
{
|
|
||||||
MigrationState *s = opaque;
|
|
||||||
|
|
||||||
return qemu_get_fd(s->migration_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *migration_thread(void *opaque)
|
static void *migration_thread(void *opaque)
|
||||||
{
|
{
|
||||||
MigrationState *s = opaque;
|
MigrationState *s = opaque;
|
||||||
@ -628,12 +592,6 @@ static void *migration_thread(void *opaque)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QEMUFileOps migration_file_ops = {
|
|
||||||
.get_fd = migration_get_fd,
|
|
||||||
.put_buffer = migration_put_buffer,
|
|
||||||
.close = migration_close,
|
|
||||||
};
|
|
||||||
|
|
||||||
void migrate_fd_connect(MigrationState *s)
|
void migrate_fd_connect(MigrationState *s)
|
||||||
{
|
{
|
||||||
s->state = MIG_STATE_ACTIVE;
|
s->state = MIG_STATE_ACTIVE;
|
||||||
@ -642,7 +600,6 @@ void migrate_fd_connect(MigrationState *s)
|
|||||||
/* This is a best 1st approximation. ns to ms */
|
/* This is a best 1st approximation. ns to ms */
|
||||||
s->expected_downtime = max_downtime/1000000;
|
s->expected_downtime = max_downtime/1000000;
|
||||||
s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s);
|
s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s);
|
||||||
s->file = qemu_fopen_ops(s, &migration_file_ops);
|
|
||||||
|
|
||||||
qemu_file_set_rate_limit(s->file,
|
qemu_file_set_rate_limit(s->file,
|
||||||
s->bandwidth_limit / XFER_LIMIT_RATIO);
|
s->bandwidth_limit / XFER_LIMIT_RATIO);
|
||||||
|
Loading…
Reference in New Issue
Block a user