diff mbox series

[v2,13/29] migration: fixed-ram: Add URI compatibility check

Message ID 20231023203608.26370-14-farosas@suse.de
State New
Headers show
Series migration: File based migration with multifd and fixed-ram | expand

Commit Message

Fabiano Rosas Oct. 23, 2023, 8:35 p.m. UTC
The fixed-ram migration format needs a channel that supports seeking
to be able to write each page to an arbitrary offset in the migration
stream.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/migration.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Comments

Daniel P. Berrangé Oct. 25, 2023, 10:27 a.m. UTC | #1
On Mon, Oct 23, 2023 at 05:35:52PM -0300, Fabiano Rosas wrote:
> The fixed-ram migration format needs a channel that supports seeking
> to be able to write each page to an arbitrary offset in the migration
> stream.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>  migration/migration.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
Peter Xu Oct. 31, 2023, 4:06 p.m. UTC | #2
On Mon, Oct 23, 2023 at 05:35:52PM -0300, Fabiano Rosas wrote:
> The fixed-ram migration format needs a channel that supports seeking
> to be able to write each page to an arbitrary offset in the migration
> stream.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>  migration/migration.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/migration/migration.c b/migration/migration.c
> index 692fbc5ad6..cabb3ad3a5 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -106,22 +106,40 @@ static bool migration_needs_multiple_sockets(void)
>      return migrate_multifd() || migrate_postcopy_preempt();
>  }
>  
> +static bool migration_needs_seekable_channel(void)
> +{
> +    return migrate_fixed_ram();
> +}
> +
>  static bool uri_supports_multi_channels(const char *uri)
>  {
>      return strstart(uri, "tcp:", NULL) || strstart(uri, "unix:", NULL) ||
>             strstart(uri, "vsock:", NULL);
>  }
>  
> +static bool uri_supports_seeking(const char *uri)
> +{
> +    return strstart(uri, "file:", NULL);
> +}
> +
>  static bool
>  migration_channels_and_uri_compatible(const char *uri, Error **errp)
>  {
> +    bool compatible = true;
> +
> +    if (migration_needs_seekable_channel() &&
> +        !uri_supports_seeking(uri)) {
> +        error_setg(errp, "Migration requires seekable transport (e.g. file)");
> +        compatible = false;

We may want to return directly after setting errp once, as error_setg() can
trigger assertion over "*errp==NULL" if below check will fail too.

> +    }
> +
>      if (migration_needs_multiple_sockets() &&
>          !uri_supports_multi_channels(uri)) {
>          error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)");
> -        return false;
> +        compatible = false;
>      }
>  
> -    return true;
> +    return compatible;
>  }
>  
>  static bool migration_should_pause(const char *uri)
> -- 
> 2.35.3
>
diff mbox series

Patch

diff --git a/migration/migration.c b/migration/migration.c
index 692fbc5ad6..cabb3ad3a5 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -106,22 +106,40 @@  static bool migration_needs_multiple_sockets(void)
     return migrate_multifd() || migrate_postcopy_preempt();
 }
 
+static bool migration_needs_seekable_channel(void)
+{
+    return migrate_fixed_ram();
+}
+
 static bool uri_supports_multi_channels(const char *uri)
 {
     return strstart(uri, "tcp:", NULL) || strstart(uri, "unix:", NULL) ||
            strstart(uri, "vsock:", NULL);
 }
 
+static bool uri_supports_seeking(const char *uri)
+{
+    return strstart(uri, "file:", NULL);
+}
+
 static bool
 migration_channels_and_uri_compatible(const char *uri, Error **errp)
 {
+    bool compatible = true;
+
+    if (migration_needs_seekable_channel() &&
+        !uri_supports_seeking(uri)) {
+        error_setg(errp, "Migration requires seekable transport (e.g. file)");
+        compatible = false;
+    }
+
     if (migration_needs_multiple_sockets() &&
         !uri_supports_multi_channels(uri)) {
         error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)");
-        return false;
+        compatible = false;
     }
 
-    return true;
+    return compatible;
 }
 
 static bool migration_should_pause(const char *uri)