Skip to content

Commit b352365

Browse files
bonziniJuan Quintela
authored and
Juan Quintela
committedMar 11, 2013
migration: eliminate s->migration_file
The indirection is useless now. Backends can open s->file directly. Reviewed-by: Orit Wasserman <[email protected]> Reviewed-by: Juan Quintela <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Juan Quintela <[email protected]>
1 parent 404a7c0 commit b352365

File tree

6 files changed

+11
-56
lines changed

6 files changed

+11
-56
lines changed
 

‎include/migration/migration.h

-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ struct MigrationState
3636
size_t xfer_limit;
3737
QemuThread thread;
3838
QEMUBH *cleanup_bh;
39-
4039
QEMUFile *file;
41-
QEMUFile *migration_file;
4240

4341
int state;
4442
MigrationParams params;

‎migration-exec.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
void exec_start_outgoing_migration(MigrationState *s, const char *command, Error **errp)
3737
{
38-
s->migration_file = qemu_popen_cmd(command, "w");
39-
if (s->migration_file == NULL) {
38+
s->file = qemu_popen_cmd(command, "w");
39+
if (s->file == NULL) {
4040
error_setg_errno(errp, errno, "failed to popen the migration target");
4141
return;
4242
}

‎migration-fd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **
3636
if (fd == -1) {
3737
return;
3838
}
39-
s->migration_file = qemu_fdopen(fd, "wb");
39+
s->file = qemu_fdopen(fd, "wb");
4040

4141
migrate_fd_connect(s);
4242
}

‎migration-tcp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ static void tcp_wait_for_connect(int fd, void *opaque)
3535

3636
if (fd < 0) {
3737
DPRINTF("migrate connect error\n");
38-
s->migration_file = NULL;
38+
s->file = NULL;
3939
migrate_fd_error(s);
4040
} else {
4141
DPRINTF("migrate connect success\n");
42-
s->migration_file = qemu_fopen_socket(fd, "wb");
42+
s->file = qemu_fopen_socket(fd, "wb");
4343
migrate_fd_connect(s);
4444
}
4545
}

‎migration-unix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ static void unix_wait_for_connect(int fd, void *opaque)
3535

3636
if (fd < 0) {
3737
DPRINTF("migrate connect error\n");
38-
s->migration_file = NULL;
38+
s->file = NULL;
3939
migrate_fd_error(s);
4040
} else {
4141
DPRINTF("migrate connect success\n");
42-
s->migration_file = qemu_fopen_socket(fd, "wb");
42+
s->file = qemu_fopen_socket(fd, "wb");
4343
migrate_fd_connect(s);
4444
}
4545
}

‎migration.c

+4-47
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,14 @@ static void migrate_fd_cleanup(void *opaque)
270270

271271
if (s->file) {
272272
DPRINTF("closing file\n");
273-
qemu_fclose(s->file);
274-
s->file = NULL;
275-
276273
qemu_mutex_unlock_iothread();
277274
qemu_thread_join(&s->thread);
278275
qemu_mutex_lock_iothread();
279276

280277
migrate_fd_close(s);
281278
}
282279

283-
assert(s->migration_file == NULL);
280+
assert(s->file == NULL);
284281
assert(s->state != MIG_STATE_ACTIVE);
285282

286283
if (s->state != MIG_STATE_COMPLETED) {
@@ -317,9 +314,9 @@ static void migrate_fd_cancel(MigrationState *s)
317314
int migrate_fd_close(MigrationState *s)
318315
{
319316
int rc = 0;
320-
if (s->migration_file != NULL) {
321-
rc = qemu_fclose(s->migration_file);
322-
s->migration_file = NULL;
317+
if (s->file != NULL) {
318+
rc = qemu_fclose(s->file);
319+
s->file = NULL;
323320
}
324321
return rc;
325322
}
@@ -506,39 +503,6 @@ int64_t migrate_xbzrle_cache_size(void)
506503

507504
/* migration thread support */
508505

509-
static int migration_put_buffer(void *opaque, const uint8_t *buf,
510-
int64_t pos, int size)
511-
{
512-
MigrationState *s = opaque;
513-
int ret;
514-
515-
DPRINTF("putting %d bytes at %" PRId64 "\n", size, pos);
516-
517-
if (size <= 0) {
518-
return size;
519-
}
520-
521-
qemu_put_buffer(s->migration_file, buf, size);
522-
ret = qemu_file_get_error(s->migration_file);
523-
if (ret) {
524-
return ret;
525-
}
526-
527-
return size;
528-
}
529-
530-
static int migration_close(void *opaque)
531-
{
532-
return 0;
533-
}
534-
535-
static int migration_get_fd(void *opaque)
536-
{
537-
MigrationState *s = opaque;
538-
539-
return qemu_get_fd(s->migration_file);
540-
}
541-
542506
static void *migration_thread(void *opaque)
543507
{
544508
MigrationState *s = opaque;
@@ -628,12 +592,6 @@ static void *migration_thread(void *opaque)
628592
return NULL;
629593
}
630594

631-
static const QEMUFileOps migration_file_ops = {
632-
.get_fd = migration_get_fd,
633-
.put_buffer = migration_put_buffer,
634-
.close = migration_close,
635-
};
636-
637595
void migrate_fd_connect(MigrationState *s)
638596
{
639597
s->state = MIG_STATE_ACTIVE;
@@ -642,7 +600,6 @@ void migrate_fd_connect(MigrationState *s)
642600
/* This is a best 1st approximation. ns to ms */
643601
s->expected_downtime = max_downtime/1000000;
644602
s->cleanup_bh = qemu_bh_new(migrate_fd_cleanup, s);
645-
s->file = qemu_fopen_ops(s, &migration_file_ops);
646603

647604
qemu_file_set_rate_limit(s->file,
648605
s->bandwidth_limit / XFER_LIMIT_RATIO);

0 commit comments

Comments
 (0)
Please sign in to comment.