Skip to contentSkip to conversation

v2 fix qemu segfault with nVidia proprietary driver

PATCH In review Zhai Edwin 4 participants 8 messages Mar 17, 2011 – Mar 18, 2011

lore
Share & tools
lore

Zhai Edwin

author
#0 lore raw

cover v2 fix qemu segfault with nVidia proprietary driver

From: Zhai Edwin <[email protected]>

Saul,
This is v2 version according to comments from Mark.

thanks,
edwin

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: gzhai/fix2
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=gzhai/fix2

Thanks,
Zhai Edwin <[email protected]>
---

Zhai Edwin (1):
qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
author
#1 lore raw

PATCH 1/1 qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +15 -1
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."
 fi
 
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede nvidia's."
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's instead
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
 
 cleanup
 
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

I reworked the patch slightly.. It's available on poky-contrib mhatle/qemu-workaround.

Specifically I changed:
- the warning message to make clarify it a bit.
- Changed the preload to be "libGL.so", so the rt-linker will now search for it (/usr/lib/libGL.so may be wrong on some systems where /usr/lib64 is the default library path)
- Added a second check to see if the workaround worked or not, if it didn't add a second warning message
- To the QEMU run line, add "stty sane" in the case of a failure. Otherwise QEMU leaves the terminal/console in a confused state.

Can you please verify that this still works on the Ubuntu systems and that I didn't miss anything/break anything else? If so I think this is the version we should go with.

--Mark

Quoted 45 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +15 -1
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."
 fi
 
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede nvidia's."
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's instead
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
 
 cleanup
 
#3 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

Quoted 6 lines

From: Mark Hatle
Sent: Thursday, March 17, 2011 11:03 PM

I reworked the patch slightly.. It's available on poky-contrib mhatle/qemu-workaround.

Quoted 6 lines

Specifically I changed:
- the warning message to make clarify it a bit.
- Changed the preload to be "libGL.so", so the rt-linker will now search for it (/usr/lib/libGL.so may be wrong on some systems where /usr/lib64 is the default
library path)

Just double confirm here. You are sure that just "libGL.so" will hit /usr/lib/libGL.so instead of the nvidia proprietary one, right? I'm interesting how nvidia proprietary driver is linked to qemu binary then? I can understand why Edwin originally use full path to make sure default one being used, but of course it may be wrong as you said on some system.

Quoted 8 lines

- Added a second check to see if the workaround worked or not, if it didn't add a second warning message
- To the QEMU run line, add "stty sane" in the case of a failure. Otherwise QEMU leaves the terminal/console in a confused state.

Can you please verify that this still works on the Ubuntu systems and that I didn't miss anything/break anything else? If so I think this is the version we should go with.

Edwin is out of office in the morning, and he will confirm them once he's back.

Thanks
Kevin

Quoted 62 lines

--Mark

Quoted 21 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +0 -0
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."

scripts/poky-qemu-internal else · line 446

Quoted 10 lines
scripts/poky-qemu-internal +8 -0
 fi
 
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede

nvidia's."

scripts/poky-qemu-internal else

Quoted 9 lines
scripts/poky-qemu-internal +6 -0
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's instead
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS

-no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'

scripts/poky-qemu-internal else · line 442

Quoted 1 line
scripts/poky-qemu-internal +0 -1
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot

$SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 456

Quoted 1 line
scripts/poky-qemu-internal +1 -0
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL

$QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 458

Quoted 3 lines
scripts/poky-qemu-internal +0 -0
 cleanup
 

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#4 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

Quoted 13 lines · Kevin
Quoted 6 lines

From: Mark Hatle
Sent: Thursday, March 17, 2011 11:03 PM

I reworked the patch slightly.. It's available on poky-contrib mhatle/qemu-workaround.

Quoted 6 lines

Specifically I changed:
- the warning message to make clarify it a bit.
- Changed the preload to be "libGL.so", so the rt-linker will now search for it (/usr/lib/libGL.so may be wrong on some systems where /usr/lib64 is the default
library path)

Quoted 5 lines

Just double confirm here. You are sure that just "libGL.so" will hit /usr/lib/libGL.so instead of the nvidia proprietary one, right? I'm interesting how nvidia proprietary driver is linked to qemu binary then? I can understand why Edwin originally use full path to make sure default one being used, but of course it may be wrong as you said on some system.

