Feeds:
Posts
Comments

cmake / kdevelop 4

source http://math.lbl.gov/~deschamp/jpg/CMakeBanner.jpgi’ve converted the second project to use ‘cmake‘. this time an qt4 application which usually uses qmake.

i love cmake. it is easy to use (once you get used to the cmake of doing things). i love ‘out of source’ builds. kdevelop4 can handle cmake so i decided to move into the future and use cmake for my kdevelop4 projects as well. so far a very good decision.

i did have problems at first. using cmake with normal cpp/h files is easy and well documented but using it with moc|uic|rcc is different. i searched for help in irc.freenode.net#cmake and ‘Marc Bowes’ gave me a link [2] to his github.com project which uses cmake for a qt4 project – an excellent resource. looking at that code made my work easy.

in case you want to convert your qt4 applications from qmake to cmake see [1] and [2]. in general i recommend reading [3], [4] and [5].

i probably said enought about cmake but one more thing a kde developer told to me:

when using cmake with uic (when using qt4) one has to maintain a list of QObject deriving classes which are then processed by a macro called: ‘QT4_WRAP_UI’. He said when using cmake with kde4 projects cmake does this automagically. This sounds great – maybe someone ports that code over to the qt4 macro – would be nice!

So finally some words about kdevelop4. I loved kdevelop3 but refactoring was a pain with kdevelop3 – that changed with kdevelop4. The language parser and ‘auto completion‘ feature now works so well you don’t think of kdevelop4 as a normal editor with syntax highlighting but more as a fully automated code generator.

Kdevelop4 can now have several projects in one widget (in kdevelop3 i needed two instances – resulting in issues since starting the second instance usually would resume the project which was used at last so one would end up having two IDEs with the same project opened). Kdevelop4 has also support for several worksets – this is one of the best features. Currently i consider it the greatest c++ IDE i’ve ever used and i didn’t even mention ‘compile sets‘ yet…

[1]  http://github.com/qknight/springrts.com-random-map-generator

[2]  http://github.com/marcbowes/mxitc

[3] http://www.linux-magazin.de/Heft-Abo/Ausgaben/2007/02/Mal-ausspannen

[4] http://www-flc.desy.de/ldcoptimization/documents/talks/CMake_Tutorial.pdf

a new workstation

source hp.com

source hp.com

finally i bought a new workstation, a ‘hp elitebook 8530w‘. this is unusual since i prefer ‘ibm’ computers in genreal – but i could not find any ibm computer which was as powerful as this hp laptop featuring a nvidia card. my first impression of the hp was that it’s well designed and the fan wasn’t bad at all. altough the fan is not perfect but i can live with it. another far more important point is that it DOES NOT HAVE ANY ATI (AMD) COMPONENT IN IT which means: NO more suffering. instead it uses a nvidia graphics card:

$ lspci
01:00.0 VGA compatible controller: nVidia Corporation Device 065c (rev a1)

$ cat /var/log/Xorg.0.log | grep Quadro

(II) NVIDIA(0): NVIDIA GPU Quadro FX 770M (G96GL) at PCI:1:0:0 (GPU-0)

I did not install gentoo the usual way but instead i cloned the image from one of my desktop computers (which all happen to be intel c2c duos) with 64bit usage. So the installation was done in about 30minutes (with some help of [1]). i could not install gentoo right away since i considered ‘bouncing the purchase’. the hard drive can be removed easily and the way it is mounted to the laptop looks ‘rock solid’ (it is fixed by 3 screws). so next i attached my desktop hard drive with a usb adapter but grub could not load the kernel and it came up with the mystic error code “error 17″. soon i found out that the kernel needs to be in the first 1gb of disk space (or maybe 4gb? or 10gb?) i really don’t care. it was at about 120gib away from the first sector. so i removed the first partition (which wasn’t in use) and installed a 100mb partition with xfs and i copied the kernel there. now everything worked and i could test the computer without having any problems with that ‘windows vista’ i didn’t want to damage (else i would not be able to return the device). finally i removed windows vista after i found out that everything worked nice – which meant i would not return the device!

The only things which didn’t work then were:

  • lan 00:19.0 Ethernet controller: Intel Corporation 82567LM Gigabit Network Connection (rev 03)
  • wlan 03:00.0 Network controller: Intel Corporation Device 4236
  • webcam (don’t need that)
  • second mouse (touchpad – i don’t need that either)

suspend2ram works with the proprietary nvidia driver ‘x11-drivers/nvidia-drivers-185.18.36‘. why should i bother with this amd open  source crap if a nvidia driven pc works out of the box? using spring (springrts.com, game) i have about 280fps peak (in windowed mode) while compositing is running. kde runs at 60fps. one would not expect that – but it’s real!

the power drain using suspend2ram is about 0.6W!  the display 1920 x 1200 Pixels anti-glare and it is very good compared to my ‘thinkpad t43′ and it is excellent compared to my wifes mac book pro’s glare display. overall i’m so happy i didn’t buy a ‘mac book pro’ since i’d be running linux on it and i would expect more problems with a mac book pro running linux than this ‘hp elite book’ – i could be wrong though.

there was one problem. i usually protect my private data with some encryption -> luks and my static 32bit initrd didn’t work anymore since cryptsetup segfaulted on boot. so i had to create a new initrd image which didn’t work at all. i really don’t know why. maybe init couldn’t be loaded because busybox (although linked statically) couldn’t find init. so i thought about giving up and do the installation without luks support – and just in that moment eliasp (a friend of mine) mentioned to me that he usually uses genkernel for doing that.

so i tried that (not expecting genkernel to be able to help me). i simply couldn’t imagine that someone wrote support for a lvm inside a luks-image which means:

  • /dev/sda3 is a luks volume which is first opened with cryptsetup luksOpen and
  • afterwards the decrypted partition can be interpreted as lvm vg in ‘/dev/vg/’.

but i was wrong with my assumption – the initrd image produced by genkernel worked out of the box, all i needed to do was issuing:

genkernel –lvm2 –luks ramdisk

I have a more detailed installation guide at [2].

To sum up: this device is a dream and if you should consider buying a laptop consider this one!

[1] http://en.gentoo-wiki.com/wiki/HP_Elitebook_8530w

[2] http://lastlog.de/wiki/index.php/Festplatte_verschluesseln (german only)

--[[
When this widget is enabled, air transports guarding factories will
automatically take new units built at the factory to the destination of the factory
--]]

function widget:GetInfo()
  return {
    name      = "Transportation Assister",
    desc      = "Transports guarding factories will automatically move new units",
    author    = "Ray",
    date      = "Feb 18, 2007",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = false
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

include("spring.h.lua")

function widget:Initialize()
	local _, _, spec = Spring.GetPlayerInfo(Spring.GetMyPlayerID())
	if spec then
		widgetHandler:RemoveWidget()
		return false
	end
end

function widget:UnitFromFactory(unitID, unitDefID, unitTeam, factID, factDefID, userOrders)
	if unitTeam ~= Spring.GetMyTeamID() then return end

	local cQueue = Spring.GetCommandQueue(factID)
	local UD = UnitDefs[Spring.GetUnitDefID(unitID)]
	local transID = null
	if not UD.springCategories["notair"] or not UD.springCategories["notship"] then return end
	for _, elem in ipairs(cQueue) do
		if elem.id ~= CMD_MOVE then
			return
		end
	end

	transID = IdleTransport(factID)
	if transID ~= null then
		MoveUnit(unitID, factID)
		TransportUnit(unitID, transID, factID)
	end

end

function TransportUnit(unitID, transID, factID)
	local transCQueue = Spring.GetCommandQueue(transID)
	local params = {}
	local newParams
	local tries = 0
	if table.getn(transCQueue) > 2 then
		Spring.GiveOrderToUnit(transID, CMD_GUARD, {factID}, {"shift"})
		Spring.GiveOrderToUnit(transID, CMD_LOAD_UNITS, {unitID}, {"shift"})
	else
		Spring.GiveOrderToUnit(transID, CMD_LOAD_UNITS, {unitID}, {""})
	end
	local fCQueue = Spring.GetCommandQueue(factID)

	local UD = UnitDefs[Spring.GetUnitDefID(transID)]

	for num, elem in ipairs(fCQueue) do
		params = elem.params
		newParams = params
		while OverOldCmd(transID, newParams) and tries < 20 do
			newParams = {params[1] + math.random(1,100), params[2], params[3] + math.random(1,100)}
			tries = tries + 1
		end
		if num ~= table.getn(fCQueue) then
			Spring.GiveOrderToUnit(transID, CMD_MOVE, newParams, {"shift"})
		else
			Spring.GiveOrderToUnit(transID, CMD_UNLOAD_UNIT, newParams, {"shift"})
		end
	end
	Spring.GiveOrderToUnit(transID, CMD_STOP, {}, {"shift"})

	Spring.GiveOrderToUnit(transID, CMD_GUARD, {factID}, {"shift"})

end

function OverOldCmd(unitID, params)
	local cQueue = Spring.GetCommandQueue(unitID)
	local nParams
	for _, elem in ipairs(cQueue) do

		if elem.id == CMD_MOVE or elem.id == CMD_UNLOAD_UNIT then
			nParams = elem.params
			if nParams[1] > params[1] - 30 and nParams[1] < params[1] + 30 then
				if nParams[3] > params[3] - 30 and nParams[3] < params[3] + 30 then
					return true
				end
			end
		end
	end
	return false
end

function MoveUnit(unitID, factID)
	local fX, fY, fZ = Spring.GetUnitPosition(factID)
	local bF = Spring.GetUnitBuildFacing(factID)
	local xAdd
	local yAdd
	if bF == 0 then
		xAdd = 0
		yAdd = 70
	elseif bF == 1 then
		xAdd = 70
		yAdd = 0
	elseif bF == 2 then
		xAdd = 0
		yAdd = -70
	else
		xAdd = -70
		yAdd = 0
	end
	Spring.GiveOrderToUnit(unitID, CMD_MOVE, {fX + xAdd, fY, fZ + yAdd} , {""})

end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function IdleTransport(factID)
	local cQueue
	local leastQCount
	local idleTrans = null
	local lastCmd
	local uList = Spring.GetTeamUnits(Spring.GetMyTeamID())
	local leastDist = null
	for _, ID in ipairs(uList) do -- cycle through every unit
		UD = UnitDefs[Spring.GetUnitDefID(ID)]
		if UD.isTransport then
			cQueue = Spring.GetCommandQueue(ID)
			lastCmd = table.getn(cQueue)

			if (lastCmd > 0 and cQueue[lastCmd].id == CMD_GUARD and cQueue[lastCmd].params[1] == factID) or (lastCmd > 1 and cQueue[lastCmd-1].id == CMD_GUARD and cQueue[lastCmd-1].params[1] == factID) then

				if idleTrans ~= null then
					if table.getn(Spring.GetCommandQueue(ID)) < table.getn(Spring.GetCommandQueue(idleTrans)) then
						leastQCount = table.getn(Spring.GetCommandQueue(ID))
						idleTrans = ID
					end
				else
					leastQCount = table.getn(Spring.GetCommandQueue(ID))
					idleTrans = ID
				end
			end

		end
	end

	if idleTrans == null then
		return null
	end

	for _, ID in ipairs(uList) do -- cycle through every unit
		UD = UnitDefs[Spring.GetUnitDefID(ID)]
		if UD.isTransport then
			cQueue = Spring.GetCommandQueue(ID)
			lastCmd = table.getn(cQueue)

			if (lastCmd > 0 and cQueue[lastCmd].id == CMD_GUARD and cQueue[lastCmd].params[1] == factID) or (lastCmd > 1 and (cQueue[lastCmd-1].id == CMD_GUARD and cQueue[lastCmd-1].params[1] == factID)) then
				if lastCmd == leastQCount or lastCmd == leastQCount + 1 then
					if leastDist ~= null then
						if DistFromFac(ID, factID) < leastDist then
							leastDist = DistFromFac(ID, factID)
							idleTrans = ID
						end
					else
						leastDist = DistFromFac(ID, factID)
						idleTrans = ID
					end
				end
			end
		end
	end

	return idleTrans

end

function DistFromFac(transID, factID)

	local uX, uY, uZ = Spring.GetUnitPosition(transID)
	local fX, fY, fZ = Spring.GetUnitPosition(factID)
    return math.sqrt((uX - fX)^2 + (uZ - fZ)^2)

end

function echo(msg)
  Spring.SendCommands({"echo " .. msg})
end

cmake and doxygen

i’ve just rewrote a library called libnoise to use cmake (instead of static Makefiles/libtool). i have to admit that cmake is probably the best buildsystem i’ve ever used. cmake does so many things better than others – but you probably know that already so i will focus on different things.

i had lot’s of problems using doxygen with an ‘out of source’ build. but i finally fixed that. i consider my hack an excellent example of how to use doxygen with cmake. the first thing i tried was hacking on [2], a posting from “Philippe Poilbarbe” (i don’t know this developer) which i couldn’t get running at first. exhausted i tried something else (for those who are interested, it was [3] a mail about a library called ‘libLASi’ using doxygen together with cmake (see [4] for libLASi). now happy to get doxygen working the ‘libLASi way’ at least  i decided to branch back to my first attempt which was [2].  finally i got that working, too. so [2] is the basis for this posting – keep that in mind.

i don’t like the way doxygen is integrated in cmake by the ‘libLASi’ developers. why?

because they write to the source directory (called ‘in source build‘) and this is not how cmake developers (that is those who wrote cmake)  consider stuff to be done right.

if you ever have to use doxygen with cmake you should look at my code [2]. it will compile on linux (probably unix in general) and all you need is a g++ compiler and doxygen installed.

in general to adapt the cmake/doxygen from any other build system keep this in mind:

  • the “Doxygen” file most often static will be rewritten (then called “Doxygen.in“) and some placeholders are inserted as:
    PROJECT_NUMBER         = @LIBNOISE_VERSION@
  • in general one could say “Doxygen.in” needs some adaption to receive cmake variables contents as i already wrote in the libnoise sourcecode (see quote below)
  • the cmake script called: CMakeLists.txt dealing with the docu (doxygen) will then replace this placeholders on the fly – that is when executing ‘cmake .
  • nearly all variables (i can’t think of any which would not work but i didn’t check them either) can be modified this way
  • one variable is replaced by a REGEXP (see quote below as well)

# you could also set the version with this, see Doxygen.in
# there you will find a line like this:
#      PROJECT_NUMBER         = @LIBNOISE_VERSION@
# @LIBNOISE_VERSION@ is then replaced by our global LIBNOISE_VERSION
#
# for instance you could uncomment the next 3 lines and change the version for testing
# SET(LIBNOISE_VERSION
#     “1.2.3-foo500″
# )

# doxygen can reference external images with IMAGE_PATH, this is how we set it dynamically
SET( CMAKE_DOXYGEN_IMAGE_PATH
“${CMAKE_CURRENT_SOURCE_DIR}/img”
)

# doxygen searches for source code (defined in FILE_PATTERNS, for example: *.cpp *.h)
# with DOXYGEN_SOURCE_DIR we fill a list of directories and later we write it into
# the Doxyfile with a REGEX REPLACE (see below)
SET( DOXYGEN_SOURCE_DIR
${CMAKE_SOURCE_DIR}
)

SET(DOXYGEN_OUTPUT_DIR html)
STRING(REGEX REPLACE “;” ” ” CMAKE_DOXYGEN_INPUT_LIST “${DOXYGEN_SOURCE_DIR}”)
CONFIGURE_FILE(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
SET(HTML_TARGET “html” )
ADD_CUSTOM_TARGET(${HTML_TARGET} ALL
/usr/bin/doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
INSTALL( DIRECTORY “${CMAKE_CURRENT_BINARY_DIR}/html/” DESTINATION “/usr/share/doc/libnoise-${LIBNOISE_VERSION}” )

  • it is very important to understand what ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} are used for

i hope you won’t loose as much time as i did figuring this out.

finally: thanks very much for help from straszheim#cmake@irc.freenode.net (general cmake questions, nothing doxygen related) and thanks to the example at [5] but it wasn’t very helpful since i didn’t understand it – nice try, maybe next time! ;-)

[1] http://github.com/qknight/libnoise

[2] http://www.cmake.org/pipermail/cmake/2006-August/010794.html

[3] http://marc.info/?l=cmake&m=119868994732284&w=2

[4] http://lasi.svn.sourceforge.net/viewvc/lasi/trunk/

[5] http://tobias.rautenkranz.ch/cmake/doxygen/

UPDATE(30Nov09): replaced static path with ${CMAKE_SOURCE_DIR} in the quoted script above

I’ve released nNull, please see [1] as official page and find the source at [2].

Some words on the release:

  • you can use this client/server to execute any kind of script, not only network scripts (might be handy for other things as well)
  • qt4.5+/dbus/GPLv3
  • nNull-server is a console qt program (uses no gui)
  • nNull-client is a normal QWidget with a systray icon, the icon has a context menu

http://www.lastlog.de/wiki/index.php/NNull

http://github.com/qknight/nNull

maybe someone likes it? if so, please drop me a mail ;-)

n0 – netw0rk manager

I’ve just finished my own ‘network manager‘ (called n0 or nNull) using Qt 4.x with a server and a client communicating via dbus. Here are some screenshots:

netw0rk manager - n0 - dbus client

 

netw0rk manager - n0 - showing the debug console

netw0rk manager - n0 - showing the debug console

netw0rk manager - n0 - server instance output

netw0rk manager - n0 - server instance output

 

I will release the source code along the terms of the GPLv3 in the coming days.

Let’s see how it works: similar to the official ‘network manager‘ there is a tray icon. In the case of ‘n0‘ or ‘nNull‘ there is just a collection of scripts listed. These scripts are handwritten by me and usually work great for my setups. If I want to change the wireless network it gets problematic since i have to edit wpa_supplicant.conf or  use wpa_cli. Anyway I can live with that. Here is such a script:

#!/bin/bash -v
killall dhcpcd
if [ -f /var/run/dhcpcd-ath0.pid ]; then
rm /var/run/dhcpcd-ath0.pid
fi
killall wpa_supplicant
killall vpnc
ifconfig br0 down
ifconfig ath0 down
ifconfig eth0 down
brctl delif br0 ath0
brctl delif br0 eth0
brctl delbr br0
ip l set vbox0 down
brctl delbr vbox0
brctl addbr vbox0
ip l set vbox0 up
ip a a 10.0.2.10/24 dev vbox0
rmmod ath5k
modprobe ath5k
#iw reg set DE
sleep 1
ifconfig ath0 up
wpa_supplicant -dd -D wext -i ath0 -c /etc/wpa_supplicant.conf > /root/config/logs/abc-stdout 2> /root/config/logs/abc-stderr &
route del default
iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
ethtool -s eth0 speed 100
dhcpcd ath0
#dhclient ath0
cp /etc/resolv.conf /etc/resolv.conf.dnsmasq
echo “nameserver 127.0.0.1″ > /etc/resolv.conf
ifconfig eth0 10.0.0.1/24 up
dhcpd eth0

The bonus point is that I get a full blown log of the script execution since it uses “#!/bin/bash -v” which is quite verbose. In the near future i might add another debug line to monitor each process started by the network script. This way one could redirect all outputs to the graphical widget with different coloring for example.

I use dbus to execute scripts. For example when I want to connect to one of the two networks I’m frequently using I usually press Fn+F9 for the first network and Fn+F10 for the second network. These shortcuts are defined by /etc/acpi/default.sh and execute this command:

exec qdbus –system de.lastlog.nmInterface /MainApplication executeConfiguration /root/config/internetlab-ath0

This way the local ‘server backend‘ uses dbus to log the output to the attached gui process as seen above. No more ‘hidden script‘ action. This system is not perfect but it’s a good starting point for me for doing further experimentation.

Using software raids on linux ‘mdadm‘ is problematic if you hit a ‘power outage’. Using a single device without a ’software raid’ is not a problem since it uses a journal – ext3++/xfs for instance are quite stable in this regard. This is probably also true when using LVM – the ‘logical volume manager’ (but don’t quote me there, my LVM ‘use case’ might differ from yours).

Using the same filesystems with a software raid makes the ‘journal’ useless, see [1] and [2]. Let’s quote [2]:

Power Loss and Ensuing Data Corruption
Many beginners think that they can test RAID by starting a disk-access intensive job, and then unplugging the power while it is running. This is usually guaranteed to cause some kind of data corruption, and RAID does nothing to prevent it or to recover the resulting lost data. This kind of data corruption/loss can be avoided by using a journaling file system, and/or a journaling database server (to avoid data loss in a running SQL server when the system goes down). In discussions of journaling, there are typically two types of protection that can be offered: journaled meta-data, and journaled (user’s) data. The term “meta-data” refers to the file name, the file owner, creation date, permissions, etc., whereas “data” is that actual contents of the file. By journaling the meta-data, a journaling file system can guarantee fast system boot times, by avoiding long integrity checks during boot. However, journaling the meta-data does not prevent the contents of the file from getting scrambled. Note that most journaling file systems journal only the meta-data, and not the data. (Ext3fs can be made to journal data, but at a tremendous performance loss). Note that databases have their own unique ways of guaranteeing data integrity in the face of power loss or system crash.

Normally one would use a ‘UPS’ to shut down the system properly. But looking at my two c2c intel archs and my 32bit intel laptop, I wonder how long this scenario will remain to be a ‘default’.

I’d expect suspend2ram or suspend2disk becoming a new way doing things better. Say the power outage is just 3minutes. Your suspend2ram takes 5secs, resume 7secs some users might not even notice your system was down.

But if the power outage was say 1-3hours and the system consumes 3W of power you would need no powerful system. Say you use suspend2disk by default you can completely shutdown the system. A battery would have to stand the peak power usage of 130W for about 7 secs (this is just a guess, say c2c processor, several network cards, 4 3,5″ harddrives (10W) each.

I have two low power gentoo fileservers, both need less than 35W and both use a different technology.

  • VIA board with a VIA Nehemiah processor (tested using 2.6.24-tuxonice-r4)
  • Intel board with Intel(R) Atom(TM) (untested)

The VIA board was already tested for support of suspend2ram/suspend2disk with great success(and I don’t mean standby). I did not test the Intel board, but I’d expect it to work as well. You might wonder why I tested suspend2disk in the first place – this was not to check for power outage capabilities! I usually have no screen attached to the computer and it is located in a very uncomfortable location. When something goes wrong – for example I shut down the network by fault and I don’t want to shut down the system I can suspend2disk this machine pressing the power button.  Next I pick that box up and put it on a desk and resume it with a screen attached. This works fine – trust me on that.

On the other hand I don’t use a ‘software raid‘ in these systems so ‘a power fail is not a problem at all‘. I just wanted to bring up the idea – maybe someone already uses this the way I proposed?!

[1] http://tldp.org/HOWTO/Software-RAID-0.4x-HOWTO-4.html

[2] http://linas.org/linux/raid.html

recently i updated my gentoo box. the computer is a c2c processor with a fast nvidia graphics card. but what is cool about that “you” wonder?

gentoo linux logo (copied from commons.wikipedia.org)

gentoo

actually the new portage kde 4.3.3 seems to be very stable (read usable) for me. the proprietary graphics driver nvidia.ko is doing great! i use suspend2ram about 10 times a day. i leave the pc in suspend2ram for days and it only needs 3W of power! suspend2ram needs 2-3 secs for going down and about 7 secs to come back up! plasma is now at a point that i see it is going to be useful. the expose clone of the kde folks is very very nice to use. dragon player seems to get stable so i can use it with the smb:// kio plugin to watch films from my server. firefox64 selfcompiled now uses a 64bit flash plugin. and finally nearly all applications i’m using regularly work like a charm, which include:

  • firefox (even watching flash films, fullscreen still stutters but then usually once can do: mplayer -fs /tmp/FlashAVE3 (name is somehow similar)
  • very fast 3d support (nvidia i love you!) in kde and in fullscreen games as well as normal 2d acceleration for movies
  • that said, the new kde desktop effects are the best user experience i’ve had for years now (i didn’t test vista/win7) but mac os x
  • sound seems to be working now. to be honest i don’t understand why (didn’t test skype tough)
  • the game ’spring’ runs with 280fps on my computer (that is a peak value of course) but then with medium details on a map with 5on5 (10 kaik ais) it still seems to be no problem to get decent 60fps!

to conclude: i’m very happy especially since this suspend2ram thing now works. both pcs (i just cloned the gentoo image from the first pc) did work with the same settings altough both use different hardware.

that is really really cool!

currently i’m looking forward getting:

  • into kdevelop 3.9.95
  • akonadi: using a backend !google for pim (i don’t have a google calender nor do i use google mail)
  • getting rid of my laptop with this awful radeon r300 card, i’ll probably buy a “hp elite” with a nvidia card and a 6mb L2 cache (c2c cpu)

to all gentoo readers out there: i love this distribution so much since portage is doing well and the update (although taking long) was a great success.

UPDATE: i forgot to feature the graphics card i use: it is a ‘Gigabyte GeForce 9600 GT Passiv 512MB for 83,90 euro’ (20 nov 2009) which is as silent as you can imagine: 0 dB

t43 radeon x300Switching on external monitors works now. Most of the time with success (except some VGA monitors when using the wrong x and y dimensions or wrong Hz. It stopped working lately – now I found out why (I bought a dock which enables the use of DVI)!

The Radeon X300 seems to have ‘two crtc‘ interfaces only. And one is always used when the LVDS (laptop builtin display) is enabled (in use). So one is left. Since i use DVI-0 on one workplace and VGA-0 on the other i usually was forced to reset X to make things work, since i wasn’t aware of the resource limitation. The error which came up was:

% xrandr –auto –output VGA-0 –mode 1024×768
xrandr: cannot find crtc for output VGA-0

The solution is easy. Just disable (in this case) DVI-0 output. Next enable VGA-0 output again.

xrandr –output DVI-0 –off
xrandr –auto –output VGA-0 –mode 1280×1024 –right-of LVDS

Usability wise this problem is a result of a missing resource counter (maybe it exists) but still the interface ‘xrandr’ was not very helpful in diagnosing the issue. I would have expected an error message as:

xrandr: no free crct for output VGA-0 left. you can only enable two devices at a time, maybe disable one to enable the other.

lspci shows:

  • 00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
  • 01:00.0 VGA compatible controller: ATI Technologies Inc M22 [Mobility Radeon X300]
  • 00:01.0 PCI bridge: Intel Corporation Mobile 915GM/PM Express PCI Express Root Port (rev 03)

Thanks to:

http://lists.freedesktop.org/archives/xorg/2007-August/027490.html

NetworkManager

network management on linux differs from distro to distro. trying various of these i liked what SuSE did over the year. they included a network manager like applet ‘knetwork’ with kde 3 which even included isdn (ppp) links.

gentoo has it’s own network configuration which is quite static using /etc/conf.d/net. i use this for static setups but i’ve written my own scripts for my laptop (aka desktop) machine. just one example:

wpa_supplicant_generic_dhcp_ath0
#!/bin/bash -v
echo “sh /root/config/wpa_supplicant_generic_dhcp_ath0″ > /root/last-lan.sh
if [ -f /var/run/dhcpcd-ath0.pid ]; then
rm /var/run/dhcpcd-ath0.pid
fi
killall dhcpcd
killall wpa_supplicant
killall vpnc
ifconfig br0 down
ifconfig ath0 down
ifconfig eth0 down
brctl delif br0 ath0
brctl delif br0 eth0
brctl delbr br0

rmmod ath5k
modprobe ath5k
#iw reg set EU #does not work
sleep 1
ifconfig ath0 up
wpa_supplicant -B -dd -D wext -i ath0 -c /etc/wpa_supplicant.conf
route del default
#dhcpcd ath0
iptables -t nat -A POSTROUTING -o ath0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

ethtool -s eth0 speed 100
dhcpcd ath0
#dhclient ath0

cp /etc/resolv.conf /etc/resolv.conf.dnsmasq
echo “nameserver 127.0.0.1″ > /etc/resolv.conf
ifconfig eth0 10.0.0.1/24 up
dhcpd eth0

although my scripts work very well (even when i restart my computer the last script is automatically run from /etc/init.d/local) this setup has it drawbacks in usability.

benefits:

  • starts a dhcpd instance, so my  laptop acts as a dhcp server (not included)
  • my local dnsmasq installation can be accessed from the eth0 subnet
  • setup for eth0 is automatically made & routing is enabled by default
  • i can adapt to new networks quite fast with yet another config file instantiation
  • once bridging is working for eth0|ath0 i can increase usability since i can transparently use either wireless lan or ethernet, say for backups the later might be much faster without having to kill all connections. (not included)

drawbacks:

  • although networks using none|wpa1|wpa2 it tends to have problems with vpn (i wrote another script)
  • it lacks usability, no monitoring what happens (in case of an issue i run it on a shell)
  • on bad connections with wifi the dhcp step fails quite some times, running the script again will result in (loss of time)
  • it reloads the wireless lan driver (helpful when i was using kismet for finding new networks), still this might not be necessary all the time (loss of time)
  • bad in regards to hot plugging (and therefore automation) after inserting a wireless lan usb stick (or similar)
  • my scripts require a static interface naming scheme, gentoo provides this by default:
    /etc/udev/rules.d/70-persistent-net.rules

i considered NetworkManager (NM). i like most of it’s technology as for instance the DBUS interface it uses is probably the best way one could implement something like NM. i also like the integration into gentoo but this came pretty late (ubuntu was the first distro which had quite acceptable NM support).

but NM does a very bad job if things don’t work. there is no debugging possible. example:

  • NM using WPA2 needs to create a wpa_supplicant.conf on the fly before executing wpa_supplicant. i did not find any way to see this file anywhere
  • NM won’t help me to see wpa_supplicant errors
  • NM will show the signal power if i’m connected to a certain network. this is limited to one interface in general. what about several wifi cards? what about bluetooth links?
  • NM lacks a graphical interface (or any interface at all) for debugging what is going on

this made me think about network and interface usage in general. i’m using many tools for years now as:

  • ip – for ipv4/ipv6 interface configuration & routing
  • dhcpcd/dhclient (managing dhcp address automation)
  • wpa_supplicant (wpa|wpa2|EAP)
  • vpnc (instead of cisco vpn)
  • dns (resolv.conf / dnsmasq) (openresolv is on the agenda, didn’t have time yet)

but these tools although relying on each other are monolithic and static software monsters. if one wants to understand what networks are all about it is one thing: dynamics in every aspect

the next graph shows a ‘network grammar’ which describes the possible dependencies or how one can stack various programs:

network grammer

but on ‘run time‘ you will end up in a ‘state graph‘ with every application somehow connected to others in various ways. states are also triggered on timeouts (for example when the ‘dhcp serverwasn’t accessible by the local dhclient one is forced to take action). now let’s look how the grammar applies on ‘run time’:

network state graph

the two previous graphics also demonstrate the stacking capabilities. looking at the grammar makes this obvious. (the grammar and the flow graph are far from complete but illustrate the basic concept).

  • if someone types ‘ip l set eth0 down‘ all connections regarding eth0 as source or target are removed as well es default or specialized routes over (through) that interfaces are dropped without being restored on ‘ip l set eth0 up’.
    example
    # ip l set eth0 up
    # tcpdump -i eth0 &
    [1] 5866
    listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
    # ip l set eth0 down
    tcpdump: pcap_loop: recvfrom: Network is down
    0 packets captured
    0 packets received by filter
    0 packets dropped by kernel
    [1]  + exit 1     tcpdump -i eth0
    HINT: dhclient for instance keeps running if the interface goes down
    HINT: ssh only detaches the eth0 interface from being used and on up reattaches it
    SOURCE: equery b ip -> sys-apps/iproute2-2.6.28 (/sbin/ip)
    iproute2-2.6.28::iplink.c shows:
    } else if (strcmp(*argv, “down”) == 0) {
    req->i.ifi_change |= IFF_UP;
    req->i.ifi_flags &= ~IFF_UP;

    this triggers the kernel in some way which then signals the change to every process using this interface.

  • in a state graph every object can perform an action considered best suited by the affected object. this helps to delegate some jobs to daemons (for example dhcpd) but every object affects the ‘state machine
  • the protocol for interaction is DBUS (there is a wpa_supplicant dbus interface, as well as one for dhcpclient usage)

maybe this idea inspires someone to rewrite NM with usability (in the sense of automation and debugging feedback) in mind. i think NM is on the right track already.

NM should:

  • show the connection state: either layer1 connection/layer2 connection/layer 3 connection
  • link quality per interface (wlan/bluetooth)network-meter
  • have a debug console which can be triggered
  • should have a ‘in detail’ network information dialog
    network information
  • should generate a wpa_supplicant.conf which can be viewed (so that one can see what the on-the-fly config file generator has created)
  • should pipe the output of all involved processes to a debug line, so that one can sort output per process with a global time line
  • regarding the ‘grammar’ above one can think of a ‘pyramid of services‘. if one of the services in the middle fails all above have to be restarted (or at least signaled on change). say vpnc fails, we need to reconnect it with all the things one has to do -> removing the current route, reset a new one (probably the same) and prior to that we have to reconnect as soon as the service is known to fail. vpnc for example fails quite some times since.
    this ‘pyramid of services’ should be visible to the user and a user ‘must have’ the possibility to see the status of every ‘floor’ in this pyramid. if layer 3 connection is working, l3 must light up. if a user wants to restart all services above layer 3 there must be a ‘restart all services above’ button. currently in NM one has to do all the steps from bottom up.

Since I am using a ATI Radeon “R300″ card, that is a card with a very poor written driver (at least for linux) I’m facing frequent X-Crashes or I am forced to restart X on ‘hot plugging‘ of external displays.Yes ‘hot plugging’ does sometimes work, sometimes not.

Since I’m also admin of several servers I’m also faced to the fact that ssh can not resume a disconnected session – that is since the session (OSI-model, layer 5, see [1]) isn’t implemented the layer 4 connection is associated as session instead.  That is a common among many programs used today – either surfing the internet or the local network. However the consequence is that once the connection is down it is unlikely to be resumed even though socket is still open on both server and client while the ip has not changed – a simple tcp timeout on one end can reset the connection.

If such a session is broken the result is that all started processes (which can be many, since they can be run in the background with the & operator) are closed immediately. For some operations as “mv dir1 dir2/” this can be fatal. Since this will result in inconsistencies most of the times.

The mainstream solution to this problem is using a program called “screen”. This “screen” has many features which make it a program worth knowing – even for local use, see [2] for screen commands I’m frequently using.

'konsole' hosting 'screen'

So back to the topic of this posting the issue with the bad R300 driver and X session resets.

The issue here is:

  • once the X server goes down my music I’m currently listening is also going down
  • all my ‘konsole’ consoles are killed (which can be plenty)
  • all my programs which use X (no wonder) are also gone

I would like to have ‘konsle’ to use a screen on every new ‘konsole tab’ I create. Or since screen itself can nest several consoles in one screen instance (that is one process) – why not start a single screen and attach the ‘konsole’ session to this screen. When a second tab is opened the second tab is automatically adding a new screen tab as well.

Once X goes down all processes are exited as already known – except screen. ‘Screen’ does not react to SIGTERM - it just keeps running. Later when you started into a new ‘X session’ you can open any console as for example ‘xterm’ or ‘konsole’ and with ’screen -r’ you can resume your session.

Now imagine ‘konsole’ to do this wrapping automatically. I could live with a toggle to switch the associated console back and forth between ‘session‘ behavior and ‘pervasive‘ behavior.

UPDATE: Think of this ’screen in konsole’ as you are already used to with firefox’s multiple tabs when doing store/restore after logout/login. (not reboot of course since our screen instances are useless after reboot).

This would be an incredible feature for ‘konsole’.

[1] http://en.wikipedia.org/wiki/OSI_model

[2] http://lastlog.de/wiki/index.php/Screenbefehle

[3] http://defindit.com/readme_files/bash_examples.html

UPDATE: ‘eliasp’ just told me to edit the ‘konsole’ profile with Settings->Manage current profile. Setting the command to “screen /bin/zsh” instead of “/bin/zsh” at least creates screen consoles on every new ‘konsole’ tab opened. I love this workaround but konsole should also resume. Consider a X crash now, after relaunch of kde I open just new ’screens’ instead of attache them.

UPDATE: ‘eliasp’ also mentioned [3]. I once tried to start ’screen’ on my internet server on login. The problem doing so is not recognized when using ’ssh’ but it will stop ’scp’ from working. Using [3] one can also detect “Disable xon/xoff and interactive login” when running screen on the remote side. This probably helps to circumvent the scp issue. Maybe once can also detect a running instance of ’screen’ and reattache with ’screen -dr’ or something alike.

I thank ‘eliasp’ for his feedback.

UPDATE: the proposal was accepted: http://forum.kde.org/brainstorm.php#idea83059

UPDATE: (2009-11-12) https://launchpad.net/byobu seems to do things as expected. I have not tested this yet but a friend of mine reported that.

Older Posts »