10.03.07

Gentoo: QEMU in 32bit Xen environment

Posted in Admin hints, Linux, Open Source, Xen at 6:13 pm

Recently I wanted to set up a testing server for the different virtualization techniques for Linux. For this I have an Asus P5LD2 mainboard with an Intel dual core Pentium D 3,2 GHz which supports the Virtual Machine Extensions (VMX). Thanks to this I can compile Xen with the ‘hvm’ USE-flag and run fully virtualized guest operating systems on my Xen supervisor. This means I could run nearly every i386 compatible operating system (even Windows ;-) ) in my Xen environment. Without such hardware every guest operating system has to have a Xen enabled kernel.

Another approach with the same result is the open source project QEMU. Its abstraction level is higher than with Xen and it can even emulate different target architectures from your current x86 host. So far x86_64, ARM, SPARC, PowerPC, MIPS and M68k target systems are supported. Its guest operating system does not need any single change to run on QEMU. This makes it very comfortable to test new live CDs or operating system images. But it is not so trivial to setup QEMU and Xen together on a Gentoo machine.

How to setup QEMU on 32bit Gentoo in Xen dom0?

If you compile Xen on a 32bit host you have to add ‘-mno-tls-direct-seg-refs’ to your CFLAGS. That is because the glibc TLS library is implemented in a way that will conflict with how Xen uses segment registers. For compiling the non-patched QEMU 0.9.0 you have to use a gcc version 3.x. The nowadays default gcc 4.x is not yet supported. After several compile failures I finally found to setup QEMU the following way:

1. For compiling gcc-3.x remove the ‘-mno-tls-direct-seg-refs’ from /etc/make.conf and set the ‘nossp’ and ‘nopie’ USE-flags. Otherwise gcc or later qemu will not compile.

2. Switch to gcc-3.x before compiling qemu-softmmu, qemu-user and qemu. In my case it’s: gcc-config i686-pc-linux-gnu-3.3.6

3. Check your CFLAGS again because the optimization flags for gcc 4.x are not always backwards compatible to gcc-3.x. In my case the make.conf looks like this:

# gcc-3.x
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer -mno-tls-direct-seg-refs"


# gcc-4.x for compiling gcc-3.3
#CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"


# gcc-4.x
#CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer -mno-tls-direct-seg-refs"

4. Now you can compile QEMU. Do not forget to switch back to your original CFLAGS and gcc-4.x after successfully emerging QEMU. I recommend to you to also build the QEMU kernel accelerator module kqemu which has to be compiled with the same compiler as the kernel itself.

Now Xen and QEMU are able to run whatever operating system image you give them. Have fun with playing around…

