User Tools

Site Tools


howto:qemu

Crossfire inside QEMU

This page contains information how to use qemu to build (and test) Crossfire on a virtual host.

  1. See Mandriva qemu setup for Crossfire testing for instructions on setting a Mandriva virtual system.
  2. Perform the Crossfire development workspace setup to create scripts and get Crossfire sources.
  3. Once setup is complete, proceed to Development and testing to get started on the fun stuff.

Development and testing

Choose a package to work on. Processes are described for:

See the side bar for specific tasks.

Client

Boot the virtual machine and open a terminal session.

Install Client Dependencies

X11 Client

OBSOLETED

GTK1 Client

OBSOLETED

GTK2 / Libglade Client

--disable-metaserver2

For the configure option –disable-metaserver2 ,
these are the minimum requirements:

$ sudo urpmi libglade2.0_0-devel
To satisfy dependencies, the following packages are going to be installed:
glib-gettextize
libatk1.0_0-devel
libcairo2-devel
libfontconfig1-devel
libfreetype6-devel
libgdk_pixbuf2.0_0-devel
libglade2.0_0-devel
libglib2.0_0-devel
libgtk+2.0_0-devel
libice6-devel
libpango1.0_0-devel
libpng3-devel
libsm6-devel
libx11_6-devel
libxau6-devel
libxcursor1-devel
libxdmcp6-devel
libxext6-devel
libxfixes3-devel
libxft2-devel
libxi6-devel
libxinerama1-devel
libxml2-devel
libxrandr2-devel
libxrender1-devel
x11-proto-devel
zlib1-devel
Proceed with the installation of the 27 packages? (48 MB) (Y/n) y
--enable-metaserver2

These are additional requirements for internet metaserver2 look up skill:

$ sudo urpmi libcurl-devel
To satisfy dependencies, the following packages are going to be installed:
   Package                        Version      Release
  libcurl-devel                   7.18.0       1mdv2008.1
  libext2fs-devel                 1.40.8       1mnb1
  libkrb53-devel                  1.6.3        6mdv2008.1
  libssh2-devel                   0.18         3mdv2008.1
Proceed with the installation of the 4 packages? (Y/n) y
lua Scripting

These are additional requirements to build the lua scripting interface.

$ sudo urpmi liblua-devel
To satisfy dependencies, the following packages are going to be installed:
   Package                        Version      Release
  liblua-devel                    5.1.3        2mdv2008.1
  libreadline5-devel              5.2          7mdv2008.1
Proceed with the installation of the 2 packages? (Y/n) y
SDL Renderer

To add SDL support, the following are required.

$ sudo urpmi libSDL_image-devel
To satisfy dependencies, the following packages are going to be installed:
   Package                        Version      Release
  libSDL_image-devel              1.2.6        5mdv2008.1
  libaa-devel                     1.4.0        0.rc5.17mdv2>
  libdirectfb-devel               1.0.1        1mdv2008.1
  libgii-devel                    1.0.2        9mdv2008.1
  libnas2-devel                   1.9a         1mdv2008.1
  libslang-devel                  2.1.3        1mdv2008.1
  libsysfs-static-devel           2.1.0        8mnb1
  libSDL-devel                    1.2.13       8mdv2008.1
  libggi2-devel                   2.2.2        7mdv2008.1
  libsysfs-devel                  2.1.0        8mnb1
Proceed with the installation of the 10 packages? (Y/n) y
Miscellaneous

A few other non-essential packages are checked for by the ./configure script:

$ sudo urpmi makedepend

Client configure

To begin with freshly checked out sources, or to properly process recent modifications to configure.in, configure.ac, or Makefile.am files, a configuration process is invoked as follows:

$ cd ~/svn/trunk/client

$ bash ../../config.sh

Feel free to append build options as arguments to the config.sh command. To find out about what options may be used, try the following command. A few of the more interesting options are shown here.

$ ./configure --help

