[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v9 09/56] Add wrapper for setting blocking status on
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v9 09/56] Add wrapper for setting blocking status on a QEMUFile |
Date: |
Thu, 5 Nov 2015 18:10:36 +0000 |
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>
---
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] [PATCH v9 03/56] Move configuration section writing, (continued)
- [Qemu-devel] [PATCH v9 03/56] Move configuration section writing, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 01/56] Add postcopy documentation, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 04/56] Move page_size_init earlier, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 05/56] qemu_ram_block_from_host, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 06/56] qemu_ram_block_by_name, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 08/56] Add qemu_get_buffer_in_place to avoid copies some of the time, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 07/56] Rename mis->file to from_src_file, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 09/56] Add wrapper for setting blocking status on a QEMUFile,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v9 10/56] Add QEMU_MADV_NOHUGEPAGE, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 11/56] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 12/56] ram_load: Factor out host_from_stream_offset call and check, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 13/56] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 16/56] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 15/56] Add Linux userfaultfd.h header, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 14/56] Rename save_live_complete to save_live_complete_precopy, Dr. David Alan Gilbert (git), 2015/11/05
- [Qemu-devel] [PATCH v9 17/56] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/11/05