Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 28

Andreas Steffen, 22.07.2011 08:14
Updated DUMM howto

1 16 Martin Willi
h1. Dynamic Uml Mesh Modeler
2 16 Martin Willi
3 16 Martin Willi
_Dumm_ is a framework to set up a virtual network using user mode linux guests.
4 1 Martin Willi
It cleverly glues together some nice technologies to build networks dynamically.
5 1 Martin Willi
To change the network topology, hosts are not required to reboot, changes apply
6 1 Martin Willi
instantly and configuration can be done on the host (no network connection
7 1 Martin Willi
required to change anything).
8 1 Martin Willi
9 1 Martin Willi
10 16 Martin Willi
h2. Status
11 1 Martin Willi
12 17 Tobias Brunner
_Dumm_ is experimental and in development (see source:src/dumm). 
13 16 Martin Willi
Along with the _dumm_ library, two frontends are currently usable:
14 17 Tobias Brunner
* A graphical GTK client
15 17 Tobias Brunner
* A console client with Ruby bindings to script scenarios in Ruby
16 16 Martin Willi
17 10 Martin Willi
The graphical client is incomplete. It is missing:
18 17 Tobias Brunner
* Removal of added switches
19 17 Tobias Brunner
* Disconnecting guests from switches
20 17 Tobias Brunner
* Scenario management
21 1 Martin Willi
22 1 Martin Willi
The Ruby console client also misses a surrounding testing infrastructure which
23 1 Martin Willi
will be built with ruby in the near future.
24 1 Martin Willi
25 16 Martin Willi
26 16 Martin Willi
h2. Why UML?
27 16 Martin Willi
28 1 Martin Willi
UML is a senior in vitualization technologies, and there is a lot of new
29 1 Martin Willi
hyped stuff about virtualization around. However, UML is lightweight, easy to
30 1 Martin Willi
set up and allows dynamic reconfiguration (e.g. add/remove interfaces at
31 1 Martin Willi
runtime), allows access to the hosts filesystem through hostfs and has some
32 1 Martin Willi
other neat features.
33 1 Martin Willi
Performance is not critical for our needs, and maybe we get hardware
34 1 Martin Willi
virtualization support soon in UML.
35 1 Martin Willi
It is free and fits perfectly.
36 1 Martin Willi
37 1 Martin Willi
38 16 Martin Willi
h2. Requirements
39 1 Martin Willi
40 17 Tobias Brunner
* Host:
41 17 Tobias Brunner
** Kernel:
42 17 Tobias Brunner
*** A recent 2.6 kernel
43 17 Tobias Brunner
*** "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ recommended
44 17 Tobias Brunner
*** "FUSE":http://fuse.sourceforge.net/ enabled
45 17 Tobias Brunner
*** support for TAP devices
46 17 Tobias Brunner
** Userland:
47 17 Tobias Brunner
*** [[libstrongswan]]
48 17 Tobias Brunner
*** libbridge from "bridge-utils":http://linux-net.osdl.org/index.php/Bridge
49 17 Tobias Brunner
*** using the GTK client:
50 17 Tobias Brunner
**** GTK+2 with developement headers
51 17 Tobias Brunner
**** Gnome VteTerminal with developement headers
52 17 Tobias Brunner
*** using the Ruby client:
53 17 Tobias Brunner
**** Ruby 1.8 with developement headers
54 17 Tobias Brunner
**** IRB
55 17 Tobias Brunner
* Guest:
56 17 Tobias Brunner
** Kernel:
57 17 Tobias Brunner
*** hostfs
58 17 Tobias Brunner
*** tuntap networking
59 17 Tobias Brunner
*** our extended mconsole exec patch (see source:src/dumm/patches)
60 17 Tobias Brunner
** Userland:
61 17 Tobias Brunner
*** ip from iproute2
62 16 Martin Willi
63 16 Martin Willi
64 16 Martin Willi
h2. Architecture
65 16 Martin Willi
66 16 Martin Willi
67 16 Martin Willi
68 16 Martin Willi
h3. Working set
69 16 Martin Willi
70 1 Martin Willi
Dumm needs a directory to store all its files, guest configurations and other
71 1 Martin Willi
stuff. Inside that working directory, you'll find:
72 1 Martin Willi
73 16 Martin Willi
<pre>
74 1 Martin Willi
workingdir/      - root folder containing a set of hosts and scenarios
75 2 Martin Willi
  guests/        - contains all created guests
76 3 Martin Willi
    alice/       - subdirectory for host "alice"
77 1 Martin Willi
      alice/     - UML created folder (named umid) containing UML runtime files
78 19 Martin Willi
      args       - additional arguments to pass to guest, such as memory configuration
79 1 Martin Willi
      pid        - PID file if guest is running, handy to attach gdb to kernel
80 1 Martin Willi
      linux      - symlinked UML kernel this host uses
81 1 Martin Willi
      master/    - symlinked master root file system for this host
82 1 Martin Willi
      diff/      - copy-on-write overlay to master this host uses
83 1 Martin Willi
      union/     - mounted unified filesystem (master + diff + optional scenario)
