Skip to contentSkip to conversation

Fix binary build of qemu-system-s390x on alpine

PATCH In review Christian Borntraeger 4 participants 7 messages Jan 30, 2018 – Jan 31, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover Fix binary build of qemu-system-s390x on alpine

Peter, Paolo,

sending this to you as you have the most commits on configure. If you are ok with it, we can also carry that via the s390 tree.

Alice Frosi (1):
Fix configure for s390 qemu on alpine and other busybox environments

 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.13.4
#1 lore raw

PATCH v2 1/1 Fix configure for s390 qemu on alpine and other busybox environments

From: Alice Frosi <[email protected]>

In alpine docker image the qemu-system-s390x build is broken and it throws this error:
qemu-system-s390x: Initialization of device s390-ipl failed: could not load bootloader 's390-ccw.img'

The grep command of busybox uses regex. This fails on binary data (e.g. stops on every \0), so it does not identify the string BiGeNdIaN in the test case big/little. Therefore, it assumes that the architecture is little endian.

This fix solves the grep problem by printing the content of TMPO with strings

[some changes to patch description, add -a option to strings]

---
v1->v2:
- Fix email address of Alice
- Fix patch prefix

 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure +2 -2
index 6d8c996c62..383b14e991 100755
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
         bigendian="no"
     else
         echo big/little test failed
Signature · 1 line
2.13.4
Reviewed-by on v2 1/1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] Fix configure for s390 qemu on alpine and other busybox environments

Quoted 15 lines · Christian Borntraeger

From: Alice Frosi <[email protected]>

In alpine docker image the qemu-system-s390x build is broken and it throws this error:
qemu-system-s390x: Initialization of device s390-ipl failed: could not load bootloader 's390-ccw.img'

The grep command of busybox uses regex. This fails on binary data (e.g. stops on every \0), so it does not identify the string BiGeNdIaN in the test case big/little. Therefore, it assumes that the architecture is little endian.

This fix solves the grep problem by printing the content of TMPO with strings

Quoted 7 lines
[some changes to patch description, add -a option to strings]

---
v1->v2:
- Fix email address of Alice
- Fix patch prefix

Oh, that reminds me I still have an old patch to qobject_from_jsonf that probed $TMPO using strings [1]. It does look like 'strings -a' is portable, so I'll have to update my patch when I dig it back out of storage.

[1] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg07963.html

configure int main(int argc, char *argv[]) { · line 1911

Quoted 10 lines

+++ b/configure

configure +2 -2
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then

Yes, this is indeed a more portable way to grep binary files (it's also possible to do:

tr -d '\0' < $TMPO | grep -q ...

if we're worried about the availability of strings, but I don't see that being a problem if no one reports it actually failing).

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

Re: [Qemu-devel] [PATCH v2 1/1] Fix configure for s390 qemu on alpine and other busybox environments

Quoted 44 lines · Eric Blake
Quoted 15 lines · Christian Borntraeger

From: Alice Frosi <[email protected]>

In alpine docker image the qemu-system-s390x build is broken and it throws this error:
qemu-system-s390x: Initialization of device s390-ipl failed: could not load bootloader 's390-ccw.img'

The grep command of busybox uses regex. This fails on binary data (e.g. stops on every \0), so it does not identify the string BiGeNdIaN in the test case big/little. Therefore, it assumes that the architecture is little endian.

This fix solves the grep problem by printing the content of TMPO with strings

Quoted 7 lines
[some changes to patch description, add -a option to strings]

---
v1->v2:
- Fix email address of Alice
- Fix patch prefix

Oh, that reminds me I still have an old patch to qobject_from_jsonf that probed $TMPO using strings [1]. It does look like 'strings -a' is portable, so I'll have to update my patch when I dig it back out of storage.

[1] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg07963.html

configure int main(int argc, char *argv[]) { · line 1911

Quoted 10 lines

+++ b/configure

configure +2 -2
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then

Yes, this is indeed a more portable way to grep binary files (it's also possible to do:

Quoted 6 lines

tr -d '\0' < $TMPO | grep -q ...

if we're worried about the availability of strings, but I don't see that being a problem if no one reports it actually failing).

Peter, does that patch work on MacOS and Windows? If yes we could get this patch in via the s390 tree.

#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] Fix configure for s390 qemu on alpine and other busybox environments

Quoted 18 lines · Christian Borntraeger
Quoted 17 lines · Eric Blake

configure int main(int argc, char *argv[]) { · line 1911

Quoted 10 lines · Christian Borntraeger

+++ b/configure

configure +2 -2
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then

Yes, this is indeed a more portable way to grep binary files (it's also possible to do:

tr -d '\0' < $TMPO | grep -q ...

Quoted 7 lines
Quoted 4 lines

if we're worried about the availability of strings, but I don't see that being a problem if no one reports it actually failing).

Peter, does that patch work on MacOS and Windows? If yes we could get this patch in via the s390 tree.

I haven't tested but I think it should be fine. OSX provides a strings binary that supports -a, and Windows cross-builds so it will use the Linux strings.

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] Fix configure for s390 qemu on alpine and other busybox environments

Quoted 28 lines · Peter Maydell
Quoted 18 lines · Christian Borntraeger
Quoted 17 lines · Eric Blake

configure int main(int argc, char *argv[]) { · line 1911

Quoted 10 lines · Christian Borntraeger

+++ b/configure

configure +2 -2
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then

Yes, this is indeed a more portable way to grep binary files (it's also possible to do:

tr -d '\0' < $TMPO | grep -q ...

Quoted 7 lines
Quoted 4 lines

if we're worried about the availability of strings, but I don't see that being a problem if no one reports it actually failing).

Peter, does that patch work on MacOS and Windows? If yes we could get this patch in via the s390 tree.

Quoted 7 lines

I haven't tested but I think it should be fine. OSX provides a strings binary that supports -a, and Windows cross-builds so it will use the Linux strings.

thanks
-- PMM

Conny, can you take this patch via s390-next?

#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/1] Fix configure for s390 qemu on alpine and other busybox environments

Quoted 33 lines · On Wed, 31 Jan 2018 14:40:00 +0100 Christian Borntraeger…
Quoted 32 lines · Peter Maydell
Quoted 18 lines · Christian Borntraeger
Quoted 17 lines · Eric Blake

configure int main(int argc, char *argv[]) { · line 1911

Quoted 10 lines · Christian Borntraeger

+++ b/configure

configure +2 -2
@@ -1906,9 +1906,9 @@ int main(int argc, char *argv[]) {
 EOF
 
 if compile_object ; then
-    if grep -q BiGeNdIaN $TMPO ; then
+    if strings -a $TMPO | grep -q BiGeNdIaN ; then
         bigendian="yes"
-    elif grep -q LiTtLeEnDiAn $TMPO ; then
+    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then  

Yes, this is indeed a more portable way to grep binary files (it's also possible to do:

tr -d '\0' < $TMPO | grep -q ...

Quoted 7 lines
Quoted 4 lines

if we're worried about the availability of strings, but I don't see that being a problem if no one reports it actually failing).

Peter, does that patch work on MacOS and Windows? If yes we could get this patch in via the s390 tree.

I haven't tested but I think it should be fine. OSX provides a strings binary that supports -a, and Windows cross-builds so it will use the Linux strings.

Quoted 6 lines
Quoted 3 lines

thanks
-- PMM

Conny, can you take this patch via s390-next?

Sure, we'll notice anyway if something goes wrong after all.

Thanks, queued to s390-next.