[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8 08/54] Add wrapper for setting blocking status on
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v8 08/54] Add wrapper for setting blocking status on a QEMUFile |
Date: |
Tue, 29 Sep 2015 09:37:32 +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>
---
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 ca96461..865f897 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 05a41b3..3c64a9c 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -658,3 +658,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 v8 02/54] Provide runtime Target page information, (continued)
- [Qemu-devel] [PATCH v8 02/54] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 01/54] Add postcopy documentation, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 04/54] Move configuration section writing, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 03/54] Init page sizes in qtest, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 06/54] Rename mis->file to from_src_file, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 05/54] qemu_ram_block_from_host, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 07/54] Add qemu_get_buffer_in_place to avoid copies some of the time, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 08/54] Add wrapper for setting blocking status on a QEMUFile,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v8 09/54] Add QEMU_MADV_NOHUGEPAGE, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 10/54] migration/ram.c: Use RAMBlock rather than MemoryRegion, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 11/54] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 12/54] migrate_init: Call from savevm, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 13/54] Move dirty page search state into separate structure, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 14/54] ram_find_and_save_block: Split out the finding, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 15/54] Rename save_live_complete to save_live_complete_precopy, Dr. David Alan Gilbert (git), 2015/10/01
- [Qemu-devel] [PATCH v8 17/54] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/10/01