84 1 Martin Willi
    bob/
85 10 Martin Willi
      ...        - same stuff as in alice
86 1 Martin Willi
  templates/     - contains all scenario templates
87 1 Martin Willi
    test1/       - a scenario folder
88 1 Martin Willi
      diff/      - copy-on-write overlays for each guest's union folder
89 1 Martin Willi
        alice/   - COW for alice
90 1 Martin Willi
        bob/     - COW for bob
91 1 Martin Willi
</pre>
92 16 Martin Willi
93 16 Martin Willi
94 16 Martin Willi
h3. Networking
95 16 Martin Willi
96 16 Martin Willi
Network connectivity is realized through tap devices. When creating a _eth0_
97 1 Martin Willi
network device on _alice_, a _alice-eth0_ tap device appears on the host. These
98 1 Martin Willi
are directly connected, when _alice_ sends traffic to _eth0_, it appears on the
99 1 Martin Willi
host at _alice-eth0_. You can see that as a small network segment (or just a
100 1 Martin Willi
cable), where these interfaces are attached directly.
101 1 Martin Willi
To build larger network segments, linux bridging on the host comes into play.
102 1 Martin Willi
Segments are created by creating a bridge (as with brctl), and then attaching
103 1 Martin Willi
our tap devices to that bridge. Routing can be done on a UML guest, or even on
104 16 Martin Willi
the host.
105 1 Martin Willi
This setup has some advantages over the _uml_switch_ solution. Bridging works
106 8 Tobias Brunner
more reliable in the kernel, and as we see every network interface on the host,
107 16 Martin Willi
we can sniff at every interface to get some clue what the guests are doing.
108 1 Martin Willi
109 1 Martin Willi
110 17 Tobias Brunner
h2. HowTo
111 16 Martin Willi
112 1 Martin Willi
In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host.
113 1 Martin Willi
We do everything as root here to simplify things!
114 16 Martin Willi
115 1 Martin Willi
116 16 Martin Willi
h3. Host setup
117 1 Martin Willi
118 25 Tobias Brunner
* Install required packages: <pre>
119 28 Andreas Steffen
apt-get install libfuse-dev libgtk2.0-dev libvte-dev ruby ruby1.8-dev irb1.8
120 1 Martin Willi
</pre>
121 17 Tobias Brunner
122 25 Tobias Brunner
* Install libbridge manually: <pre>
123 1 Martin Willi
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
124 1 Martin Willi
cd bridge-utils
125 1 Martin Willi
autoconf
126 1 Martin Willi
./configure
127 1 Martin Willi
cd libbridge
128 18 Martin Willi
gcc -fPIC -c libbridge_devif.c libbridge_if.c libbridge_init.c libbridge_misc.c
129 18 Martin Willi
ar rcs libbridge.a libbridge_devif.o libbridge_if.o libbridge_init.o libbridge_misc.o
130 18 Martin Willi
ranlib libbridge.a
131 18 Martin Willi
install libbridge.a /usr/local/lib
132 18 Martin Willi
install libbridge.h /usr/local/include
133 10 Martin Willi
</pre>
134 17 Tobias Brunner
135 17 Tobias Brunner
* Build and install strongSwan from Git sources: <pre>
136 17 Tobias Brunner
git clone http://git.strongswan.org/strongswan.git
137 1 Martin Willi
cd strongswan
138 16 Martin Willi
less HACKING
139 1 Martin Willi
./autogen
140 16 Martin Willi
./configure --enable-dumm [other options]
141 1 Martin Willi
make
142 1 Martin Willi
make install
143 1 Martin Willi
</pre>
144 16 Martin Willi
145 17 Tobias Brunner
* Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, SKAS3 mode is missing. Build your own kernel based on the "Ubuntu Howto":https://wiki.ubuntu.com/KernelCustomBuild, patched with the "SKAS3 patch":http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/. SKAS3 is not required, but guests run much faster with SKAS3 enabled on the host.
146 10 Martin Willi
147 10 Martin Willi
148 16 Martin Willi
h3. Guest master filesystem setup
149 16 Martin Willi
150 25 Tobias Brunner
* Create a clean directory and a directory for our master filesystem in it: <pre>
151 16 Martin Willi
mkdir umldir
152 10 Martin Willi
cd umldir
153 10 Martin Willi
mkdir master
154 16 Martin Willi
</pre>
155 17 Tobias Brunner
156 1 Martin Willi
* Bootstrap a debian sid system into master: <pre>
157 28 Andreas Steffen
apt-get install debootstrap
158 16 Martin Willi
debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/
159 22 Martin Willi
</pre>To build a x86 guest on a x64 host, use the --arch option.
160 17 Tobias Brunner
161 25 Tobias Brunner
* Enter chroot <pre>
162 16 Martin Willi
chroot master
163 16 Martin Willi
</pre>
164 17 Tobias Brunner
165 17 Tobias Brunner
* Enable main repository <pre>
166 4 Martin Willi
echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list
167 23 Tobias Brunner
apt-get update
168 16 Martin Willi
</pre>
169 17 Tobias Brunner
170 17 Tobias Brunner
* Install proper locales support <pre>
171 23 Tobias Brunner
apt-get install locales
172 16 Martin Willi
dpkg-reconfigure locales
173 16 Martin Willi
</pre>
174 17 Tobias Brunner
175 20 Martin Willi
* For Ubuntu lucid guests, you'll have to specify the locales before generating them: <pre>
176 20 Martin Willi
echo "en_US.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local
177 20 Martin Willi
</pre>
178 20 Martin Willi
179 17 Tobias Brunner
* Install some packages for strongSwan <pre>
180 23 Tobias Brunner
apt-get install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils
181 16 Martin Willi
</pre>
182 1 Martin Willi
183 28 Andreas Steffen
* Remove the root password by deleting the asterisk in /etc/shadow <pre>
184 28 Andreas Steffen
grep root /etc/shadow
185 28 Andreas Steffen
root:*:15173:0:99999:7:::
186 28 Andreas Steffen
vi /etc/shadow
187 28 Andreas Steffen
grep root /etc/shadow
188 28 Andreas Steffen
root::15173:0:99999:7:::
189 28 Andreas Steffen
</pre>
190 28 Andreas Steffen
191 16 Martin Willi
* Leave chroot <pre>
192 16 Martin Willi
exit
193 1 Martin Willi
</pre>
194 1 Martin Willi
195 28 Andreas Steffen
h3. Build a UML guest kernel
196 28 Andreas Steffen
197 28 Andreas Steffen
<pre>
198 27 Andreas Steffen
git clone git://git.strongswan.org/linux-dumm.git
199 27 Andreas Steffen
cd linux-dumm
200 27 Andreas Steffen
git checkout -b uml-ha-2.6.39 uml-ha-2.6.39
201 27 Andreas Steffen
wget http://download.strongswan.org/uml/config-2.6.39
202 27 Andreas Steffen
mv config-2.6.39 .config
203 27 Andreas Steffen
make linux ARCH=um SUBARCH=i386
204 25 Tobias Brunner
</pre>
205 25 Tobias Brunner
206 16 Martin Willi
207 16 Martin Willi
h3. Start a network
208 16 Martin Willi
209 16 Martin Willi
You'll have to run the tools as root. Make sure you have a DISPLAY set, e.g. by starting it under _sudo_.
210 17 Tobias Brunner
211 17 Tobias Brunner
* Invoke the graphical client <pre>
212 16 Martin Willi
sudo ipsec dumm
213 10 Martin Willi
</pre>
214 1 Martin Willi
Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it.
215 10 Martin Willi
Start your guests and configure them. 
216 1 Martin Willi
217 16 Martin Willi
* Using the _irdumm_ ruby client <pre>
218 17 Tobias Brunner
sudo ipsec irdumm
219 21 Martin Willi
irb> sun = Guest.new("sun", "path/to/linux-2.6.27/linux", "path/to/master/", "mem=64M con1=xterm")
220 1 Martin Willi
irb> sun.start
221 1 Martin Willi
irb> sun.exec("echo sun > /etc/hostname")
222 1 Martin Willi
irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1")
223 1 Martin Willi
irb> sun.exec("ifconfig") { |line| puts line }
224 1 Martin Willi
irb> quit
225 16 Martin Willi
</pre>
226 1 Martin Willi
227 16 Martin Willi
228 16 Martin Willi
h2. Installing strongSwan on guests
229 16 Martin Willi
230 1 Martin Willi
As we have full access to the master filesystem on the host, we can build strongSwan on the host and install it to the guests
231 16 Martin Willi
<pre>
232 1 Martin Willi
cd path/to/strongswan/
233 1 Martin Willi
DESTDIR=/full/path/to/master make install
234 16 Martin Willi
</pre>
235 24 Martin Willi
236 24 Martin Willi
h2. Troubleshooting
237 24 Martin Willi
238 24 Martin Willi
h3. The kernel cant find _init_, but it's there!?
239 24 Martin Willi
240 26 Martin Willi
Double check you are using the same architecture for kernel and filesystem. A i386 kernel can't boot a x64 init, and it currently does not work vice-versa, either. Pass the ARCH/SUBARCH variables after _make_, otherwise they get ignored!
241 24 Martin Willi
242 24 Martin Willi
h3. Debugging with gdb inside a x64 UML guest fails with an Input/Output error!
243 24 Martin Willi
244 24 Martin Willi
This is a known issue, but has not yet been solved.
245 24 Martin Willi
246 24 Martin Willi
h3. I'm using a maverick i386 guest on a x64 host, but condition variables behave strangely.
247 24 Martin Willi
248 24 Martin Willi
This is a known issue, somehow related to eglibc version. Threads waiting in condvars don't get
249 1 Martin Willi
wakened up while signaled. Not yet solved.
250 26 Martin Willi
251 26 Martin Willi
h3. Unix sockets created in the guest through hostfs are inaccessible in the guest.
252 26 Martin Willi
253 26 Martin Willi
Looks like an issue with hostfs, not yet solved. Creating Unix Sockets on an in-guest mounted tmpfs should work.