Continuative links:

  • gentoo-wiki.com - HOWTO Xen and Gentoo
  • wiki.xensource.com - HVM Compatible Processors
  • gentoo-wiki.com - HOWTO Qemu
  • 09.26.07

    DokuWiki - A small Wiki for everyday use

    Posted in Open Source at 6:38 pm

    For organizing our move to the shared flat I was looking for a small, simple to use Wiki for collecting ideas and coordinating our flat inventory. After a little search I found DokuWiki. It can be easily installed by every Linux distribution’s package manager. Unfortunately the stable Debian package was not the newest version and annoyed me with banners that there are some upgrades available. So I tried again with the newest version from the developers site. After unpacking, the directory has to be made accessible through your Web server and after running the install.php where you actually only create the administrator user, the Wiki is already prepared to use. In the default configuration there is no database needed. But the strength of this Wiki is that it can be expanded by more sophisticated configurations using MySQL or an LDAP back-end for user administration. The syntax is quite simple and similar to other Wiki systems. Also my friends were surprised by the usability of this piece of Open Source software. So if you are planning to use a powerful but simple Wiki software, keep an eye on DokuWiki.

    08.16.07

    Open Source Instant Messaging with GoogleTalk

    Posted in Open Source, google at 8:39 am

    Most of you may have a similar problem. A lot of friends are present in the Internet but all of them use a different instant messenger. There are ICQ, MSN, Yahoo Messenger, Jabber and a lot more. With multi-protocol messenger like Pidgin (former Gaim) or Adium it is not that laborious to manage all your contacts anymore. But still you would like to reduce your number of accounts as much as possible.

    Once more open source software gives an example how it could be. The protocol is called XMPP and originally used by Jabber. When Google introduced their own messenger GoogleTalk in 2005 they made the wise decision to also use XMPP instead of inventing a new protocol. The next big thing is that everybody with a Gmail account can also use this credentials for GoogleTalk. One account connects you to your friends of two networks. Why is not everything in information technology so handy?

    Now you are maybe wondering that Gaim/Pidgin does not support GoogleTalk. But it does support Jabber/XMPP. So it is an easy thing to set up your GoogleTalk account. Enter your Gmail address as “Screen Name”; the server is not “jabber.org” but “gmail.com” and the connect server is “talk.google.com”. As resource you can leave “Home”. Finished and ready for chatting…

    07.24.07

    Arming against SSH Attacks

    Posted in Admin hints, Linux, Open Source at 8:53 pm

    I think everybody that runs an own Linux server with the SSH daemon listening on port 22 is sooner or later annoyed by the amount of password attacks done by bots somewhere out in the Internet. What can you do against it?

    Blocking via iptables ‘recent’ module
    How you can do this on a Gentoo system is described in the Gentoo Wiki here. Because it blocks the connection attempt only due to the number of tries within a certain time it is a very basic solution and needs quite a lot of testing to examine the good parameters for the ‘hitcount’ and ’seconds’ arguments. You do not unintentionally want to block yourself when you only try to open several connections within a short time period. So not really the thing I recommend here.

    Log parsing with sshguard
    sshguard uses another approach. It parses the SSH log messages and searches for login failures. For example when you try to connect with a non-existent user sshguard catches it and creates an iptables deny rule. But also sshguard has a small design mistake. It wants you to create a sshguard chain in iptables and redirect all the traffic to the chain assuming that your default INPUT policy is ACCEPT. When it wants to block a host it runs iptables -A sshguard -s host-to-block -j DROP. In case you have your policy set to DROP you cannot configure the iptables to accept the allowed SSH traffic because else the blocking rules will not work anymore. I made a small patch to change the blocking command to insert the rule in first place of the chain. After you applied the patch you have to make sure that you setup your iptables the following way:

    iptables -N sshguard
    iptables -A sshguard -j ACCEPT
    iptables -A INPUT -p tcp --dport ssh -j sshguard

    Further you have to edit your system logger configuration file. Please read the documentation.

    For all the lazy people I even made a Ebuild that also adds a second patch where you can disable the IPv6 ability of sshguard. You can find it here.

    07.09.07

    Migration of Xen SMP domU

    Posted in Admin hints, Linux, Open Source, Xen at 1:36 am

    YES, YES, YES! Finally I made it.

    Since a while I am playing with the migration functionality of a Xen domU between two Xen servers. It allows to move a virtual machine without reboot between two physical machines. But my problem was: It did not hold what it promised.

    Trying all possible versions of Xen and the xen-sources in the Gentoo Portage I was able to migrate a domU but not when it was configured as SMP machine. After I found that the kernel has to include the CONFIG_HOTPLUG_CPU option, I was able to migrate the domU at least one time from one host to the other. When repeating this procedure the domU crashed with a kernel oops. By finally trying the latest Xen 3.1 version from the unofficial mescalito portage overlay with the xen-sources-2.6.18, repeated migration of a domU between the Xen servers does work now. Prerequisite is that both dom0 and domU run the 2.6.18 kernel. I am trying to run this in production now and will see how reliable it is.

    I just remember that I did also remove the memory restriction from the dom0. The dom0_mem parameter in the grub configuration is optional and when omitting it the dom0 can use the unused memory for itself.

    07.07.07

    Parallel Port in Xen domU

    Posted in Admin hints, Linux, Open Source, Xen at 7:00 pm

    For my home server I wanted to act a Xen domU as CUPS printing server. Therefore I needed access to my parallel printer connected to the Xen server. How are I/O-ports handled in Xen?

    The I/O-addresses of the devices which can be found with cat /proc/ioports can be redirected from the Xen dom0. You have to enter the address range of the device you want to use in a domU in their configuration file (/etc/xen/domain-config). For my parallel port it would be:

    ioports = [ '0278-027a' ]

    Further I make sure that my dom0 does not access the device by removing parallel port support in the kernel configuration. When you boot then a domU kernel with parallel port and printer support it can access the device natively. Here a cut out from dmesg:

    parport0: PC-style at 0x278 [PCSPP,TRISTATE]
    parport0: Printer, Hewlett-Packard HP LaserJet 6P
    lp0: using parport0 (polling).

    In CUPS the printer is now accessible under /dev/lp0.

    Unfortunately the documentation about this feature of Xen is a little bit rare. Another interesting thing is the redirection of PCI devices to a domU. Unfortunately I did not test this at my setup yet. I hope to come back to this topic later. For your creativity here some more examples from the net:

  • dulug.de - serielle Schnittstelle mit XEN
  • wiki.xensource.com - Assign hardware to DomU with PCI Backend as module
  • PCI Delegation in Xen
  • 09.10.06

    Neues vom Firefox

    Posted in News, Open Source at 2:55 am

    An den verschiedensten Enden gab es in letzter Zeit Neuigkeiten über den Open Source Internet Browser Firefox. Um die schlechte Nachricht schon einmal vorwegzunehmen, der Releasetermin von Firefox 2.0, welcher im August 2006 angesetzt war, konnte nicht eingehalten werden. Dafür hat sich die Oregon State University Linux User Group etwas einfallen lassen und einen Kornkreis in Form des Firefox Logos getrampelt.

    Auch die Leute bei Mozilla selber sorgen dafür, dass das Warten auf die nächste Firefox Version nicht langweilig wird und verspricht jedem Firefox Benutzer, der noch bis am 15. September einen Neubenutzer gewinnen kann, dass deren Namen in der 2.0 Version des Programms verewigt wird. Damit sich nicht nur die Verbreitung des Browsers sondern auch dessen Kundennähe vergrössert, wurde im August eine Umfrage über die gewünschten Features anderer Browser durchgeführt. Die Auswertung ergab als wünschenswertesten Punkt eine integrierte PDF Engine wie im Apple Safari.

    Dass sich das Projekt auf dem richtigen Weg befindet, zeigte im Juli der 200 Millionste Download von Firefox. Computerbase zeigt schliesslich, dass er nicht nur heruntergeladen, sondern vor allem von interessierten Computerbenutzern rege genutzt wird. Mit knapp 57% kann sich der Open Source Browser recht deutlich gegen den Microsoft Internet Explorer (35%) und Opera (6%) durchsetzen.

    Und als richtiges Schmankerl zum Schluss gibt jetzt auch noch die Firefox 2.0 Beta 2. Erstmals sind jetzt auch Änderungen in der grafischen Oberfläche sichtbar. Für die neue Version wurde ein neues Theme erstellt. Neue glossy-like Icons, sowie Tabs, die schattiert werden, wenn sie im Hintergrund sind, soll die Übersicht verbessern. Hie und da sind aber nach meinem Geschmack noch einige Verbesserungen anzubringen. Wie schon früher erwähnt, besitzt jedes Tab einen eigenen Close-Button. Beim Starten wird zudem gefragt, ob man die Tabs der letzten Sitzung wieder herstellen soll. Die RSS Integration sowie das Extensions (neuerdings “Add-ons”) Menu wurden überarbeitet. Etwas sehr sinnvolles Neues ist die Rechtschreibeprüfung für Eingabefelder in Webseiten. Bisher hatte ich noch keine Probleme mit der Beta 2 und so kann ich allen, die schon jetzt die neuen Features ausprobieren wollen, empfehlen, diese Version zu installieren. Sonst bleibt nur das Warten auf den nächsten offiziellen Releasetermin, welcher nun auf den 24. Oktober lautet.

    08.05.06

    Webtipps - 5. August 2006

    Posted in Open Source, Webtipps at 1:43 am

    heise.de: Wo bleibt der Linux Desktop?
    ibm.com: Linux threading models compared: LinuxThreads and NPTL
    linuxworld.com.au: Forget about open source at Apple

    06.28.06

    Spam gibts nicht nur im Email

    Posted in Admin hints, News, Open Source, Website at 11:52 pm

    Vielleicht ist es schon jemandem aufgefallen. Ganz unten auf der Seite ist eine Statuszeile von Spam Karma 2 einem Programm, welches dieses WordPress-Blog von ungewollten Einträgen schützt. Seit ich dieses SK2 Plugin vor genau einer Woche installiert habe, sind jetzt sage und schreibe bereits 124 Spam Einträge gefiltert worden. Nein, ich habe definitiv keine Lust, dass jemand auf meiner Seite mit zwielichtigen Sachen wirbt. Die geposteten Links müssen aber nicht immer nur auf Werbeangebote führen. Im schlimmeren Fall haben sie auf ihrer Zielseite Code eingebaut, um durch eine Browserschwachstelle ungewollte Programme zu installieren. Ich möchte nicht unerwähnt lassen, dass der Internet Explorer immer noch Angriffsziel Nummer eins ist und daher nicht als bevorzugter Browser gewählt werden sollte. Diese Spameinträge werden dann schliesslich auch von solchen ungewollten Programmen gemacht, sogenannten Spam Bots. Das macht die Filterung relativ einfach. Beispielsweise wird auf die Zeit geschaut, welche verstreicht nach dem Aufrufen der Seite bis zum Abschicken des Kommentars. Nun kommen wir aber zum eigentlichen Problem, nämlich der Ursache dieser Bots. Und schon sind wir wieder einmal bei Windows angelangt. Leider ist dieses Betriebssystem für die meisten Benutzer so einfach zu bedienen, dass sie keine weiteren Ansprüche stellen sich tiefer mit der Materie auseinander zu setzen, was bei Windows leider eindeutig nötig wäre… hier haben wir jetzt den Mist. Merci

    03.23.06

    Mozilla Firefox Alpha 1 (Bon Echo) released!

    Posted in News, Open Source at 11:33 am

    Die von mir am meisten verwendete Applikation ist in einer neuen Alphaversion erschienen. Die implementierten Änderungen betreffen bisher vor allem das Back-end betreffend der History und den Bookmarks des Browsers. Die auffälligste Änderung für den Benutzer sind die separaten “Close”-Buttons an den einzelnen Tabs. Laut der Firefox 2.0 Roadmap will man die finale Version etwa mitte Sommer herausbringen. Bis dahin ist also noch viel Zeit. Wer sich schon jetzt über die zu erwartenden Neuerungen informieren will, kann das in der Firefox 2 Features-Liste machen. Leider wurde aber der verbesserte Downloadmanager bereits wieder von der Liste gestrichen. Wer sich nun bereits an das Preview wagen will (ich habe es natürlich schon längst getan), kann sich die passende Version vom Mozilla FTP herunterladen. Da dies die erste Version des 2.0 Zweigs ist, ist zu beachten, dass leider sämtliche Extensions noch nicht funktionieren.

    Quelle: mozillazine.org: Bon Echo Alpha 1 Available