Telling HAL about TUN/TAP interfaces

Today, I started using Virtual Machine Manager (VMM) to help me with my development. Previously, I had been using VirtualBox. Both are GPLed, but VirtualBox is Dual Licensed with a more “feature-full” version that isn’t GPL’d. The GPL’d version of VirtualBox doesn’t seem like it is really intended for hard-core use. So far I’ve really been liking VMM. It can bring up my instances at boot time and can run them headless. Nice. This will really help with the packaging work I’m doing right now for IntraHealth’s iHRIS Suite. Still, networking is a bear in both VirtualBox and VMM. I was able to use my TUN/TAP bridged network in VMM that I had set up before in VirtualBox. But only after I told HAL about the TAP interface. Here’s the deal: VMM uses HAL to discover the network interface. It then lets you use any of those interfaces that are bridged for your virtual machines. Alternatively, you can just use user-mode NAT, but that is less than ideal since ping doesn’t work and it is harder to test network apps or ssh into your virtual box. The problem: HAL only knows about physical network devices, not any TUN/TAP interfaces you have set up. Since my bridge was on a TUN/TAP interface, HAL didn’t know about it and VMM couldn’t use it. After a little poking around, I found the command line utility hal-device that would let me add the interface dynamically. Now, when VMM queries HAL, the interface shows up. (By the way, since HAL communicates over D-Bus, I was able to use Emacs’ D-Bus integration for debugging.) Here’s the script I wrote to add the TUN/TAP interface:

#!/bin/sh    hal-device --add '/org/freedesktop/Hal/devices/net_tap0' <<EOF  info.capabilities = {'net'} (string list)  info.category = 'net'  (string)  info.product = 'Networking Interface'  (string)  info.subsystem = 'net'  (string)  info.udi = '/org/freedesktop/Hal/devices/net_tap0'  (string)  net.address = 'ea:08:21:d4:c8:90' (string)  net.interface = 'tap0' (string)  linux.subsystem = 'net'  (string)  linux.sysfs_path = '/sys/devices/virtual/net/tap0'  (string)  net.interface = 'tap0'  (string)  EOF  

I hope to have something more generic that will work with HAL and Ubuntu’s networking soon so that any TUN/TAP interface is automatically recognised by HAL.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.