# FreeBSD11 on Qemu Xorg Fails



## lcr0n05 (May 6, 2017)

Hi, I'm trying to set up a FreeBSD guest on Qemu/KVM (Gentoo host) so I can try Plasma 5 from area51 without messing up my install on my laptop.  Originally I tried TrueOS but couldn't install it because when xorg tried to load it seemed to just crash part way through.  http://imgur.com/a/NtqZ6 this is what I see when I try to load it.  To test whether it was TrueOS or just qemu I then installed OpenBSD and xorg loaded there.  After that I decided to try FreeBSD directly to see if it would work that way.  It installed, but I can't start xorg.  Xorg -configure results in a segfault, startkde doesn't work at all, and if I add enable_sddm="YES" to my /etc/rc.conf I get the same screen I got on TrueOS.  This occurs whether I use -vga std, virtio, vmware, or qxl.  Any ideas?


----------



## tyo100 (Jun 6, 2017)

Hi Icr0n05, same problem here i tried with freebsd 10 and 11, i tests with with std, virtio, vmware or qxl and same screen, if you found a solution please share

Rergards


----------



## dragon321 (Jun 6, 2017)

Hi everyone.

Same problem for me. Xorg log tell about "illegal instruction". I tried FreeBSD 11 STABLE and 12 CURRENT - on both same issue. Now I'm trying 10.3-RELEASE. I will tell if this will work.

Edit: Nope, 10.3 not working too. Well, I'll try to compile Xorg from ports, maybe this will help.

Here is log from my KVM machine:

```
[    71.104] (II) VESA(0): Attempting to use 60Hz refresh for mode "1024x768" (144)
[    71.104] (II) VESA(0): Attempting to use 60Hz refresh for mode "800x600" (143)
[    71.105] (II) VESA(0): Attempting to use 60Hz refresh for mode "640x480" (142)
[    71.105] (**) VESA(0): Using "Shadow Framebuffer"
[    71.105] (II) Loading sub module "shadow"
[    71.105] (II) LoadModule: "shadow"
[    71.105] (II) Loading /usr/local/lib/xorg/modules/libshadow.so
[    71.106] (II) Module shadow: vendor="X.Org Foundation"
[    71.106]     compiled for 1.18.4, module version = 1.1.0
[    71.106]     ABI class: X.Org ANSI C Emulation, version 0.4
[    71.106] (II) Loading sub module "fb"
[    71.106] (II) LoadModule: "fb"
[    71.106] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[    71.108] (II) Module fb: vendor="X.Org Foundation"
[    71.108]     compiled for 1.18.4, module version = 1.0.0
[    71.108]     ABI class: X.Org ANSI C Emulation, version 0.4
[    71.108] (II) UnloadModule: "scfb"
[    71.108] (II) Unloading scfb
[    71.108] (==) Depth 24 pixmap format is 32 bpp
[    71.108] (II) Loading sub module "int10"
[    71.108] (II) LoadModule: "int10"
[    71.108] (II) Loading /usr/local/lib/xorg/modules/libint10.so
[    71.108] (II) Module int10: vendor="X.Org Foundation"
[    71.108]     compiled for 1.18.4, module version = 1.0.0
[    71.108]     ABI class: X.Org Video Driver, version 20.0
[    71.108] (II) VESA(0): initializing int10
[    71.108] (II) VESA(0): Primary V_BIOS segment is: 0xc000
[    71.108] (II) VESA(0): VESA BIOS detected
[    71.109] (II) VESA(0): VESA VBE Version 3.0
[    71.109] (II) VESA(0): VESA VBE Total Mem: 16384 kB
[    71.109] (II) VESA(0): VESA VBE OEM: SeaBIOS VBE(C) 2011
[    71.109] (II) VESA(0): VESA VBE OEM Software Rev: 0.0
[    71.109] (II) VESA(0): VESA VBE OEM Vendor: SeaBIOS Developers
[    71.109] (II) VESA(0): VESA VBE OEM Product: SeaBIOS VBE Adapter
[    71.109] (II) VESA(0): VESA VBE OEM Product Rev: Rev. 1
[    71.110] (II) VESA(0): virtual address = 0x807600000,
    physical address = 0xfd000000, size = 16777216
[    71.123] (EE)
[    71.123] (EE) Backtrace:
[    71.131] (EE) 0: /usr/local/bin/X (OsInit+0x38a) [0x5abfba]
[    71.132] (EE) 1: /lib/libthr.so.3 (_pthread_sigmask+0x504) [0x8025cedb4]
[    71.133] (EE) 2: /lib/libthr.so.3 (_pthread_getspecific+0xe5f) [0x8025cec8f]
[    71.133] (EE) 3: ? (?+0xe5f) [0x7ffffffffff2]
[    71.135] (EE) 4: /usr/local/bin/X (xf86SlowBcopy+0xe0) [0x49f5e0]
[    71.147] (EE) 5: /usr/local/lib/xorg/modules/drivers/vesa_drv.so (_init+0x1fc9) [0x806512a79]
[    71.148] (EE) 6: /usr/local/lib/xorg/modules/drivers/vesa_drv.so (_init+0x1177) [0x806510f37]
[    71.149] (EE) 7: /usr/local/bin/X (AddScreen+0x93) [0x4373d3]
[    71.149] (EE) 8: /usr/local/bin/X (InitOutput+0x427) [0x47ed07]
[    71.150] (EE) 9: /usr/local/bin/X (remove_fs_handlers+0x38b) [0x43b48b]
[    71.151] (EE) 10: /usr/local/bin/X (_start+0x17f) [0x42506f]
[    71.151] (EE) 11: ? (?+0x17f) [0x80083317f]
[    71.151] (EE)
[    71.151] (EE) Illegal instruction at address 0x49f5e0
[    71.151] (EE)
Fatal server error:
[    71.151] (EE) Caught signal 4 (Illegal instruction). Server aborting
[    71.151] (EE)
[    71.151] (EE)
Please consult the The X.Org Foundation support
    at http://wiki.x.org
 for help.
[    71.151] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[    71.151] (EE)
[    71.152] (EE) Server terminated with error (1). Closing log file.
```

