Changeset
tests/Makefile.include |  1 +
tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
tests/pxe-test.c       |  7 ++++++
3 files changed, 54 insertions(+), 15 deletions(-)
Git apply log
Switched to a new branch '1502431076-22849-1-git-send-email-thuth@redhat.com'
Applying: tests/boot-sector: Do not overwrite the x86 buffer on other architectures
Applying: tests/pxe: Check virtio-net-ccw on s390x
To https://github.com/patchew-project/qemu
 + f82ef199ea...36e2646523 patchew/1502431076-22849-1-git-send-email-thuth@redhat.com -> patchew/1502431076-22849-1-git-send-email-thuth@redhat.com (forced update)
Test passed: s390x

loading

Test passed: docker

loading

Test passed: checkpatch

loading

Test passed: FreeBSD

loading

[Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Thomas Huth, 14 weeks ago
The first patch improves the buffer handling in the pxe tester a
little bit by allocating a separate buffer on the heap for each
architecture. This also gets rid of the huge pre-initialized
array in the tester, shrinking the size of the executable by
half of a megabyte!
The second patch adds s390x support to the pxe tester. Starting
with QEMU 2.10, the guest firmware on s390x can now net-boot via
TFTP, too, so we can automatically test this code in the pxe tester.

v2: Adressed Cornelia's review feedback from the first version, e.g.:
 - Use g_malloc0() instead of g_malloc()
 - Use sizeof with parentheses

Thomas Huth (2):
  tests/boot-sector: Do not overwrite the x86 buffer on other
    architectures
  tests/pxe: Check virtio-net-ccw on s390x

 tests/Makefile.include |  1 +
 tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
 tests/pxe-test.c       |  7 ++++++
 3 files changed, 54 insertions(+), 15 deletions(-)

-- 
1.8.3.1


Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Cornelia Huck, 14 weeks ago
On Fri, 11 Aug 2017 07:57:54 +0200
Thomas Huth <thuth@redhat.com> wrote:

> The first patch improves the buffer handling in the pxe tester a
> little bit by allocating a separate buffer on the heap for each
> architecture. This also gets rid of the huge pre-initialized
> array in the tester, shrinking the size of the executable by
> half of a megabyte!
> The second patch adds s390x support to the pxe tester. Starting
> with QEMU 2.10, the guest firmware on s390x can now net-boot via
> TFTP, too, so we can automatically test this code in the pxe tester.
> 
> v2: Adressed Cornelia's review feedback from the first version, e.g.:
>  - Use g_malloc0() instead of g_malloc()
>  - Use sizeof with parentheses
> 
> Thomas Huth (2):
>   tests/boot-sector: Do not overwrite the x86 buffer on other
>     architectures
>   tests/pxe: Check virtio-net-ccw on s390x
> 
>  tests/Makefile.include |  1 +
>  tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
>  tests/pxe-test.c       |  7 ++++++
>  3 files changed, 54 insertions(+), 15 deletions(-)
> 

Haven't reviewed the updates yet, but tried it out (on my laptop and on
a z/VM guest). Laptop went fine; on the z/VM guest, I forgot to turn on
vm.allocate_pgste at first:

TEST: tests/pxe-test... (pid=56084)
  /s390x/pxe/virtio-ccw:                                               ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
Host kernel setup problem detected. Please verify:
- for kernels supporting the switch_amode or user_mode parameters, whether
  user space is running in primary address space
- for kernels supporting the vm.allocate_pgste sysctl, whether it is enabled
qemu-system-s390x: failed to initialize KVM: Invalid argument
qemu-system-s390x: Back to tcg accelerator
OK
PASS: tests/pxe-test

It does the correct fallback (the need for allocate_pgste will go away
with future kernels), so this is fine. However, it prompted me to test
with --disable-tcg:

TEST: tests/boot-serial-test... (pid=60499)
  /s390x/boot-serial/s390-ccw-virtio:                                  qemu-system-s390x: -machine accel=tcg: No accelerator found
socket_accept failed: Resource temporarily unavailable
**
ERROR:/root/git/qemu/tests/libqtest.c:212:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
FAIL
GTester: last random seed: R02S83c8a1860bbd8c2658647407c7070b7e
(pid=60503)
FAIL: tests/boot-serial-test

