2005-12-07 21:00

Xen on CentOS4

Just in case anyone is wondering if you can install the Xen hypervisor on a CentOS box:

  1. Sure. It works just fine.
  2. Ok, there are a couple of glitches in the install.

Here's how I did it, on a CentOS 4.2 box:

  • Get the install script for RHEL 4.1
  • Fix the validate_os_version function:
validate_os_version() {
    #grep "Red Hat Enterprise Linux AS release 4 (Nahant Update 1)" /etc/redhat-release 2>/dev/null >/dev/null
  • Run it
  • Fix your grub.conf adding this :
title Xen 3.0 / XenLinux 2.6
  kernel /boot/xen-3.0.gz dom0_mem=262144
  module /boot/vmlinuz-2.6-xen root=/dev/hda1 ro console=tty0
  module /boot/initrd-2.6-xen.img
  • Fix your glibc by doing this:
mv /lib/tls/ /lib/tls.disabled
  • Boot on the Xen option from Grub, and you already have a CentOS Dom0. Quite simple, wasn't it? :-)

Main problem: The Xen kernel you are booting sucks, because it supports no unusual hardware. So, it would be a good idea to hack a decent Xen-linux-kernel similar to CentOS unsupported one.

Now it's time to start toying with CentOS partitions, but they are supposed to be simple.

2005-10-25 14:48

vmysql: sql error[3]: MySQL server has gone away

Well, I am in the middle of migrating a rather large mail server, using qmail+vpopmail+mysql+courier-imap.

And just when it's starting into production usage, we find the error in the title.

A lot.

Sadly, since that error indicates a failed MySQL query, it means you get stuff like random auth failures. Which sucks a lot.

Googling gave a lot of hints. But nothing would fix it.

Until.... lucky strike.

So, I will put my solution here for future googlers.

If you see this:

vmysql: sql error[3]: MySQL server has gone away
vmysql: sql error[3]: MySQL server has gone away
vmysql: sql error[3]: MySQL server has gone away
vmysql: sql error[3]: MySQL server has gone away
vmysql: sql error[3]: MySQL server has gone away

Do the following:

  1. Check if you are exceeding mysql's max_connections parameter. The default is 100.
  2. Check if your cpu can take the load. (No, don't look at the load average. Look at the CPU usage).
  3. Make really sure that vpopmail and courier-authlib are built using the exact mysql you have installed. No, it doesn't matter if it's the same version. Go, and rebuild the things!

That fixed it for me.

On other bizarre news about this server, I have low CPU usage (95% idle), low IO (iostat reports under 1MB/sec, 40 tps), yet I have a load that can go up to 120.

Yet, interactive response is fine.


2005-10-18 00:46

A simple question

I was trying to do something weird: take one of my PyQt proggies, and compile it into a standalone binary using Jython, koala/qtjava and gjc.

Sadly, it doesn't work :-(

Has anyone ever gotten a rather recent gjc and jython to work together?

The best I can get is this:

System Message: ERROR/3 (<string>, line 9)

Cannot find pygments lexer for language "NULL"

.. code-block:: NULL

  [[email protected] jython]$ gcj -fjni /usr/lib/lib-org-*.so.* --classpath=/usr/java/j2sdk1.4.2_08/jre/lib/ --main=org.python.util.jython /usr/share/java/dom3-xerces-j2.jar /usr/share/java/ant.jar /usr/share/java/servlet.jar /usr/share/java/oro.jar /usr/share/java/jython.jar  -o jython
  org/apache/html/dom/HTMLAnchorElementImpl.java:0: error: cannot find file for class   org.w3c.dom.events.EventTarget
  org/apache/html/dom/HTMLAnchorElementImpl.java:0: error: cannot find file for class org.w3c.dom.TypeInfo
  org/apache/html/dom/HTMLAnchorElementImpl.java:0: error: cannot find file for class org.w3c.dom.html.HTMLElement
  org/apache/html/dom/HTMLAnchorElementImpl.java:0: error: cannot find file for class org.w3c.dom.html.HTMLAnchorElement
  org/apache/html/dom/HTMLAnchorElementImpl.class:0: confused by earlier errors, bailing out

This is using gcc-java-3.4.3-22.1 and jython-2.2-0.a0.2jpp

I mean, this is completely unnecessary, but it would be a nice hack :-)

2005-10-17 17:30

A *real* programming challenge.

A long time ago, I wrote a piece about how I didn't like kcalc. It contained a very lame pyqt script showing a (IMHO) nicer calculator. Strangely, that lead to two very cool implementations of the concept!

One of them was written in Ruby, the other one in C++. I think that has some potential.

A few months later, I wrote a spreadsheet based on the same concept. Also based on PyQt.

This StupidSheet has some conceptual problems. Like, if you want to import Excel sheets, you would have to rewrite basic in python, so it's not a practical program, but it is a rather nice example showing programming using dynamic languages.

In fact, I used it as such last week at CafeConf.

Now, here's the challenge. If people that know how to write Ruby or Java apps using Qt (or KDE, why not) could write a similar application, we all could write a comparative guide to Qt/KDE programming on different languages.

Since we would all be starting with a not-too-complex, but really non-trivial example, and we would all do the same one, it should be pretty unbiased.

In fact, if you think this example is biased, please propose another one, and do this thing anyway.

You can find StupidSheet here

It has some small bugs (try setting B1 to A1+1 with no value in A1 ;-) but they are easy to fix.

We could remove some features (like the weird pasting stuff) to make the example more didactic.

I hope this gets some answers :-)