Edit2: Ok, now it's working for me. You have to compile Xorg from ports using GCC instead of clang. After this X server should run.

http://imgur.com/a/jAHor


----------



## tyo100 (Jun 7, 2017)

dragon321 said:


> Hi everyone.
> 
> Edit2: Ok, now it's working for me. You have to compile Xorg from ports using GCC instead of clang. After this X server should run.
> 
> http://imgur.com/a/jAHor



You can help me telling me how compile using GCC instead of clang?


----------



## dragon321 (Jun 8, 2017)

tyo100 said:


> You can help me telling me how compile using GCC instead of clang?



Of course. First You should install gcc (if You don't want to compile it) using pkg. I installed gmake and mesa too. Then follow this instructions (about using gcc for ports):
https://forums.freebsd.org/threads/36469/

The easiest way is add to /etc/make.conf (if it doesn't exist You have to create it) line:

```
USE_GCC=any
```

You can use gcc to chosen ports, this option will use gcc for all ports. When You do it just compile x11/xorg from ports. I believe that You know how to do it. After install try Xorg with startx command. It should start without problems.


----------



## tyo100 (Jun 9, 2017)

Thanks dragon321, now i have xorg working on FreeBSD11, but some things do not compile with GCC, those I had to compile with clang


----------



## dragon321 (Jun 15, 2017)

tyo100 said:


> Thanks dragon321, now i have xorg working on FreeBSD11, but some things do not compile with GCC, those I had to compile with clang



No problem.


----------



## cabriofahrer (Dec 20, 2017)

I ran into the same problem, too, using a FreeBSD Image for qemu (under Centos) and then installing xorg and fluxbox with pkg install.
So is there really no other way than compiling xorg as ports?

Or what other virtual machines can you recommend for linux that would execute FreeBSD without a problem using FreeBSD Packages only? 3D-acceleration also desired.


----------



## Jerome___ (Feb 14, 2018)

Actually, i have success to install FreeBSD and xorg on VIRTUALBOX with 3D acceleration.
It looks like VirtualBox is more easy for FreeBSD guest installation.
You need to install on freebsd virtualbox-ose-additions package (pkg ins virtualbox-ose-additions) for have all the virtualization supports on guest.
You also need to add user to group video.
How to do:
1_install FreeBSD-11.1 iso image on Qemu (just follow the freebsd recommandations for install like you normally do allready) and update all
2_pkg ins virtualbox-ose-additions
3_pkg ins hal
4_add needed service inside /etc/rc.conf (hald_enable="YES" dbus_enable="YES")
5_ add you locale (not really required, but better for non english users who want to get languages abilities) inside /etc/login.conf
6_pkg ins xorg
7_configure your /etc/X11/xorg.conf file (or better, mkdir /etc/X11/xorg.conf.d/ and add one file .conf file for each device: keyboard, mouse, video) from freebsd doc explications
8_ add hal .fdi xml config files for your devices in /usr/local/etc/hal/policy/fdi/ directory (this is also indicate in the freebsd doc about xorg installation)

YOU CAN NOT STARTX FROM TOOR OR ROOT USER (i loose lot of time from this point who is NOT indicate in poor FreeBSD docs)
/var/log/Xorg.0.log file can give some little information if there is a problem, but if one of your .conf file is wrong (syntax), NO LINE ERROR DEBUG will be clearly show... if something is not perfectly configured, it is a pain for just find where is the problem.
In addition with xorg config files, there is again some informations to indicate to hal policy .fdi files... and also, there is many places to write config files and it will be more and more confused after that to target where a problem come from.  Administration is painfull on FreeBSD due to this point and poor documentations, little community with clearly lake of share experiencies with technical/usual informations.

I try on Qemu, but i failed out of the box, because what ever was the video emulator: QXL, VGA or VESA same... no X environment success. 
I also try to compil from GCC, but informations provided are more than minimalist... which version of GCC ? which config of emulator ? 
And why error 1 at compil time (3 hours of compilation for nothing at end time).
It should works... but how ? no one provide precise and relevant complete doc on that.
So i'm thinking that, actually in 2018,  FreeBSD is not well supported for guest on Qemu if you want X environment.


----------



## azure (Jan 9, 2019)

It's 2019 now and FreeBSD still has issues running xorg/desktop. I am running FreeBSD as a guest OS on QEMU/Linux mint (tessa/bionic) and I have experienced failure in trying to install xorg/lightdm/cinnamon/gnome3 on freebsd for the umpteenth time. I bet I am doing something wrong, maybe missing updating a configuration file or something. I tried with Cinnamon and Gnome3 separately and ended up with FreeBSD starting up fuzzy funky unusable screens. In all fairness though the xorg seems to work with virtualbox. I tried with VirtualBox/TrueOSDesktop Unstable/Lumina and that worked. So I believe that problem lies more with QEMU than with FreeBSD. Meanwhile though,I would love to the FreeBsdian opinions on whether there is a workaround to this short coming. Apparently the problem lies with QEMU's support for video drivers. Also, why do all other linux desktop distros work with existing QEMU video drivers but not FreeBSD. What is FreeBSD missing, or more likely what am I missing ??


----------



## Spartrekus (Jan 9, 2019)

lcr0n05 said:


> Hi, I'm trying to set up a FreeBSD guest on Qemu/KVM (Gentoo host) so I can try Plasma 5 from area51 without messing up my install on my laptop.  Originally I tried TrueOS but couldn't install it because when xorg tried to load it seemed to just crash part way through.  http://imgur.com/a/NtqZ6 this is what I see when I try to load it.  To test whether it was TrueOS or just qemu I then installed OpenBSD and xorg loaded there.  After that I decided to try FreeBSD directly to see if it would work that way.  It installed, but I can't start xorg.  Xorg -configure results in a segfault, startkde doesn't work at all, and if I add enable_sddm="YES" to my /etc/rc.conf I get the same screen I got on TrueOS.  This occurs whether I use -vga std, virtio, vmware, or qxl.  Any ideas?



really strange, what are the specs of your hardware, especially video? pciconf. 

sddm is large. Likely did you start with xinit : startx (~/.xinitrc)  and xterm to make a clean check if everything works. Log helps too.


----------



## cabriofahrer (Jan 9, 2019)

Personally, since I found out how well FreeBSD works with VirtualBox (both as host and guest), I couldn't be bothered anymore about QEMU.
I even have a FreeBSD-guest running on a FreeBSD-host with virtualbox. There is just a sound issue in the guest when playing youtube videos, the sound is somehow accelerated with a high pitch, which is annoying.


----------



## azure (Jan 24, 2019)

Yippeee .... success ... So I finally managed to install a desktop for my freebsd. I had been trying to install and use freebsd for years now ... but each time the shell prompt put me off and I never really had the patience to stick around. This time ... hung on and did not give up. Also this time round I was more interested in virtualization tools; and the ease and safe manner it made installing multiple OS without messing up the drive partitions. So for my lessons learnt, I learnt that QEMU/KVM path is not great for testing out FreeBSD/Desktop. I wasted nearly 10 days trying out various configs. Installing FreeBSD is easy but QEMU does display not the desktop. Apparently QEMU has issues with its emulation of the graphics card on intel hd620 kabylake. So the problem may be specific to the hardware on my laptop. I like QEMU because of the ease with which one can run an OS image with just a command line. I made a switch to virtualbox and ran the FreeBSD installation with KDE5 plasma desktop. I was successful with this but it took me nearly 5 attempts before I was successful.  And on each failure, I learnt something new. As follows:
- Install freebsd on your virtual drive following all the std procedures. Keep in mind while creating users pls be sure to add the user to wheel and operator groups  If you miss this step you can always come back to the shell as root and add user to wheel and operator with command. So

$pw group mod {groupNameHere} -m {userNameHere}

for eg if solaris was your userid (just for for fun ..  ).

$pw group mod wheel -m solaris

Once you log into your freebsd shell as root user. Pls run following commands and install a few tools.


$pkg upgrade
$pkg update -f
$portsnap fetch extract
$portsnap update

or

$portsnap auto

$pkg install sudo

run the visudo command and add the user to sudoer.
$visudo

If solaris was the user add the following line.

solaris ALL=(ALL) NOPASSWD: ALL
or
solaris ALL=(ALL) ALL

save the file and exit back to shell prompt.

Run the following commands to begin the installation of KDE5 plasma desktop.

$pkg install nano vim
$pkg install xorg
$pkg install kde5
$pkg install sddm
$pkg install virtualbox-ose-additions

Edit /etc/rc.conf and add the following entries


##### Desktop KDE5 setting
dbus_enable="YES"
sddm_enable="YES"
devd_enable="YES"

##### These are virtualbox guest additions features
vboxguest_enable="YES"
vboxservice_enable="YES"

Edit /etc/sysctl.conf  file and add the following entries

######### Settings for a KDE tool, probably gstreamer
##########################################
net.local.stream.recvspace=65536
net.local.stream.sendspace=65536
###########################################
kern.ipc.shm_allow_removed=1
###########################################
kern.maxfiles=1000000
##########################################

You may also add the following line to /etc/fstab for mount the proc device to /proc.
proc                    /proc   procfs  rw      0       0

save the settings and quit.
$reboot.

Hopefully you will see your KDE5 plasma desktop up and runining on freebsd. Gnome and other desktop installations are quite similar and may differ in the display managers used. All the best ...


----------

