qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH v9 12/12] migration: Add multifd test
Date: Tue, 17 Oct 2017 16:27:47 +0100	[thread overview]
Message-ID: <20171017152746.GE2326@work-vm> (raw)
In-Reply-To: <20171004104636.7963-13-quintela@redhat.com>

* Juan Quintela (quintela@redhat.com) wrote:
> We set the x-multifd-page-count and x-multifd-channels.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

<snip>
We *must* find a way to share all the boiler plate I've snipped
out;  even this test_migrate function is almost identical to
your other test series with just those few extra parameter sets.

> +static void test_migrate(void)
> +{
> +    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> +    QTestState *global = global_qtest, *from, *to;
> +    unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
> +    gchar *cmd, *cmd_src, *cmd_dst;
> +    QDict *rsp;
> +
> +    char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
> +    const char *arch = qtest_get_arch();
> +
> +    got_stop = false;
> +
> +    if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
> +        init_bootfile_x86(bootpath);
> +        cmd_src = g_strdup_printf("-machine accel=kvm:tcg -m 150M"
> +                                  " -name pcsource,debug-threads=on"
> +                                  " -serial file:%s/src_serial"
> +                                  " -drive file=%s,format=raw",
> +                                  tmpfs, bootpath);
> +        cmd_dst = g_strdup_printf("-machine accel=kvm:tcg -m 150M"
> +                                  " -name pcdest,debug-threads=on"
> +                                  " -serial file:%s/dest_serial"
> +                                  " -drive file=%s,format=raw"
> +                                  " -incoming %s",
> +                                  tmpfs, bootpath, uri);
> +    } else if (strcmp(arch, "ppc64") == 0) {
> +        const char *accel;
> +
> +        /* On ppc64, the test only works with kvm-hv, but not with kvm-pr */
> +        accel = access("/sys/module/kvm_hv", F_OK) ? "tcg" : "kvm:tcg";
> +        init_bootfile_ppc(bootpath);
> +        cmd_src = g_strdup_printf("-machine accel=%s -m 256M"
> +                                  " -name pcsource,debug-threads=on"
> +                                  " -serial file:%s/src_serial"
> +                                  " -drive file=%s,if=pflash,format=raw",
> +                                  accel, tmpfs, bootpath);
> +        cmd_dst = g_strdup_printf("-machine accel=%s -m 256M"
> +                                  " -name pcdest,debug-threads=on"
> +                                  " -serial file:%s/dest_serial"
> +                                  " -incoming %s",
> +                                  accel, tmpfs, uri);
> +    } else {
> +        g_assert_not_reached();
> +    }
> +
> +    g_free(bootpath);
> +
> +    from = qtest_start(cmd_src);
> +    g_free(cmd_src);
> +
> +    to = qtest_init(cmd_dst);
> +    g_free(cmd_dst);
> +
> +    global_qtest = from;
> +    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
> +                  "'arguments': { "
> +                      "'capabilities': [ {"
> +                          "'capability': 'x-multifd',"
> +                          "'state': true } ] } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    global_qtest = to;
> +    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
> +                  "'arguments': { "
> +                      "'capabilities': [ {"
> +                          "'capability': 'x-multifd',"
> +                          "'state': true } ] } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    /* We want to pick a speed slow enough that the test completes
> +     * quickly, but that it doesn't complete precopy even on a slow
> +     * machine, so also set the downtime.
> +     */
> +    global_qtest = from;
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'max-bandwidth': 100000000 } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    /* 200ms downtime */
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'downtime-limit': 300 } }");

Note 200 vs 300 !

> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    /* set 4 channels */
> +    global_qtest = to;
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'x-multifd-channels': 4 } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'x-multifd-page-count': 64 } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    /* set 4 channels */
> +    global_qtest = from;
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'x-multifd-channels': 4 } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    rsp = qmp("{ 'execute': 'migrate-set-parameters',"
> +              "'arguments': { 'x-multifd-page-count': 64 } }");
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +
> +    /* Wait for the first serial output from the source */
> +    wait_for_serial("src_serial");
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate',"
> +                          "'arguments': { 'uri': '%s' } }",
> +                          uri);
> +    rsp = qmp(cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +
> +    wait_for_migration_pass();
> +
> +    if (!got_stop) {
> +        qmp_eventwait("STOP");
> +    }
> +
> +    global_qtest = to;
> +    qmp_eventwait("RESUME");
> +
> +    wait_for_serial("dest_serial");
> +    global_qtest = from;
> +    wait_for_migration_complete();
> +
> +    qtest_quit(from);
> +
> +    global_qtest = to;
> +
> +    qtest_memread(to, start_address, &dest_byte_a, 1);
> +
> +    /* Destination still running, wait for a byte to change */
> +    do {
> +        qtest_memread(to, start_address, &dest_byte_b, 1);
> +        usleep(10 * 1000);
> +    } while (dest_byte_a == dest_byte_b);

Are there any multifd stats we can check?  I guess the migration
wont start until all channels are connected, so we know they're all
in use in theory, so there's nothing specific.

Dave

> +    qmp_discard_response("{ 'execute' : 'stop'}");
> +    /* With it stopped, check nothing changes */
> +    qtest_memread(to, start_address, &dest_byte_c, 1);
> +    sleep(1);
> +    qtest_memread(to, start_address, &dest_byte_d, 1);
> +    g_assert_cmpint(dest_byte_c, ==, dest_byte_d);
> +
> +    check_guests_ram();
> +
> +    qtest_quit(to);
> +    g_free(uri);
> +
> +    global_qtest = global;
> +
> +    cleanup("bootsect");
> +    cleanup("migsocket");
> +    cleanup("src_serial");
> +    cleanup("dest_serial");
> +}
> +
> +int main(int argc, char **argv)
> +{
> +    char template[] = "/tmp/multifd-test-XXXXXX";
> +    int ret;
> +
> +    g_test_init(&argc, &argv, NULL);
> +
> +    tmpfs = mkdtemp(template);
> +    if (!tmpfs) {
> +        g_test_message("mkdtemp on path (%s): %s\n", template, strerror(errno));
> +    }
> +    g_assert(tmpfs);
> +
> +    module_call_init(MODULE_INIT_QOM);
> +
> +    qtest_add_func("/multifd", test_migrate);
> +
> +    ret = g_test_run();
> +
> +    g_assert_cmpint(ret, ==, 0);
> +
> +    ret = rmdir(tmpfs);
> +    if (ret != 0) {
> +        g_test_message("unable to rmdir: path (%s): %s\n",
> +                       tmpfs, strerror(errno));
> +    }
> +
> +    return ret;
> +}
> -- 
> 2.13.5
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2017-10-17 15:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 10:46 [Qemu-devel] [PATCH v9 00/12] Multifd Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 01/12] qapi: Fix grammar in x-multifd-page-count descriptions Juan Quintela
2017-10-16 16:53   ` Dr. David Alan Gilbert
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 02/12] migration: Improve migration thread error handling Juan Quintela
2017-10-09  9:28   ` Peter Xu
2017-10-16 17:34   ` Dr. David Alan Gilbert
2017-10-16 17:48     ` Dr. David Alan Gilbert
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 03/12] migration: Make migrate_fd_error() the owner of the Error Juan Quintela
2017-10-09  9:34   ` Peter Xu
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 04/12] migration: Start of multiple fd work Juan Quintela
2017-10-09 10:05   ` Peter Xu
2017-10-09 10:15   ` Daniel P. Berrange
2017-10-09 12:32     ` Juan Quintela
2017-10-09 12:32     ` Juan Quintela
2017-10-16 19:11   ` Dr. David Alan Gilbert
2017-12-09 16:46     ` Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 05/12] migration: Create ram_multifd_page Juan Quintela
2017-10-09 13:08   ` Paolo Bonzini
2017-10-16 19:43   ` Dr. David Alan Gilbert
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 06/12] migration: Send the fd number which we are going to use for this page Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 07/12] migration: Create thread infrastructure for multifd recv side Juan Quintela
2017-10-17 11:07   ` Dr. David Alan Gilbert
2018-01-08  9:24     ` Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 08/12] migration: Test new fd infrastructure Juan Quintela
2017-10-17 11:11   ` Dr. David Alan Gilbert
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 09/12] migration: Rename initial_bytes Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 10/12] migration: Transfer pages over new channels Juan Quintela
2017-10-17 14:18   ` Dr. David Alan Gilbert
2018-01-08  9:40     ` Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 11/12] migration: Flush receive queue Juan Quintela
2017-10-17 14:51   ` Dr. David Alan Gilbert
2017-12-11  9:40     ` Juan Quintela
2017-10-04 10:46 ` [Qemu-devel] [PATCH v9 12/12] migration: Add multifd test Juan Quintela
2017-10-17 15:27   ` Dr. David Alan Gilbert [this message]
2017-12-11  9:40     ` Juan Quintela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171017152746.GE2326@work-vm \
    --to=dgilbert@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).