--disable-sound         Disable sound support default=implement sound support if supported libraries exist
--disable-alsa9         Disable ALSA9 sound support default=use alsa9 sound support if alsa9 libraries exist
--disable-alsa          Disable ALSA sound support default=use alsa sound support if alsa libraries exist
--disable-gtkv1         Do not make original gtk client default=make it if available
--disable-gtkv2         Do not make gtk-v2 client default=make it if available
--enable-cfgtk2         Enable building the original gtkv1 client with GTK+ 2
--disable-sdl           Disable linking with the SDL library, default is to use it if available
--disable-metaserver2   Do not build in metaserver2 support
--enable-maintainer-mode  enable make rules and dependencies not useful
                        (and sometimes confusing) to the casual installer

Server

Boot the virtual machine and open a terminal session.

Install server dependencies

Server configure

$ cd ~/svn/trunk/server
$ bash ../../config.sh

Notes about the virtual system environment

Konsole shell

  • On the Mandriva One 2007 virtual machine, the Konsole terminal shell seems to have some issues.
    1. In the vi editor, it seems especially difficult to type quote characters ().
      • A workaround may be to use another editor. One possibility is the Start | Office | Text Editor.
      • Also, installing vim-enhanced as part of the tool set seems to make the situation better.

Crossfire development workspace setup

Start the virtual system in a manner similar to:

$ cd ~/qemu/mandriva-one-2007-qemu-image
$ bash launch.sh

Boot the virtual machine.

Launch a terminal by clicking the Terminal Program icon on the Start Bar. It is the icon that looks like a monitor. Size and/or configure the terminal to taste as it will be used heavily.

Create a work area for the development sources

Set up a work area for the crossfire sources.

$ cd ~
$ mkdir -p svn/trunk
$ cd svn

Create some utility scripts

Scripts to facilitate use of svn

This example will presume the use of trunk sources. Feel free to deviate from these instructions to reduce the size of the workspace and the amount of data that must be downloaded. Create a shell script called svn-co.sh that contains the following:

svn-co.sh

#!/bin/bash
#
for dir in arch client maps server sounds
do
  svn co https://crossfire.svn.sourceforge.net/svnroot/crossfire/${dir}/trunk trunk/${dir}
done
echo

svn-up.sh

Create another shell script called svn-up.sh as follows:

#!/bin/bash
#
for co in trunk
do
  for dir in arch client maps server sounds
  do
    WORKING=${co}/${dir}
    if [ -d ${CWD}/${WORKING} ]
    then
      echo; echo ${WORKING}; echo
      cd ${CWD}/${WORKING}
      svn update
      cd ${CWD}
  done
done
echo

Scripts to facilitate development

config.sh

Create yet another shell script called config.sh as follows:

#!/bin/bash
#
export CFLAGS="-ggdb -g -O0"
bash autogen.sh --prefix=${HOME} ${*}
echo

Backup scripts on the host box

Just to be safe, save the scripts just created outside of the virtual box to make it easier to recover them if the virtual box is rebuilt. Furthermore, they are as useful there as they are on the virtual system…

In the following example, replace <username> with your user account on the host system. Do not include the less-than and greater-than symbols.

$ cd ~/svn
$ scp *.sh <username>@10.0.2.2:/home/<username>/qemu

Checkout the Crossfire sources

Execute the svn-co.sh script to check out the development sources.

$ cd ~/svn
$ bash svn-co.sh

Shut down the virtual system with Star | Log Out… | Turn Off Computer.

Make a backup of the virtual box that only has the Crossfire sources installed on it and does not have the client or server dependencies installed. On the host computer, execute the following commands:

$ cd ~/qemu
$ tar -cjf mandriva-one-2007-qemu-image.cfsvn.tar.bz2 mandriva-one-2007-qemu-image

The reason to do this backup is so that it becomes possible to undo the installation of libraries that the Crossfire sources depend on. The main reason to do it is to avoid having to re-checkout the svn sources just to retry dependency checking.

Proceed to Development and testing.

Mandriva qemu setup for Crossfire testing

