Bug 11526

Summary: ROOTLESS_X prevents X from running in Qemu
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa>
Component: graphicsAssignee: Kevin Hao <kexin.hao>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: jku, joshuagloe, meta.mr.watcher, meta.watcher, randy.macleod, ross.burton
Version: 2.3   
Target Milestone: 3.1 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Raphael Kubo da Costa (rakuco) 2017-05-18 14:11:34 UTC
I was talking to Jussi earlier today about changing the default user in core-image-sato and he mentioned xserver-nodm-init and the ROOTLESS_X option.

I've added ROOTLESS_X = "1" to my local.conf, bitbake'd core-image-sato and ran the qemux86 image with runqemu.

The image boots fine, but X fails to start. After a few seconds, I can see the following messages on the terminal:

  xinit: giving up
  xinit: unable to connect to X server: Connection refused
  xinit: server error
Comment 1 Joshua Lock 2017-05-18 14:50:33 UTC
Sounds like we need a test for rootless X
Comment 2 Ross Burton 2017-05-18 16:14:19 UTC
Jussi, can you take this?
Comment 3 Jussi Kukkonen 2017-05-18 17:47:29 UTC
(In reply to comment #2)
> Jussi, can you take this?

Yup.

Joshua, you changed milestone and importance -- mistakes?
Comment 4 Joshua Lock 2017-05-18 17:48:33 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > Jussi, can you take this?
> 
> Yup.
> 
> Joshua, you changed milestone and importance -- mistakes?

Yes, sorry. I manage to do this quite often…
Comment 5 Jussi Kukkonen 2017-05-26 07:11:35 UTC
some notes in case I don't find a solution today and need to remember later:

* xserver crashes when initializing input devices
* This has apparently been broken for a long time, possibly even since xorg 1.17.2 (when logind support for input permissions was added)
* logind seems to do a bit more than that but possibly some combo of udev rule and/or "setgid input" might get us a working non-root xserver
* with systemd something seems to currently break a little earlier (as if it wasn't able to open a VT), this might be another issue as logind really should be handling the input permissions in this case...

Also agree with Joshua: we'd need a test for this if we want this to keep working.
Comment 6 Jussi Kukkonen 2017-05-26 08:33:13 UTC
> * xserver crashes when initializing input devices

That may have been too hasty. There is indeed this warning when starting as "xuser":

 [     6.555] xf86EnableIOPorts: failed to set IOPL for I/O (Operation not permitted)

but the actual crash happens in libvgahw.so module load (InitOutput()):

[     6.557] (II) Loading sub module "vgahw"
[     6.557] (II) LoadModule: "vgahw"
[     6.557] (II) Loading /usr/lib/xorg/modules/libvgahw.so
[     6.557] (II) Module vgahw: vendor="X.Org Foundation"
[     6.557] 	compiled for 1.19.1, module version = 0.1.0
[     6.557] 	ABI class: X.Org Video Driver, version 23.0
[     6.557] (EE) 
[     6.557] (EE) Backtrace:
[     6.558] (EE) 0: /usr/bin/Xorg (xorg_backtrace+0x3d) [0x57250d]
[     6.558] (EE) 1: /usr/bin/Xorg (0x400000+0x175e69) [0x575e69]
[     6.558] (EE) 2: /lib/libpthread.so.0 (0x7f5a8a995000+0x119e0) [0x7f5a8a9a69e0]
[     6.558] (EE) 3: /usr/lib/libpciaccess.so.0 (pci_io_write8+0x3) [0x7f5a8bbbf863]
[     6.558] (EE) 4: /usr/lib/xorg/modules/libvgahw.so (vgaHWSaveColormap+0x56) [0x7f5a87650ee6]
[     6.558] (EE) 5: /usr/lib/xorg/modules/libvgahw.so (vgaHWSave+0x55) [0x7f5a876529d5]
[     6.558] (EE) 6: /usr/lib/xorg/modules/drivers/vmware_drv.so (0x7f5a87e76000+0x4552) [0x7f5a87e7a552]
[     6.558] (EE) 7: /usr/bin/Xorg (InitOutput+0xa5a) [0x4765ea]
[     6.558] (EE) 8: /usr/bin/Xorg (0x400000+0x37ab6) [0x437ab6]
[     6.558] (EE) 9: /lib/libc.so.6 (__libc_start_main+0xf1) [0x7f5a8a6184e1]
[     6.558] (EE) 10: /usr/bin/Xorg (_start+0x2a) [0x422e2a]
[     6.558] (EE) 
[     6.558] (EE) Segmentation fault at address 0x8
[     6.558] (EE) 

This was a little different with older releases and that confused me -- the above is from current poky master with ROOTLESS_X and sysvinit.
Comment 7 Jussi Kukkonen 2017-05-26 08:49:54 UTC
Workaround: Passing this to runqemu:
   qemuparams="-vga std"
makes X work (slowly but still).

So it could be an issue with wmvare driver, not with our X setup.
Comment 8 Jussi Kukkonen 2017-06-08 12:37:59 UTC
Moving to M2, no solution yet.

Just to reiterate if it wasn't clear: this does not look like an issue with xserver-nodm. It's probably the vmware X driver not working without root.

I guess we could add an error/warning in the recipe when building with ROOTLESS_X in the mean time...
Comment 9 Jussi Kukkonen 2017-07-07 08:33:27 UTC
I've not confirmed this but my current working hypothesis is this:
xf86-video-vmware does work with rootless X _if_ the host is compatible (in other words, one of the VMWare ones). We're running in qemus vmware emulation and something isn't right.

I don't have any VMWare machines to test the assumption.

I wonder if spice + qxl works any better?
Comment 10 Ross Burton 2018-10-18 15:24:05 UTC
Related: I've been idly looking at overhauling how qemu does graphics in our images from vmware bits to modern virtio.  This should resolve this.
Comment 11 Kevin Hao 2020-03-17 01:09:47 UTC
commit ba279900933d
Author: Kevin Hao <kexin.hao@windriver.com>
Date:   Sat Feb 8 20:36:42 2020 +0800

    xserver-nodm-init: Fix the start failure for non-root user
    
    In order to start the xserver, a non-root user should have the
    cap_sys_admin capability to set the drm master. We try to get
    the cap_sys_admin capability by setting it in both the thread
    and file inheritable set. The side effect of this is that we
    would have to add the "pam" to the distro features if we want
    use the xserver-nodm-init for a non-root user.
    
    [Yocto #11526]
    
    (From OE-Core rev: cfd71a68a4931c8bda15357ebb1e9ebcf0e302dc)
    
    Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>