jb’s open source blog

A look into my work and play in open source

Quickfix: AR5418 with ndiswrapper

with one comment

Problem: madwifi is buggy with this wireless chip. If using 32-bit, ndiswrapper is possible and far more stable.

lspci:
03:00.0 Network controller: Atheros Communications, Inc. AR5418 802.11a/b/g/n Wireless PCI Express Adapter (rev 01)

Solution: (Kubuntu 7.10, YMMV)
wget ftp://ftp.software.ibm.com/pc/pccbbs/mobiles/7iwc28ww.exe
sudo apt-get install cabextract ndiswrapper-utils-1.9
cabextract 7iwc28ww.exe
sudo ndiswrapper -i WINXP_2K/NET5416.INF
sudo modprobe ndiswrapper
echo ndiswrapper |sudo tee -a /etc/modules

Written by jbopensrc

December 3, 2007 at 2:07 am

Posted in Linux, Quickfix

Quickfix: Weird KDE menu (“_: Entries in K-menu”)

with one comment

Problem: KDE menu shortcuts prefixed with “_: Entries in K-menu: ” (screenshot)

Cause: Selected English (Canada). en_ca broken in Kubuntu 7.10.

Workaround:
sudo qt-language-selector --mode select

Change to English (United States of America).

References:
Bug #135084 in kdebase (Ubuntu)

Written by jbopensrc

December 3, 2007 at 1:57 am

Posted in Linux, Quickfix

Quickfix: TrackPoint scrolling on Thinkpad

leave a comment »

To get TrackPoint (the red nub) scrolling in Linux on your Thinkpad, i.e. hold the middle mouse button down to activate scrolling:

Add the following to your mouse settings (i.e. Section “InputDevice”) in /etc/X11/Xorg.conf:

Option "EmulateWheel" "on"
Option "EmulateWheelButton" "2"
Option "EmulateWheelTimeOut" "1" # to disable middle click

In Firefox, do about:config and set:

mousewheel.horizscroll.withnokey.action = 0;

Written by jbopensrc

December 3, 2007 at 1:25 am

Posted in Linux, Quickfix

XPCOM lab (FirstXpcom)

leave a comment »

First off, let me start by saying despite reading about it for 20 minutes, before starting I had no idea what the purpose of XPCOM was. Wikipedia’s articles on COM and CORBA gave me an idea of what problem it tries to solve: the ability to “export” functionality in a language neutral way through interfaces, or contracts. The XPCOM article paints a different picture, calling XPCOM the reason Mozilla is an “actual framework”, because it offers features such as file abstraction, memory management. The Zenit wiki’s definition is much more concise:

XPCOM is a framework for developing cross platform software that can be written in C, C++, JavaScript with extensions for Perl and Python.You can access the XPCOM component through the web or any Mozilla application (similar to the idea of accessing web services).

After diving into the lab I think I have a better feel for it. It appears (one possible use for) XPCOM is to expose C++/C methods to Javascript. This is what the lab covered.

The gory details:

  • Create an interface specification in XPIDL (.idl) format: one attribute (name), one method (add): IFirstXpcom.idl
  • Create a (bunch of) Makefile.in file(s) to make the build system automatically translate our .idl to .cpp/.h:

  • Create an install manifest (install.rdf)
  • Use make-makefile to create a Makefile inside objdir/extensions/firstxpcom
  • Run make from objdir/extensions/firstxpcom
  • Watch it fail. Look in objdir/dist/include/firstxpcom. A header file, IFirstXpcom.h, was generated.
  • Copy/paste implementation stub from IFirstXpcom.h into extensions/firstxpcom/src/FirstXpcom.cpp. Replace _MYCLASS_ with FirstXpcom.
  • Run make in objdir/extensions/firstxpcom. (It fails.)
  • Add #include "IFirstXpcom.h" at the top of FirstXpcom.cpp.
  • Run make in objdir/extensions/firstxpcom. (Success!)
  • Look at IFirstXpcom.h, make observations:
    • AString => nsAString
    • long => PRInt32
  • “Write a bit of code to get component registered”. Copy and paste from here. Read explanations here.
  • Run make. (It fails.)
  • Change line mName.Assign(L"FirstXpcom Component"); to mName.AssignLiteral("FirstXpcom Component");. (Thanks mmullin/gavin).
  • Run make. (Success!)
  • Run objdir/dist/bin/firefox -no-remote -profilemanager.
  • (!) Minefield could not install this item because “install.rdf” (provided by the item) is not well-formed or does not exist.
  • Open install.rdf in vi. Fix indentation (gg=G), save. No more install.rdf errors. (No idea how that fixed it, but it did.)
  • Use this tip from Rueen to install Extension Developer’s Extension in Minefield without security warnings.
  • Open the Javascript shell and access the FirstXpcom component.

