All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration
@ 2017-10-26  7:52 Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx


Hi

This is on top of my set_cache_size series.

big changes is this v2:
- to make review easier, I started renaming postcopy-test.c to migration-test.c
- Did cleanups/refactoring there
- Don't use global-qtest anymore
- check that the parameters that we sent got really set
- RFH: comrpress threads tests is not working for some weird reason.  Using the same code on command line works.
  still investigating why.

ToDoo:

- tcp: after discussions with dave, we ended in conclusion that we
  need to use the 0 port and let the system gives us a free one

  But .... that means that we need to be able to get that port back somehow.
  "info migrate" woring on destination side?

- compression threads.  There is some weird interaction with the test
  hardness and every migration thread get waiting in a different
  semaphore.  Investigating if it is a race/bug/whateverr

- deprecated commands: There was a suggestion to make
  migrate_set_parameter look at the parameter name and test old/new
  depending on something.  Not sure what to do here.

- testing commands: Is there a way to launch qemu and just sent
  qmp/hmp commands without having to really run anything else?

Please review,.

Later, Juan.

[v1]
- add test for precopy for unix/tcp
  exec and fd to came, don't know how to test rdma without hardware
- add tests using deprecated interfaces
- add test for xbzrle
  Note to myself, there is no way to set the cache size with migraton_set_parameters
- Add test for compress threads
  disabled on the series, right now it appears that compression is not working at all
- Move postcopy to use new results
  Idea is to move it on top of migration-test.c, but first I want some reviews on basic idea

Please, review.

Juan.



*** BLURB HERE ***

Juan Quintela (10):
  tests: rename postcopy-test to migration-test
  tests: Refactor setting of parameters/capabilities
  tests: Factorize out migrate_test_start/end
  tests: Don't abuse global_qtest
  tests: check that migration parameters are really assigned
  tests: Add migration precopy test
  tests: Add basic migration precopy tcp test
  tests: Add precopy test using deprecated commands
  tests: Add migration xbzrle test
  [RFH] tests: Add migration compress threads tests

 MAINTAINERS                                 |   1 +
 tests/Makefile.include                      |   6 +-
 tests/{postcopy-test.c => migration-test.c} | 492 ++++++++++++++++++++++------
 3 files changed, 394 insertions(+), 105 deletions(-)
 rename tests/{postcopy-test.c => migration-test.c} (59%)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-27  1:50   ` Dr. David Alan Gilbert
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities Juan Quintela
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Instead of repeating the code, we are going to bo more tests on this file

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 MAINTAINERS                                 | 1 +
 tests/Makefile.include                      | 6 +++---
 tests/{postcopy-test.c => migration-test.c} | 8 +++-----
 3 files changed, 7 insertions(+), 8 deletions(-)
 rename tests/{postcopy-test.c => migration-test.c} (98%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 12175425a7..8d0a3de734 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1562,6 +1562,7 @@ F: include/migration/
 F: migration/
 F: scripts/vmstate-static-checker.py
 F: tests/vmstate-static-checker-data/
+F: tests/migration-test.c
 F: docs/devel/migration.txt
 F: qapi/migration.json
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 70dc711bca..434a2ce868 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -287,7 +287,7 @@ endif
 check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
-check-qtest-i386-y += tests/postcopy-test$(EXESUF)
+check-qtest-i386-y += tests/migration-test$(EXESUF)
 check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
 check-qtest-i386-y += tests/numa-test$(EXESUF)
 check-qtest-x86_64-y += $(check-qtest-i386-y)
@@ -315,7 +315,7 @@ check-qtest-ppc64-y += tests/boot-order-test$(EXESUF)
 check-qtest-ppc64-y += tests/prom-env-test$(EXESUF)
 check-qtest-ppc64-y += tests/pnv-xscom-test$(EXESUF)
 check-qtest-ppc64-y += tests/drive_del-test$(EXESUF)
-check-qtest-ppc64-y += tests/postcopy-test$(EXESUF)
+check-qtest-ppc64-y += tests/migration-test$(EXESUF)
 check-qtest-ppc64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-ppc64-y += tests/rtas-test$(EXESUF)
 check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
@@ -784,7 +784,7 @@ tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y)
 tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
 tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
 tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
-tests/postcopy-test$(EXESUF): tests/postcopy-test.o
+tests/migration-test$(EXESUF): tests/migration-test.o
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
 	$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
 	$(chardev-obj-y)
diff --git a/tests/postcopy-test.c b/tests/migration-test.c
similarity index 98%
rename from tests/postcopy-test.c
rename to tests/migration-test.c
index 8142f2ab90..55c4aed719 100644
--- a/tests/postcopy-test.c
+++ b/tests/migration-test.c
@@ -1,5 +1,5 @@
 /*
- * QTest testcase for postcopy
+ * QTest testcase for migration
  *
  * Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
  *   based on the vhost-user-test.c that is:
@@ -243,8 +243,6 @@ static QDict *return_or_event(QDict *response)
 /*
  * It's tricky to use qemu's migration event capability with qtest,
  * events suddenly appearing confuse the qmp()/hmp() responses.
- * so wait for a couple of passes to have happened before
- * going postcopy.
  */
 
 static uint64_t get_migration_pass(void)
@@ -504,7 +502,7 @@ static void test_migrate(void)
 
 int main(int argc, char **argv)
 {
-    char template[] = "/tmp/postcopy-test-XXXXXX";
+    char template[] = "/tmp/migration-test-XXXXXX";
     int ret;
 
     g_test_init(&argc, &argv, NULL);
@@ -521,7 +519,7 @@ int main(int argc, char **argv)
 
     module_call_init(MODULE_INIT_QOM);
 
-    qtest_add_func("/postcopy", test_migrate);
+    qtest_add_func("/migration/postcopy/unix", test_migrate);
 
     ret = g_test_run();
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-27  1:54   ` Dr. David Alan Gilbert
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end Juan Quintela
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

So we can use them in future tests

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 101 +++++++++++++++++++++++++++++++------------------
 1 file changed, 64 insertions(+), 37 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 55c4aed719..19a1445076 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -351,12 +351,69 @@ static void cleanup(const char *filename)
     g_free(path);
 }
 
+static void migrate_set_downtime(QTestState *who, const char *value)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
+                          "'arguments': { 'value': %s } }", value);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+}
+
+static void migrate_set_speed(QTestState *who, const char *value)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed',"
+                          "'arguments': { 'value': %s } }", value);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+}
+
+static void migrate_set_capability(QTestState *who, const char *capability,
+                                   const char *value)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate-set-capabilities',"
+                          "'arguments': { "
+                          "'capabilities': [ { "
+                          "'capability': '%s', 'state': %s } ] } }",
+                          capability, value);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+}
+
+static void migrate(QTestState *who, const char *uri)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate',"
+                          "'arguments': { 'uri': '%s' } }",
+                          uri);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+}
+
 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;
+    gchar *cmd_src, *cmd_dst;
     QDict *rsp;
 
     char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
@@ -405,52 +462,22 @@ static void test_migrate(void)
     to = qtest_init(cmd_dst);
     g_free(cmd_dst);
 
-    global_qtest = from;
-    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
-                  "'arguments': { "
-                      "'capabilities': [ {"
-                          "'capability': 'postcopy-ram',"
-                          "'state': true } ] } }");
-    g_assert(qdict_haskey(rsp, "return"));
-    QDECREF(rsp);
-
-    global_qtest = to;
-    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
-                  "'arguments': { "
-                      "'capabilities': [ {"
-                          "'capability': 'postcopy-ram',"
-                          "'state': true } ] } }");
-    g_assert(qdict_haskey(rsp, "return"));
-    QDECREF(rsp);
+    migrate_set_capability(from, "postcopy-ram", "true");
+    migrate_set_capability(to, "postcopy-ram", "true");
 
     /* 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_speed',"
-              "'arguments': { 'value': 100000000 } }");
-    g_assert(qdict_haskey(rsp, "return"));
-    QDECREF(rsp);
-
-    /* 1ms downtime - it should never finish precopy */
-    rsp = qmp("{ 'execute': 'migrate_set_downtime',"
-              "'arguments': { 'value': 0.001 } }");
-    g_assert(qdict_haskey(rsp, "return"));
-    QDECREF(rsp);
-
+    migrate_set_speed(from, "100000000");
+    migrate_set_downtime(from, "0.001");
 
     /* 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);
+    migrate(from, uri);
 
+    global_qtest = from;
     wait_for_migration_pass();
 
     rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-27  2:15   ` Dr. David Alan Gilbert
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest Juan Quintela
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

We fix global_test users left and right

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 86 ++++++++++++++++++++++++++++----------------------
 1 file changed, 48 insertions(+), 38 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 19a1445076..91fb0277d6 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -301,7 +301,7 @@ static void wait_for_migration_pass(void)
     } while (pass == initial_pass && !got_stop);
 }
 
-static void check_guests_ram(void)
+static void check_guests_ram(QTestState *who)
 {
     /* Our ASM test will have been incrementing one byte from each page from
      * 1MB to <100MB in order.
@@ -316,13 +316,13 @@ static void check_guests_ram(void)
     bool hit_edge = false;
     bool bad = false;
 
-    qtest_memread(global_qtest, start_address, &first_byte, 1);
+    qtest_memread(who, start_address, &first_byte, 1);
     last_byte = first_byte;
 
     for (address = start_address + 4096; address < end_address; address += 4096)
     {
         uint8_t b;
-        qtest_memread(global_qtest, address, &b, 1);
+        qtest_memread(who, address, &b, 1);
         if (b != last_byte) {
             if (((b + 1) % 256) == last_byte && !hit_edge) {
                 /* This is OK, the guest stopped at the point of
@@ -408,14 +408,10 @@ static void migrate(QTestState *who, const char *uri)
     QDECREF(rsp);
 }
 
-static void test_migrate(void)
+static void test_migrate_start(QTestState **from, QTestState **to,
+                               const char *uri)
 {
-    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_src, *cmd_dst;
-    QDict *rsp;
-
     char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
     const char *arch = qtest_get_arch();
 
@@ -456,11 +452,51 @@ static void test_migrate(void)
 
     g_free(bootpath);
 
-    from = qtest_start(cmd_src);
+    *from = qtest_start(cmd_src);
     g_free(cmd_src);
 
-    to = qtest_init(cmd_dst);
+    *to = qtest_init(cmd_dst);
     g_free(cmd_dst);
+}
+
+static void test_migrate_end(QTestState *from, QTestState *to)
+{
+    unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
+
+    qtest_quit(from);
+
+    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);
+
+    qtest_qmp_discard_response(to, "{ '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(to);
+
+    qtest_quit(to);
+
+    cleanup("bootsect");
+    cleanup("migsocket");
+    cleanup("src_serial");
+    cleanup("dest_serial");
+}
+
+static void test_migrate(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+    QTestState *global = global_qtest, *from, *to;
+    QDict *rsp;
+
+    test_migrate_start(&from, &to, uri);
 
     migrate_set_capability(from, "postcopy-ram", "true");
     migrate_set_capability(to, "postcopy-ram", "true");
@@ -495,36 +531,10 @@ static void test_migrate(void)
     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);
-
-    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");
+    test_migrate_end(from, to);
 }
 
 int main(int argc, char **argv)
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (2 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-27  2:37   ` Dr. David Alan Gilbert
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

As we have two guests running, just pass always who we want to send a
message to.  Once there, refactor return_or_event() into wait_command.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 55 +++++++++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 91fb0277d6..c429a13403 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -223,20 +223,23 @@ static void wait_for_serial(const char *side)
 /*
  * Events can get in the way of responses we are actually waiting for.
  */
-static QDict *return_or_event(QDict *response)
+static QDict *wait_command(QTestState *who, const char *command)
 {
     const char *event_string;
-    if (!qdict_haskey(response, "event")) {
-        return response;
-    }
+    QDict *response;
+
+    response = qtest_qmp(who, command);
 
-    /* OK, it was an event */
-    event_string = qdict_get_str(response, "event");
-    if (!strcmp(event_string, "STOP")) {
-        got_stop = true;
+    while (qdict_haskey(response, "event")) {
+        /* OK, it was an event */
+        event_string = qdict_get_str(response, "event");
+        if (!strcmp(event_string, "STOP")) {
+            got_stop = true;
+        }
+        QDECREF(response);
+        response = qtest_qmp_receive(who);
     }
-    QDECREF(response);
-    return return_or_event(qtest_qmp_receive(global_qtest));
+    return response;
 }
 
 
@@ -245,12 +248,12 @@ static QDict *return_or_event(QDict *response)
  * events suddenly appearing confuse the qmp()/hmp() responses.
  */
 
-static uint64_t get_migration_pass(void)
+static uint64_t get_migration_pass(QTestState *who)
 {
     QDict *rsp, *rsp_return, *rsp_ram;
     uint64_t result;
 
-    rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
+    rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
     rsp_return = qdict_get_qdict(rsp, "return");
     if (!qdict_haskey(rsp_return, "ram")) {
         /* Still in setup */
@@ -263,7 +266,7 @@ static uint64_t get_migration_pass(void)
     return result;
 }
 
-static void wait_for_migration_complete(void)
+static void wait_for_migration_complete(QTestState *who)
 {
     QDict *rsp, *rsp_return;
     bool completed;
@@ -271,7 +274,7 @@ static void wait_for_migration_complete(void)
     do {
         const char *status;
 
-        rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
+        rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
         rsp_return = qdict_get_qdict(rsp, "return");
         status = qdict_get_str(rsp_return, "status");
         completed = strcmp(status, "completed") == 0;
@@ -281,14 +284,14 @@ static void wait_for_migration_complete(void)
     } while (!completed);
 }
 
-static void wait_for_migration_pass(void)
+static void wait_for_migration_pass(QTestState *who)
 {
-    uint64_t initial_pass = get_migration_pass();
+    uint64_t initial_pass = get_migration_pass(who);
     uint64_t pass;
 
     /* Wait for the 1st sync */
     do {
-        initial_pass = get_migration_pass();
+        initial_pass = get_migration_pass(who);
         if (got_stop || initial_pass) {
             break;
         }
@@ -297,7 +300,7 @@ static void wait_for_migration_pass(void)
 
     do {
         usleep(1000 * 100);
-        pass = get_migration_pass();
+        pass = get_migration_pass(who);
     } while (pass == initial_pass && !got_stop);
 }
 
@@ -493,7 +496,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
 static void test_migrate(void)
 {
     char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
-    QTestState *global = global_qtest, *from, *to;
+    QTestState *from, *to;
     QDict *rsp;
 
     test_migrate_start(&from, &to, uri);
@@ -513,26 +516,22 @@ static void test_migrate(void)
 
     migrate(from, uri);
 
-    global_qtest = from;
-    wait_for_migration_pass();
+    wait_for_migration_pass(from);
 
-    rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
+    rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);
 
     if (!got_stop) {
-        qmp_eventwait("STOP");
+        qtest_qmp_eventwait(from, "STOP");
     }
 
-    global_qtest = to;
-    qmp_eventwait("RESUME");
+    qtest_qmp_eventwait(to, "RESUME");
 
     wait_for_serial("dest_serial");
-    global_qtest = from;
-    wait_for_migration_complete();
+    wait_for_migration_complete(from);
 
     g_free(uri);
-    global_qtest = global;
 
     test_migrate_end(from, to);
 }
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (3 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-27  3:47   ` Dr. David Alan Gilbert
  2017-10-29 13:24   ` Peter Xu
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test Juan Quintela
                   ` (4 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index c429a13403..be598d3257 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -354,17 +354,37 @@ static void cleanup(const char *filename)
     g_free(path);
 }
 
-static void migrate_set_downtime(QTestState *who, const char *value)
+static void migrate_check_parameter(QTestState *who, const char *parameter,
+                                    const char *value)
+{
+    QDict *rsp, *rsp_return;
+    const char *result;
+
+    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
+    rsp_return = qdict_get_qdict(rsp, "return");
+    result = g_strdup_printf("%" PRId64,
+                             qdict_get_try_int(rsp_return,  parameter, -1));
+    g_assert_cmpstr(result, ==, value);
+    QDECREF(rsp);
+}
+
+static void migrate_set_downtime(QTestState *who, const double value)
 {
     QDict *rsp;
     gchar *cmd;
+    char *expected;
+    int64_t result_int;
 
     cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
-                          "'arguments': { 'value': %s } }", value);
+                          "'arguments': { 'value': %g } }", value);
     rsp = qtest_qmp(who, cmd);
     g_free(cmd);
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);
+    result_int = value * 1000L;
+    expected = g_strdup_printf("%" PRId64, result_int);
+    migrate_check_parameter(who, "downtime-limit", expected);
+    g_free(expected);
 }
 
 static void migrate_set_speed(QTestState *who, const char *value)
@@ -378,6 +398,7 @@ static void migrate_set_speed(QTestState *who, const char *value)
     g_free(cmd);
     g_assert(qdict_haskey(rsp, "return"));
     QDECREF(rsp);
+    migrate_check_parameter(who, "max-bandwidth", value);
 }
 
 static void migrate_set_capability(QTestState *who, const char *capability,
@@ -509,7 +530,7 @@ static void test_migrate(void)
      * machine, so also set the downtime.
      */
     migrate_set_speed(from, "100000000");
-    migrate_set_downtime(from, "0.001");
+    migrate_set_downtime(from, 0.001);
 
     /* Wait for the first serial output from the source */
     wait_for_serial("src_serial");
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (4 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-29 13:56   ` Peter Xu
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 07/10] tests: Add basic migration precopy tcp test Juan Quintela
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 66 insertions(+), 2 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index be598d3257..a8718770c9 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -401,6 +401,22 @@ static void migrate_set_speed(QTestState *who, const char *value)
     migrate_check_parameter(who, "max-bandwidth", value);
 }
 
+static void migrate_set_parameter(QTestState *who, const char *parameter,
+                                  const char *value)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate-set-parameters',"
+                          "'arguments': { '%s': %s } }",
+                          parameter, value);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+    migrate_check_parameter(who, parameter, value);
+}
+
 static void migrate_set_capability(QTestState *who, const char *capability,
                                    const char *value)
 {
@@ -514,7 +530,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
     cleanup("dest_serial");
 }
 
-static void test_migrate(void)
+static void test_postcopy(void)
 {
     char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
     QTestState *from, *to;
@@ -557,6 +573,53 @@ static void test_migrate(void)
     test_migrate_end(from, to);
 }
 
+
+static void test_precopy(const char *uri)
+{
+    QTestState *from, *to;
+
+    test_migrate_start(&from, &to, uri);
+
+    /* 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.
+     */
+    /* 1 ms */
+    migrate_set_parameter(from, "downtime-limit", "1");
+    /* 1GB/s slow*/
+    migrate_set_parameter(from, "max-bandwidth", "1000000000");
+
+
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    migrate(from, uri);
+
+    wait_for_migration_pass(from);
+
+    /* 1GB/s now it should converge */
+    migrate_set_parameter(from, "downtime-limit", "300");
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to);
+}
+
+static void test_precopy_unix(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+
+    test_precopy(uri);
+    g_free(uri);
+}
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -576,7 +639,8 @@ int main(int argc, char **argv)
 
     module_call_init(MODULE_INIT_QOM);
 
-    qtest_add_func("/migration/postcopy/unix", test_migrate);
+    qtest_add_func("/migration/precopy/unix", test_precopy_unix);
+    qtest_add_func("/migration/postcopy/unix", test_postcopy);
 
     ret = g_test_run();
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 07/10] tests: Add basic migration precopy tcp test
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (5 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands Juan Quintela
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index a8718770c9..338254bafe 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -620,6 +620,13 @@ static void test_precopy_unix(void)
     g_free(uri);
 }
 
+static void test_precopy_tcp(void)
+{
+    const char *uri = "tcp:0:44444";
+
+    test_precopy(uri);
+}
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -640,6 +647,7 @@ int main(int argc, char **argv)
     module_call_init(MODULE_INIT_QOM);
 
     qtest_add_func("/migration/precopy/unix", test_precopy_unix);