2005-10-11 11:15

CafeConf 2005

Nuevamente este año voy a estar en CafeConf . Es una charla de 45 minutos sobre PyQt el 13 de octubre al mediodía.

La idea: La gente se sorprende cuando uno agarra KHTML, engancha un par de widgets y sale con un navegador web. Se deberian sorprender más de que uno puede partir de una receta de 20 líneas en una página web y terminar con una planilla que funciona ;-)

Por lo tanto, voy a mostrar StupidSheet como un ejemplo de que el desarrollo de software con interface gráfica es mas facil de lo que la gente cree.

Como siempre, si mencionás esta página, te ganás una cerveza. Máximo 2 cervezas, no muy buenas.

I will be at CafeConf again this year. It's a 45-minute thing about PyQt in October 13th, at noon.

My idea is: People are amazed when you hook Khtml to a couple of widgets and write a lame web browser. They should be more amazed that it is possible to start with nothing more than a 20-line recipe from a website and end with a functional spreadsheet ;-)

So, I will be showing StupidSheet as an example of how writing GUI software in Python is simpler than people think.

As usual, if you mention this page, you get a free beer, maximum 2 beers, and not very good beer.

2005-09-09 19:34

Authenticated Pages in CherryPy

CherryPy is a cool, pythonic, simple, quick, fun way to write web applications.