What packages are there?

$ urpmq –fuzzy qemu
dkms-kqemu
qemu
qemu-img
qemu-launcher

Installation

$ sudo urpmi qemu dkms-kqemu qemu-img qemu-launcher
To satisfy dependencies, the following packages are going to be installed:
dkms-kqemu-1.3.0-0.pre11.3mdv2007.0.x86_64
perl-Gtk2-GladeXML-1.005-1mdk.x86_64
qemu-0.9.0-6mdv2007.0.x86_64
qemu-img-0.9.0-6mdv2007.0.x86_64
qemu-launcher-1.7.0-1mdv2007.0.noarch
Proceed with the installation of the 5 packages? (11 MB) (Y/n) y
...
installing qemu-launcher-1.7.0-1mdv2007.0.noarch.rpm perl-Gtk2-GladeXML-1.005-1mdk.x86_64.rpm dkms-kqemu-1.3.0-0.pre11.3mdv2007.0.x86_64.rpm
qemu-0.9.0-6mdv2007.0.x86_64.rpm qemu-img-0.9.0-6mdv2007.0.x86_64.rpm from /var/cache/urpmi/rpms
Preparing...                     #############################################
      1/5: qemu-img              #############################################
      2/5: dkms-kqemu            #############################################
+ /usr/sbin/dkms --rpm_safe_upgrade add -m kqemu -v 1.3.0pre11-3

Creating symlink /var/lib/dkms/kqemu/1.3.0pre11-3/source ->
                 /usr/src/kqemu-1.3.0pre11-3

DKMS: add Completed.
+ /usr/sbin/dkms --rpm_safe_upgrade build -m kqemu -v 1.3.0pre11-3

Preparing kernel 2.6.17-14mdv for module build:
(This is not compiling a kernel, just preparing kernel symbols)
Storing current .config to be restored when complete
Running Mandrakelinux style preparation routine
make clean....(bad exit status: 2)
using /proc/config.gz
make oldconfig....(bad exit status: 2)
running dkms_mkkerneldoth....

Building module:
cleaning build area....(bad exit status: 2)
./configure --kernel-path=/lib/modules/2.6.17-14mdv/source && make.......
cleaning build area....

DKMS: build Completed.
+ /usr/sbin/dkms --rpm_safe_upgrade install -m kqemu -v 1.3.0pre11-3
Running module version sanity check.

kqemu.ko.gz:
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/2.6.17-14mdv/kernel/3rdparty/kqemu/

depmod.....

DKMS: install Completed.
+ /sbin/modprobe kqemu
      3/5: perl-Gtk2-GladeXML    #############################################
      4/5: qemu-launcher         #############################################
      5/5: qemu                  #############################################
$

Verification

$ sudo lsmod | grep qemu
kqemu                 163368  0

Note: Using the kernel plug-in may or may not work well. The author's experience was that the mouse froze and X on the host machine needed to be restarted. Therefore, this example does not actually use the kernel plug-in, though your mileage may vary. To try using the plug-in, refer to README.txt in the virtual box directory, and alter launch.sh to include the command argument -kernel-kqemu.

OS Setup

Operating system images may be found at oszoo.org.

This example uses Mandriva-One-2007.

Download the .zip file… for purposes of this example to /home/<username>/Download/mandriva-one-2007-qemu-image.zip

$ cd ~
$ mkdir qemu
$ cd qemu
$ unzip ~/Download/mandriva-one-2007-qemu-image.zip
Archive:  /home/krb/Download/mandriva-one-2007-qemu-image.zip
   creating: mandriva-one-2007-qemu-image/
  inflating: mandriva-one-2007-qemu-image/mandriva-one-2007.qcow.img
  inflating: mandriva-one-2007-qemu-image/mandriva-one-screen-shot.gif
  inflating: mandriva-one-2007-qemu-image/README.txt
$ cd mandriva-one-2007-qemu-image

NOTE: If you are not using an x86_64 system, the qemu command will vary based on your system.

