[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 30/30] migration/rdma: Split qemu_fopen_rdma() into input/output f
From: |
Juan Quintela |
Subject: |
[PULL 30/30] migration/rdma: Split qemu_fopen_rdma() into input/output functions |
Date: |
Thu, 22 Jun 2023 04:13:20 +0200 |
This is how everything else in QEMUFile is structured.
As a bonus they are three less lines of code.
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-ID: <20230530183941.7223-17-quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/qemu-file.h | 1 -
migration/qemu-file.c | 12 ------------
migration/rdma.c | 39 +++++++++++++++++++--------------------
3 files changed, 19 insertions(+), 33 deletions(-)
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
index 8b8b7d27fe..47015f5201 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
@@ -102,7 +102,6 @@ uint64_t qemu_file_transferred_noflush(QEMUFile *f);
*/
void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, size_t size,
bool may_free);
-bool qemu_file_mode_is_not_valid(const char *mode);
#include "migration/qemu-file-types.h"
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index d30bf3c377..19c33c9985 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -100,18 +100,6 @@ int qemu_file_shutdown(QEMUFile *f)
return 0;
}
-bool qemu_file_mode_is_not_valid(const char *mode)
-{
- if (mode == NULL ||
- (mode[0] != 'r' && mode[0] != 'w') ||
- mode[1] != 'b' || mode[2] != 0) {
- fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
- return true;
- }
-
- return false;
-}
-
static QEMUFile *qemu_file_new_impl(QIOChannel *ioc, bool is_writable)
{
QEMUFile *f;
diff --git a/migration/rdma.c b/migration/rdma.c
index dd1c039e6c..ca430d319d 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -4053,27 +4053,26 @@ static void qio_channel_rdma_register_types(void)
type_init(qio_channel_rdma_register_types);
-static QEMUFile *qemu_fopen_rdma(RDMAContext *rdma, const char *mode)
+static QEMUFile *rdma_new_input(RDMAContext *rdma)
{
- QIOChannelRDMA *rioc;
+ QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA));
- if (qemu_file_mode_is_not_valid(mode)) {
- return NULL;
- }
+ rioc->file = qemu_file_new_input(QIO_CHANNEL(rioc));
+ rioc->rdmain = rdma;
+ rioc->rdmaout = rdma->return_path;
+ qemu_file_set_hooks(rioc->file, &rdma_read_hooks);
- rioc = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA));
+ return rioc->file;
+}
- if (mode[0] == 'w') {
- rioc->file = qemu_file_new_output(QIO_CHANNEL(rioc));
- rioc->rdmaout = rdma;
- rioc->rdmain = rdma->return_path;
- qemu_file_set_hooks(rioc->file, &rdma_write_hooks);
- } else {
- rioc->file = qemu_file_new_input(QIO_CHANNEL(rioc));
- rioc->rdmain = rdma;
- rioc->rdmaout = rdma->return_path;
- qemu_file_set_hooks(rioc->file, &rdma_read_hooks);
- }
+static QEMUFile *rdma_new_output(RDMAContext *rdma)
+{
+ QIOChannelRDMA *rioc = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA));
+
+ rioc->file = qemu_file_new_output(QIO_CHANNEL(rioc));
+ rioc->rdmaout = rdma;
+ rioc->rdmain = rdma->return_path;
+ qemu_file_set_hooks(rioc->file, &rdma_write_hooks);
return rioc->file;
}
@@ -4099,9 +4098,9 @@ static void rdma_accept_incoming_migration(void *opaque)
return;
}
- f = qemu_fopen_rdma(rdma, "rb");
+ f = rdma_new_input(rdma);
if (f == NULL) {
- fprintf(stderr, "RDMA ERROR: could not qemu_fopen_rdma\n");
+ fprintf(stderr, "RDMA ERROR: could not open RDMA for input\n");
qemu_rdma_cleanup(rdma);
return;
}
@@ -4224,7 +4223,7 @@ void rdma_start_outgoing_migration(void *opaque,
trace_rdma_start_outgoing_migration_after_rdma_connect();
- s->to_dst_file = qemu_fopen_rdma(rdma, "wb");
+ s->to_dst_file = rdma_new_output(rdma);
migrate_fd_connect(s, NULL);
return;
return_path_err:
--
2.40.1
- [PULL 20/30] migration: Update error description whenever migration fails, (continued)
- [PULL 20/30] migration: Update error description whenever migration fails, Juan Quintela, 2023/06/21
- [PULL 16/30] migration-test: bootpath is the same for all tests and for all archs, Juan Quintela, 2023/06/21
- [PULL 25/30] migration: Change qemu_file_transferred to noflush, Juan Quintela, 2023/06/21
- [PULL 22/30] migration: enforce multifd and postcopy preempt to be set before incoming, Juan Quintela, 2023/06/21
- [PULL 24/30] qemu-file: Rename qemu_file_transferred_ fast -> noflush, Juan Quintela, 2023/06/21
- [PULL 26/30] migration: Use qemu_file_transferred_noflush() for block migration., Juan Quintela, 2023/06/21
- [PULL 28/30] qemu-file: Simplify qemu_file_shutdown(), Juan Quintela, 2023/06/21
- [PULL 27/30] qemu_file: Make qemu_file_is_writable() static, Juan Quintela, 2023/06/21
- [PULL 29/30] qemu-file: Make qemu_file_get_error_obj() static, Juan Quintela, 2023/06/21
- [PULL 30/30] migration/rdma: Split qemu_fopen_rdma() into input/output functions,
Juan Quintela <=
- Re: [PULL 00/30] Next patches, Richard Henderson, 2023/06/22
- [PULL 00/30] Next patches, Juan Quintela, 2023/06/22
- [PULL 01/30] migration/multifd: Rename threadinfo.c functions, Juan Quintela, 2023/06/22
- [PULL 02/30] migration/multifd: Protect accesses to migration_threads, Juan Quintela, 2023/06/22
- [PULL 06/30] migration: Introduce dirty-limit capability, Juan Quintela, 2023/06/22
- [PULL 04/30] qapi/migration: Introduce x-vcpu-dirty-limit-period parameter, Juan Quintela, 2023/06/22
- [PULL 05/30] qapi/migration: Introduce vcpu-dirty-limit parameters, Juan Quintela, 2023/06/22
- [PULL 03/30] softmmu/dirtylimit: Add parameter check for hmp "set_vcpu_dirty_limit", Juan Quintela, 2023/06/22
- [PULL 07/30] migration: Refactor auto-converge capability logic, Juan Quintela, 2023/06/22