Currently showing posts tagged: Linux

port redirection from kvm host to guest

By Adam, January 23, 2012 2:58 am

I’ve just started using kvm in earnest, and immediately ran into the challenge of how to access my guest via ssh. My first instinct was to configure the guest in bridged mode, but this doesn’t work well (or at all) with wireless interfaces.

So plan B was to set up port redirection from the host to the guest, e.g. so that ssh’ing to localhost port 2222 would redirect to the guest’s port 22.

After a quick google, some fiddling with iptables, and a glance at the libvirt Networking wiki page, I was still having no luck. Then it hit me – my guest was using user-mode networking, and rather than getting its DHCP-allocated IP from the libvirtd-launched dnsmasq instance on the host, was receiving a hardcoded allocation of 10.0.2.15 from the host which is on 10.0.2.2. This can be extremely puzzling at first, because no network commands run on the host (such as ifconfig, iptables, brctl, route) will reveal this magic address, yet the host is still accessible from the guest via it.

After a lot more googling, I stumbled across a technique for configuring host to guest port redirection on a running VM. This sounded very promising, but virt-manager refused to accept the magic Control-Alt-2 key combination to switch to QEMU monitor mode. It turns out that this is no accident. However, since libvirt 0.8.8, the QEMU monitor can be accessed via virsh.
Note that the --hmp option is required, otherwise the monitor expects the command in JSON format, so omitting it leads to errors like error: internal error cannot parse json ... lexical error: invalid char in json text.

The final hurdle was figuring out the correct monitor command. The host_net_redir command as mentioned in the above article is no longer recognized. Luckily the QEMU monitor interface helped me out here – I spotted an encouraging sounding command hostfwd_add:

# virsh qemu-monitor-command --hmp sles11 'help hostfwd_add'
hostfwd_add [vlan_id name] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport -- redirect TCP or UDP connections from host to guest (requires -net user)

and google confirmed that the latter had superceded the former.

So finally we have the complete solution:

# virsh qemu-monitor-command --hmp sles11 'hostfwd_add ::2222-:22'
# ssh -p 2222 localhost
Password:
Last login: Mon Jan 23 00:37:44 2012
linux-mnsh:~ #

Hooray!

UPDATE: just found another very simple solution – add a new NIC to the VM which doesn’t use user-mode networking. Then it will get a IP (on 192.168.100.0/24 by default) which is still NAT’d but also routable via virbr0 on the host, meaning no redirection is necessary; just ssh directly to the guest’s IP from the host. A minor disadvantage of this is that the guest won’t be directly reachable from outside the host, but that’s unlikely to be an issue in most scenarios.

Share

Linux desktop community “outraged” by latest Torvalds comments

By Adam, November 29, 2011 4:40 pm

Once again, users and developers all around the Linux desktop community have been provoked by controversial comments from Linus Torvalds, creator and long-time maintainer of the Linux kernel. Back in October, Linus dubbed GNOME 3 an “unholy mess”, referring to one of the changes as “crazy crap” and demanding “I want my sane interfaces back”. Since then he has gone even further, contending that “for some people, a stable, flexible functional desktop environment is far more important than the latest eye candy or trendy minimalist UI design.”

Reaction from the desktop development community has been swift and mostly unapologetic. Mark Shuttleworth, the founder of Canonical, responded “Once again, Linus is underestimating the importance of aesthetics in computing. You only have to look at Apple to see that people place more importance on visual beauty than the kind of efficient work processes that a flexible and reliable desktop environment enable. This is why we’re pushing our new Unity launcher as a mandatory part of Ubuntu. We’re confident that people will quickly overcome the initial shock of everything taking longer to find and access because they’ll be too busy admiring how beautiful it looks.” He then cited the latest 11.10 release as an example of this. “If you look in the release notes for [Oneiric Ocelot], you’ll see a new Alt+Tab switcher at the top of the list of highlights, and below it other radical changes such as renaming ‘Places’ to ‘Lenses’. Frankly, most people lap up this whizzbang shit, and as long as it looks cooler than their friend’s Windows 7 netbook they’ll be willing to tolerate some minor annoyances which are unavoidable when making immature software a critical component of the desktop. Sure, we could prioritise boring bug-fixing over innovation, but that just doesn’t excite the teenagers on the web forums, and we have to think about the next generation of users. Besides, if you want a dumbed down system that mostly works, there’s always Mac OS X.”

Havoc Pennington, a GNOME developer well-known for initiating the war on Linux desktop flexibility by drastically reducing the number of preferences and replacing GNOME’s default window manager, the high-performance scriptable Sawfish, with Metacity, commented: “It’s about achieving the right work/play balance. If your desktop allowed you to get stuff done too quickly, it would just increase your stress levels. Some ‘power’ users think they want to be able to stream-line their workflows, but we know better, so we are doing them a favour by making this customizability harder. After all, everyone needs basically the same things. Rather than trying to be different, these people should instead learn to enjoy the cute visuals and focus more on having fun. Life’s more than just work, work, work, you know.”