FirstXpcom in the Addon Manager
FirstXpcom in the Addon Manager

FirstXpcom and the Javascript shell
FirstXpcom and the Javascript shell

firstxpcom_jb.tar.bz2 – all files from this lab

Written by jbopensrc

November 15, 2007 at 3:27 am

Posted in Open Source

Diving into KVM, Part 2

with one comment

Continuing my work from Part 1, I attempted to use virt-manager to create a KVM virtual machine. The GUI asked me a bunch of questions beyond what the CLI virt-install did, such as number of VCPUs, networking config, etc. It didn’t ask me whether I wanted a GUI – it assumed I did. Upon clicking Finish, I was still plagued with this error:

virDomainCreateLinux() failed Timed out while reading monitor startup output.

Ready to start asking for some help, for some reason I decided to click Finish again. Voila, it worked! And repeated tests prove it: the first time you click Finish, it fails, the second time, it succeeds.

To be honest, this kind of “magic” bothers me. I hate it with a passion, and it’s why I tend to lean towards command line for learning most new things; because in this case, I have no idea what the issue is or why it was fixed.

I installed Fedora 7 overnight in the VM, and everything went pretty well. No lockups, full GUI, etc. I didn’t really inspect much inside VM: it took me a day to even notice I don’t have networking. However, I’m not too concerned with the VM itself right now. (During my week off I’m going to work on a side project which might help me get used to working inside QEMU/KVM VMs day to day — as well as coding Python — I tend to learn more working on side projects than real projects. More on that later.) For now, my focus is on completing my 0.1 goals.

Written by jbopensrc

October 20, 2007 at 4:40 pm

Posted in Open Source

Diving into KVM, Part 1: Progress, but limited

with one comment

KVM stands for Kernel-based Virtual Machine. If I understand correctly, there was some debate as to whether to integrate Xen into the kernel, but the Linux developers opted to include their own(?) solution instead, KVM.

My first bit of confusion was the difference between virtualization, para-virtualization, and real virtualization. As I understood it:

Virtualization: All x86 calls, devices, etc. are emulated in software.
Paravirtualization: Layer of abstraction between real hardware calls and the virtual machine. Guest kernels must be modified to make these “idealized CPU calls”.
Real virtualization: Most x86 calls are emulated in software, but some “tricky” (i.e. slow) ones are done in hardware via Intel VT/AMD Pacifica extensions.

Confusing though, in the comparison of virtualization technologies chart, it says paravirtualization can be faster than real virtualization. That kind of surprises me. I suppose it entails creating “idealized” wrappers around real but imperfect hardware and doing optimizations, as in the DMA NIC example in the Wikipedia article. For my purposes, I’d be using “real virtualization”, but the idea that paravirt might be faster is intriguing.