$ ls -l /usr/bin/qemu*
lrwxrwxrwx 1 root root      18 Sep  2 11:20 /usr/bin/qemu -> qemu-system-x86_64*
-rwxr-xr-x 1 root root  355832 Apr 18 09:40 /usr/bin/qemu-arm*
-rwxr-xr-x 1 root root  359552 Apr 18 09:40 /usr/bin/qemu-armeb*
-rwxr-xr-x 1 root root  513648 Apr 18 09:40 /usr/bin/qemu-i386*
-rwxr-xr-x 1 root root  123872 Apr 18 09:40 /usr/bin/qemu-img*
-rwxr-xr-x 1 root root   58646 Aug 14  2006 /usr/bin/qemu-launcher*
-rwxr-xr-x 1 root root  454416 Apr 18 09:40 /usr/bin/qemu-ppc*
-rwxr-xr-x 1 root root  487968 Apr 18 09:40 /usr/bin/qemu-sparc*
-rwxr-xr-x 1 root root  744880 Apr 18 09:40 /usr/bin/qemu-system-arm*
-rwxr-xr-x 1 root root 1209152 Apr 18 09:40 /usr/bin/qemu-system-i386*
-rwxr-xr-x 1 root root 1094848 Apr 18 09:40 /usr/bin/qemu-system-mips*
-rwxr-xr-x 1 root root  995632 Apr 18 09:40 /usr/bin/qemu-system-ppc*
-rwxr-xr-x 1 root root  871688 Apr 18 09:40 /usr/bin/qemu-system-sparc*
-rwxr-xr-x 1 root root 1366240 Apr 18 09:40 /usr/bin/qemu-system-x86_64*

NOTE: The following echo command will create a launch script to start up the virtual system. Please note that the -m 1024 option allocates 1Gb of RAM to the virtual system. If the host system does not have that much free RAM, you must lower the number accordingly.

