Skip to contentSkip to conversation

tests/migration: Add source to PC boot block

PATCH Superseded Dr. David Alan Gilbert (git) 2 participants 3 messages Feb 12, 2018 – Feb 13, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 tests/migration: Add source to PC boot block

From: "Dr. David Alan Gilbert" <[email protected]>

The boot block used in the migration test is currently only shipped as a hex (with the source in the git commit message), change this to actually include the source.

A script is added to rebuild the header but the expectation is that the generated hex is shipped as well as the .s, so that there's no requirement to have just the right assembler etc.

---
 tests/migration-test.c                   | 48 +----------------
 tests/migration/rebuild-x86-bootblock.sh | 35 ++++++++++++
 tests/migration/x86-a-b-bootblock.h      | 51 ++++++++++++++++++
 tests/migration/x86-a-b-bootblock.s      | 92 ++++++++++++++++++++++++++++++++
 4 files changed, 180 insertions(+), 46 deletions(-)
 create mode 100755 tests/migration/rebuild-x86-bootblock.sh
 create mode 100644 tests/migration/x86-a-b-bootblock.h
 create mode 100644 tests/migration/x86-a-b-bootblock.s
tests/migration-test.c +2 -46
index c1ebbdf08f..8da0974b80 100644
@@ -80,57 +80,13 @@ static const char *tmpfs;
 /* A simple PC boot sector that modifies memory (1-100MB) quickly
  * outputing a 'B' every so often if it's still running.
  */
-unsigned char bootsect[] = {
-  0xfa, 0x0f, 0x01, 0x16, 0x74, 0x7c, 0x66, 0xb8, 0x01, 0x00, 0x00, 0x00,
-  0x0f, 0x22, 0xc0, 0x66, 0xea, 0x20, 0x7c, 0x00, 0x00, 0x08, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x92, 0x0c, 0x02,
-  0xe6, 0x92, 0xb8, 0x10, 0x00, 0x00, 0x00, 0x8e, 0xd8, 0x66, 0xb8, 0x41,
-  0x00, 0x66, 0xba, 0xf8, 0x03, 0xee, 0xb3, 0x00, 0xb8, 0x00, 0x00, 0x10,
-  0x00, 0xfe, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x40,
-  0x06, 0x7c, 0xf2, 0xfe, 0xc3, 0x75, 0xe9, 0x66, 0xb8, 0x42, 0x00, 0x66,
-  0xba, 0xf8, 0x03, 0xee, 0xeb, 0xde, 0x66, 0x90, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x9a, 0xcf, 0x00,
-  0xff, 0xff, 0x00, 0x00, 0x00, 0x92, 0xcf, 0x00, 0x27, 0x00, 0x5c, 0x7c,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
-};
+#include "tests/migration/x86-a-b-bootblock.h"
 
 static void init_bootfile_x86(const char *bootpath)
 {
     FILE *bootfile = fopen(bootpath, "wb");
 
-    g_assert_cmpint(fwrite(bootsect, 512, 1, bootfile), ==, 1);
+    g_assert_cmpint(fwrite(x86_bootsect, 512, 1, bootfile), ==, 1);
     fclose(bootfile);
 }
 
tests/migration/rebuild-x86-bootblock.sh new file +35 -0
new file mode 100755
index 0000000000..ee9b53ceb4
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# Author: [email protected]
+
+ASMFILE=$PWD/tests/migration/x86-a-b-bootblock.s
+HEADER=$PWD/tests/migration/x86-a-b-bootblock.h
+
+if [ ! -e "$ASMFILE" ]
+then
+  echo "Couldn't find $ASMFILE" >&2
+  exit 1
+fi
+
+ASM_WORK_DIR=$(mktemp -d --tmpdir X86BB.XXXXX)
+cd $ASM_WORK_DIR &&
+as --32 -march=i486 "$ASMFILE" -o x86.o &&
+objcopy -O binary x86.o x86.boot &&
+dd if=x86.boot of=x86.bootsect \
+  bs=256 count=2 skip=124 &&
+xxd -i x86.bootsect |
+sed -e 's/.*int.*//' > x86.hex &&
+cat - x86.hex <<HERE > "$HEADER"
+/* This file is automatically generated from
+ * tests/migration/x86-a-b-bootblock.s, edit that and then run
+ * tests/migration/rebuild-x86-bootblock.sh to update,
+ * and then remember to send both in your patch submission.
+ */
+HERE
+
+rm x86.hex x86.bootsect x86.boot x86.o
+cd .. && rmdir $ASM_WORK_DIR
+
tests/migration/x86-a-b-bootblock.h new file +51 -0