There are probably more tests that rely on tcg always being available,
which is no longer true. (Also, the boot-serial test should probably
check if qemu even started rather than run into in a timeout.)

[Your patches are fine, but I think we really need to consider tests
and accelerators.]

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Cornelia Huck, 14 weeks ago
On Fri, 11 Aug 2017 11:49:22 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> On Fri, 11 Aug 2017 07:57:54 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > The first patch improves the buffer handling in the pxe tester a
> > little bit by allocating a separate buffer on the heap for each
> > architecture. This also gets rid of the huge pre-initialized
> > array in the tester, shrinking the size of the executable by
> > half of a megabyte!
> > The second patch adds s390x support to the pxe tester. Starting
> > with QEMU 2.10, the guest firmware on s390x can now net-boot via
> > TFTP, too, so we can automatically test this code in the pxe tester.
> > 
> > v2: Adressed Cornelia's review feedback from the first version, e.g.:
> >  - Use g_malloc0() instead of g_malloc()
> >  - Use sizeof with parentheses
> > 
> > Thomas Huth (2):
> >   tests/boot-sector: Do not overwrite the x86 buffer on other
> >     architectures
> >   tests/pxe: Check virtio-net-ccw on s390x
> > 
> >  tests/Makefile.include |  1 +
> >  tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
> >  tests/pxe-test.c       |  7 ++++++
> >  3 files changed, 54 insertions(+), 15 deletions(-)
> >   
> 
> Haven't reviewed the updates yet, but tried it out (on my laptop and on
> a z/VM guest). Laptop went fine; on the z/VM guest, I forgot to turn on
> vm.allocate_pgste at first:
> 
> TEST: tests/pxe-test... (pid=56084)
>   /s390x/pxe/virtio-ccw:                                               ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
> Host kernel setup problem detected. Please verify:
> - for kernels supporting the switch_amode or user_mode parameters, whether
>   user space is running in primary address space
> - for kernels supporting the vm.allocate_pgste sysctl, whether it is enabled
> qemu-system-s390x: failed to initialize KVM: Invalid argument
> qemu-system-s390x: Back to tcg accelerator
> OK
> PASS: tests/pxe-test
> 
> It does the correct fallback (the need for allocate_pgste will go away
> with future kernels), so this is fine. However, it prompted me to test
> with --disable-tcg:
> 
> TEST: tests/boot-serial-test... (pid=60499)
>   /s390x/boot-serial/s390-ccw-virtio:                                  qemu-system-s390x: -machine accel=tcg: No accelerator found
> socket_accept failed: Resource temporarily unavailable
> **
> ERROR:/root/git/qemu/tests/libqtest.c:212:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
> FAIL
> GTester: last random seed: R02S83c8a1860bbd8c2658647407c7070b7e
> (pid=60503)
> FAIL: tests/boot-serial-test
> 
> There are probably more tests that rely on tcg always being available,
> which is no longer true. (Also, the boot-serial test should probably
> check if qemu even started rather than run into in a timeout.)
> 
> [Your patches are fine, but I think we really need to consider tests
> and accelerators.]