By specifying "libGL.so", it will cause the ld.so to resolve the path using the normal resolution. Usually the nVidia stuff is linked in via libGL.so.1 or similar. libGL.so is usually only used for development linking.

Quoted 10 lines
Quoted 8 lines

- Added a second check to see if the workaround worked or not, if it didn't add a second warning message
- To the QEMU run line, add "stty sane" in the case of a failure. Otherwise QEMU leaves the terminal/console in a confused state.

Can you please verify that this still works on the Ubuntu systems and that I didn't miss anything/break anything else? If so I think this is the version we should go with.

Edwin is out of office in the morning, and he will confirm them once he's back.

ok.

--Mark

Quoted 65 lines

Thanks
Kevin

Quoted 62 lines

--Mark

Quoted 21 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +0 -0
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."

scripts/poky-qemu-internal else · line 446

Quoted 10 lines
scripts/poky-qemu-internal +8 -0
 fi
 
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede

nvidia's."

scripts/poky-qemu-internal else

Quoted 9 lines
scripts/poky-qemu-internal +6 -0
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's instead
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS

-no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'

scripts/poky-qemu-internal else · line 442

Quoted 1 line
scripts/poky-qemu-internal +0 -1
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot

$SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 456

Quoted 1 line
scripts/poky-qemu-internal +1 -0
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL

$QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 458

Quoted 3 lines
scripts/poky-qemu-internal +0 -0
 cleanup
 

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#5 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

Quoted 22 lines

From: Mark Hatle [mailto:[email protected]]
Sent: Friday, March 18, 2011 10:43 AM

Quoted 6 lines · Kevin
Quoted 6 lines

From: Mark Hatle
Sent: Thursday, March 17, 2011 11:03 PM

I reworked the patch slightly.. It's available on poky-contrib mhatle/qemu-workaround.

Quoted 8 lines
Quoted 6 lines

Specifically I changed:
- the warning message to make clarify it a bit.
- Changed the preload to be "libGL.so", so the rt-linker will now search for it (/usr/lib/libGL.so may be wrong on some systems where /usr/lib64 is the default
library path)

Just double confirm here. You are sure that just "libGL.so" will hit

/usr/lib/libGL.so

Quoted 3 lines

instead of the nvidia proprietary one, right? I'm interesting how nvidia proprietary driver is linked to qemu binary then? I can understand why Edwin originally use full path to make sure default one being used, but of course it

Quoted 6 lines

may

Quoted 1 line

be wrong as you said on some system.

By specifying "libGL.so", it will cause the ld.so to resolve the path using the normal resolution. Usually the nVidia stuff is linked in via libGL.so.1 or similar. libGL.so is usually only used for development linking.

nice to know that and thanks for explanation. Edwin is verifying it now, and we'll see how it works. :-)

Thanks
Kevin

Quoted 85 lines
Quoted 2 lines
Quoted 2 lines

- Added a second check to see if the workaround worked or not, if it didn't

add

Quoted 6 lines
Quoted 6 lines

a second warning message
- To the QEMU run line, add "stty sane" in the case of a failure. Otherwise QEMU leaves the terminal/console in a confused state.

Can you please verify that this still works on the Ubuntu systems and that I didn't miss anything/break anything else? If so I think this is the version

we

Quoted 3 lines
Quoted 1 line

should go with.

Edwin is out of office in the morning, and he will confirm them once he's back.

ok.

--Mark

Quoted 41 lines

Thanks
Kevin

Quoted 38 lines

--Mark

Quoted 21 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +0 -0
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."

scripts/poky-qemu-internal else · line 446

Quoted 10 lines
scripts/poky-qemu-internal +8 -0
 fi
 
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede

nvidia's."

Quoted 2 lines
scripts/poky-qemu-internal +2 -0
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's

instead

Quoted 11 lines
Quoted 11 lines

scripts/poky-qemu-internal else

Quoted 7 lines
scripts/poky-qemu-internal +4 -0
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS

-no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'

scripts/poky-qemu-internal else · line 442

Quoted 1 line
scripts/poky-qemu-internal +0 -1
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot

$SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append

"$KERNCMDLINE