51 lines not on this page · raw message

tests/migration/x86-a-b-bootblock.s new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

The boot block used in the migration test is currently only shipped as a hex (with the source in the git commit message),

Would be nice to point to commit ea0c6d62 (I assume that's the commit message you're referring to).

Quoted 1 line

change this to actually include the source.

Yeah, GPL really wants us to ship the preferred editing form of sources ;)

tests/migration-test.c static const char *tmpfs; · line 81

Quoted 12 lines

A script is added to rebuild the header but the expectation is that the generated hex is shipped as well as the .s, so that there's no requirement to have just the right assembler etc.

---

+++ b/tests/migration-test.c

tests/migration-test.c +0 -0
@@ -80,57 +80,13 @@ static const char *tmpfs;
  /* A simple PC boot sector that modifies memory (1-100MB) quickly
   * outputing a 'B' every so often if it's still running.

Pre-existing, but while here,
s/outputing/outputting/

Quoted 13 lines
tests/migration/rebuild-x86-bootblock.sh new file +7 -0
new file mode 100755
index 0000000000..ee9b53ceb4
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# Author: [email protected]
+

tests/migration/rebuild-x86-bootblock.sh line 17

Quoted 10 lines
tests/migration/rebuild-x86-bootblock.sh new file +10 -0
+ASMFILE=$PWD/tests/migration/x86-a-b-bootblock.s
+HEADER=$PWD/tests/migration/x86-a-b-bootblock.h
+
+if [ ! -e "$ASMFILE" ]
+then
+  echo "Couldn't find $ASMFILE" >&2
+  exit 1
+fi
+
+ASM_WORK_DIR=$(mktemp -d --tmpdir X86BB.XXXXX)

Portable use of mktemp requires at least 6 X, not 5.

tests/migration/rebuild-x86-bootblock.sh line 18

Quoted 1 line
tests/migration/rebuild-x86-bootblock.sh new file +1 -0
+cd $ASM_WORK_DIR &&

Unsafe if $PWD contains spaces; needs to be quoted.

Quoted 6 lines
tests/migration/rebuild-x86-bootblock.sh new file +6 -0
+as --32 -march=i486 "$ASMFILE" -o x86.o &&
+objcopy -O binary x86.o x86.boot &&
+dd if=x86.boot of=x86.bootsect \
+  bs=256 count=2 skip=124 &&
+xxd -i x86.bootsect |
+sed -e 's/.*int.*//' > x86.hex &&

tests/migration/rebuild-x86-bootblock.sh line 34

Quoted 10 lines
tests/migration/rebuild-x86-bootblock.sh new file +10 -0
+cat - x86.hex <<HERE > "$HEADER"
+/* This file is automatically generated from
+ * tests/migration/x86-a-b-bootblock.s, edit that and then run
+ * tests/migration/rebuild-x86-bootblock.sh to update,
+ * and then remember to send both in your patch submission.
+ */
+HERE
+
+rm x86.hex x86.bootsect x86.boot x86.o
+cd .. && rmdir $ASM_WORK_DIR

Another place that needs quoting.

tests/migration/rebuild-x86-bootblock.sh line 10

Quoted 12 lines
tests/migration/rebuild-x86-bootblock.sh new file +11 -0
+++ b/tests/migration/x86-a-b-bootblock.s
@@ -0,0 +1,92 @@
+# x86 bootblock used in migration test
+#  repeatedly increments the first byte of each page in a 100MB
+#  range.
+#  Outputs an initial 'A' on serial followed by repeated 'B's
+#
+# run   tests/migration/rebuild-x86-bootblock.sh
+#   to regenerate the hex, and remember to include both the .h and .s
+#   in any patches.
+#
+# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates

Do you want to add 2018, since you've now modified things since the original commit?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 8 lines · * Eric Blake ([email protected]) wrote:
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

