Skip to contentSkip to conversation

tests/qtest/migration-test: Improve and enable on ppc64

PATCH Superseded Nicholas Piggin 3 participants 10 messages May 25, 2024 – May 27, 2024

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#5 lore raw

PATCH 2/3 tests/qtest/migration-test: Enable on ppc64

In reply to Nicholas Piggin

ppc64 with TCG seems to no longer be failing this test. Let's try to enable it. s390x is still hanging about 1 in 10 runs.

---
 tests/qtest/migration-test.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
tests/qtest/migration-test.c +3 -13
index c13535c37d..b8617cc843 100644
@@ -3454,19 +3454,9 @@ int main(int argc, char **argv)
 #endif
 
     /*
-     * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
-     * is touchy due to race conditions on dirty bits (especially on PPC for
-     * some reason)
-     */
-    if (g_str_equal(arch, "ppc64") &&
-        (!has_kvm || access("/sys/module/kvm_hv", F_OK))) {
-        g_test_message("Skipping tests: kvm_hv not available");
-        goto test_add_done;
-    }
-
-    /*
-     * Similar to ppc64, s390x seems to be touchy with TCG, so disable it
-     * there until the problems are resolved
+     * On s390x, the test seems to be touchy with TCG, perhaps due to race
+     * conditions on dirty bits, so disable it there until the problems are
+     * resolved.
      */
     if (g_str_equal(arch, "s390x") && !has_kvm) {
         g_test_message("Skipping tests: s390x host with KVM is required");
Signature · 1 line
2.43.0
#8 lore raw

PATCH 3/3 tests/qtest/migration-test: Use custom asm bios for ppc64

In reply to Nicholas Piggin

Similar to other archs, build a custom bios memory updater. Running the test with OF code is a cool trick, but SLOF takes a long time to boot. This reduces test time by around 3x (150s to 50s).

---
 tests/migration/migration-test.h   |  1 +
 tests/migration/ppc64/a-b-kernel.h | 42 +++++++++++++++++++
 tests/qtest/migration-test.c       | 35 +++-------------
 tests/migration/Makefile           |  2 +-
 tests/migration/ppc64/Makefile     | 15 +++++++
 tests/migration/ppc64/a-b-kernel.S | 66 ++++++++++++++++++++++++++++++
 6 files changed, 130 insertions(+), 31 deletions(-)
 create mode 100644 tests/migration/ppc64/a-b-kernel.h
 create mode 100644 tests/migration/ppc64/Makefile
 create mode 100644 tests/migration/ppc64/a-b-kernel.S
tests/migration/migration-test.h +1 -0
index 68512c0b1b..194df7df6f 100644
@@ -22,6 +22,7 @@
 /* PPC */
 #define PPC_TEST_MEM_START (1 * 1024 * 1024)
 #define PPC_TEST_MEM_END   (100 * 1024 * 1024)
+#define PPC_H_PUT_TERM_CHAR 0x58
 
 /* ARM */
 #define ARM_TEST_MEM_START (0x40000000 + 1 * 1024 * 1024)
tests/migration/ppc64/a-b-kernel.h new file +42 -0

42 lines not on this page · raw message

tests/qtest/migration-test.c +5 -30
index b8617cc843..94d5057857 100644
@@ -128,6 +128,7 @@ static char *bootpath;
  */
 #include "tests/migration/i386/a-b-bootblock.h"
 #include "tests/migration/aarch64/a-b-kernel.h"
+#include "tests/migration/ppc64/a-b-kernel.h"
 #include "tests/migration/s390x/a-b-bios.h"
 
 static void bootfile_create(char *dir, bool suspend_me)
@@ -147,10 +148,8 @@ static void bootfile_create(char *dir, bool suspend_me)
         content = s390x_elf;
         len = sizeof(s390x_elf);
     } else if (strcmp(arch, "ppc64") == 0) {
-        /*
-         * sane architectures can be programmed at the boot prompt
-         */
-        return;
+        content = ppc64_kernel;
+        len = sizeof(ppc64_kernel);
     } else if (strcmp(arch, "aarch64") == 0) {
         content = aarch64_kernel;
         len = sizeof(aarch64_kernel);
@@ -181,29 +180,10 @@ static void wait_for_serial(const char *side)
 {
     g_autofree char *serialpath = g_strdup_printf("%s/%s", tmpfs, side);
     FILE *serialfile = fopen(serialpath, "r");
-    const char *arch = qtest_get_arch();
-    int started = (strcmp(side, "src_serial") == 0 &&
-                   strcmp(arch, "ppc64") == 0) ? 0 : 1;
 
     do {
         int readvalue = fgetc(serialfile);
 
-        if (!started) {
-            /* SLOF prints its banner before starting test,
-             * to ignore it, mark the start of the test with '_',
-             * ignore all characters until this marker
-             */
-            switch (readvalue) {
-            case '_':
-                started = 1;
-                break;
-            case EOF:
-                fseek(serialfile, 0, SEEK_SET);
-                usleep(1000);
-                break;
-            }
-            continue;
-        }
         switch (readvalue) {
         case 'A':
             /* Fine */
@@ -215,8 +195,6 @@ static void wait_for_serial(const char *side)
             return;
 
         case EOF:
-            started = (strcmp(side, "src_serial") == 0 &&
-                       strcmp(arch, "ppc64") == 0) ? 0 : 1;
             fseek(serialfile, 0, SEEK_SET);
             usleep(1000);
             break;
@@ -737,14 +715,11 @@ static int test_migrate_start(QTestState **from, QTestState **to,
         memory_size = "256M";
         start_address = PPC_TEST_MEM_START;
         end_address = PPC_TEST_MEM_END;
-        arch_source = g_strdup_printf("-prom-env 'use-nvramrc?=true' -prom-env "
-                                      "'nvramrc=hex .\" _\" begin %x %x "
-                                      "do i c@ 1 + i c! 1000 +loop .\" B\" 0 "
-                                      "until'", end_address, start_address);
         machine_alias = "pseries";
         machine_opts = "vsmt=8";
         arch_opts = g_strdup_printf("-nodefaults "
-                        "-machine " PSERIES_DEFAULT_CAPABILITIES);
+                        "-machine " PSERIES_DEFAULT_CAPABILITIES " "
+                        "-bios %s", bootpath);
     } else if (strcmp(arch, "aarch64") == 0) {
         memory_size = "150M";
         machine_alias = "virt";
tests/migration/Makefile +1 -1
index 13e99b1692..2c5ee287ec 100644
@@ -5,7 +5,7 @@
 # See the COPYING file in the top-level directory.
 #
 
-TARGET_LIST = i386 aarch64 s390x
+TARGET_LIST = i386 aarch64 s390x ppc64
 
 SRC_PATH = ../..
 
tests/migration/ppc64/Makefile new file +15 -0
new file mode 100644
index 0000000000..a3a2d98ac8
@@ -0,0 +1,15 @@
+.PHONY: all clean
+all: a-b-kernel.h
+
+a-b-kernel.h: ppc64.kernel
+	echo "$$__note" > $@
+	xxd -i $< | sed -e 's/.*int.*//' >> $@
+
+ppc64.kernel: ppc64.elf
+	$(CROSS_PREFIX)objcopy -O binary -S $< $@
+
+ppc64.elf: a-b-kernel.S
+	$(CROSS_PREFIX)gcc -static -o $@ -nostdlib -Wl,--build-id=none $<
+
+clean:
+	$(RM) *.kernel *.elf
tests/migration/ppc64/a-b-kernel.S new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.43.0
#0 lore raw

cover tests/qtest/migration-test: Improve and enable on ppc64

ppc64 seems to be stable now, only problem is the speed, so I rewrote the test to avoid SLOF and use special bios blob like the other archs.

Thanks,
Nick

Nicholas Piggin (3):
tests/qtest/migration-test: Quieten ppc64 QEMU warnigns tests/qtest/migration-test: Enable on ppc64 tests/qtest/migration-test: Use custom asm bios for ppc64

 tests/migration/migration-test.h   |  1 +
 tests/migration/ppc64/a-b-kernel.h | 42 +++++++++++++++++++
 tests/qtest/migration-test.c       | 53 +++++-------------------
 tests/migration/Makefile           |  2 +-
 tests/migration/ppc64/Makefile     | 15 +++++++
 tests/migration/ppc64/a-b-kernel.S | 66 ++++++++++++++++++++++++++++++
 6 files changed, 135 insertions(+), 44 deletions(-)
 create mode 100644 tests/migration/ppc64/a-b-kernel.h
 create mode 100644 tests/migration/ppc64/Makefile
 create mode 100644 tests/migration/ppc64/a-b-kernel.S
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 tests/qtest/migration-test: Quieten ppc64 QEMU warnigns

---
 tests/qtest/migration-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +3 -1
index b7e3406471..c13535c37d 100644
@@ -21,6 +21,7 @@
 #include "chardev/char.h"
 #include "crypto/tlscredspsk.h"
 #include "qapi/qmp/qlist.h"
+#include "libqos/libqos-spapr.h"
 
 #include "migration-helpers.h"
 #include "tests/migration/migration-test.h"
@@ -742,7 +743,8 @@ static int test_migrate_start(QTestState **from, QTestState **to,
                                       "until'", end_address, start_address);
         machine_alias = "pseries";
         machine_opts = "vsmt=8";
-        arch_opts = g_strdup("-nodefaults");
+        arch_opts = g_strdup_printf("-nodefaults "
+                        "-machine " PSERIES_DEFAULT_CAPABILITIES);
     } else if (strcmp(arch, "aarch64") == 0) {
         memory_size = "150M";
         machine_alias = "virt";
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] tests/qtest/migration-test: Quieten ppc64 QEMU warnigns

Quoted 10 lines · Nicholas Piggin
---
  tests/qtest/migration-test.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index b7e3406471..c13535c37d 100644

tests/qtest/migration-test.c line 24

Quoted 4 lines
tests/qtest/migration-test.c +1 -0
@@ -21,6 +21,7 @@
  #include "chardev/char.h"
  #include "crypto/tlscredspsk.h"
  #include "qapi/qmp/qlist.h"
+#include "libqos/libqos-spapr.h"

It's a little bit unfortunate to include a libqos header in a non-qos test ... so in case you respin, maybe add a comment at the end of the line like:

/* just for PSERIES_DEFAULT_CAPABILITIES */

?

tests/qtest/migration-test.c static int test_migrate_start(QTestState **from, QTestState **to, · line 750

Quoted 12 lines
tests/qtest/migration-test.c +2 -1
  #include "migration-helpers.h"
  #include "tests/migration/migration-test.h"
@@ -742,7 +743,8 @@ static int test_migrate_start(QTestState **from, QTestState **to,
                                        "until'", end_address, start_address);
          machine_alias = "pseries";
          machine_opts = "vsmt=8";
-        arch_opts = g_strdup("-nodefaults");
+        arch_opts = g_strdup_printf("-nodefaults "
+                        "-machine " PSERIES_DEFAULT_CAPABILITIES);
      } else if (strcmp(arch, "aarch64") == 0) {
          memory_size = "150M";
          machine_alias = "virt";
Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] tests/qtest/migration-test: Enable on ppc64

In reply to Nicholas Piggin
Quoted 25 lines · Nicholas Piggin

ppc64 with TCG seems to no longer be failing this test. Let's try to enable it. s390x is still hanging about 1 in 10 runs.

---
  tests/qtest/migration-test.c | 16 +++-------------
  1 file changed, 3 insertions(+), 13 deletions(-)
tests/qtest/migration-test.c +0 -9
index c13535c37d..b8617cc843 100644
@@ -3454,19 +3454,9 @@ int main(int argc, char **argv)
  #endif
 
      /*
-     * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
-     * is touchy due to race conditions on dirty bits (especially on PPC for
-     * some reason)
-     */
-    if (g_str_equal(arch, "ppc64") &&
-        (!has_kvm || access("/sys/module/kvm_hv", F_OK))) {
-        g_test_message("Skipping tests: kvm_hv not available");
-        goto test_add_done;
-    }

tests/qtest/migration-test.c int main(int argc, char **argv) · line 3462

Quoted 10 lines
tests/qtest/migration-test.c +3 -4
-
-    /*
-     * Similar to ppc64, s390x seems to be touchy with TCG, so disable it
-     * there until the problems are resolved
+     * On s390x, the test seems to be touchy with TCG, perhaps due to race
+     * conditions on dirty bits, so disable it there until the problems are
+     * resolved.
       */
      if (g_str_equal(arch, "s390x") && !has_kvm) {
          g_test_message("Skipping tests: s390x host with KVM is required");

Since you've identified the problem on s390x, you could maybe adjust the comment in case you respin ... OTOH, it will get removed anyway once we merge the s390x fix, so no need to respin just because of this.

#3 lore raw

Re: [PATCH 1/3] tests/qtest/migration-test: Quieten ppc64 QEMU warnigns

In reply to Thomas Huth
Quoted 19 lines · Thomas Huth
Quoted 10 lines · Nicholas Piggin
---
  tests/qtest/migration-test.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index b7e3406471..c13535c37d 100644

tests/qtest/migration-test.c line 24

Quoted 4 lines
tests/qtest/migration-test.c +1 -0
@@ -21,6 +21,7 @@
  #include "chardev/char.h"
  #include "crypto/tlscredspsk.h"
  #include "qapi/qmp/qlist.h"
+#include "libqos/libqos-spapr.h"

It's a little bit unfortunate to include a libqos header in a non-qos test ... so in case you respin, maybe add a comment at the end of the line like:

Quoted 3 lines
   /* just for PSERIES_DEFAULT_CAPABILITIES */

?

Same as other uses of it by the looks. Could just put it in a new header in tests/qtest/ppc-util.h or something?

Thanks,
Nick

Quoted 15 lines

tests/qtest/migration-test.c static int test_migrate_start(QTestState **from, QTestState **to, · line 750

Quoted 13 lines
tests/qtest/migration-test.c +2 -1
  #include "migration-helpers.h"
  #include "tests/migration/migration-test.h"
@@ -742,7 +743,8 @@ static int test_migrate_start(QTestState **from, QTestState **to,
                                        "until'", end_address, start_address);
          machine_alias = "pseries";
          machine_opts = "vsmt=8";
-        arch_opts = g_strdup("-nodefaults");
+        arch_opts = g_strdup_printf("-nodefaults "
+                        "-machine " PSERIES_DEFAULT_CAPABILITIES);
      } else if (strcmp(arch, "aarch64") == 0) {
          memory_size = "150M";
          machine_alias = "virt";
#7 lore raw

Re: [PATCH 2/3] tests/qtest/migration-test: Enable on ppc64

In reply to Thomas Huth
Quoted 41 lines · Thomas Huth
Quoted 25 lines · Nicholas Piggin

ppc64 with TCG seems to no longer be failing this test. Let's try to enable it. s390x is still hanging about 1 in 10 runs.

---
  tests/qtest/migration-test.c | 16 +++-------------
  1 file changed, 3 insertions(+), 13 deletions(-)
tests/qtest/migration-test.c +0 -9
index c13535c37d..b8617cc843 100644
@@ -3454,19 +3454,9 @@ int main(int argc, char **argv)
  #endif
 
      /*
-     * On ppc64, the test only works with kvm-hv, but not with kvm-pr and TCG
-     * is touchy due to race conditions on dirty bits (especially on PPC for
-     * some reason)
-     */
-    if (g_str_equal(arch, "ppc64") &&
-        (!has_kvm || access("/sys/module/kvm_hv", F_OK))) {
-        g_test_message("Skipping tests: kvm_hv not available");
-        goto test_add_done;
-    }

tests/qtest/migration-test.c int main(int argc, char **argv) · line 3462

Quoted 10 lines
tests/qtest/migration-test.c +3 -4
-
-    /*
-     * Similar to ppc64, s390x seems to be touchy with TCG, so disable it
-     * there until the problems are resolved
+     * On s390x, the test seems to be touchy with TCG, perhaps due to race
+     * conditions on dirty bits, so disable it there until the problems are
+     * resolved.
       */
      if (g_str_equal(arch, "s390x") && !has_kvm) {
          g_test_message("Skipping tests: s390x host with KVM is required");

Since you've identified the problem on s390x, you could maybe adjust the comment in case you respin ... OTOH, it will get removed anyway once we merge the s390x fix, so no need to respin just because of this.

Quoted 1 line

Thanks. I will respin to at least fix the subjet "Enable on ppc64 TCG" so I can do the other minor things too.

Thanks,
Nick

#4 lore raw

Re: [PATCH 1/3] tests/qtest/migration-test: Quieten ppc64 QEMU warnigns

In reply to Nicholas Piggin
Quoted 20 lines · Nicholas Piggin
Quoted 19 lines · Thomas Huth
Quoted 10 lines · Nicholas Piggin
---
   tests/qtest/migration-test.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/migration-test.c +0 -0
index b7e3406471..c13535c37d 100644

tests/qtest/migration-test.c line 24

Quoted 4 lines
tests/qtest/migration-test.c +1 -0
@@ -21,6 +21,7 @@
   #include "chardev/char.h"
   #include "crypto/tlscredspsk.h"
   #include "qapi/qmp/qlist.h"
+#include "libqos/libqos-spapr.h"

It's a little bit unfortunate to include a libqos header in a non-qos test ... so in case you respin, maybe add a comment at the end of the line like:

Quoted 6 lines
Quoted 3 lines
    /* just for PSERIES_DEFAULT_CAPABILITIES */

?

Same as other uses of it by the looks. Could just put it in a new header in tests/qtest/ppc-util.h or something?

Yes, that would be cleaner, indeed.

Thanks,
Thomas