A quick test on x86_64 with --disable-tcg showed no further problems
than boot-serial-test, so at least it's only the one for now (and it
might make sense to simply use accel=tcg:kvm for it).

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Thomas Huth, 14 weeks ago
On 11.08.2017 12:19, Cornelia Huck wrote:
> On Fri, 11 Aug 2017 11:49:22 +0200
> Cornelia Huck <cohuck@redhat.com> wrote:
> 
>> On Fri, 11 Aug 2017 07:57:54 +0200
>> Thomas Huth <thuth@redhat.com> wrote:
>>
>>> The first patch improves the buffer handling in the pxe tester a
>>> little bit by allocating a separate buffer on the heap for each
>>> architecture. This also gets rid of the huge pre-initialized
>>> array in the tester, shrinking the size of the executable by
>>> half of a megabyte!
>>> The second patch adds s390x support to the pxe tester. Starting
>>> with QEMU 2.10, the guest firmware on s390x can now net-boot via
>>> TFTP, too, so we can automatically test this code in the pxe tester.
>>>
>>> v2: Adressed Cornelia's review feedback from the first version, e.g.:
>>>  - Use g_malloc0() instead of g_malloc()
>>>  - Use sizeof with parentheses
>>>
>>> Thomas Huth (2):
>>>   tests/boot-sector: Do not overwrite the x86 buffer on other
>>>     architectures
>>>   tests/pxe: Check virtio-net-ccw on s390x
>>>
>>>  tests/Makefile.include |  1 +
>>>  tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
>>>  tests/pxe-test.c       |  7 ++++++
>>>  3 files changed, 54 insertions(+), 15 deletions(-)
>>>   
>>
>> Haven't reviewed the updates yet, but tried it out (on my laptop and on
>> a z/VM guest). Laptop went fine; on the z/VM guest, I forgot to turn on
>> vm.allocate_pgste at first:
>>
>> TEST: tests/pxe-test... (pid=56084)
>>   /s390x/pxe/virtio-ccw:                                               ioctl(KVM_CREATE_VM) failed: 22 Invalid argument
>> Host kernel setup problem detected. Please verify:
>> - for kernels supporting the switch_amode or user_mode parameters, whether
>>   user space is running in primary address space
>> - for kernels supporting the vm.allocate_pgste sysctl, whether it is enabled
>> qemu-system-s390x: failed to initialize KVM: Invalid argument
>> qemu-system-s390x: Back to tcg accelerator
>> OK
>> PASS: tests/pxe-test
>>
>> It does the correct fallback (the need for allocate_pgste will go away
>> with future kernels), so this is fine. However, it prompted me to test
>> with --disable-tcg:
>>
>> TEST: tests/boot-serial-test... (pid=60499)
>>   /s390x/boot-serial/s390-ccw-virtio:                                  qemu-system-s390x: -machine accel=tcg: No accelerator found
>> socket_accept failed: Resource temporarily unavailable
>> **
>> ERROR:/root/git/qemu/tests/libqtest.c:212:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
>> FAIL
>> GTester: last random seed: R02S83c8a1860bbd8c2658647407c7070b7e
>> (pid=60503)
>> FAIL: tests/boot-serial-test
>>
>> There are probably more tests that rely on tcg always being available,
>> which is no longer true. (Also, the boot-serial test should probably
>> check if qemu even started rather than run into in a timeout.)
>>
>> [Your patches are fine, but I think we really need to consider tests
>> and accelerators.]
> 
> A quick test on x86_64 with --disable-tcg showed no further problems
> than boot-serial-test, so at least it's only the one for now (and it
> might make sense to simply use accel=tcg:kvm for it).

$ grep -rl accel=tcg tests/
tests/pnv-xscom-test.c
tests/boot-serial-test.c
tests/prom-env-test.c

... so the other problematic tests are for ppc only - which does not
support --disable-tcg yet.

 Thomas

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Cornelia Huck, 14 weeks ago
On Fri, 11 Aug 2017 12:52:54 +0200
Thomas Huth <thuth@redhat.com> wrote:

> On 11.08.2017 12:19, Cornelia Huck wrote:

> > A quick test on x86_64 with --disable-tcg showed no further problems
> > than boot-serial-test, so at least it's only the one for now (and it
> > might make sense to simply use accel=tcg:kvm for it).  
> 
> $ grep -rl accel=tcg tests/
> tests/pnv-xscom-test.c
> tests/boot-serial-test.c
> tests/prom-env-test.c
> 
> ... so the other problematic tests are for ppc only - which does not
> support --disable-tcg yet.

I'll send a patch for boot serial, then. You probably know more about
whether the ppc tests would make sense with kvm as well than I do :)

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Michael S. Tsirkin, 13 weeks ago
On Fri, Aug 11, 2017 at 01:43:55PM +0200, Cornelia Huck wrote:
> On Fri, 11 Aug 2017 12:52:54 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > On 11.08.2017 12:19, Cornelia Huck wrote:
> 
> > > A quick test on x86_64 with --disable-tcg showed no further problems
> > > than boot-serial-test, so at least it's only the one for now (and it
> > > might make sense to simply use accel=tcg:kvm for it).  
> > 
> > $ grep -rl accel=tcg tests/
> > tests/pnv-xscom-test.c
> > tests/boot-serial-test.c
> > tests/prom-env-test.c
> > 
> > ... so the other problematic tests are for ppc only - which does not
> > support --disable-tcg yet.
> 
> I'll send a patch for boot serial, then. You probably know more about
> whether the ppc tests would make sense with kvm as well than I do :)

