[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH FYI 34/46] migration: introduce qemu_fset_blocking f
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH FYI 34/46] migration: introduce qemu_fset_blocking function on QEMUFile |
Date: |
Thu, 3 Sep 2015 16:39:16 +0100 |
Remove the assumption that every QEMUFile implementation has
a file descriptor available by introducing a new function
to change the blocking state of a QEMUFile.
Provide a default impl of the new method based on the get_fd
method.
Signed-off-by: Daniel P. Berrange <address@hidden>
---
include/migration/qemu-file.h | 6 ++++++
migration/migration.c | 4 +---
migration/qemu-file.c | 15 +++++++++++++++
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index a4e5468..2625d9b 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -55,6 +55,10 @@ typedef int (QEMUFileCloseFunc)(void *opaque);
*/
typedef int (QEMUFileGetFD)(void *opaque);
+/* Called to change the blocking mode of the file
+ */
+typedef int (QEMUFileSetBlocking)(void *opaque, bool enabled);
+
/*
* This function writes an iovec to file. The handler must write all
* of the data or return a negative errno value.
@@ -103,6 +107,7 @@ typedef struct QEMUFileOps {
QEMUFileGetBufferFunc *get_buffer;
QEMUFileCloseFunc *close;
QEMUFileGetFD *get_fd;
+ QEMUFileSetBlocking *set_blocking;
QEMUFileWritevBufferFunc *writev_buffer;
QEMUFileShutdownFunc *shut_down;
} QEMUFileOps;
@@ -128,6 +133,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode);
QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks);
int qemu_get_fd(QEMUFile *f);
+int qemu_fset_blocking(QEMUFile *f, bool enabled);
int qemu_fclose(QEMUFile *f);
int64_t qemu_ftell(QEMUFile *f);
int64_t qemu_ftell_fast(QEMUFile *f);
diff --git a/migration/migration.c b/migration/migration.c
index 662e77e..83a3960 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -317,11 +317,9 @@ static void process_incoming_migration_co(void *opaque)
void process_incoming_migration(QEMUFile *f)
{
Coroutine *co = qemu_coroutine_create(process_incoming_migration_co);
- int fd = qemu_get_fd(f);
- assert(fd != -1);
migrate_decompress_threads_create();
- qemu_set_nonblock(fd);
+ qemu_fset_blocking(f, false);
qemu_coroutine_enter(co, f);
}
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 9f42f5c..c8b0b79 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -270,6 +270,21 @@ int qemu_get_fd(QEMUFile *f)
return -1;
}
+int qemu_fset_blocking(QEMUFile *f, bool enabled)
+{
+ if (f->ops->set_blocking) {
+ return f->ops->set_blocking(f->opaque, enabled);
+ } else if (f->ops->get_fd) {
+ int fd = f->ops->get_fd(f->opaque);
+ if (enabled) {
+ qemu_set_block(fd);
+ } else {
+ qemu_set_nonblock(fd);
+ }
+ }
+ return -1;
+}
+
void qemu_update_position(QEMUFile *f, size_t size)
{
f->pos += size;
--
2.4.3
- [Qemu-devel] [PATCH FYI 26/46] sockets: remove use of QemuOpts from socket_listen, (continued)
- [Qemu-devel] [PATCH FYI 26/46] sockets: remove use of QemuOpts from socket_listen, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 28/46] sockets: remove use of QemuOpts from socket_dgram, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 27/46] sockets: remove use of QemuOpts from socket_connect, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 29/46] migration: remove use of qemu_bufopen from vmstate tests, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 31/46] migration: move definition of struct QEMUFile back into qemu-file.c, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 32/46] migration: split migration hooks out of QEMUFileOps, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 30/46] migration: remove memory buffer based QEMUFile backend, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 33/46] migration: ensure qemu_fflush() always writes full data amount, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 34/46] migration: introduce qemu_fset_blocking function on QEMUFile,
Daniel P. Berrange <=
- [Qemu-devel] [PATCH FYI 36/46] migration: introduce a new QEMUFile impl based on QIOChannel, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 35/46] migration: force QEMUFile to blocking mode for outgoing migration, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 37/46] migration: convert unix socket protocol to use QIOChannel, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 39/46] migration: convert fd socket protocol to use QIOChannel, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 38/46] migration: convert tcp socket protocol to use QIOChannel, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 42/46] migration: convert savevm to use QIOChannel for writing to files, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 40/46] migration: convert exec socket protocol to use QIOChannel, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 43/46] migration: delete QEMUFile sockets implementation, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 44/46] migration: delete QEMUFile stdio implementation, Daniel P. Berrange, 2015/09/03
- [Qemu-devel] [PATCH FYI 41/46] migration: convert RDMA to use QIOChannel interface, Daniel P. Berrange, 2015/09/03