$ echo qemu-system-x86_64 -L . -hda mandriva-one-2007.qcow.img -m 1024 -boot c >launch.sh
$ cp /usr/share/qemu/*.bin .
$ bash launch.sh

A QEMU/KQEMU window appears with a Mandriva boot menu. Select linux-nonfb and press Enter. The virtual system will boot up and eventually present you with a KDE desktop. You are auto-logged in as a user named tux.

If you click inside that window, your mouse pointer will be trapped inside the window until you press Ctrl-Alt, so keep this in mind whenever you wish to switch back and forth between the host and the virtual system.

A Mandriva Linux window will pop up. Uncheck the Open this window on startup box, and press the Close button.

On a 3.6 Ghz CoreDuo system with 1Gb of RAM, the virtual system runs very fast, and it is very difficult to use the keyboard because keys repeat. The first thing to do, then, is to slow down or disable the key repeat. Start the KDE Control Center by clicking Star | System | Control Center. Navigate to Peripherals | Keyboard and set Delay to about 1000 msec, or uncheck the Enable keyboard repeat check box. Click the Apply button, and close the KDE Control Center with File | Quit.

About your virtual system

  • The tux and root account passwords are both qemuisgreat.
  • The system's IP address is 10.0.2.15.
  • The host system's IP address is 10.0.2.2.
  • The virtual system has access the internet if the host system has access.

About your host system

This example makes certain presumptions about your host system set up. Among them are:

  • It is possible to ssh into your user account on the host system from localhost, and, that scp is installed.
  • Your host system has internet access.

About your skills

This example does presume some things about your skills.

  • You can use the vi editor, or can figure out how to find and use a different text editor on your own.
  • You are reasonably comfortable with using a BASH command-line when directed about what to type.

Setting up the tool chain

Give tux sudo privileges

First, you will need root access from time to time, so set that up first. Open up a terminal session by clicking the Terminal Program icon on the start bar. Size and configure it to taste, and settle in for a session at the command prompt. The prompt will look like:

[tux@localhost ~]$ 
$ su -l root -c urpmi\ sudo
Password:

ftp://ftp.u-strasbg.fr...
installing sudo...
Preparing...
      1/1: sudo...

Remember, the password was documented above in About your virtual system.

$ su -l root -c visudo

You are in the vim editor. Use the arrow keys to move down to the first character of the line that reads:

# %wheel  ALL=(ALL)       ALL

Press xx<Esc>:wq. Teaching you how to use vim is outside of the scope of this tutorial, so from here on, you are on your own. When you did it correctly, the above line will look like:

%wheel  ALL=(ALL)       ALL

To finally give tux sudo rights, enter the following command.

$ su -l root -c usermod\ -G\ wheel\ tux

Set up a toolchain

$ sudo urpmi autoconf2.5 automake cproto gcc gdb libtool make subversion
To satisfy dependencies, the following packages are going to be installed:
autoconf2.1...
autoconf2.5...
automake1.8...
binutils...
cproto...
gcc...
glibc-devel...
libapr-util1...
libapr1...
libbinutils2...
libsvn0...
libtool...
libtool-base...
m4...
make
subversion...
Proceed with the installation of the 17 packages? (43 MB) (Y/n) y
...
$ sudo urpmi makedepend patch tree
$ sudo urpmi vim-enhanced
To satisfy dependencies, the following packages are going to be installed:
vim-common...
vim-enhanced...
Proceed with the installation of the 2 packages? (20 MB) (Y/n) y
...
$ exit

Shut down the virtual system with Star | Log Out… | Turn Off Computer.

Make a backup of a clean virtual box that only has the development tools installed on it. On the host computer, execute the following commands:

$ cd ~/qemu
$ tar -cjf mandriva-one-2007-qemu-image.devel.tar.bz2 mandriva-one-2007-qemu-image

The reason to do this backup is so that it becomes possible to checkout, build, and test Crossfire sources on a clean system. It also gives us a backup that we can modify in the event that other tools need to be added to the clean development image.

Proceed to Crossfire development workspace setup.

qemu packages

The following Mandriva packages are available via urpmi.

qemu

QEMU is a FAST! processor emulator. By using dynamic translation it
achieves a reasonnable speed while being easy to port on new host
CPUs. QEMU has two operating modes:
   
* User mode emulation. In this mode, QEMU can launch Linux processes
   compiled for one CPU on another CPU. Linux system calls are
   converted because of endianness and 32/64 bit mismatches. Wine
   (Windows emulation) and DOSEMU (DOS emulation) are the main targets
   for QEMU.
   
* Full system emulation. In this mode, QEMU emulates a full system,
   including a processor and various peripherials. Currently, it is
   only used to launch an x86 Linux kernel on an x86 Linux system. It
   enables easier testing and debugging of system code. It can also be
   used to provide virtual hosting of several virtual PC on a single
   server.
   
   This QEMU package provides support for KQEMU, the QEMU Accelerator
   module.
   
This QEMU package provides support for KVM (Kernel-based Virtual
Machine), a full virtualization solution for Linux on x86 hardware
containing virtualization extensions (AMD-v or Intel VT).

qemu-img

This package contains the QEMU disk image utility that is used to
create, commit, convert and get information from a disk image.

qemu-launcher

A launcher for Qemu that manages Qemu configs and creates disk images
Qemu-launcher provides a point and click interface to Qemu. It also
allows you to create, save, load, and run multiple Qemu VM
configurations. It has a basic interface for creating or convertering
disk images.

dkms-kqemu

QEMU Accelerator (KQEMU) is a driver allowing the QEMU PC emulator to
run much faster when emulating a PC on an x86 host.

Full virtualization mode can also be enabled (with -kernel-kqemu) for
best performance. This mode only works with the following guest OSes:
Linux 2.4, Linux 2.6, Windows 2000 and Windows XP. WARNING: for
Windows 2000/XP, you cannot use it during installation.

Use "qemu-system-x86_64" to benefit from the QEMU Accelerator Module.
howto/qemu.txt · Last modified: 2018/04/04 19:15 by karl