Weird I thought I fixed that one.  Tweaking that is trivial though.
Posted - could someone try on ppc pls? If it helps pls merge through the
ppc tree.

-- 
MST

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Cornelia Huck, 13 weeks ago
On Fri, 11 Aug 2017 07:57:54 +0200
Thomas Huth <thuth@redhat.com> wrote:

> The first patch improves the buffer handling in the pxe tester a
> little bit by allocating a separate buffer on the heap for each
> architecture. This also gets rid of the huge pre-initialized
> array in the tester, shrinking the size of the executable by
> half of a megabyte!
> The second patch adds s390x support to the pxe tester. Starting
> with QEMU 2.10, the guest firmware on s390x can now net-boot via
> TFTP, too, so we can automatically test this code in the pxe tester.
> 
> v2: Adressed Cornelia's review feedback from the first version, e.g.:
>  - Use g_malloc0() instead of g_malloc()
>  - Use sizeof with parentheses
> 
> Thomas Huth (2):
>   tests/boot-sector: Do not overwrite the x86 buffer on other
>     architectures
>   tests/pxe: Check virtio-net-ccw on s390x
> 
>  tests/Makefile.include |  1 +
>  tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
>  tests/pxe-test.c       |  7 ++++++
>  3 files changed, 54 insertions(+), 15 deletions(-)
> 

It's that question again: Who picks this up? :)

I can take it through the s390 tree if nobody else wants it.

Re: [Qemu-devel] [PATCH v2 for-2.11 0/2] Improvements for the pxe tester
Posted by Cornelia Huck, 13 weeks ago
On Tue, 15 Aug 2017 17:27:55 +0200
Cornelia Huck <cohuck@redhat.com> wrote:

> On Fri, 11 Aug 2017 07:57:54 +0200
> Thomas Huth <thuth@redhat.com> wrote:
> 
> > The first patch improves the buffer handling in the pxe tester a
> > little bit by allocating a separate buffer on the heap for each
> > architecture. This also gets rid of the huge pre-initialized
> > array in the tester, shrinking the size of the executable by
> > half of a megabyte!
> > The second patch adds s390x support to the pxe tester. Starting
> > with QEMU 2.10, the guest firmware on s390x can now net-boot via
> > TFTP, too, so we can automatically test this code in the pxe tester.
> > 
> > v2: Adressed Cornelia's review feedback from the first version, e.g.:
> >  - Use g_malloc0() instead of g_malloc()
> >  - Use sizeof with parentheses
> > 
> > Thomas Huth (2):
> >   tests/boot-sector: Do not overwrite the x86 buffer on other
> >     architectures
> >   tests/pxe: Check virtio-net-ccw on s390x
> > 
> >  tests/Makefile.include |  1 +
> >  tests/boot-sector.c    | 61 +++++++++++++++++++++++++++++++++++++-------------
> >  tests/pxe-test.c       |  7 ++++++
> >  3 files changed, 54 insertions(+), 15 deletions(-)
> >   
> 
> It's that question again: Who picks this up? :)
> 
> I can take it through the s390 tree if nobody else wants it.

OK, I just went ahead and queued it to my s390-next branch.

[Qemu-devel] [PATCH v2 for-2.11 1/2] tests/boot-sector: Do not overwrite the x86 buffer on other architectures
Posted by Thomas Huth, 14 weeks ago
Re-using the boot_sector code buffer from x86 for other architectures
is not very nice, especially if we add more architectures later. It's
also ugly that the test uses a huge pre-initialized array at all - the
size of the executable is very huge due to this array. So let's use a
separate buffer for each architecture instead, allocated from the heap,
so that we really just use the memory that we need.

Suggested-by: Michael Tsirkin <mst@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/boot-sector.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index e3880f4..8729562 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -21,13 +21,12 @@
 #define SIGNATURE 0xdead
 #define SIGNATURE_OFFSET 0x10
 #define BOOT_SECTOR_ADDRESS 0x7c00
+#define SIGNATURE_ADDR (BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET)
 
