# Kernel Based Virtualization (KVM) and SDL

## netboy1977

Dear Gentoo'ers,

I plan to set up a Windows guest on my kvm/qemu system (kernel 2.6.20) without a X graphical system on it.

When I try to start the Vm using the installation medium I receive an error message telling me that sdl could not be initialised.

Do I have to run a X-server for sdl?

Thanks in advance!

Dominik

----------

## DirtyHairy

I never fiddled around with KVM, but you don't necessarily need a X server for SDL; it can utilise the framebuffer or aalib for video output. The output device is choosen vie the environment variable "SDL_VIDEODRVIER"; just google for it to find the necessary settings  :Smile: 

----------

## netboy1977

That did not make it:

I tried

```
export SDL_VIDEODRIVER=fbcon
```

 and then

```
export SDL_VIDEODRIVER=x11
```

Still says

Could not initialise SDL -exiting

Libs should be found:

```
 ldd `which qemu`
```

libm.so.6 => /lib/libm.so.6 (0x00002b619af2c000)

        libz.so.1 => /lib/libz.so.1 (0x00002b619b081000)

        libasound.so.2 => /usr/lib/libasound.so.2 (0x00002b619b195000)

        libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0x00002b619b36e000)

        libpthread.so.0 => /lib/libpthread.so.0 (0x00002b619b4f5000)

        libutil.so.1 => /lib/libutil.so.1 (0x00002b619b60f000)

        librt.so.1 => /lib/librt.so.1 (0x00002b619b713000)

        libc.so.6 => /lib/libc.so.6 (0x00002b619b81c000)

        libdl.so.2 => /lib/libdl.so.2 (0x00002b619ba5a000)

        libX11.so.6 => /usr/lib/libX11.so.6 (0x00002b619bb5f000)

        libXext.so.6 => /usr/lib/libXext.so.6 (0x00002b619bd6c000)

        libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00002b619be7d000)

        libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00002b619bf81000)

        /lib64/ld-linux-x86-64.so.2 (0x00002b619ae0f000)

        libXau.so.6 => /usr/lib/libXau.so.6 (0x00002b619c08a000)

        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00002b619c18d000)

Any idea?

----------

## JoeUser

maybe one of these command line options will help?

```
`-nographic'

    Normally, QEMU uses SDL to display the VGA output. With this option, you can totally disable graphical output so that QEMU is a simple command line application. The emulated serial port is redirected on the console. Therefore, you can still use QEMU to debug a Linux kernel with a serial console. 

`-vnc display'

    Normally, QEMU uses SDL to display the VGA output. With this option, you can have QEMU listen on VNC display display and redirect the VGA display over the VNC session. It is very useful to enable the usb tablet device when using this option (option `-usbdevice tablet'). When using the VNC display, you must use the `-k' option to set the keyboard layout if you are not using en-us. display may be in the form interface:d, in which case connections will only be allowed from interface on display d. Optionally, interface can be omitted. display can also be in the form unix:path where path is the location of a unix socket to listen for connections on.
```

----------

## DirtyHairy

Did you try aalib (its pretty useless for display, but it should initialize on any terminal)?

----------

## netboy1977

Thanks for your replies.

The vnc option 

```
 -vnc 0 
```

 worked great.

I am now executing qemu/kvm in X. The sdl error has gone.

Cheers,

Dominik

----------

## lagaffe

hello!

I had the same problem with my PC. That thread help me until the last.... I had the same response to the "ldd `which qemu`" and the error about SDL goes away with the "vnc 0" option. But it remains a little problem : nothing appears... I mean I lauch the command 

qemu -cdrom /home/yves/dsl-3.3.iso -boot d -m 128 -vnc 0

it does not give me back the prompt but no X window appears. It is the same behaviour either with "export SDL_VIDEODRIVER=fbcon" and "export SDL_VIDEODRIVER=x11". I emerged also aalib. Do you lauch qemu through X or not?

----------

## lagaffe

Ok I found that through a vnc, I can view what I want... Excuse-me for my question, but, if I don't want to pass through VNC to view my virtual machine, I need X up and running right? If not how can qemu do to build some X windows?

----------

## netboy1977

I am not quite sure about how sdl works. In my understanding sdl somehow uses the X system to bring up the kvm machine.

You don't need to have a running X to start a GUI kvm machine like windows but X has to be configured correctly.

I prefer to run it from a working X since I have problems with keyboard and with shutdown when I start it right away from non-GUI terminal with no X-server running before. (But there might be ways to fix these errors.)

To my understanding the SDL error (below) results from a misconfiguration of X.

```
Could not initialise SDL -exiting 
```

Check your /var/log/Xorg.0.log for any hints.   :Wink: 

----------

## DirtyHairy

SDL is a cross platform media library which provides a platform independent way to access graphics and sound hardware and such. On UNIX, it uses X, but it can also use other backends on linux like direcfb or fbcon...

----------