To the Fedora 7 Virt Quick Start guide:

  • Filtering out the Xen specific stuff is kind of frustrating. They should really separate the two.
  • virt-install asks me “What would you like to use as the disk (path)?” – I assume I’m supposed to put an empty dir with sufficient free space here.
  • I make a partition for “boxbox1”, my virtual machine:

    # lvcreate -L 4500M -n boxbox1 VolGroup00
    Rounding up size to full physical extent 4.41 GB
    Logical volume "boxbox1" created
    # mke2fs -j -m 0 /dev/mapper/VolGroup00-boxbox1
    # mount /dev/mapper/VolGroup00-boxbox1 /mnt/boxbox1/
  • I specify /mnt/boxbox1/ as my path:
    • Ooops: ERROR: The disk path must be a file or a device, not a directory
    • Used /dev/mapper/VolGroup00-boxbox1 instead
  • Asks me “Would you like to enable graphics support? (yes or no)“. Somehow I know this will come back to haunt me, but I say ‘yes’.
  • Guide says It is not possible to install from a local disk or CDROM., but virt-install is asking me: What is the virtual CD image, CD device or install location?
  • I try /dev/cdrom first, but it doesn’t like that.
  • Trying again as root was an idea (probably need to be), but still no good.
  • Trying again without graphics, I still get a bunch of blank libvir: QEMU errors. However, it’s told me that I can reconnect to the console to complete the installation process. From what I’ve read, the console should just “appear” in my current terminal. Not the case.
  • I see qemu is running..

    $ ps aux |grep qemu
    root 21866 7.7 2.4 565316 51520 ? Sl 23:18 1:53 /usr/bin/qemu -M pc -no-kqemu -m 512 -smp 1 -nographic -monitor pty -no-reboot -boot d -hda /dev/mapper/VolGroup00-boxbox1 -cdrom /dev/cdrom -net nic,macaddr=00:16:3e:2a:3f:2e,vlan=0 -net tap,fd=10,script=,vlan=0 -usb

    …but I don’t have any idea how to connect to it.

Strange. I’ll investigate more tomorrow morning, and maybe try using the GUI tool, virt-manager, instead.

Written by jbopensrc

October 11, 2007 at 12:00 am

Posted in Open Source

Growing a LVM2 + ext3 partition

with 4 comments

I have Windows XP in a VMWare virtual machine for the times I need to use Windows. I love open source software, but I have to admit, I’m quite fond of C# and ASP.NET. (Now that I’ve lost half my readers…)

I made my VMWare partition too small on purpose: I wanted it to be a tight fit so as to not waste any space – and if I had issues, I could just grow it with LVM2. When I booted my VM, VMWare complained that there wasn’t enough free space and I might corrupt the VM’s RAM. So I wanted to add 1 gig to it.

Quick and to the point

# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
# resize2fs /dev/VolGroup00/LogVolVMWareXP

Wow! That’s it! I didn’t have to reboot, I didn’t even have to umount the partition! (Mind you, I wasn’t brave enough to try this while things were going on in this partition – no files were open and the VM wasn’t booted. EDIT: 1GB wasn’t enough, so I added another 512MB while the VM was “hot” with no issues!) Surprisingly, the resize2fs command needed no parameters: it just grows to fill the partition. LVM-HOWTO helped me with this. I ignored the part that said “the online resizing patch is rather dangerous, so use at your own risk“, hoping it’s outdated *knock on wood*.

Detailed

# vgdisplay |grep -i free
Free PE / Size 639 / 19.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 19.97G
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVolVMWareXP
23G 23G 335M 99% /mnt/vmwarexp
# lvscan
ACTIVE '/dev/VolGroup00/LogVolFedora' [7.81 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolSwap' [1.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [22.88 GB] inherit
# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
Extending logical volume LogVolVMWareXP to 23.88 GB
Logical volume LogVolVMWareXP successfully resized
# resize2fs /dev/VolGroup00/LogVolVMWareXP
resize2fs 1.40.2 (12-Jul-2007)
Filesystem at /dev/VolGroup00/LogVolVMWareXP is mounted on /mnt/vmwarexp; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/LogVolVMWareXP to 6258688 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVolVMWareXP is now 6258688 blocks long.
# vgdisplay |grep -i free
Free PE / Size 607 / 18.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 18.97G
# lvscan |grep VM
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [23.88 GB] inherit
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVolVMWareXP
24G 23G 1.4G 95% /mnt/vmwarexp

So far LVM2 is pretty neat. Should be interesting digging deeper into it.

Written by jbopensrc

October 10, 2007 at 9:22 pm

Posted in Open Source