[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 06/23] Introduce read() to FdMigrationState.
From: |
Yoshiaki Tamura |
Subject: |
[Qemu-devel] [RFC PATCH 06/23] Introduce read() to FdMigrationState. |
Date: |
Tue, 25 May 2010 17:36:47 +0900 |
Currently FdMigrationState doesn't support read(), and this patch
introduces it to get response from the other side.
Signed-off-by: Yoshiaki Tamura <address@hidden>
---
migration-tcp.c | 14 ++++++++++++++
migration.c | 12 ++++++++++++
migration.h | 3 +++
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/migration-tcp.c b/migration-tcp.c
index e7f307c..cffc4df 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -39,6 +39,19 @@ static int socket_write(FdMigrationState *s, const void *
buf, size_t size)
return send(s->fd, buf, size, 0);
}
+static int socket_read(FdMigrationState *s, const void * buf, size_t size)
+{
+ ssize_t len;
+
+ do {
+ len = recv(s->fd, (void *)buf, size, 0);
+ } while (len == -1 && socket_error() == EINTR);
+ if (len == -1)
+ len = -socket_error();
+
+ return len;
+}
+
static int tcp_close(FdMigrationState *s)
{
DPRINTF("tcp_close\n");
@@ -94,6 +107,7 @@ MigrationState *tcp_start_outgoing_migration(Monitor *mon,
s->get_error = socket_errno;
s->write = socket_write;
+ s->read = socket_read;
s->close = tcp_close;
s->mig_state.cancel = migrate_fd_cancel;
s->mig_state.get_status = migrate_fd_get_status;
diff --git a/migration.c b/migration.c
index 05f6cc5..a2ca6ef 100644
--- a/migration.c
+++ b/migration.c
@@ -337,6 +337,18 @@ ssize_t migrate_fd_put_buffer(void *opaque, const void
*data, size_t size)
return ret;
}
+int migrate_fd_get_buffer(void *opaque, uint8_t *data, int64_t pos, int size)
+{
+ FdMigrationState *s = opaque;
+ ssize_t ret;
+ ret = s->read(s, data, size);
+
+ if (ret == -1)
+ ret = -(s->get_error(s));
+
+ return ret;
+}
+
void migrate_fd_connect(FdMigrationState *s)
{
int ret;
diff --git a/migration.h b/migration.h
index 385423f..6f8af97 100644
--- a/migration.h
+++ b/migration.h
@@ -47,6 +47,7 @@ struct FdMigrationState
int (*get_error)(struct FdMigrationState*);
int (*close)(struct FdMigrationState*);
int (*write)(struct FdMigrationState*, const void *, size_t);
+ int (*read)(struct FdMigrationState *, const void *, size_t);
void *opaque;
};
@@ -113,6 +114,8 @@ void migrate_fd_put_notify(void *opaque);
ssize_t migrate_fd_put_buffer(void *opaque, const void *data, size_t size);
+int migrate_fd_get_buffer(void *opaque, uint8_t *data, int64_t pos, int size);
+
void migrate_fd_connect(FdMigrationState *s);
void migrate_fd_put_ready(void *opaque);
--
1.7.0.31.g1df487
- [Qemu-devel] [RFC PATCH 19/23] Introduce ft_tranx_ready(), and modify migrate_fd_put_ready() when ft_mode is on., (continued)
- [Qemu-devel] [RFC PATCH 19/23] Introduce ft_tranx_ready(), and modify migrate_fd_put_ready() when ft_mode is on., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 22/23] Introduce -k option to enable FT migration mode (Kemari)., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 21/23] virtio-blk: Modify save/load handler to handle inuse varialble., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 08/23] Introduce some socket util functions., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 04/23] Use cpu_physical_memory_get_dirty_range() to check multiple dirty pages., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 20/23] Modify tcp_accept_incoming_migration() to handle ft_mode, and add a hack not to close fd when ft_mode is enabled., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 23/23] Add a parser to accept FT migration incoming mode., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 07/23] Introduce skip_header parameter to qemu_loadvm_state()., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 12/23] Insent event-tap callbacks to net/block layer., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 03/23] Use cpu_physical_memory_set_dirty_range() to update phys_ram_dirty., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 06/23] Introduce read() to FdMigrationState.,
Yoshiaki Tamura <=
- [Qemu-devel] [RFC PATCH 18/23] Call event_tap_replay() at vm_start()., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 11/23] Introduce qemu_savevm_state_all()., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 13/23] Introduce event-tap., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 17/23] Skip assert() when event_tap_state weren't EVENT_TAP_OFF., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 05/23] Make QEMUFile buf expandable, and introduce qemu_realloc_buffer() and qemu_clear_buffer()., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 00/23] Kemari for KVM v0.1.1, Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 01/23] Modify DIRTY_FLAG value and introduce DIRTY_IDX to use as indexes of bit-based phys_ram_dirty., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 02/23] Introduce cpu_physical_memory_get_dirty_range()., Yoshiaki Tamura, 2010/05/25
- [Qemu-devel] [RFC PATCH 09/23] Introduce fault tolerant VM transaction QEMUFile and ft_mode., Yoshiaki Tamura, 2010/05/25