[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/40] migration: Convert the file backend to the new QAPI syntax
From: |
Juan Quintela |
Subject: |
[PULL 35/40] migration: Convert the file backend to the new QAPI syntax |
Date: |
Thu, 2 Nov 2023 12:40:49 +0100 |
From: Fabiano Rosas <farosas@suse.de>
Convert the file: URI to accept a FileMigrationArgs to be compatible
with the new migration QAPI.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20231023182053.8711-9-farosas@suse.de>
---
migration/file.h | 9 ++++++---
migration/file.c | 22 +++++++---------------
migration/migration.c | 10 ++++------
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/migration/file.h b/migration/file.h
index 3888a57105..37d6a08bfc 100644
--- a/migration/file.h
+++ b/migration/file.h
@@ -7,9 +7,12 @@
#ifndef QEMU_MIGRATION_FILE_H
#define QEMU_MIGRATION_FILE_H
-void file_start_incoming_migration(const char *filename, Error **errp);
-void file_start_outgoing_migration(MigrationState *s, const char *filename,
- Error **errp);
+#include "qapi/qapi-types-migration.h"
+
+void file_start_incoming_migration(FileMigrationArgs *file_args, Error **errp);
+
+void file_start_outgoing_migration(MigrationState *s,
+ FileMigrationArgs *file_args, Error **errp);
int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp);
#endif
diff --git a/migration/file.c b/migration/file.c
index ec069ef329..5d4975f43e 100644
--- a/migration/file.c
+++ b/migration/file.c
@@ -36,20 +36,16 @@ int file_parse_offset(char *filespec, uint64_t *offsetp,
Error **errp)
return 0;
}
-void file_start_outgoing_migration(MigrationState *s, const char *filespec,
- Error **errp)
+void file_start_outgoing_migration(MigrationState *s,
+ FileMigrationArgs *file_args, Error **errp)
{
- g_autofree char *filename = g_strdup(filespec);
g_autoptr(QIOChannelFile) fioc = NULL;
- uint64_t offset = 0;
+ g_autofree char *filename = g_strdup(file_args->filename);
+ uint64_t offset = file_args->offset;
QIOChannel *ioc;
trace_migration_file_outgoing(filename);
- if (file_parse_offset(filename, &offset, errp)) {
- return;
- }
-
fioc = qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TRUNC,
0600, errp);
if (!fioc) {
@@ -73,19 +69,15 @@ static gboolean file_accept_incoming_migration(QIOChannel
*ioc,
return G_SOURCE_REMOVE;
}
-void file_start_incoming_migration(const char *filespec, Error **errp)
+void file_start_incoming_migration(FileMigrationArgs *file_args, Error **errp)
{
- g_autofree char *filename = g_strdup(filespec);
+ g_autofree char *filename = g_strdup(file_args->filename);
QIOChannelFile *fioc = NULL;
- uint64_t offset = 0;
+ uint64_t offset = file_args->offset;
QIOChannel *ioc;
trace_migration_file_incoming(filename);
- if (file_parse_offset(filename, &offset, errp)) {
- return;
- }
-
fioc = qio_channel_file_new_path(filename, O_RDONLY, 0, errp);
if (!fioc) {
return;
diff --git a/migration/migration.c b/migration/migration.c
index 0911fb310c..04037b340c 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -508,7 +508,6 @@ static bool migrate_uri_parse(const char *uri,
static void qemu_start_incoming_migration(const char *uri, Error **errp)
{
- const char *p = NULL;
g_autoptr(MigrationAddress) channel = NULL;
MigrationIncomingState *mis = migration_incoming_get_current();
@@ -551,8 +550,8 @@ static void qemu_start_incoming_migration(const char *uri,
Error **errp)
#endif
} else if (channel->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
exec_start_incoming_migration(channel->u.exec.args, errp);
- } else if (strstart(uri, "file:", &p)) {
- file_start_incoming_migration(p, errp);
+ } else if (channel->transport == MIGRATION_ADDRESS_TYPE_FILE) {
+ file_start_incoming_migration(&channel->u.file, errp);
} else {
error_setg(errp, "unknown migration protocol: %s", uri);
}
@@ -1900,7 +1899,6 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
bool resume_requested;
Error *local_err = NULL;
MigrationState *s = migrate_get_current();
- const char *p = NULL;
g_autoptr(MigrationAddress) channel = NULL;
/* URI is not suitable for migration? */
@@ -1940,8 +1938,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
#endif
} else if (channel->transport == MIGRATION_ADDRESS_TYPE_EXEC) {
exec_start_outgoing_migration(s, channel->u.exec.args, &local_err);
- } else if (strstart(uri, "file:", &p)) {
- file_start_outgoing_migration(s, p, &local_err);
+ } else if (channel->transport == MIGRATION_ADDRESS_TYPE_FILE) {
+ file_start_outgoing_migration(s, &channel->u.file, &local_err);
} else {
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "uri",
"a valid migration protocol");
--
2.41.0
- [PULL 24/40] cpr: reboot mode, (continued)
- [PULL 24/40] cpr: reboot mode, Juan Quintela, 2023/11/02
- [PULL 26/40] migration: Refactor error handling in source return path, Juan Quintela, 2023/11/02
- [PULL 27/40] migration: Allow network to fail even during recovery, Juan Quintela, 2023/11/02
- [PULL 28/40] tests/migration-test: Add a test for postcopy hangs during RECOVER, Juan Quintela, 2023/11/02
- [PULL 29/40] migration: Change ram_dirty_bitmap_reload() retval to bool, Juan Quintela, 2023/11/02
- [PULL 30/40] migration: New QAPI type 'MigrateAddress', Juan Quintela, 2023/11/02
- [PULL 31/40] migration: convert migration 'uri' into 'MigrateAddress', Juan Quintela, 2023/11/02
- [PULL 32/40] migration: convert socket backend to accept MigrateAddress, Juan Quintela, 2023/11/02
- [PULL 34/40] migration: convert exec backend to accept MigrateAddress., Juan Quintela, 2023/11/02
- [PULL 33/40] migration: convert rdma backend to accept MigrateAddress, Juan Quintela, 2023/11/02
- [PULL 35/40] migration: Convert the file backend to the new QAPI syntax,
Juan Quintela <=
- [PULL 36/40] migration: New migrate and migrate-incoming argument 'channels', Juan Quintela, 2023/11/02
- [PULL 38/40] migration: Implement MigrateChannelList to qmp migration flow., Juan Quintela, 2023/11/02
- [PULL 39/40] migration: Implement MigrateChannelList to hmp migration flow., Juan Quintela, 2023/11/02
- [PULL 40/40] migration: modify test_multifd_tcp_none() to use new QAPI syntax., Juan Quintela, 2023/11/02
- [PULL 37/40] migration: modify migration_channels_and_uri_compatible() for new QAPI syntax, Juan Quintela, 2023/11/02
- Re: [PULL 00/40] Migration 20231102 patches, Stefan Hajnoczi, 2023/11/02