+    qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
     qtest_add_func("/migration/postcopy/unix", test_postcopy);
 
     ret = g_test_run();
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (6 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 07/10] tests: Add basic migration precopy tcp test Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-29 13:40   ` Peter Xu
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 09/10] tests: Add migration xbzrle test Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 10/10] [RFH] tests: Add migration compress threads tests Juan Quintela
  9 siblings, 1 reply; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Once there, make postcopy test to use the new commands now that we
have other test for deprecated ones

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index 338254bafe..b72dff3917 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -545,8 +545,8 @@ static void test_postcopy(void)
      * quickly, but that it doesn't complete precopy even on a slow
      * machine, so also set the downtime.
      */
-    migrate_set_speed(from, "100000000");
-    migrate_set_downtime(from, 0.001);
+    migrate_set_parameter(from, "max-bandwidth", "1000000000");
+    migrate_set_parameter(from, "downtime-limit", "1");
 
     /* Wait for the first serial output from the source */
     wait_for_serial("src_serial");
@@ -573,6 +573,49 @@ static void test_postcopy(void)
     test_migrate_end(from, to);
 }
 
+static void test_precopy_deprecated(const char *uri)
+{
+    QTestState *from, *to;
+
+    test_migrate_start(&from, &to, uri);
+
+    /* 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.
+     */
+    /* 100 ms */
+    migrate_set_downtime(from, 0.001);
+    /* 1MB/s slow*/
+    migrate_set_speed(from, "1000000000");
+
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    migrate(from, uri);
+
+    wait_for_migration_pass(from);
+
+    /* 300ms it should converge */
+    migrate_set_downtime(from, 0.3);
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to);
+}
+
+static void test_deprecated_unix(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+
+    test_precopy_deprecated(uri);
+    g_free(uri);
+}
 
 static void test_precopy(const char *uri)
 {
@@ -648,6 +691,7 @@ int main(int argc, char **argv)
 
     qtest_add_func("/migration/precopy/unix", test_precopy_unix);
     qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
+    qtest_add_func("/migration/deprecated/unix", test_deprecated_unix);
     qtest_add_func("/migration/postcopy/unix", test_postcopy);
 
     ret = g_test_run();
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 09/10] tests: Add migration xbzrle test
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (7 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 10/10] [RFH] tests: Add migration compress threads tests Juan Quintela
  9 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index b72dff3917..db30b3864b 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -573,6 +573,19 @@ static void test_postcopy(void)
     test_migrate_end(from, to);
 }
 
+static void migrate_set_cache_size(QTestState *who, const char *value)
+{
+    QDict *rsp;
+    gchar *cmd;
+
+    cmd = g_strdup_printf("{ 'execute': 'migrate-set-cache-size',"
+                          "'arguments': { 'value': %s } }", value);
+    rsp = qtest_qmp(who, cmd);
+    g_free(cmd);
+    g_assert(qdict_haskey(rsp, "return"));
+    QDECREF(rsp);
+}
+
 static void test_precopy_deprecated(const char *uri)
 {
     QTestState *from, *to;
@@ -588,6 +601,9 @@ static void test_precopy_deprecated(const char *uri)
     /* 1MB/s slow*/
     migrate_set_speed(from, "1000000000");
 
+    /* we don't use xbzrle here, but we test old commands */
+    migrate_set_cache_size(from, "33554432");
+
     /* Wait for the first serial output from the source */
     wait_for_serial("src_serial");
 
@@ -670,6 +686,55 @@ static void test_precopy_tcp(void)
     test_precopy(uri);
 }
 
+static void test_xbzrle(const char *uri)
+{
+    QTestState *from, *to;
+
+    test_migrate_start(&from, &to, uri);
+
+    /* 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.
+     */
+    /* 100 ms */
+    migrate_set_parameter(from, "downtime-limit", "1");
+    /* 1MB/s slow*/
+    migrate_set_parameter(from, "max-bandwidth", "1000000000");
+
+    migrate_set_parameter(from, "xbzrle-cache-size", "33554432");
+
+    migrate_set_capability(from, "xbzrle", "true");
+    migrate_set_capability(to, "xbzrle", "true");
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    migrate(from, uri);
+
+    wait_for_migration_pass(from);
+
+    /* 300ms it should converge */
+    migrate_set_parameter(from, "downtime-limit", "300");
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to);
+}
+
+static void test_xbzrle_unix(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+
+    test_xbzrle(uri);
+    g_free(uri);
+}
+
+
 int main(int argc, char **argv)
 {
     char template[] = "/tmp/migration-test-XXXXXX";
@@ -693,6 +758,7 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
     qtest_add_func("/migration/deprecated/unix", test_deprecated_unix);
     qtest_add_func("/migration/postcopy/unix", test_postcopy);
+    qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix);
 
     ret = g_test_run();
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Qemu-devel] [PATCH v2 10/10] [RFH] tests: Add migration compress threads tests
  2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
                   ` (8 preceding siblings ...)
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 09/10] tests: Add migration xbzrle test Juan Quintela
@ 2017-10-26  7:52 ` Juan Quintela
  9 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-26  7:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: dgilbert, lvivier, peterx

Yeap, it is still not working. trying to learn how to debug threads
for guests running from the testt hardness.

For some reason, compression is not working at the moment, test is
disabled until I found why.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 tests/migration-test.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/migration-test.c b/tests/migration-test.c
index db30b3864b..d4c4301cd4 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -734,6 +734,54 @@ static void test_xbzrle_unix(void)
     g_free(uri);
 }
 
+static void test_compress(const char *uri)
+{
+    QTestState *from, *to;
+
+    test_migrate_start(&from, &to, uri);
+
+    /* 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.
+     */
+    /* 100 ms */
+    migrate_set_parameter(from, "downtime-limit", "100");
+    /* 1MB/s slow*/
+    migrate_set_parameter(from, "max-bandwidth", "100000000");
+
+    migrate_set_parameter(from, "compress-threads", "4");
+    migrate_set_parameter(from, "decompress-threads", "3");
+
+    migrate_set_capability(from, "compress", "true");
+    migrate_set_capability(to, "compress", "true");
+    /* Wait for the first serial output from the source */
+    wait_for_serial("src_serial");
+
+    migrate(from, uri);
+
+    wait_for_migration_pass(from);
+
+    /* 1GB/s now it should converge */
+    migrate_set_parameter(from, "max-bandwidth", "1000000000");
+
+    if (!got_stop) {
+        qtest_qmp_eventwait(from, "STOP");
+    }
+    qtest_qmp_eventwait(to, "RESUME");
+
+    wait_for_serial("dest_serial");
+    wait_for_migration_complete(from);
+
+    test_migrate_end(from, to);
+}
+
+static void test_compress_unix(void)
+{
+    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
+
+    test_compress(uri);
+    g_free(uri);
+}
 
 int main(int argc, char **argv)
 {
@@ -759,6 +807,9 @@ int main(int argc, char **argv)
     qtest_add_func("/migration/deprecated/unix", test_deprecated_unix);
     qtest_add_func("/migration/postcopy/unix", test_postcopy);
     qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix);
+    if (0) {
+        qtest_add_func("/migration/compress/unix", test_compress_unix);
+    }
 
     ret = g_test_run();
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
@ 2017-10-27  1:50   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 22+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-27  1:50 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> Instead of repeating the code, we are going to bo more tests on this file
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  MAINTAINERS                                 | 1 +
>  tests/Makefile.include                      | 6 +++---
>  tests/{postcopy-test.c => migration-test.c} | 8 +++-----
>  3 files changed, 7 insertions(+), 8 deletions(-)
>  rename tests/{postcopy-test.c => migration-test.c} (98%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 12175425a7..8d0a3de734 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1562,6 +1562,7 @@ F: include/migration/
>  F: migration/
>  F: scripts/vmstate-static-checker.py
>  F: tests/vmstate-static-checker-data/
> +F: tests/migration-test.c
>  F: docs/devel/migration.txt
>  F: qapi/migration.json
>  
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 70dc711bca..434a2ce868 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -287,7 +287,7 @@ endif
>  check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
>  check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
>  check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
> -check-qtest-i386-y += tests/postcopy-test$(EXESUF)
> +check-qtest-i386-y += tests/migration-test$(EXESUF)
>  check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
>  check-qtest-i386-y += tests/numa-test$(EXESUF)
>  check-qtest-x86_64-y += $(check-qtest-i386-y)
> @@ -315,7 +315,7 @@ check-qtest-ppc64-y += tests/boot-order-test$(EXESUF)
>  check-qtest-ppc64-y += tests/prom-env-test$(EXESUF)
>  check-qtest-ppc64-y += tests/pnv-xscom-test$(EXESUF)
>  check-qtest-ppc64-y += tests/drive_del-test$(EXESUF)
> -check-qtest-ppc64-y += tests/postcopy-test$(EXESUF)
> +check-qtest-ppc64-y += tests/migration-test$(EXESUF)
>  check-qtest-ppc64-y += tests/boot-serial-test$(EXESUF)
>  check-qtest-ppc64-y += tests/rtas-test$(EXESUF)
>  check-qtest-ppc64-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
> @@ -784,7 +784,7 @@ tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y)
>  tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
>  tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
>  tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
> -tests/postcopy-test$(EXESUF): tests/postcopy-test.o
> +tests/migration-test$(EXESUF): tests/migration-test.o
>  tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
>  	$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
>  	$(chardev-obj-y)
> diff --git a/tests/postcopy-test.c b/tests/migration-test.c
> similarity index 98%
> rename from tests/postcopy-test.c
> rename to tests/migration-test.c
> index 8142f2ab90..55c4aed719 100644
> --- a/tests/postcopy-test.c
> +++ b/tests/migration-test.c
> @@ -1,5 +1,5 @@
>  /*
> - * QTest testcase for postcopy
> + * QTest testcase for migration
>   *
>   * Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
>   *   based on the vhost-user-test.c that is:
> @@ -243,8 +243,6 @@ static QDict *return_or_event(QDict *response)
>  /*
>   * It's tricky to use qemu's migration event capability with qtest,
>   * events suddenly appearing confuse the qmp()/hmp() responses.
> - * so wait for a couple of passes to have happened before
> - * going postcopy.
>   */
>  
>  static uint64_t get_migration_pass(void)
> @@ -504,7 +502,7 @@ static void test_migrate(void)
>  
>  int main(int argc, char **argv)
>  {
> -    char template[] = "/tmp/postcopy-test-XXXXXX";
> +    char template[] = "/tmp/migration-test-XXXXXX";
>      int ret;
>  
>      g_test_init(&argc, &argv, NULL);
> @@ -521,7 +519,7 @@ int main(int argc, char **argv)
>  
>      module_call_init(MODULE_INIT_QOM);
>  
> -    qtest_add_func("/postcopy", test_migrate);
> +    qtest_add_func("/migration/postcopy/unix", test_migrate);
>  
>      ret = g_test_run();
>  
> -- 
> 2.13.6
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities Juan Quintela
@ 2017-10-27  1:54   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 22+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-27  1:54 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> So we can use them in future tests
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/migration-test.c | 101 +++++++++++++++++++++++++++++++------------------
>  1 file changed, 64 insertions(+), 37 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 55c4aed719..19a1445076 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -351,12 +351,69 @@ static void cleanup(const char *filename)
>      g_free(path);
>  }
>  
> +static void migrate_set_downtime(QTestState *who, const char *value)
> +{
> +    QDict *rsp;
> +    gchar *cmd;
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
> +                          "'arguments': { 'value': %s } }", value);
> +    rsp = qtest_qmp(who, cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +}
> +
> +static void migrate_set_speed(QTestState *who, const char *value)
> +{
> +    QDict *rsp;
> +    gchar *cmd;
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed',"
> +                          "'arguments': { 'value': %s } }", value);
> +    rsp = qtest_qmp(who, cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +}
> +
> +static void migrate_set_capability(QTestState *who, const char *capability,
> +                                   const char *value)
> +{

I'd be tempted to make value a bool here; but it's still better
than where we were so,


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> +    QDict *rsp;
> +    gchar *cmd;
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate-set-capabilities',"
> +                          "'arguments': { "
> +                          "'capabilities': [ { "
> +                          "'capability': '%s', 'state': %s } ] } }",
> +                          capability, value);
> +    rsp = qtest_qmp(who, cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +}
> +
> +static void migrate(QTestState *who, const char *uri)
> +{
> +    QDict *rsp;
> +    gchar *cmd;
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate',"
> +                          "'arguments': { 'uri': '%s' } }",
> +                          uri);
> +    rsp = qtest_qmp(who, cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +}
> +
>  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;
> +    gchar *cmd_src, *cmd_dst;
>      QDict *rsp;
>  
>      char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
> @@ -405,52 +462,22 @@ static void test_migrate(void)
>      to = qtest_init(cmd_dst);
>      g_free(cmd_dst);
>  
> -    global_qtest = from;
> -    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
> -                  "'arguments': { "
> -                      "'capabilities': [ {"
> -                          "'capability': 'postcopy-ram',"
> -                          "'state': true } ] } }");
> -    g_assert(qdict_haskey(rsp, "return"));
> -    QDECREF(rsp);
> -
> -    global_qtest = to;
> -    rsp = qmp("{ 'execute': 'migrate-set-capabilities',"
> -                  "'arguments': { "
> -                      "'capabilities': [ {"
> -                          "'capability': 'postcopy-ram',"
> -                          "'state': true } ] } }");
> -    g_assert(qdict_haskey(rsp, "return"));
> -    QDECREF(rsp);
> +    migrate_set_capability(from, "postcopy-ram", "true");
> +    migrate_set_capability(to, "postcopy-ram", "true");
>  
>      /* 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_speed',"
> -              "'arguments': { 'value': 100000000 } }");
> -    g_assert(qdict_haskey(rsp, "return"));
> -    QDECREF(rsp);
> -
> -    /* 1ms downtime - it should never finish precopy */
> -    rsp = qmp("{ 'execute': 'migrate_set_downtime',"
> -              "'arguments': { 'value': 0.001 } }");
> -    g_assert(qdict_haskey(rsp, "return"));
> -    QDECREF(rsp);
> -
> +    migrate_set_speed(from, "100000000");
> +    migrate_set_downtime(from, "0.001");
>  
>      /* 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);
> +    migrate(from, uri);
>  
> +    global_qtest = from;
>      wait_for_migration_pass();
>  
>      rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
> -- 
> 2.13.6
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end Juan Quintela
@ 2017-10-27  2:15   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 22+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-27  2:15 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> We fix global_test users left and right
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tests/migration-test.c | 86 ++++++++++++++++++++++++++++----------------------
>  1 file changed, 48 insertions(+), 38 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 19a1445076..91fb0277d6 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -301,7 +301,7 @@ static void wait_for_migration_pass(void)
>      } while (pass == initial_pass && !got_stop);
>  }
>  
> -static void check_guests_ram(void)
> +static void check_guests_ram(QTestState *who)
>  {
>      /* Our ASM test will have been incrementing one byte from each page from
>       * 1MB to <100MB in order.
> @@ -316,13 +316,13 @@ static void check_guests_ram(void)
>      bool hit_edge = false;
>      bool bad = false;
>  
> -    qtest_memread(global_qtest, start_address, &first_byte, 1);
> +    qtest_memread(who, start_address, &first_byte, 1);
>      last_byte = first_byte;
>  
>      for (address = start_address + 4096; address < end_address; address += 4096)
>      {
>          uint8_t b;
> -        qtest_memread(global_qtest, address, &b, 1);
> +        qtest_memread(who, address, &b, 1);
>          if (b != last_byte) {
>              if (((b + 1) % 256) == last_byte && !hit_edge) {
>                  /* This is OK, the guest stopped at the point of
> @@ -408,14 +408,10 @@ static void migrate(QTestState *who, const char *uri)
>      QDECREF(rsp);
>  }
>  
> -static void test_migrate(void)
> +static void test_migrate_start(QTestState **from, QTestState **to,
> +                               const char *uri)
>  {
> -    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_src, *cmd_dst;
> -    QDict *rsp;
> -
>      char *bootpath = g_strdup_printf("%s/bootsect", tmpfs);
>      const char *arch = qtest_get_arch();
>  
> @@ -456,11 +452,51 @@ static void test_migrate(void)
>  
>      g_free(bootpath);
>  
> -    from = qtest_start(cmd_src);
> +    *from = qtest_start(cmd_src);
>      g_free(cmd_src);
>  
> -    to = qtest_init(cmd_dst);
> +    *to = qtest_init(cmd_dst);
>      g_free(cmd_dst);
> +}
> +
> +static void test_migrate_end(QTestState *from, QTestState *to)
> +{
> +    unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d;
> +
> +    qtest_quit(from);
> +
> +    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);
> +
> +    qtest_qmp_discard_response(to, "{ '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(to);
> +
> +    qtest_quit(to);
> +
> +    cleanup("bootsect");
> +    cleanup("migsocket");
> +    cleanup("src_serial");
> +    cleanup("dest_serial");
> +}
> +
> +static void test_migrate(void)
> +{
> +    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> +    QTestState *global = global_qtest, *from, *to;
> +    QDict *rsp;
> +
> +    test_migrate_start(&from, &to, uri);
>  
>      migrate_set_capability(from, "postcopy-ram", "true");
>      migrate_set_capability(to, "postcopy-ram", "true");
> @@ -495,36 +531,10 @@ static void test_migrate(void)
>      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);
> -
> -    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");
> +    test_migrate_end(from, to);
>  }
>  
>  int main(int argc, char **argv)
> -- 
> 2.13.6
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest Juan Quintela
@ 2017-10-27  2:37   ` Dr. David Alan Gilbert
  2017-10-29  8:29     ` Juan Quintela
  0 siblings, 1 reply; 22+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-27  2:37 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> As we have two guests running, just pass always who we want to send a
> message to.  Once there, refactor return_or_event() into wait_command.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

Hmm was there anything else anywhere that relied on global_qtest?
Hopefully not.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  tests/migration-test.c | 55 +++++++++++++++++++++++++-------------------------
>  1 file changed, 27 insertions(+), 28 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 91fb0277d6..c429a13403 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -223,20 +223,23 @@ static void wait_for_serial(const char *side)
>  /*
>   * Events can get in the way of responses we are actually waiting for.
>   */
> -static QDict *return_or_event(QDict *response)
> +static QDict *wait_command(QTestState *who, const char *command)
>  {
>      const char *event_string;
> -    if (!qdict_haskey(response, "event")) {
> -        return response;
> -    }
> +    QDict *response;
> +
> +    response = qtest_qmp(who, command);
>  
> -    /* OK, it was an event */
> -    event_string = qdict_get_str(response, "event");
> -    if (!strcmp(event_string, "STOP")) {
> -        got_stop = true;
> +    while (qdict_haskey(response, "event")) {
> +        /* OK, it was an event */
> +        event_string = qdict_get_str(response, "event");
> +        if (!strcmp(event_string, "STOP")) {
> +            got_stop = true;
> +        }
> +        QDECREF(response);
> +        response = qtest_qmp_receive(who);
>      }
> -    QDECREF(response);
> -    return return_or_event(qtest_qmp_receive(global_qtest));
> +    return response;
>  }
>  
>  
> @@ -245,12 +248,12 @@ static QDict *return_or_event(QDict *response)
>   * events suddenly appearing confuse the qmp()/hmp() responses.
>   */
>  
> -static uint64_t get_migration_pass(void)
> +static uint64_t get_migration_pass(QTestState *who)
>  {
>      QDict *rsp, *rsp_return, *rsp_ram;
>      uint64_t result;
>  
> -    rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
> +    rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
>      rsp_return = qdict_get_qdict(rsp, "return");
>      if (!qdict_haskey(rsp_return, "ram")) {
>          /* Still in setup */
> @@ -263,7 +266,7 @@ static uint64_t get_migration_pass(void)
>      return result;
>  }
>  
> -static void wait_for_migration_complete(void)
> +static void wait_for_migration_complete(QTestState *who)
>  {
>      QDict *rsp, *rsp_return;
>      bool completed;
> @@ -271,7 +274,7 @@ static void wait_for_migration_complete(void)
>      do {
>          const char *status;
>  
> -        rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
> +        rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
>          rsp_return = qdict_get_qdict(rsp, "return");
>          status = qdict_get_str(rsp_return, "status");
>          completed = strcmp(status, "completed") == 0;
> @@ -281,14 +284,14 @@ static void wait_for_migration_complete(void)
>      } while (!completed);
>  }
>  
> -static void wait_for_migration_pass(void)
> +static void wait_for_migration_pass(QTestState *who)
>  {
> -    uint64_t initial_pass = get_migration_pass();
> +    uint64_t initial_pass = get_migration_pass(who);
>      uint64_t pass;
>  
>      /* Wait for the 1st sync */
>      do {
> -        initial_pass = get_migration_pass();
> +        initial_pass = get_migration_pass(who);
>          if (got_stop || initial_pass) {
>              break;
>          }
> @@ -297,7 +300,7 @@ static void wait_for_migration_pass(void)
>  
>      do {
>          usleep(1000 * 100);
> -        pass = get_migration_pass();
> +        pass = get_migration_pass(who);
>      } while (pass == initial_pass && !got_stop);
>  }
>  
> @@ -493,7 +496,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
>  static void test_migrate(void)
>  {
>      char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> -    QTestState *global = global_qtest, *from, *to;
> +    QTestState *from, *to;
>      QDict *rsp;
>  
>      test_migrate_start(&from, &to, uri);
> @@ -513,26 +516,22 @@ static void test_migrate(void)
>  
>      migrate(from, uri);
>  
> -    global_qtest = from;
> -    wait_for_migration_pass();
> +    wait_for_migration_pass(from);
>  
> -    rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
> +    rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
>      g_assert(qdict_haskey(rsp, "return"));
>      QDECREF(rsp);
>  
>      if (!got_stop) {
> -        qmp_eventwait("STOP");
> +        qtest_qmp_eventwait(from, "STOP");
>      }
>  
> -    global_qtest = to;
> -    qmp_eventwait("RESUME");
> +    qtest_qmp_eventwait(to, "RESUME");
>  
>      wait_for_serial("dest_serial");
> -    global_qtest = from;
> -    wait_for_migration_complete();
> +    wait_for_migration_complete(from);
>  
>      g_free(uri);
> -    global_qtest = global;
>  
>      test_migrate_end(from, to);
>  }
> -- 
> 2.13.6
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
@ 2017-10-27  3:47   ` Dr. David Alan Gilbert
  2017-10-29  8:30     ` Juan Quintela
  2017-10-29 13:24   ` Peter Xu
  1 sibling, 1 reply; 22+ messages in thread