-/* Boot sector code: write SIGNATURE into memory,
+/* x86 boot sector code: write SIGNATURE into memory,
  * then halt.
- * Q35 machine requires a minimum 0x7e000 bytes disk.
- * (bug or feature?)
  */
-static uint8_t boot_sector[0x7e000] = {
+static uint8_t x86_boot_sector[512] = {
     /* The first sector will be placed at RAM address 00007C00, and
      * the BIOS transfers control to 00007C00
      */
@@ -50,8 +49,8 @@ static uint8_t boot_sector[0x7e000] = {
     [0x07] = HIGH(SIGNATURE),
     /* 7c08:  mov %ax,0x7c10 */
     [0x08] = 0xa3,
-    [0x09] = LOW(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
-    [0x0a] = HIGH(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET),
+    [0x09] = LOW(SIGNATURE_ADDR),
+    [0x0a] = HIGH(SIGNATURE_ADDR),
 
     /* 7c0b cli */
     [0x0b] = 0xfa,
@@ -72,7 +71,9 @@ static uint8_t boot_sector[0x7e000] = {
 int boot_sector_init(char *fname)
 {
     int fd, ret;
-    size_t len = sizeof boot_sector;
+    size_t len;
+    char *boot_code;
+    const char *arch = qtest_get_arch();
 
     fd = mkstemp(fname);
     if (fd < 0) {
@@ -80,16 +81,26 @@ int boot_sector_init(char *fname)
         return 1;
     }
 
-    /* For Open Firmware based system, we can use a Forth script instead */
-    if (strcmp(qtest_get_arch(), "ppc64") == 0) {
-        len = sprintf((char *)boot_sector, "\\ Bootscript\n%x %x c! %x %x c!\n",
-                LOW(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET,
-                HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+    if (g_str_equal(arch, "i386") || g_str_equal(arch, "x86_64")) {
+        /* Q35 requires a minimum 0x7e000 bytes disk (bug or feature?) */
+        len = MAX(0x7e000, sizeof(x86_boot_sector));
+        boot_code = g_malloc0(len);
+        memcpy(boot_code, x86_boot_sector, sizeof(x86_boot_sector));
+    } else if (g_str_equal(arch, "ppc64")) {
+        /* For Open Firmware based system, use a Forth script */
+        boot_code = g_strdup_printf("\\ Bootscript\n%x %x c! %x %x c!\n",
+                                    LOW(SIGNATURE), SIGNATURE_ADDR,
+                                    HIGH(SIGNATURE), SIGNATURE_ADDR + 1);
+        len = strlen(boot_code);
+    } else {
+        g_assert_not_reached();
     }
 
-    ret = write(fd, boot_sector, len);
+    ret = write(fd, boot_code, len);
     close(fd);
 
+    g_free(boot_code);
+
     if (ret != len) {
         fprintf(stderr, "Could not write \"%s\"", fname);
         return 1;
@@ -115,8 +126,8 @@ void boot_sector_test(void)
      * instruction.
      */
     for (i = 0; i < TEST_CYCLES; ++i) {
-        signature_low = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET);
-        signature_high = readb(BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
+        signature_low = readb(SIGNATURE_ADDR);
+        signature_high = readb(SIGNATURE_ADDR + 1);
         signature = (signature_high << 8) | signature_low;
         if (signature == SIGNATURE) {
             break;
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH v2 for-2.11 1/2] tests/boot-sector: Do not overwrite the x86 buffer on other architectures
Posted by Cornelia Huck, 13 weeks ago
On Fri, 11 Aug 2017 07:57:55 +0200
Thomas Huth <thuth@redhat.com> wrote:

> Re-using the boot_sector code buffer from x86 for other architectures
> is not very nice, especially if we add more architectures later. It's
> also ugly that the test uses a huge pre-initialized array at all - the
> size of the executable is very huge due to this array. So let's use a
> separate buffer for each architecture instead, allocated from the heap,
> so that we really just use the memory that we need.
> 
> Suggested-by: Michael Tsirkin <mst@redhat.com>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/boot-sector.c | 41 ++++++++++++++++++++++++++---------------
>  1 file changed, 26 insertions(+), 15 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>

[Qemu-devel] [PATCH v2 for-2.11 2/2] tests/pxe: Check virtio-net-ccw on s390x
Posted by Thomas Huth, 14 weeks ago
Now that we've got a firmware that can do TFTP booting on s390x (i.e.
the pc-bios/s390-netboot.img), we can enable the PXE tester for this
architecture, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/Makefile.include |  1 +
 tests/boot-sector.c    | 20 ++++++++++++++++++++
 tests/pxe-test.c       |  7 +++++++
 3 files changed, 28 insertions(+)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index eb4895f..2a238db 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -337,6 +337,7 @@ check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
 check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)
 
 check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
+check-qtest-s390x-$(CONFIG_SLIRP) += tests/pxe-test$(EXESUF)
 
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
diff --git a/tests/boot-sector.c b/tests/boot-sector.c
index 8729562..9ee8537 100644
--- a/tests/boot-sector.c
+++ b/tests/boot-sector.c
@@ -67,6 +67,21 @@ static uint8_t x86_boot_sector[512] = {
     [0x1FF] = 0xAA,
 };
 
+/* For s390x, use a mini "kernel" with the appropriate signature */
+static const uint8_t s390x_psw[] = {
+    0x00, 0x08, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00
+};
+static const uint8_t s390x_code[] = {
+    0xa7, 0xf4, 0x00, 0x0a,                                /* j 0x10010 */
+    0x00, 0x00, 0x00, 0x00,
+    'S', '3', '9', '0',
+    'E', 'P', 0x00, 0x01,
+    0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c10 */
+    0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE),           /* lhi r4,0xadde */
+    0x40, 0x40, 0x30, 0x00,                                /* sth r4,0(r3) */
+    0xa7, 0xf4, 0xff, 0xfa                                 /* j 0x10010 */
+};
+
 /* Create boot disk file.  */
 int boot_sector_init(char *fname)
 {
@@ -92,6 +107,11 @@ int boot_sector_init(char *fname)
                                     LOW(SIGNATURE), SIGNATURE_ADDR,
                                     HIGH(SIGNATURE), SIGNATURE_ADDR + 1);
         len = strlen(boot_code);
+    } else if (g_str_equal(arch, "s390x")) {
+        len = 0x10000 + sizeof(s390x_code);
+        boot_code = g_malloc0(len);
+        memcpy(boot_code, s390x_psw, sizeof(s390x_psw));
+        memcpy(&boot_code[0x10000], s390x_code, sizeof(s390x_code));
     } else {
         g_assert_not_reached();
     }
diff --git a/tests/pxe-test.c b/tests/pxe-test.c
index cf6e225..0d70afc 100644
--- a/tests/pxe-test.c
+++ b/tests/pxe-test.c
@@ -51,6 +51,11 @@ static void test_pxe_spapr_vlan(void)
     test_pxe_one("-device spapr-vlan,netdev=" NETNAME, true);
 }
 
+static void test_pxe_virtio_ccw(void)
+{
+    test_pxe_one("-device virtio-net-ccw,bootindex=1,netdev=" NETNAME, false);
+}
+
 int main(int argc, char *argv[])
 {
     int ret;
@@ -68,6 +73,8 @@ int main(int argc, char *argv[])
     } else if (strcmp(arch, "ppc64") == 0) {
         qtest_add_func("pxe/virtio", test_pxe_virtio_pci);
         qtest_add_func("pxe/spapr-vlan", test_pxe_spapr_vlan);
+    } else if (g_str_equal(arch, "s390x")) {
+        qtest_add_func("pxe/virtio-ccw", test_pxe_virtio_ccw);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH v2 for-2.11 2/2] tests/pxe: Check virtio-net-ccw on s390x
Posted by Cornelia Huck, 13 weeks ago
On Fri, 11 Aug 2017 07:57:56 +0200
Thomas Huth <thuth@redhat.com> wrote:

> Now that we've got a firmware that can do TFTP booting on s390x (i.e.
> the pc-bios/s390-netboot.img), we can enable the PXE tester for this
> architecture, too.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  tests/Makefile.include |  1 +
>  tests/boot-sector.c    | 20 ++++++++++++++++++++
>  tests/pxe-test.c       |  7 +++++++
>  3 files changed, 28 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>