|
@@ -4053,27 +4053,26 @@ static void qio_channel_rdma_register_types(void)
|
|
|
|
|
|
type_init(qio_channel_rdma_register_types);
|
|
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);
|
|
|
|
+
|
|
|
|
+ return rioc->file;
|
|
|
|
+}
|
|
|
|
|
|
- rioc = QIO_CHANNEL_RDMA(object_new(TYPE_QIO_CHANNEL_RDMA));
|
|
|
|
|
|
+static QEMUFile *rdma_new_output(RDMAContext *rdma)
|
|
|
|
+{
|
|
|
|
+ QIOChannelRDMA *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;
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
|
|
+ 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;
|
|
return rioc->file;
|
|
}
|
|
}
|
|
@@ -4099,9 +4098,9 @@ static void rdma_accept_incoming_migration(void *opaque)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- f = qemu_fopen_rdma(rdma, "rb");
|
|
|
|
|
|
+ f = rdma_new_input(rdma);
|
|
if (f == NULL) {
|
|
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);
|
|
qemu_rdma_cleanup(rdma);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -4224,7 +4223,7 @@ void rdma_start_outgoing_migration(void *opaque,
|
|
|
|
|
|
trace_rdma_start_outgoing_migration_after_rdma_connect();
|
|
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);
|
|
migrate_fd_connect(s, NULL);
|
|
return;
|
|
return;
|
|
return_path_err:
|
|
return_path_err:
|