The boot block used in the migration test is currently only shipped as a hex (with the source in the git commit message),

Would be nice to point to commit ea0c6d62 (I assume that's the commit message you're referring to).

Done.

Quoted 12 lines
Quoted 1 line

change this to actually include the source.

Yeah, GPL really wants us to ship the preferred editing form of sources ;)

Quoted 7 lines

A script is added to rebuild the header but the expectation is that the generated hex is shipped as well as the .s, so that there's no requirement to have just the right assembler etc.

---

Quoted 7 lines

tests/migration-test.c static const char *tmpfs; · line 81

Quoted 4 lines

+++ b/tests/migration-test.c

tests/migration-test.c +0 -0
@@ -80,57 +80,13 @@ static const char *tmpfs;
  /* A simple PC boot sector that modifies memory (1-100MB) quickly
   * outputing a 'B' every so often if it's still running.

Pre-existing, but while here,
s/outputing/outputting/

Extra 't'

Quoted 16 lines
Quoted 16 lines
tests/migration/rebuild-x86-bootblock.sh new file +10 -0
new file mode 100755
index 0000000000..ee9b53ceb4
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+#
+# Author: [email protected]
+
+ASMFILE=$PWD/tests/migration/x86-a-b-bootblock.s
+HEADER=$PWD/tests/migration/x86-a-b-bootblock.h
+
Quoted 8 lines

tests/migration/rebuild-x86-bootblock.sh line 17

Quoted 7 lines
tests/migration/rebuild-x86-bootblock.sh new file +7 -0
+if [ ! -e "$ASMFILE" ]
+then
+  echo "Couldn't find $ASMFILE" >&2
+  exit 1
+fi
+
+ASM_WORK_DIR=$(mktemp -d --tmpdir X86BB.XXXXX)

Portable use of mktemp requires at least 6 X, not 5.

Extra 'X'

Quoted 3 lines

tests/migration/rebuild-x86-bootblock.sh line 18

Quoted 1 line
tests/migration/rebuild-x86-bootblock.sh new file +1 -0
+cd $ASM_WORK_DIR &&

Unsafe if $PWD contains spaces; needs to be quoted.

Done.

Quoted 10 lines
Quoted 10 lines
tests/migration/rebuild-x86-bootblock.sh new file +10 -0
+as --32 -march=i486 "$ASMFILE" -o x86.o &&
+objcopy -O binary x86.o x86.boot &&
+dd if=x86.boot of=x86.bootsect \
+  bs=256 count=2 skip=124 &&
+xxd -i x86.bootsect |
+sed -e 's/.*int.*//' > x86.hex &&
+cat - x86.hex <<HERE > "$HEADER"
+/* This file is automatically generated from
+ * tests/migration/x86-a-b-bootblock.s, edit that and then run
+ * tests/migration/rebuild-x86-bootblock.sh to update,
Quoted 8 lines

tests/migration/rebuild-x86-bootblock.sh line 34

Quoted 6 lines
tests/migration/rebuild-x86-bootblock.sh new file +6 -0
+ * and then remember to send both in your patch submission.
+ */
+HERE
+
+rm x86.hex x86.bootsect x86.boot x86.o
+cd .. && rmdir $ASM_WORK_DIR

Another place that needs quoting.

Done.

Quoted 7 lines
Quoted 7 lines
tests/migration/rebuild-x86-bootblock.sh new file +6 -0
+++ b/tests/migration/x86-a-b-bootblock.s
@@ -0,0 +1,92 @@
+# x86 bootblock used in migration test
+#  repeatedly increments the first byte of each page in a 100MB
+#  range.
+#  Outputs an initial 'A' on serial followed by repeated 'B's
+#
Quoted 8 lines

tests/migration/rebuild-x86-bootblock.sh line 10

Quoted 5 lines
tests/migration/rebuild-x86-bootblock.sh new file +5 -0
+# run   tests/migration/rebuild-x86-bootblock.sh
+#   to regenerate the hex, and remember to include both the .h and .s
+#   in any patches.
+#
+# Copyright (c) 2016 Red Hat, Inc. and/or its affiliates

Do you want to add 2018, since you've now modified things since the original commit?

Done.

Dave

Quoted 4 lines
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK