Het Gala <het.g...@nutanix.com> writes:

> Introduce support for adding a 'channels' argument to migrate_qmp_fail,
> migrate_incoming_qmp and migrate_qmp functions within the migration qtest
> framework, enabling enhanced control over migration scenarios.

Can't we just pass a channels string like you did in the original series
with migrate_postcopy_prepare?

We'd change migrate_* functions like this:

  void migrate_qmp(QTestState *who, const char *uri, const char *channels,
                   const char *fmt, ...)
  {
  ...
      g_assert(!qdict_haskey(args, "uri"));
      if (uri) {
          qdict_put_str(args, "uri", uri);
      }
  
      g_assert(!qdict_haskey(args, "channels"));
      if (channels) {
          qdict_put_str(args, "channels", channels);
      }
  }

Write the test like this:

  static void test_multifd_tcp_none_channels(void)
  {
      MigrateCommon args = {
          .listen_uri = "defer",
          .start_hook = test_migrate_precopy_tcp_multifd_start,
          .live = true,
          .connect_channels = "'channels': [ { 'channel-type': 'main',"
                              "      'addr': { 'transport': 'socket',"
                              "                'type': 'inet',"
                              "                'host': '127.0.0.1',"
                              "                'port': '0' } } ]",
          .connect_uri = NULL;
                               
      };
      test_precopy_common(&args);
  }

  static void do_test_validate_uri_channel(MigrateCommon *args)
  {
      QTestState *from, *to;
      g_autofree char *connect_uri = NULL;
  
      if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) {
          return;
      }
  
      wait_for_serial("src_serial");
  
      if (args->result == MIG_TEST_QMP_ERROR) {
          migrate_qmp_fail(from, args->connect_uri, args->connect_channels, 
"{}");
      } else {
          migrate_qmp(from, args->connect_uri, args->connect_channels, "{}");
      }
  
      test_migrate_end(from, to, false);
  }

It's better to require test writers to pass in their own uri and channel
strings. Otherwise any new transport added will require people to modify
these conversion helpers.

Also, using the same string as the user would use in QMP helps with
development in general. One could refer to the tests to see how to
invoke the migration or experiment with the string in the tests during
development.

Reply via email to