From: Dr. David Alan Gilbert @ 2017-10-27  3:47 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, lvivier, peterx

* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/migration-test.c | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index c429a13403..be598d3257 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -354,17 +354,37 @@ static void cleanup(const char *filename)
>      g_free(path);
>  }
>  
> -static void migrate_set_downtime(QTestState *who, const char *value)
> +static void migrate_check_parameter(QTestState *who, const char *parameter,
> +                                    const char *value)
> +{
> +    QDict *rsp, *rsp_return;
> +    const char *result;
> +
> +    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
> +    rsp_return = qdict_get_qdict(rsp, "return");
> +    result = g_strdup_printf("%" PRId64,
> +                             qdict_get_try_int(rsp_return,  parameter, -1));
> +    g_assert_cmpstr(result, ==, value);
> +    QDECREF(rsp);
> +}
> +
> +static void migrate_set_downtime(QTestState *who, const double value)
>  {
>      QDict *rsp;
>      gchar *cmd;
> +    char *expected;
> +    int64_t result_int;
>  
>      cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
> -                          "'arguments': { 'value': %s } }", value);
> +                          "'arguments': { 'value': %g } }", value);

I wonder if that will hit any FP representation problems for some
values?


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>      rsp = qtest_qmp(who, cmd);
>      g_free(cmd);
>      g_assert(qdict_haskey(rsp, "return"));
>      QDECREF(rsp);
> +    result_int = value * 1000L;
> +    expected = g_strdup_printf("%" PRId64, result_int);
> +    migrate_check_parameter(who, "downtime-limit", expected);
> +    g_free(expected);
>  }
>  
>  static void migrate_set_speed(QTestState *who, const char *value)
> @@ -378,6 +398,7 @@ static void migrate_set_speed(QTestState *who, const char *value)
>      g_free(cmd);
>      g_assert(qdict_haskey(rsp, "return"));
>      QDECREF(rsp);
> +    migrate_check_parameter(who, "max-bandwidth", value);
>  }
>  
>  static void migrate_set_capability(QTestState *who, const char *capability,
> @@ -509,7 +530,7 @@ static void test_migrate(void)
>       * machine, so also set the downtime.
>       */
>      migrate_set_speed(from, "100000000");
> -    migrate_set_downtime(from, "0.001");
> +    migrate_set_downtime(from, 0.001);
>  
>      /* Wait for the first serial output from the source */
>      wait_for_serial("src_serial");
> -- 
> 2.13.6
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest
  2017-10-27  2:37   ` Dr. David Alan Gilbert
@ 2017-10-29  8:29     ` Juan Quintela
  0 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-29  8:29 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> As we have two guests running, just pass always who we want to send a
>> message to.  Once there, refactor return_or_event() into wait_command.
>> 
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>
> Hmm was there anything else anywhere that relied on global_qtest?
> Hopefully not.

I tested making global_qtest = NULL for the whole test (and put it back
at the end), so ...

>
>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>
>> ---
>>  tests/migration-test.c | 55 +++++++++++++++++++++++++-------------------------
>>  1 file changed, 27 insertions(+), 28 deletions(-)
>> 
>> diff --git a/tests/migration-test.c b/tests/migration-test.c
>> index 91fb0277d6..c429a13403 100644
>> --- a/tests/migration-test.c
>> +++ b/tests/migration-test.c
>> @@ -223,20 +223,23 @@ static void wait_for_serial(const char *side)
>>  /*
>>   * Events can get in the way of responses we are actually waiting for.
>>   */
>> -static QDict *return_or_event(QDict *response)
>> +static QDict *wait_command(QTestState *who, const char *command)
>>  {
>>      const char *event_string;
>> -    if (!qdict_haskey(response, "event")) {
>> -        return response;
>> -    }
>> +    QDict *response;
>> +
>> +    response = qtest_qmp(who, command);
>>  
>> -    /* OK, it was an event */
>> -    event_string = qdict_get_str(response, "event");
>> -    if (!strcmp(event_string, "STOP")) {
>> -        got_stop = true;
>> +    while (qdict_haskey(response, "event")) {
>> +        /* OK, it was an event */
>> +        event_string = qdict_get_str(response, "event");
>> +        if (!strcmp(event_string, "STOP")) {
>> +            got_stop = true;
>> +        }
>> +        QDECREF(response);
>> +        response = qtest_qmp_receive(who);
>>      }
>> -    QDECREF(response);
>> -    return return_or_event(qtest_qmp_receive(global_qtest));
>> +    return response;
>>  }
>>  
>>  
>> @@ -245,12 +248,12 @@ static QDict *return_or_event(QDict *response)
>>   * events suddenly appearing confuse the qmp()/hmp() responses.
>>   */
>>  
>> -static uint64_t get_migration_pass(void)
>> +static uint64_t get_migration_pass(QTestState *who)
>>  {
>>      QDict *rsp, *rsp_return, *rsp_ram;
>>      uint64_t result;
>>  
>> -    rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
>> +    rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
>>      rsp_return = qdict_get_qdict(rsp, "return");
>>      if (!qdict_haskey(rsp_return, "ram")) {
>>          /* Still in setup */
>> @@ -263,7 +266,7 @@ static uint64_t get_migration_pass(void)
>>      return result;
>>  }
>>  
>> -static void wait_for_migration_complete(void)
>> +static void wait_for_migration_complete(QTestState *who)
>>  {
>>      QDict *rsp, *rsp_return;
>>      bool completed;
>> @@ -271,7 +274,7 @@ static void wait_for_migration_complete(void)
>>      do {
>>          const char *status;
>>  
>> -        rsp = return_or_event(qmp("{ 'execute': 'query-migrate' }"));
>> +        rsp = wait_command(who, "{ 'execute': 'query-migrate' }");
>>          rsp_return = qdict_get_qdict(rsp, "return");
>>          status = qdict_get_str(rsp_return, "status");
>>          completed = strcmp(status, "completed") == 0;
>> @@ -281,14 +284,14 @@ static void wait_for_migration_complete(void)
>>      } while (!completed);
>>  }
>>  
>> -static void wait_for_migration_pass(void)
>> +static void wait_for_migration_pass(QTestState *who)
>>  {
>> -    uint64_t initial_pass = get_migration_pass();
>> +    uint64_t initial_pass = get_migration_pass(who);
>>      uint64_t pass;
>>  
>>      /* Wait for the 1st sync */
>>      do {
>> -        initial_pass = get_migration_pass();
>> +        initial_pass = get_migration_pass(who);
>>          if (got_stop || initial_pass) {
>>              break;
>>          }
>> @@ -297,7 +300,7 @@ static void wait_for_migration_pass(void)
>>  
>>      do {
>>          usleep(1000 * 100);
>> -        pass = get_migration_pass();
>> +        pass = get_migration_pass(who);
>>      } while (pass == initial_pass && !got_stop);
>>  }
>>  
>> @@ -493,7 +496,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
>>  static void test_migrate(void)
>>  {
>>      char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
>> -    QTestState *global = global_qtest, *from, *to;
>> +    QTestState *from, *to;
>>      QDict *rsp;
>>  
>>      test_migrate_start(&from, &to, uri);
>> @@ -513,26 +516,22 @@ static void test_migrate(void)
>>  
>>      migrate(from, uri);
>>  
>> -    global_qtest = from;
>> -    wait_for_migration_pass();
>> +    wait_for_migration_pass(from);
>>  
>> -    rsp = return_or_event(qmp("{ 'execute': 'migrate-start-postcopy' }"));
>> +    rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }");
>>      g_assert(qdict_haskey(rsp, "return"));
>>      QDECREF(rsp);
>>  
>>      if (!got_stop) {
>> -        qmp_eventwait("STOP");
>> +        qtest_qmp_eventwait(from, "STOP");
>>      }
>>  
>> -    global_qtest = to;
>> -    qmp_eventwait("RESUME");
>> +    qtest_qmp_eventwait(to, "RESUME");
>>  
>>      wait_for_serial("dest_serial");
>> -    global_qtest = from;
>> -    wait_for_migration_complete();
>> +    wait_for_migration_complete(from);
>>  
>>      g_free(uri);
>> -    global_qtest = global;
>>  
>>      test_migrate_end(from, to);
>>  }
>> -- 
>> 2.13.6
>> 
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned
  2017-10-27  3:47   ` Dr. David Alan Gilbert
@ 2017-10-29  8:30     ` Juan Quintela
  0 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-29  8:30 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: qemu-devel, lvivier, peterx

"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  tests/migration-test.c | 27 ++++++++++++++++++++++++---
>>  1 file changed, 24 insertions(+), 3 deletions(-)
>> 
>> diff --git a/tests/migration-test.c b/tests/migration-test.c
>> index c429a13403..be598d3257 100644
>> --- a/tests/migration-test.c
>> +++ b/tests/migration-test.c
>> @@ -354,17 +354,37 @@ static void cleanup(const char *filename)
>>      g_free(path);
>>  }
>>  
>> -static void migrate_set_downtime(QTestState *who, const char *value)
>> +static void migrate_check_parameter(QTestState *who, const char *parameter,
>> +                                    const char *value)
>> +{
>> +    QDict *rsp, *rsp_return;
>> +    const char *result;
>> +
>> +    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
>> +    rsp_return = qdict_get_qdict(rsp, "return");
>> +    result = g_strdup_printf("%" PRId64,
>> +                             qdict_get_try_int(rsp_return,  parameter, -1));
>> +    g_assert_cmpstr(result, ==, value);
>> +    QDECREF(rsp);
>> +}
>> +
>> +static void migrate_set_downtime(QTestState *who, const double value)
>>  {
>>      QDict *rsp;
>>      gchar *cmd;
>> +    char *expected;
>> +    int64_t result_int;
>>  
>>      cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
>> -                          "'arguments': { 'value': %s } }", value);
>> +                          "'arguments': { 'value': %g } }", value);
>
> I wonder if that will hit any FP representation problems for some
> values?

This is a deprecated function, so .....

Thanks, Juan.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
  2017-10-27  3:47   ` Dr. David Alan Gilbert
@ 2017-10-29 13:24   ` Peter Xu
  2017-10-30 13:28     ` Juan Quintela
  1 sibling, 1 reply; 22+ messages in thread
From: Peter Xu @ 2017-10-29 13:24 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, dgilbert, lvivier

On Thu, Oct 26, 2017 at 09:52:17AM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/migration-test.c | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index c429a13403..be598d3257 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -354,17 +354,37 @@ static void cleanup(const char *filename)
>      g_free(path);
>  }
>  
> -static void migrate_set_downtime(QTestState *who, const char *value)
> +static void migrate_check_parameter(QTestState *who, const char *parameter,
> +                                    const char *value)
> +{
> +    QDict *rsp, *rsp_return;
> +    const char *result;
> +
> +    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
> +    rsp_return = qdict_get_qdict(rsp, "return");
> +    result = g_strdup_printf("%" PRId64,
> +                             qdict_get_try_int(rsp_return,  parameter, -1));
> +    g_assert_cmpstr(result, ==, value);
> +    QDECREF(rsp);

Maybe we need to free "result" as well?  I see a pull request already,
so maybe another fix patch on top.  Thanks,

> +}
> +
> +static void migrate_set_downtime(QTestState *who, const double value)
>  {
>      QDict *rsp;
>      gchar *cmd;
> +    char *expected;
> +    int64_t result_int;
>  
>      cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
> -                          "'arguments': { 'value': %s } }", value);
> +                          "'arguments': { 'value': %g } }", value);
>      rsp = qtest_qmp(who, cmd);
>      g_free(cmd);
>      g_assert(qdict_haskey(rsp, "return"));
>      QDECREF(rsp);
> +    result_int = value * 1000L;
> +    expected = g_strdup_printf("%" PRId64, result_int);
> +    migrate_check_parameter(who, "downtime-limit", expected);
> +    g_free(expected);
>  }
>  
>  static void migrate_set_speed(QTestState *who, const char *value)
> @@ -378,6 +398,7 @@ static void migrate_set_speed(QTestState *who, const char *value)
>      g_free(cmd);
>      g_assert(qdict_haskey(rsp, "return"));
>      QDECREF(rsp);
> +    migrate_check_parameter(who, "max-bandwidth", value);
>  }
>  
>  static void migrate_set_capability(QTestState *who, const char *capability,
> @@ -509,7 +530,7 @@ static void test_migrate(void)
>       * machine, so also set the downtime.
>       */
>      migrate_set_speed(from, "100000000");
> -    migrate_set_downtime(from, "0.001");
> +    migrate_set_downtime(from, 0.001);
>  
>      /* Wait for the first serial output from the source */
>      wait_for_serial("src_serial");
> -- 
> 2.13.6
> 

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands Juan Quintela
@ 2017-10-29 13:40   ` Peter Xu
  0 siblings, 0 replies; 22+ messages in thread
From: Peter Xu @ 2017-10-29 13:40 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, dgilbert, lvivier

On Thu, Oct 26, 2017 at 09:52:20AM +0200, Juan Quintela wrote:
> Once there, make postcopy test to use the new commands now that we
> have other test for deprecated ones
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/migration-test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 46 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index 338254bafe..b72dff3917 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -545,8 +545,8 @@ static void test_postcopy(void)
>       * quickly, but that it doesn't complete precopy even on a slow
>       * machine, so also set the downtime.
>       */
> -    migrate_set_speed(from, "100000000");
> -    migrate_set_downtime(from, 0.001);
> +    migrate_set_parameter(from, "max-bandwidth", "1000000000");
> +    migrate_set_parameter(from, "downtime-limit", "1");
>  
>      /* Wait for the first serial output from the source */
>      wait_for_serial("src_serial");
> @@ -573,6 +573,49 @@ static void test_postcopy(void)
>      test_migrate_end(from, to);
>  }
>  
> +static void test_precopy_deprecated(const char *uri)
> +{
> +    QTestState *from, *to;
> +
> +    test_migrate_start(&from, &to, uri);
> +
> +    /* 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.
> +     */
> +    /* 100 ms */
> +    migrate_set_downtime(from, 0.001);
> +    /* 1MB/s slow*/
> +    migrate_set_speed(from, "1000000000");
> +
> +    /* Wait for the first serial output from the source */
> +    wait_for_serial("src_serial");
> +
> +    migrate(from, uri);
> +
> +    wait_for_migration_pass(from);
> +
> +    /* 300ms it should converge */
> +    migrate_set_downtime(from, 0.3);
> +
> +    if (!got_stop) {
> +        qtest_qmp_eventwait(from, "STOP");
> +    }
> +    qtest_qmp_eventwait(to, "RESUME");
> +
> +    wait_for_serial("dest_serial");
> +    wait_for_migration_complete(from);
> +
> +    test_migrate_end(from, to);

Again, instead of doing real migration to test deprecated commands,
how about just set/check them one by one?  After all we have
migrate_check_parameter() now, which seems even easier than before.

Thanks,

> +}
> +
> +static void test_deprecated_unix(void)
> +{
> +    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> +
> +    test_precopy_deprecated(uri);
> +    g_free(uri);
> +}
>  
>  static void test_precopy(const char *uri)
>  {
> @@ -648,6 +691,7 @@ int main(int argc, char **argv)
>  
>      qtest_add_func("/migration/precopy/unix", test_precopy_unix);
>      qtest_add_func("/migration/precopy/tcp", test_precopy_tcp);
> +    qtest_add_func("/migration/deprecated/unix", test_deprecated_unix);
>      qtest_add_func("/migration/postcopy/unix", test_postcopy);
>  
>      ret = g_test_run();
> -- 
> 2.13.6
> 

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test
  2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test Juan Quintela
@ 2017-10-29 13:56   ` Peter Xu
  0 siblings, 0 replies; 22+ messages in thread
From: Peter Xu @ 2017-10-29 13:56 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel, dgilbert, lvivier

On Thu, Oct 26, 2017 at 09:52:18AM +0200, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>

I am not sure whether some numbers below are the best, but I believe
it should pass your smoke test at least, and I really want to have
some migration unit tests there in master sonner or later (even, I
would be happy if I can run them if I need to post another postcopy
recovery series :-).

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks,

> ---
>  tests/migration-test.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 66 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/migration-test.c b/tests/migration-test.c
> index be598d3257..a8718770c9 100644
> --- a/tests/migration-test.c
> +++ b/tests/migration-test.c
> @@ -401,6 +401,22 @@ static void migrate_set_speed(QTestState *who, const char *value)
>      migrate_check_parameter(who, "max-bandwidth", value);
>  }
>  
> +static void migrate_set_parameter(QTestState *who, const char *parameter,
> +                                  const char *value)
> +{
> +    QDict *rsp;
> +    gchar *cmd;
> +
> +    cmd = g_strdup_printf("{ 'execute': 'migrate-set-parameters',"
> +                          "'arguments': { '%s': %s } }",
> +                          parameter, value);
> +    rsp = qtest_qmp(who, cmd);
> +    g_free(cmd);
> +    g_assert(qdict_haskey(rsp, "return"));
> +    QDECREF(rsp);
> +    migrate_check_parameter(who, parameter, value);
> +}
> +
>  static void migrate_set_capability(QTestState *who, const char *capability,
>                                     const char *value)
>  {
> @@ -514,7 +530,7 @@ static void test_migrate_end(QTestState *from, QTestState *to)
>      cleanup("dest_serial");
>  }
>  
> -static void test_migrate(void)
> +static void test_postcopy(void)
>  {
>      char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
>      QTestState *from, *to;
> @@ -557,6 +573,53 @@ static void test_migrate(void)
>      test_migrate_end(from, to);
>  }
>  
> +
> +static void test_precopy(const char *uri)
> +{
> +    QTestState *from, *to;
> +
> +    test_migrate_start(&from, &to, uri);
> +
> +    /* 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.
> +     */
> +    /* 1 ms */
> +    migrate_set_parameter(from, "downtime-limit", "1");
> +    /* 1GB/s slow*/
> +    migrate_set_parameter(from, "max-bandwidth", "1000000000");
> +
> +
> +    /* Wait for the first serial output from the source */
> +    wait_for_serial("src_serial");
> +
> +    migrate(from, uri);
> +
> +    wait_for_migration_pass(from);
> +
> +    /* 1GB/s now it should converge */
> +    migrate_set_parameter(from, "downtime-limit", "300");
> +
> +    if (!got_stop) {
> +        qtest_qmp_eventwait(from, "STOP");
> +    }
> +
> +    qtest_qmp_eventwait(to, "RESUME");
> +
> +    wait_for_serial("dest_serial");
> +    wait_for_migration_complete(from);
> +
> +    test_migrate_end(from, to);
> +}
> +
> +static void test_precopy_unix(void)
> +{
> +    char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs);
> +
> +    test_precopy(uri);
> +    g_free(uri);
> +}
> +
>  int main(int argc, char **argv)
>  {
>      char template[] = "/tmp/migration-test-XXXXXX";
> @@ -576,7 +639,8 @@ int main(int argc, char **argv)
>  
>      module_call_init(MODULE_INIT_QOM);
>  
> -    qtest_add_func("/migration/postcopy/unix", test_migrate);
> +    qtest_add_func("/migration/precopy/unix", test_precopy_unix);
> +    qtest_add_func("/migration/postcopy/unix", test_postcopy);
>  
>      ret = g_test_run();
>  
> -- 
> 2.13.6
> 

-- 
Peter Xu

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned
  2017-10-29 13:24   ` Peter Xu
@ 2017-10-30 13:28     ` Juan Quintela
  0 siblings, 0 replies; 22+ messages in thread
From: Juan Quintela @ 2017-10-30 13:28 UTC (permalink / raw)
  To: Peter Xu; +Cc: qemu-devel, dgilbert, lvivier

Peter Xu <peterx@redhat.com> wrote:
> On Thu, Oct 26, 2017 at 09:52:17AM +0200, Juan Quintela wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  tests/migration-test.c | 27 ++++++++++++++++++++++++---
>>  1 file changed, 24 insertions(+), 3 deletions(-)
>> 
>> diff --git a/tests/migration-test.c b/tests/migration-test.c
>> index c429a13403..be598d3257 100644
>> --- a/tests/migration-test.c
>> +++ b/tests/migration-test.c
>> @@ -354,17 +354,37 @@ static void cleanup(const char *filename)
>>      g_free(path);
>>  }
>>  
>> -static void migrate_set_downtime(QTestState *who, const char *value)
>> +static void migrate_check_parameter(QTestState *who, const char *parameter,
>> +                                    const char *value)
>> +{
>> +    QDict *rsp, *rsp_return;
>> +    const char *result;
>> +
>> +    rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }");
>> +    rsp_return = qdict_get_qdict(rsp, "return");
>> +    result = g_strdup_printf("%" PRId64,
>> +                             qdict_get_try_int(rsp_return,  parameter, -1));
>> +    g_assert_cmpstr(result, ==, value);
>> +    QDECREF(rsp);
>
> Maybe we need to free "result" as well?  I see a pull request already,
> so maybe another fix patch on top.  Thanks,

Done, thanks.

>
>> +}
>> +
>> +static void migrate_set_downtime(QTestState *who, const double value)
>>  {
>>      QDict *rsp;
>>      gchar *cmd;
>> +    char *expected;
>> +    int64_t result_int;
>>  
>>      cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime',"
>> -                          "'arguments': { 'value': %s } }", value);
>> +                          "'arguments': { 'value': %g } }", value);
>>      rsp = qtest_qmp(who, cmd);
>>      g_free(cmd);
>>      g_assert(qdict_haskey(rsp, "return"));
>>      QDECREF(rsp);
>> +    result_int = value * 1000L;
>> +    expected = g_strdup_printf("%" PRId64, result_int);
>> +    migrate_check_parameter(who, "downtime-limit", expected);
>> +    g_free(expected);
>>  }
>>  
>>  static void migrate_set_speed(QTestState *who, const char *value)
>> @@ -378,6 +398,7 @@ static void migrate_set_speed(QTestState *who, const char *value)
>>      g_free(cmd);
>>      g_assert(qdict_haskey(rsp, "return"));
>>      QDECREF(rsp);
>> +    migrate_check_parameter(who, "max-bandwidth", value);
>>  }
>>  
>>  static void migrate_set_capability(QTestState *who, const char *capability,
>> @@ -509,7 +530,7 @@ static void test_migrate(void)
>>       * machine, so also set the downtime.
>>       */
>>      migrate_set_speed(from, "100000000");
>> -    migrate_set_downtime(from, "0.001");
>> +    migrate_set_downtime(from, 0.001);
>>  
>>      /* Wait for the first serial output from the source */
>>      wait_for_serial("src_serial");
>> -- 
>> 2.13.6
>> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2017-10-30 13:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26  7:52 [Qemu-devel] [PATCH v2 00/10] Add make check tests for Migration Juan Quintela
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 01/10] tests: rename postcopy-test to migration-test Juan Quintela
2017-10-27  1:50   ` Dr. David Alan Gilbert
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 02/10] tests: Refactor setting of parameters/capabilities Juan Quintela
2017-10-27  1:54   ` Dr. David Alan Gilbert
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 03/10] tests: Factorize out migrate_test_start/end Juan Quintela
2017-10-27  2:15   ` Dr. David Alan Gilbert
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 04/10] tests: Don't abuse global_qtest Juan Quintela
2017-10-27  2:37   ` Dr. David Alan Gilbert
2017-10-29  8:29     ` Juan Quintela
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 05/10] tests: check that migration parameters are really assigned Juan Quintela
2017-10-27  3:47   ` Dr. David Alan Gilbert
2017-10-29  8:30     ` Juan Quintela
2017-10-29 13:24   ` Peter Xu
2017-10-30 13:28     ` Juan Quintela
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 06/10] tests: Add migration precopy test Juan Quintela
2017-10-29 13:56   ` Peter Xu
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 07/10] tests: Add basic migration precopy tcp test Juan Quintela
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 08/10] tests: Add precopy test using deprecated commands Juan Quintela
2017-10-29 13:40   ` Peter Xu
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 09/10] tests: Add migration xbzrle test Juan Quintela
2017-10-26  7:52 ` [Qemu-devel] [PATCH v2 10/10] [RFH] tests: Add migration compress threads tests Juan Quintela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.