I often use CherryPy to write custom web admin tools for customers. Suppose you want to provide them with a simple way for password management. Usually I have the following requirements:

  • It must be simple ( not webmin )
  • It must not be a terminal session (bye ssh :-( )
  • It must not be a graphical session (sadly, that leaves out PyQt :-( )
  • It needs to do custom stuff: set the samba password at the same time, send a mail warning about the next forced change, whatever.

Someday I may be able to use a single-app freeNX session, but right now that's a bit too much problem for different reasons.

So, I wrote a CherryPy page. Over time, I have become quite fond of it, and wrote a bunch of small tools around it. One of them was a way to login the user into the site using the system's users and passwords. Now I got to throw it away :-)

The new CherryPy 2.1 has a mechanism for implementing password-protected pages, called the Session authenticate filter which is sadly not documented yet anywhere I can find.

So, here is my attempt, so people googling it up can use it. Excuse me:

cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter cherrypy sessionauthenticatefilter

That should do it :-)

What you need first is a function that takes a username and password, and returns None on success, or an error message for the failure.

For example, I can adapt something I wrote earlier using checkpassword-pam

def validPass(name,password):
                cmd='/usr/bin/checkpassword-pam -s xdm -- /bin/true 3<&0'
                print cmd,s
                if r==None: #Success
                        return None
        return "Login Incorrect"

Also, you may want a function that returns the login screen. If you do, remember the following:

  1. It must set the form action to doLogin
  2. The user field should be called login
  3. The password field should be called password
  4. You will take a fromPage argument that you should pass through, so the user will end on the page he wants.
  5. You will take a errorMsg argument which is probably the result of a failed previous login. Display it red or something like it. Unless it's empty, in which case it should not be visible.

Here's mine.

def loginScreen(fromPage, login = '', errorMsg = ''):
<form method="post" action="doLogin">
<div align=center>
        <span class=errormsg>%s</span><p>
        <table >
                <input type="text" name="login" value="%s" size="40"/>
        <input type="password" name="password" size="40"/>
        <input type="hidden" name="fromPage" value="%s"/>
        <td colspan=2 align=right>
        <input type="submit" value="Login" />
""" % (errorMsg, login, fromPage)
return renderTemplate(file='logintemplate.html')

Although I am using a template to display it nicely and with the right style, it should be pretty obvious how it works.

You could use the default login screen provided by the filter. While it works, it's just ugly.

Then you need to apply the filter to the set of your pass-protected pages. Suppose you want the whole site to be protected, except for your /static directory, which contains the stylesheet, images and such. Then you put this in your configuration file:



Next thing is to hook the session authenticate filter to your custom auth code. In your app, do the following. It seems that you can't do this in the config file, though, so do it in code.

            '/': {
                                    'sessionAuthenticateFilter.checkLoginAndPassword': validPass,

And that's it. Now your site is password protected. You can even have different authentication schemes for different pieces of the site, by resetting the hooks for the folder you prefer to a different function.

Also, I think this is a good example of why I like CherryPy. This mechanism is both flexible, powerful and simple.

2005-09-02 23:16

Small Linux Revisited

A Little History

Many moons (almost two years!) ago, I wrote an article called Small Linux detailing what I had done to make a reasonable Linux fit in a Toshiba Libretto 50.

That's a very limited notebook, with under 800MB of disk, a 75Mhz Pentium CPU and 16MB of RAM, and it has served me well for a long time.

Now, however, I am using the almost exact opposite, a second-hand Toshiba Satellite 1955-S805.

Where Salma (the Libretto) had a 640x480 screen, Monty (Toshiba), has a 16" 1280x1024. The RAM has increased 32 times. But they have one thing in common....

The 800MB HD

You see, Monty is second hand. My future mother-in-law and brother-in-law brought it from New York when they visited, for Rosario (My future wife, until February 18 2006 ;-).

And it had a broken HD. And I wanted to use it while I got a nice new 60GB one.

So, overcoming my fear of destroying expensive equipment, I got the HD out of Salma and into Monty, and started thinking....

The Tallest Guy In The World

He had a problem: really bad feet. He died of it, too. In the same way, Monty now booted, but the app selection was outdated, and really, lots of things Salma couldn't do, Monty could.

What on earth can one install on that disk when you don't have any other real hardware limitations?

The choice of distribution was tricky.

I am a CentOS guy lately, but the package selection is entangled enough that you can hardly get X installed without crossing the 800MB. The minimal install is about 450MB.

Debian again? Well... no.


Now, that has some serious potential, since I could run the OS from DVD/CD, and then use the whole 800MB for data. But I wanted something where I could choose what to install.

I could have gone the path of one of the modular Knoppix derivatives, but it was yet another task on the pile.

So, I went with.... ARCH.

ARCH Is Arch

Yes, ARCH is saucy. It installs in roughly 200MB, including kernel sources and GCC. That's quite small.

I managed to create a reasonable desktop in about 550MB, including:

A nice text editor
Needed it to work in a few proggies.
I have the RAM. The CPU is a 2.56 P4.
Xorg 8.2 with Nvidia drivers:
And just for kicks, 3ddesktop to see if they work ;-)
I know it, and it's nice enough.
Nicer than xterm, and has a handy SSH builtin.
ROX Filer:
Not really all that useful, but what the hell, for 3MB you get sidebars, a file manager and a few extra tricks.
A very nice xdm replacement. Specially with the mindlock theme :-)
Compress the exes. Save 30MB. Good.
It's what I am working with. And it's only 74KB.
Simple, small tool to set the X root decoration.
Stay synced with my older desktop.

All included, I am at 120 packages, using 557MB of disk (with extensive trimming, see the original article for some examples).

So, what's the difference between this set of apps and my previous choice....

Well, look at the result of free:

             total       used       free     shared    buffers     cached
Mem:        512544     408924     103620          0      33468     162916
-/+ buffers/cache:     212540     300004
Swap:            0          0          0

Just for laughs: here's the old one, when doing roughly the same things: editing an article, browsing the web, a few terminals:

                total    used    free    shared   buffers        cached
Mem:            14708   14144     564      4644       816          5304
-/+ buffers/cache:       8024    6684
Swap:           47992   18880   29112

Scary isn't it? I am using roughly 25 times the amount of memory I used on the libretto. It's easy to see why, tho.

Consider the desktop. It shows a pretty picture. It is 1280x1024. It is in millions of colors. That is in RAM. That is either 3932160 or 5242880 bytes. On the libretto, I was intentionally not using anything there :-)

So, it really is not comparable anyway, and Monty's life as a malformed box will be short. But it was quite a bit of fun :-)

2005-08-05 22:42


Just for the record, I have recently converted to Flying Spaghetti Monsterism.

More information here and there.

2005-08-04 21:27

Not letting stuff fall off the ' net

For a bunch of apps I write, I often want to be able to add a systray icon.

But... I write them using PyQt, and the systray stuff is in PyKDE.

But... Torsten Marek did write a module to do that. The only problem for me is the python-ctypes requirement, but it's no big deal for my apps that are not massively deployed.

You can find his code, in a somewhat mangled form, here

And since building extension modules is not completely trivial, here's a simple setup.py that will do it:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from distutils.core import setup
from distutils.extension import Extension

  name = "systray",
    Extension('traywin', ['traywin.c'],  libraries=["X11"],library_dirs=['/usr/X11R6/lib'])],

Put it in the same folder with his code, then you can do python setup.py install or somesuch, then you can use it in your app like in Torsten's systray2.py example, and it will work.

2005-08-02 19:17

Deployments and stuff

Have been reading the planets lately (I mean planetkde.org and planet.gnome.org, not astrology) and run into posts by Aaron Seigo and Luis Villa which are, let's say, interesting.

Luis' post took me to this page which is interesting too, and I would like to see something like it for KDE (and I am sure it is somewhere, but I can't seem to find it)

And I don't mean the page is interesting only for having Australia listed as an asian country ;-)

Some of the items talk about hundreds of thousands (or hundreds of millions) of desktops, and others talk about 11 seats.

Is there nothing in the middle, or is it just not reported?

I decided to put out another datapoint.

Here in Argentina, the best-selling OS has KDE as the default desktop. It's a Linux from Pixart , and is more or less what on other countries is sold as Xandros.

It seems Pixart made some development work for Corel, and then for Xandros when they bought the linux distro business. Their boss is the former (?) boss of Corel argentina, too.

Almost every whitebox clone is sold with one of their distros installed and preconfigured.

Oh, sure, most of them get wiped out and replaced with a stolen windows xp in 24 hours, but it's quite a number. Think 100K or 200K sold each year, at least.

Of some concern is that some of the GNOME deployments used to be KDE deployments. For example, the Sao Paulo telecentros used to be Conectiva boxes with KDE (and windows, in dualboot).

The City of Largo used KDE for quite a while.

But what the heck, we are both desktops squeezed into a ketchup bottle, there's a whole world outside to spread into ;-)

Contents © 2000-2019 Roberto Alsina