[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 16/20] migration/rdma: Split qemu_fopen_rdma() into input/outp
From: |
Juan Quintela |
Subject: |
[PATCH v2 16/20] migration/rdma: Split qemu_fopen_rdma() into input/output functions |
Date: |
Tue, 30 May 2023 20:39:37 +0200 |
This is how everything else in QEMUFile is structured.
As a bonus they are three less lines of code.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
migration/rdma.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index 3ef35fc635..606837bd45 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -4046,25 +4046,22 @@ 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));
+ rioc->file = qemu_file_new_input(QIO_CHANNEL(rioc));
+ rioc->rdmain = rdma;
+ rioc->rdmaout = rdma->return_path;
- if (qemu_file_mode_is_not_valid(mode)) {
- return NULL;
- }
+ return rioc->file;
+}
- rioc = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA));
-
- if (mode[0] == 'w') {
- rioc->file = qemu_file_new_output(QIO_CHANNEL(rioc));
- rioc->rdmaout = rdma;
- rioc->rdmain = rdma->return_path;
- } else {
- rioc->file = qemu_file_new_input(QIO_CHANNEL(rioc));
- rioc->rdmain = rdma;
- rioc->rdmaout = rdma->return_path;
- }
+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;
return rioc->file;
}
@@ -4090,9 +4087,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;
}
@@ -4217,7 +4214,7 @@ void rdma_start_outgoing_migration(void *opaque,
trace_rdma_start_outgoing_migration_after_rdma_connect();
s->rdma_migration = true;
- 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
- [PATCH v2 09/20] qemu-file: Remove _noflush from qemu_file_transferred_noflush(), (continued)
- [PATCH v2 09/20] qemu-file: Remove _noflush from qemu_file_transferred_noflush(), Juan Quintela, 2023/05/30
- [PATCH v2 10/20] migration: migration_transferred_bytes() don't need the QEMUFile, Juan Quintela, 2023/05/30
- [PATCH v2 11/20] migration: migration_rate_limit_reset() don't need the QEMUFile, Juan Quintela, 2023/05/30
- [PATCH v2 13/20] migration: Use migration_transferred_bytes(), Juan Quintela, 2023/05/30
- [PATCH v2 12/20] qemu-file: Simplify qemu_file_get_error(), Juan Quintela, 2023/05/30
- [PATCH v2 14/20] migration: Remove transferred atomic counter, Juan Quintela, 2023/05/30
- [PATCH v2 15/20] qemu-file: Make qemu_fflush() return errors, Juan Quintela, 2023/05/30
- [PATCH v2 18/20] qemu_file: Make qemu_file_is_writable() static, Juan Quintela, 2023/05/30
- [PATCH v2 19/20] qemu-file: Simplify qemu_file_shutdown(), Juan Quintela, 2023/05/30
- [PATCH v2 20/20] qemu-file: Make qemu_file_get_error_obj() static, Juan Quintela, 2023/05/30
- [PATCH v2 16/20] migration/rdma: Split qemu_fopen_rdma() into input/output functions,
Juan Quintela <=
- [PATCH v2 17/20] qemu-file: Remove unused qemu_file_mode_is_not_valid(), Juan Quintela, 2023/05/30
- Re: [PATCH v2 00/20] Next round of migration atomic counters, Fiona Ebner, 2023/05/31