[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 09/47] Add wrapper for setting blocking status on
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH v6 09/47] Add wrapper for setting blocking status on a QEMUFile |
Date: |
Tue, 14 Apr 2015 18:03:35 +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>
---
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 4cac58f..c14555d 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -190,6 +190,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_change_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 ec3a598..d84830f 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -609,3 +609,18 @@ int qemu_get_counted_string(QEMUFile *f, char buf[256])
return res != len;
}
+/*
+ * Change 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_change_blocking(QEMUFile *f, bool block)
+{
+ if (block) {
+ qemu_set_block(qemu_get_fd(f));
+ } else {
+ qemu_set_nonblock(qemu_get_fd(f));
+ }
+}
+
--
2.1.0
- [Qemu-devel] [PATCH v6 00/47] Postcopy implementation, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 02/47] Split header writing out of qemu_savevm_state_begin, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 01/47] Start documenting how postcopy works., Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 04/47] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 03/47] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 05/47] Create MigrationIncomingState, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 06/47] Provide runtime Target page information, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 09/47] Add wrapper for setting blocking status on a QEMUFile,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH v6 07/47] Move copy out of qemu_peek_buffer, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 13/47] Migration commands, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 10/47] Rename save_live_complete to save_live_complete_precopy, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 12/47] Return path: socket_writev_buffer: Block even on non-blocking fd's, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 08/47] Add qemu_get_buffer_less_copy to avoid copies some of the time, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 11/47] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 15/47] Return path: Send responses from destination to source, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 14/47] Return path: Control commands, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 17/47] ram_debug_dump_bitmap: Dump a migration bitmap as text, Dr. David Alan Gilbert (git), 2015/04/14
- [Qemu-devel] [PATCH v6 18/47] Move loadvm_handlers into MigrationIncomingState, Dr. David Alan Gilbert (git), 2015/04/14