aboutsummaryrefslogtreecommitdiff
path: root/migration/migration.c
diff options
context:
space:
mode:
authorFabiano Rosas <farosas@suse.de>2024-02-29 12:30:02 -0300
committerPeter Xu <peterx@redhat.com>2024-03-01 15:42:04 +0800
commit8d9e0d41006f094a8a377f0a12bef1e34b0a70b7 (patch)
tree16f37b1d673994b34325cb568c93460db77c8cb2 /migration/migration.c
parent4ed49feb4449f6959256c083afcb94116561b507 (diff)
downloadqemu-8d9e0d41006f094a8a377f0a12bef1e34b0a70b7.zip
qemu-8d9e0d41006f094a8a377f0a12bef1e34b0a70b7.tar.gz
qemu-8d9e0d41006f094a8a377f0a12bef1e34b0a70b7.tar.bz2
migration: Add mapped-ram URI compatibility check
The mapped-ram migration format needs a channel that supports seeking to be able to write each page to an arbitrary offset in the migration stream. Reviewed-by: "Daniel P. Berrangé" <berrange@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/r/20240229153017.2221-9-farosas@suse.de Signed-off-by: Peter Xu <peterx@redhat.com>
Diffstat (limited to 'migration/migration.c')
-rw-r--r--migration/migration.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/migration/migration.c b/migration/migration.c
index 69f68f9..2669600 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -148,10 +148,39 @@ static bool transport_supports_multi_channels(MigrationAddress *addr)
return false;
}
+static bool migration_needs_seekable_channel(void)
+{
+ return migrate_mapped_ram();
+}
+
+static bool transport_supports_seeking(MigrationAddress *addr)
+{
+ if (addr->transport == MIGRATION_ADDRESS_TYPE_FILE) {
+ return true;
+ }
+
+ /*
+ * At this point, the user might not yet have passed the file
+ * descriptor to QEMU, so we cannot know for sure whether it
+ * refers to a plain file or a socket. Let it through anyway.
+ */
+ if (addr->transport == MIGRATION_ADDRESS_TYPE_SOCKET) {
+ return addr->u.socket.type == SOCKET_ADDRESS_TYPE_FD;
+ }
+
+ return false;
+}
+
static bool
migration_channels_and_transport_compatible(MigrationAddress *addr,
Error **errp)
{
+ if (migration_needs_seekable_channel() &&
+ !transport_supports_seeking(addr)) {
+ error_setg(errp, "Migration requires seekable transport (e.g. file)");
+ return false;
+ }
+
if (migration_needs_multiple_sockets() &&
!transport_supports_multi_channels(addr)) {
error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)");