Quoted 13 lines
Quoted 13 lines

$SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 456

Quoted 1 line
scripts/poky-qemu-internal +1 -0
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL

$QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 458

Quoted 3 lines
scripts/poky-qemu-internal +0 -0
 cleanup
 

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#6 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

In reply to Mark Hatle

Mark,
It doesn't work on my ubuntu 10 system:(

gzhai@yocto-build3:/distro/edwin-working/poky/build-arm-bernard$ ldd /distro/edwin-working/poky/build-arm-bernard/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-arm|grep -i nvidia
18:     libGL.so.1 => /usr/lib/nvidia-current/libGL.so.1 (0x00007f1c5f4ac000)
   26: libnvidia-tls.so.260.19.06 => 
/usr/lib/nvidia-current/tls/libnvidia-tls.so.260.19.06 (0x00007f1c5e462000)
   27: libnvidia-glcore.so.260.19.06 => 
/usr/lib/nvidia-current/libnvidia-glcore.so.260.19.06 (0x00007f1c5c889000)
gzhai@yocto-build3:/distro/edwin-working/poky/build-arm-bernard$ ll /usr/lib/libGL* lrwxrwxrwx 1 root root     13 2011-02-28 20:26 /usr/lib/libGL.so -> mesa/libGL.so
-rw-r--r-- 1 root root 931734 2010-10-01 01:21 /usr/lib/libGLU.a
lrwxrwxrwx 1 root root     11 2011-02-28 20:26 /usr/lib/libGLU.so -> libGLU.so.1
lrwxrwxrwx 1 root root     20 2011-02-28 13:45 /usr/lib/libGLU.so.1 -> libGLU.so.1.3.070900
-rw-r--r-- 1 root root 465520 2010-10-01 01:21 /usr/lib/libGLU.so.1.3.070900
Quoted 121 lines · Mark Hatle
Quoted 9 lines · Kevin
Quoted 9 lines

From: Mark Hatle
Sent: Thursday, March 17, 2011 11:03 PM

I reworked the patch slightly.. It's available on poky-contrib mhatle/qemu-workaround.

Specifically I changed:
- the warning message to make clarify it a bit.
- Changed the preload to be "libGL.so", so the rt-linker will now

search for it

Quoted 1 line
Quoted 1 line

(/usr/lib/libGL.so may be wrong on some systems where /usr/lib64 is

the

Quoted 4 lines
Quoted 2 lines

default
library path)

Just double confirm here. You are sure that just "libGL.so" will hit

/usr/lib/libGL.so

Quoted 1 line

instead of the nvidia proprietary one, right? I'm interesting how

nvidia

Quoted 1 line

proprietary driver is linked to qemu binary then? I can understand

why Edwin

Quoted 1 line

originally use full path to make sure default one being used, but of

course it may

Quoted 1 line

be wrong as you said on some system.

By specifying "libGL.so", it will cause the ld.so to resolve the path using the normal resolution. Usually the nVidia stuff is linked in via libGL.so.1 or similar. libGL.so is usually only used for development linking.

Quoted 1 line
Quoted 1 line

- Added a second check to see if the workaround worked or not, if

it didn't add

Quoted 2 lines
Quoted 2 lines

a second warning message
- To the QEMU run line, add "stty sane" in the case of a failure.

Otherwise

Quoted 3 lines
Quoted 3 lines

QEMU leaves the terminal/console in a confused state.

Can you please verify that this still works on the Ubuntu systems

and that I

Quoted 1 line
Quoted 1 line

didn't miss anything/break anything else? If so I think this is

the version we

Quoted 3 lines
Quoted 1 line

should go with.

Edwin is out of office in the morning, and he will confirm them once

he's back.

ok.

--Mark

Quoted 10 lines

Thanks
Kevin

Quoted 7 lines

--Mark

Quoted 3 lines · Zhai Edwin

From: Zhai Edwin <[email protected]>

Proprietary nVidia driver introduce its own libGL that precede

mesa's.

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

---
 scripts/poky-qemu-internal |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +0 -0
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
     echo "Warning: distccd not present, no distcc support loaded."
 fi
 
Quoted 7 lines
Quoted 7 lines

scripts/poky-qemu-internal else

