Skip to contentSkip to conversation

migration to/from file (v3 aio) -- additions

PATCH New Uri Lublin 1 participant 1 message Feb 24, 2009

lore
Share & tools
lore

Uri Lublin

author
#0 lore raw

PATCH 1/1 migration to/from file (v3 aio) -- additions

Hello,

The first patch-for-review that implemented migration-to-file using aio, used polling to figure out an aio operation completed.

The attached two patches make the migration-to-file not poll for aio completion, but use signal instead (SIGUSR1).

As Anthony suggested I've added a set_fd callback to the fd-migration code.
Now upon EAGAIN we do not automatically add the fd to qemu-select rfds set (but the default callback does that). Instead we call set_fd callback. Most migration protocols would use the default. Current migration-to-file implementation (v3 aio) fake EAGAIN, and thus make its set_fd empty. When aio is completed a signal is received and only then the fd is added to the qemu-select rfds.

This version is quite slow (takes a few minutes to save a stopped 128M guest). I think if we add more aio calls (currently only 1), we can get better performance.

Alternatively we can try to open a pipe and create a "writing-thread" use the fd-migration code as is (v4).

Regards,
Uri.

Quoted 1 line

From 41ff718ab6f08a83e81c45e4da6ec5b250680a14 Mon Sep 17 00:00:00 2001

From: Uri Lublin <[email protected]>
Date: Tue, 24 Feb 2009 07:03:40 +0200
Subject: [PATCH FOR REVIEW 1/2] migration: adding set_fd callback to fd-migration

The default fd_migrate_set_fd just add the fd to "qemu-big-select". Can be implemented differently for other migration protocols.

---
 migration-exec.c |    1 +
 migration-tcp.c  |    1 +
 migration.c      |    9 +++++++--
 migration.h      |    3 +++
 4 files changed, 12 insertions(+), 2 deletions(-)
migration-exec.c +1 -0
index 6ed322a..ede63ae 100644
@@ -84,6 +84,7 @@ MigrationState *exec_start_outgoing_migration(const char *command,
     s->close = exec_close;
     s->get_error = file_errno;
     s->write = file_write;
+    s->set_fd =  migrate_fd_set_fd;
     s->mig_state.cancel = migrate_fd_cancel;
     s->mig_state.get_status = migrate_fd_get_status;
     s->mig_state.release = migrate_fd_release;
migration-tcp.c +1 -0
index 3f5b104..5772d21 100644
@@ -93,6 +93,7 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
     s->get_error = socket_errno;
     s->write = socket_write;
     s->close = tcp_close;
+    s->set_fd = migrate_fd_set_fd;
     s->mig_state.cancel = migrate_fd_cancel;
     s->mig_state.get_status = migrate_fd_get_status;
     s->mig_state.release = migrate_fd_release;
migration.c +7 -2
index 234dcf6..e4961ea 100644
@@ -169,6 +169,11 @@ void migrate_fd_put_notify(void *opaque)
     qemu_file_put_notify(s->file);
 }
 
+int migrate_fd_set_fd(FdMigrationState *s)
+{
+    return qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
+}
+
 ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
 {
     FdMigrationState *s = opaque;
@@ -176,13 +181,13 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size)
 
     do {
         ret = s->write(s, data, size);
-    } while (ret == -1 && ((s->get_error(s)) == EINTR || (s->get_error(s)) == EWOULDBLOCK));
+    } while (ret == -1 && (s->get_error(s) == EINTR));
 
     if (ret == -1)
         ret = -(s->get_error(s));
 
     if (ret == -EAGAIN)
-        qemu_set_fd_handler2(s->fd, NULL, NULL, migrate_fd_put_notify, s);
+        s->set_fd(s);
 
     return ret;
 }
migration.h +3 -0
index ae78792..5c3d5eb 100644
@@ -42,6 +42,7 @@ struct FdMigrationState
     int (*get_error)(struct FdMigrationState*);
     int (*close)(struct FdMigrationState*);
     int (*write)(struct FdMigrationState*, const void *, size_t);
+    int (*set_fd)(struct FdMigrationState*);
     void *opaque;
 };
 
@@ -79,6 +80,8 @@ void migrate_fd_cleanup(FdMigrationState *s);
 
 void migrate_fd_put_notify(void *opaque);
 
+int migrate_fd_set_fd(FdMigrationState *s);
+
 ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size);
 
 void migrate_fd_connect(FdMigrationState *s);
Signature · 1 line
1.6.0.6
Quoted 1 line

From f765d3baaf10174e7942f15dd801975125bc3d34 Mon Sep 17 00:00:00 2001

From: Uri Lublin <[email protected]>
Date: Tue, 24 Feb 2009 07:12:18 +0200
Subject: [PATCH 2/2 FOR REVIEW] migration to file: use signal for async-write notification

Instead of looping by io-handler called by writeable fd, do not register handler, and use signal SIGUSR1 for aio completion notifications.

---
 migration-file.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 113 insertions(+), 11 deletions(-)
migration-file.c +113 -11

194 lines not on this page · raw message

Signature · 1 line
1.6.0.6