The KDE camp has been slightly less vociferous, perhaps because it’s old hat for them – back in 2008 they pioneered the concept of intrusive redesigns and ended up the wrong end of one of Linus’ rants as a result. “With KDE 4.0, we did our best to prevent people achieving real work, and I think we largely succeeded”, one of the KDE team leaders recalls. “I mean, there was a significant period of time where neither the KDE3 version of knetworkmanager nor its KDE4 rewrite worked properly, so for many wireless networks, the only way you could connect was to disable NetworkManager and write a shell-script to interface directly with wpa-supplicant and ifup. And that’s just one small example.”

Despite Torvalds’ comments, the move towards form over function has been witnessed elsewhere outside the desktop software space. For example, Apple have introduced the MacWheel, a move so bold that it makes innovations such as Unity and the GNOME Shell look positively conservative. However there is no clear industry-wide consensus; in fact companies such as Ebay and Sony are beginning to experiment with rejecting both form and function, turning conventional wisdom on its head.

Share

Running Amazon MP3 downloader on 64-bit Ubuntu 11.04 (Natty Narwhal)

By Adam, September 25, 2011 3:00 pm

Amazon MP3 store – a phenomenonly popular online music store. Ubuntu – a phenomenonly popular version of Linux. 64-bit x86_64 CPUs – been around for years. You’d think this was a good combination, wouldn’t you? Wrong :-( Amazon, along with Spotify and countless others, is dismally failing to support its rapidly growing set of customers who run Linux. As I’ve said elsewhere, even if 2% of your customers use Linux, that can still be a huge number. Hopefully some day these big companies will acquire some common sense.

Anyway, in the mean time a quick google brought up the following solution:

Unfortunately it doesn’t work – the step which installs the manually downloaded .deb files fails due to broken dependencies. However further googling found a post from 2008 which revealed a technique based on the very useful getlibs utility.

So here’s my solution:

  1. Download the 32-bit Amazon downloader app for Ubuntu 9.10.
  2. Run sudo dpkg -i --force-all AmazonMP3DownloaderInstall.deb
  3. Run sudo apt-get install getlibs if you don’t already have getlibs installed.
  4. Run sudo getlibs /usr/bin/amazonmp3 and answer yes to the confirmation.

At this point if you try to run /usr/bin/amazonmp3 you’ll probably hit Ubuntu bug 781870. The workaround is as follows:

export GDK_PIXBUF_MODULE_FILE=/usr/lib32/gdk-pixbuf-2.0/2.10.0/loaders.cache
/usr/bin/amazonmp3

You’ll still get an error that it’s trying to load the 64-bit version of libgvfsdbus.so thanks to Ubuntu bug 369498. I had hopes that export GIO_EXTRA_MODULES=/usr/lib32/gio/modules would fix this, but it seems that this variable only gets honoured too late. However, apparently this issue doesn’t stop the program working so can be ignored.

Another option is to use Banshee’s built-in Amazon downloader, but even without all the politics surrounding Ubuntu’s version of Banshee this didn’t suit my tastes.

UPDATE: Wow. Just found out Amazon doesn’t support re-downloading stuff you’ve already bought. This is truly pathetic, especially considering their Android app kind of implements a locker service. From now on I’ll be using 7digital whenever I can – unfortunately their selection isn’t as big though. The quest for the perfect music services continues … :-/

Share

CompuTrainer on Linux

By Adam, June 20, 2009 7:13 pm

Finally started using my CompuTrainer a bit more. Just rode 20km in the lounge with the computer pacing me at 200 Watts. After so much riding with guys way stronger than me, the temptation to draft the computer is difficult to resist. However in the last 500 metres it spontaneously decided to make a sprint for the finish line – the bloody cheek! Obviously I couldn’t allow a bunch of transistors to beat me so I sprinted after it and hit the finish line 0.05 seconds ahead, narrowly avoiding embarassment. Next step is to start doing brick sessions
Continue reading 'CompuTrainer on Linux'»

Share

farewell KDE, hello GNOME

By Adam, May 11, 2009 2:13 pm

Sad to say, I’ve jumped on the Torvalds bandwagon and switched from KDE 4 to GNOME. Sorry to all the hard-working KDE developers, but I just don’t have time to put up with a desktop plagued by numerous regressions, and worse, a crippled front-end to NetworkManager. There appear to be two versions of knetworkmanager – the 3.5.x branch which for some reason went under a significant UI redesign and is now harder to use and more buggy, and the 4.x branch which AFAIK is still unfinished and unreleased. That was the last straw for me – the NM front-end is arguably the most important component of any modern Linux desktop (from the point of view of laptop users anyway), so I find it fairly staggering that KDE still doesn’t have one which is stable, polished, and well-designed with respect to usability.

There were other things, like korganizer getting slower and more buggy, phonon not working right, plasma’s bizarre customisation UI and tendency to leak memory like a sieve, a device notifier pop-up which often makes new devices invisible and unclickable … but enough is enough, life is too short. GNOME does what I need (which isn’t much, thanks to the flexibility of openbox).

Share

Panorama theme by Themocracy