[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a Q
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile |
Date: |
Tue, 10 Nov 2015 15:24:58 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Add a wrapper to change the blocking status on a QEMUFile
rather than having to use qemu_set_block(qemu_get_fd(f));
it seems best to avoid exposing the fd since not all QEMUFile's
really have one. With this wrapper we could move the implementation
down to be different on different transports.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Amit Shah <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
---
include/migration/qemu-file.h | 1 +
migration/qemu-file.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 86bb972..66e741f 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -197,6 +197,7 @@ int qemu_file_get_error(QEMUFile *f);
void qemu_file_set_error(QEMUFile *f, int ret);
int qemu_file_shutdown(QEMUFile *f);
void qemu_fflush(QEMUFile *f);
+void qemu_file_set_blocking(QEMUFile *f, bool block);
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
{
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index e41a677..9ec2267 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -648,3 +648,18 @@ size_t qemu_get_counted_string(QEMUFile *f, char buf[256])
return res == len ? res : 0;
}
+
+/*
+ * Set the blocking state of the QEMUFile.
+ * Note: On some transports the OS only keeps a single blocking state for
+ * both directions, and thus changing the blocking on the main
+ * QEMUFile can also affect the return path.
+ */
+void qemu_file_set_blocking(QEMUFile *f, bool block)
+{
+ if (block) {
+ qemu_set_block(qemu_get_fd(f));
+ } else {
+ qemu_set_nonblock(qemu_get_fd(f));
+ }
+}
--
2.5.0
- [Qemu-devel] [PULL 00/57] Migration pull (take 2), Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 01/57] Add postcopy documentation, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 03/57] Move configuration section writing, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 02/57] Provide runtime Target page information, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 05/57] qemu_ram_block_from_host, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 04/57] Move page_size_init earlier, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 06/57] qemu_ram_block_by_name, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 08/57] Add qemu_get_buffer_in_place to avoid copies some of the time, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 09/57] Add wrapper for setting blocking status on a QEMUFile,
Juan Quintela <=
- [Qemu-devel] [PULL 10/57] Add QEMU_MADV_NOHUGEPAGE, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 07/57] Rename mis->file to from_src_file, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 11/57] ram_debug_dump_bitmap: Dump a migration bitmap as text, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 12/57] ram_load: Factor out host_from_stream_offset call and check, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 14/57] Rename save_live_complete to save_live_complete_precopy, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 15/57] Add Linux userfaultfd.h header, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 13/57] migrate_init: Call from savevm, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 16/57] Return path: Open a return path on QEMUFile for sockets, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 17/57] Return path: socket_writev_buffer: Block even on non-blocking fd's, Juan Quintela, 2015/11/10
- [Qemu-devel] [PULL 19/57] Return path: Control commands, Juan Quintela, 2015/11/10