Quoted 7 lines
scripts/poky-qemu-internal +7 -0
+# qemu got segfault if linked with nVidia's libgl
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia &> /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu 

segfault!

Quoted 1 line
Quoted 1 line

scripts/poky-qemu-internal else · line 446

Quoted 1 line
scripts/poky-qemu-internal +1 -0
+    Pls. uninstall proprietary nVidia driver or make mesa libgl 

precede

Quoted 3 lines
Quoted 3 lines

nvidia's."

Quoted 2 lines
scripts/poky-qemu-internal +2 -0
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use 

mesa's instead

Quoted 24 lines
Quoted 24 lines

scripts/poky-qemu-internal else

Quoted 7 lines
scripts/poky-qemu-internal +4 -0
+    echo "Skip nVidia's libGL!"
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
 echo "Running $QEMU..."
 # -no-reboot is a mandatory option - see bug #100
 echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS

-no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'

scripts/poky-qemu-internal else · line 442

Quoted 1 line
scripts/poky-qemu-internal +0 -1
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot

$SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 456

Quoted 1 line
scripts/poky-qemu-internal +1 -0
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL

$QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true

scripts/poky-qemu-internal else · line 458

Quoted 3 lines
scripts/poky-qemu-internal +0 -0
 cleanup
 

_______________________________________________
poky mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/poky

#7 lore raw

Re: [PATCH 1/1] qemu: Use mesa's libGL rather than nVidia's to avoid segfault of qemu

In reply to Zhai Edwin
Quoted 9 lines · Zhai Edwin

From: Zhai Edwin<[email protected]>

Proprietary nVidia driver introduce its own libGL that precede mesa's. qemu has segfault if linked with it. This fix try to use mesa's libGL if ldd find qemu linked with nVidia libGL.

[YOCTO #649]
[YOCTO #698]

Looks like the right approach, my only concern is the wording of the error messages. They are ambiguous with respect to what the script WILL DO and what it is telling the user THEY SHOULD DO. Also, avoiding the "you did this, bad user" sort of language wold be good.

Consider the following:

Quoted 15 lines
---
  scripts/poky-qemu-internal |   16 +++++++++++++++-
  1 files changed, 15 insertions(+), 1 deletions(-)
scripts/poky-qemu-internal +1 -0
index 3638a65..1f09fe7 100755
@@ -436,10 +436,24 @@ else
      echo "Warning: distccd not present, no distcc support loaded."
  fi
 
+# qemu got segfault if linked with nVidia's libgl

scripts/poky-qemu-internal else · line 449

Quoted 10 lines
scripts/poky-qemu-internal +10 -0
+GL_LD_PRELOAD=$LD_PRELOAD
+
+if ldd $QEMUBIN | grep -i nvidia&>  /dev/null
+then
+    echo "************** !!!Warning!!! **************
+    You installed nVidia's libGL.so that probably lead qemu segfault!
+    Pls. uninstall proprietary nVidia driver or make mesa libgl precede nvidia's."
+
+    # To avoid segfault of qemu, skip nVidia's libGL and use mesa's instead
+    echo "Skip nVidia's libGL!"

No need for two separate messages here, consider:

cat <<EOM
************** !!! Warning !!! **************
nVidia's proprietary OpenGL libraries are known to have compatibility issues with qemu, resulting in a segfault. Please uninstall these drivers or ensure the mesa libGL libraries precede nvidia's.

Attempting to use mesa's libGL.so via GL_LD_PRELOAD." EOM

--
Darren

Quoted 11 lines
scripts/poky-qemu-internal +4 -1
+    GL_LD_PRELOAD="/usr/lib/libGL.so $LD_PRELOAD"
+fi
+
  echo "Running $QEMU..."
  # -no-reboot is a mandatory option - see bug #100
  echo $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append '"'$KERNCMDLINE $SCRIPT_KERNEL_OPT'"'
-$QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
+LD_PRELOAD="$GL_LD_PRELOAD" $QEMUBIN -kernel $KERNEL $QEMUOPTIONS $SERIALOPTS -no-reboot $SCRIPT_QEMU_OPT $SCRIPT_QEMU_EXTRA_OPT --append "$KERNCMDLINE $SCRIPT_KERNEL_OPT" || /bin/true
 
  cleanup
 
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel