+ 6 - 4 | § ¶Linux Power Management
I must admit, Linux Power Management is Fuckin' Pathetic.
On a Dell XPS M1210 Laptop with a 6 Cell battery, I get a shitty 15 mins of power backup compared to 2 hrs on Microsoft Windows XP.
And woo, On my IBM T43 running Microsoft Windows XP, I watched a full movie on battery, and it still survived.
The Linux running laptop had no sound enabled.
Yes, Yes Yes!!! As many would say
- I wouldn't have rolled out a kernel optimized for my machine
- I should have run a lightweight window manager like FVWM (not KDE)
- I should have not used binary only drivers
- And many more reasons...........
But hey, Microsoft Windows XP has that too:
- It was playing a full movie under VLC (2+ hrs)
- It used the laptop's in-built speakers
- It had the antivirus software and others running.
Keywords: linux_power_management_pathetic
+ 6 - 3 | § ¶ANSI Color Codes
So in the search of finding a simple solution for printing colored text in python, it took me some time to dig up. Most solutions people have done were using curses or some modules. My ultimate intention has always been to cut down on the dependency on the 3rd party modules.
I think the ANSI Color Codes would be good enough for my requirements to print colored text on an ANSI compliant terminal.
The ANSI Terminal Specification gives programs the ability to change the text color or background color.
An ansi code begins with the ESC character [^ (ascii 27) followed by a number (or 2 or more separated by a semicolon) and a letter.
In the case of colour codes, the trailing letter is "m"...
So as an example, we have ESC[31m ... this will change the foreground colour to red.
The codes are as follows:
For Foreground Colors
1m - Hicolour (bold) mode
4m - Underline (doesn't seem to work)
5m - BLINK!!
8m - Hidden (same colour as bg)
30m - Black
31m - Red
32m - Green
33m - Yellow
34m - Blue
35m - Magenta
36m - Cyan
37m - White
For Background Colors
40m - Change Background to Black
41m - Red
42m - Green
43m - Yellow
44m - Blue
45m - Magenta
46m - Cyan
47m - White
7m - Change to Black text on a White bg
0m - Turn off all attributes.
Now for example, say I wanted blinking, yellow text on a magenta background... I'd type ESC[45;33;5m
This isn't a complete list of features provided by the ANSI Codes. There are many more....
Keywords: ansi_color_pypt_offline_terminal_command_interpreter
+ 8 - 1 | § ¶Networking in KVM/QEMU
In my previous blog entry, I mentioned about not being able to simply configured networking for the Guest VMs. I feel that area is still unimplemented properly by the GUI wrappers available for KVM/QEMU.
There is a good utility VDE2, which can work great for all your networking needs for the Guest VMs. But unfortunately none of the GUI wrappers (Qemulator, QtEmu, Qlauncher) are handling it.
The simplicity of vde is amazing. Here's what all you need to do:
iface tap0eth2 inet static
address 172.16.1.1
netmask 255.255.0.0
network 172.16.1.0
broadcast 172.16.1.255
vde2-switch -
#tunctl_user uml-net
pre-up /sbin/iptables -t nat -A POSTROUTING -s 172.16.1.1/24 -o eth2 -j MASQUERADE;
pre-down /sbin/iptables -t nat -D POSTROUTING -s 172.16.1.1/24 -o eth2 -j MASQUERADE;
up echo 1 > /proc/sys/net/ipv4/ip_forward
down echo 0 > /proc/sys/net/ipv4/ip_forward
And this is how you'd execute each VM (be it from a wrapper of from the command-line)
rrs@learner:~/bin$ cat virtual-hurd
#!/bin/sh
vdeq kvm -M pc -hda /media/VMIMAGES/Debian_GNU_Hurd.img -m 128 -usb \
-net nic,vlan=1,macaddr=52:54:00:12:02:00 -net vde,vlan=1,sock=/var/run/vde2/tap0eth2.ctl -fda \
/media/VMIMAGES/hurd-floppy.img -boot a
rrs@learner:~/bin$ cat virtual-kfreeBSD
#!/bin/sh
vdeq kvm -M pc -hda /media/VMIMAGES/Debian_GNU_kFreeBSD -m 256 -usb -net \
nic,vlan=1,macaddr=52:54:00:12:01:00 -net vde,vlan=1,sock=/var/run/vde2/tap0eth2.ctl -boot c
rrs@learner:~/bin$ cat virtual-PCBSD
#!/bin/sh
vdeq kvm -M pc -hda /media/VMIMAGES/PC-BSD.img -m 512 -usb -net \
nic,vlan=1,macaddr=52:54:00:12:03:00 -net vde,vlan=1,sock=/var/run/vde2/tap0eth2.ctl -boot c
Interesting things to notice here are the vde2-switch - option in the network configuration section and macaddr=52:54:00:12:03:00 being used with each instance of KVM/QEMU. The macaddr needs to be unique for all the VMs or otherwise you'll have network lost in all VMs except the one that gets executed last.
As for the tap0eth2 interface, it is very simple. All you'll need to do is to NAT tap to the interface (eth2 in my case) which talks to the external network.
That's it. Enjoy the network access in the Guest VMs.
PS: Network access has worked for me in Guest VMs on Hurd, FreeBSD, PCBSD, Minix. These are the only ones I've tried till now.
Keywords: vde_vde2_qemu_kvm_virtualization_qemulator_qtemu_qlauncher
