Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1.. SPDX-License-Identifier: GPL-2.0
2
3=====================
4User Mode Linux HOWTO
5=====================
6
7:Author: User Mode Linux Core Team
8:Last-updated: Sat Jan 25 16:07:55 CET 2020
9
10This document describes the use and abuse of Jeff Dike's User Mode
11Linux: a port of the Linux kernel as a normal Intel Linux process.
12
13
14.. Table of Contents
15
16 1. Introduction
17
18 1.1 How is User Mode Linux Different?
19 1.2 Why Would I Want User Mode Linux?
20
21 2. Compiling the kernel and modules
22
23 2.1 Compiling the kernel
24 2.2 Compiling and installing kernel modules
25 2.3 Compiling and installing uml_utilities
26
27 3. Running UML and logging in
28
29 3.1 Running UML
30 3.2 Logging in
31 3.3 Examples
32
33 4. UML on 2G/2G hosts
34
35 4.1 Introduction
36 4.2 The problem
37 4.3 The solution
38
39 5. Setting up serial lines and consoles
40
41 5.1 Specifying the device
42 5.2 Specifying the channel
43 5.3 Examples
44
45 6. Setting up the network
46
47 6.1 General setup
48 6.2 Userspace daemons
49 6.3 Specifying ethernet addresses
50 6.4 UML interface setup
51 6.5 Multicast
52 6.6 TUN/TAP with the uml_net helper
53 6.7 TUN/TAP with a preconfigured tap device
54 6.8 Ethertap
55 6.9 The switch daemon
56 6.10 Slip
57 6.11 Slirp
58 6.12 pcap
59 6.13 Setting up the host yourself
60
61 7. Sharing Filesystems between Virtual Machines
62
63 7.1 A warning
64 7.2 Using layered block devices
65 7.3 Note!
66 7.4 Another warning
67 7.5 uml_moo : Merging a COW file with its backing file
68
69 8. Creating filesystems
70
71 8.1 Create the filesystem file
72 8.2 Assign the file to a UML device
73 8.3 Creating and mounting the filesystem
74
75 9. Host file access
76
77 9.1 Using hostfs
78 9.2 hostfs as the root filesystem
79 9.3 Building hostfs
80
81 10. The Management Console
82 10.1 version
83 10.2 halt and reboot
84 10.3 config
85 10.4 remove
86 10.5 sysrq
87 10.6 help
88 10.7 cad
89 10.8 stop
90 10.9 go
91
92 11. Kernel debugging
93
94 11.1 Starting the kernel under gdb
95 11.2 Examining sleeping processes
96 11.3 Running ddd on UML
97 11.4 Debugging modules
98 11.5 Attaching gdb to the kernel
99 11.6 Using alternate debuggers
100
101 12. Kernel debugging examples
102
103 12.1 The case of the hung fsck
104 12.2 Episode 2: The case of the hung fsck
105
106 13. What to do when UML doesn't work
107
108 13.1 Strange compilation errors when you build from source
109 13.2 (obsolete)
110 13.3 A variety of panics and hangs with /tmp on a reiserfs filesystem
111 13.4 The compile fails with errors about conflicting types for 'open', 'dup', and 'waitpid'
112 13.5 UML doesn't work when /tmp is an NFS filesystem
113 13.6 UML hangs on boot when compiled with gprof support
114 13.7 syslogd dies with a SIGTERM on startup
115 13.8 TUN/TAP networking doesn't work on a 2.4 host
116 13.9 You can network to the host but not to other machines on the net
117 13.10 I have no root and I want to scream
118 13.11 UML build conflict between ptrace.h and ucontext.h
119 13.12 The UML BogoMips is exactly half the host's BogoMips
120 13.13 When you run UML, it immediately segfaults
121 13.14 xterms appear, then immediately disappear
122 13.15 Any other panic, hang, or strange behavior
123
124 14. Diagnosing Problems
125
126 14.1 Case 1 : Normal kernel panics
127 14.2 Case 2 : Tracing thread panics
128 14.3 Case 3 : Tracing thread panics caused by other threads
129 14.4 Case 4 : Hangs
130
131 15. Thanks
132
133 15.1 Code and Documentation
134 15.2 Flushing out bugs
135 15.3 Buglets and clean-ups
136 15.4 Case Studies
137 15.5 Other contributions
138
139
1401. Introduction
141================
142
143 Welcome to User Mode Linux. It's going to be fun.
144
145
146
1471.1. How is User Mode Linux Different?
148---------------------------------------
149
150 Normally, the Linux Kernel talks straight to your hardware (video
151 card, keyboard, hard drives, etc), and any programs which run ask the
152 kernel to operate the hardware, like so::
153
154
155
156 +-----------+-----------+----+
157 | Process 1 | Process 2 | ...|
158 +-----------+-----------+----+
159 | Linux Kernel |
160 +----------------------------+
161 | Hardware |
162 +----------------------------+
163
164
165
166
167 The User Mode Linux Kernel is different; instead of talking to the
168 hardware, it talks to a `real` Linux kernel (called the `host kernel`
169 from now on), like any other program. Programs can then run inside
170 User-Mode Linux as if they were running under a normal kernel, like
171 so::
172
173
174
175 +----------------+
176 | Process 2 | ...|
177 +-----------+----------------+
178 | Process 1 | User-Mode Linux|
179 +----------------------------+
180 | Linux Kernel |
181 +----------------------------+
182 | Hardware |
183 +----------------------------+
184
185
186
187
188
1891.2. Why Would I Want User Mode Linux?
190---------------------------------------
191
192
193 1. If User Mode Linux crashes, your host kernel is still fine.
194
195 2. You can run a usermode kernel as a non-root user.
196
197 3. You can debug the User Mode Linux like any normal process.
198
199 4. You can run gprof (profiling) and gcov (coverage testing).
200
201 5. You can play with your kernel without breaking things.
202
203 6. You can use it as a sandbox for testing new apps.
204
205 7. You can try new development kernels safely.
206
207 8. You can run different distributions simultaneously.
208
209 9. It's extremely fun.
210
211
212
213.. _Compiling_the_kernel_and_modules:
214
2152. Compiling the kernel and modules
216====================================
217
218
219
220
2212.1. Compiling the kernel
222--------------------------
223
224
225 Compiling the user mode kernel is just like compiling any other
226 kernel.
227
228
229 1. Download the latest kernel from your favourite kernel mirror,
230 such as:
231
232 https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.14.tar.xz
233
234 2. Make a directory and unpack the kernel into it::
235
236 host%
237 mkdir ~/uml
238
239 host%
240 cd ~/uml
241
242 host%
243 tar xvf linux-5.4.14.tar.xz
244
245
246 3. Run your favorite config; ``make xconfig ARCH=um`` is the most
247 convenient. ``make config ARCH=um`` and ``make menuconfig ARCH=um``
248 will work as well. The defaults will give you a useful kernel. If
249 you want to change something, go ahead, it probably won't hurt
250 anything.
251
252
253 Note: If the host is configured with a 2G/2G address space split
254 rather than the usual 3G/1G split, then the packaged UML binaries
255 will not run. They will immediately segfault. See
256 :ref:`UML_on_2G/2G_hosts` for the scoop on running UML on your system.
257
258
259
260 4. Finish with ``make linux ARCH=um``: the result is a file called
261 ``linux`` in the top directory of your source tree.
262
263
2642.2. Compiling and installing kernel modules
265---------------------------------------------
266
267 UML modules are built in the same way as the native kernel (with the
268 exception of the 'ARCH=um' that you always need for UML)::
269
270
271 host% make modules ARCH=um
272
273
274
275
276 Any modules that you want to load into this kernel need to be built in
277 the user-mode pool. Modules from the native kernel won't work.
278
279 You can install them by using ftp or something to copy them into the
280 virtual machine and dropping them into ``/lib/modules/$(uname -r)``.
281
282 You can also get the kernel build process to install them as follows:
283
284 1. with the kernel not booted, mount the root filesystem in the top
285 level of the kernel pool::
286
287
288 host% mount root_fs mnt -o loop
289
290
291
292
293
294
295 2. run::
296
297
298 host%
299 make modules_install INSTALL_MOD_PATH=`pwd`/mnt ARCH=um
300
301
302
303
304
305
306 3. unmount the filesystem::
307
308
309 host% umount mnt
310
311
312
313
314
315
316 4. boot the kernel on it
317
318
319 When the system is booted, you can use insmod as usual to get the
320 modules into the kernel. A number of things have been loaded into UML
321 as modules, especially filesystems and network protocols and filters,
322 so most symbols which need to be exported probably already are.
323 However, if you do find symbols that need exporting, let us
324 know at http://user-mode-linux.sourceforge.net/, and
325 they'll be "taken care of".
326
327
328
3292.3. Compiling and installing uml_utilities
330--------------------------------------------
331
332 Many features of the UML kernel require a user-space helper program,
333 so a uml_utilities package is distributed separately from the kernel
334 patch which provides these helpers. Included within this is:
335
336 - port-helper - Used by consoles which connect to xterms or ports
337
338 - tunctl - Configuration tool to create and delete tap devices
339
340 - uml_net - Setuid binary for automatic tap device configuration
341
342 - uml_switch - User-space virtual switch required for daemon
343 transport
344
345 The uml_utilities tree is compiled with::
346
347
348 host#
349 make && make install
350
351
352
353
354 Note that UML kernel patches may require a specific version of the
355 uml_utilities distribution. If you don't keep up with the mailing
356 lists, ensure that you have the latest release of uml_utilities if you
357 are experiencing problems with your UML kernel, particularly when
358 dealing with consoles or command-line switches to the helper programs
359
360
361
362
363
364
365
366
3673. Running UML and logging in
368==============================
369
370
371
3723.1. Running UML
373-----------------
374
375 It runs on 2.2.15 or later, and all kernel versions since 2.4.
376
377
378 Booting UML is straightforward. Simply run 'linux': it will try to
379 mount the file ``root_fs`` in the current directory. You do not need to
380 run it as root. If your root filesystem is not named ``root_fs``, then
381 you need to put a ``ubd0=root_fs_whatever`` switch on the linux command
382 line.
383
384
385 You will need a filesystem to boot UML from. There are a number
386 available for download from http://user-mode-linux.sourceforge.net.
387 There are also several tools at
388 http://user-mode-linux.sourceforge.net/ which can be
389 used to generate UML-compatible filesystem images from media.
390 The kernel will boot up and present you with a login prompt.
391
392
393Note:
394 If the host is configured with a 2G/2G address space split
395 rather than the usual 3G/1G split, then the packaged UML binaries will
396 not run. They will immediately segfault. See :ref:`UML_on_2G/2G_hosts`
397 for the scoop on running UML on your system.
398
399
400
4013.2. Logging in
402----------------
403
404
405
406 The prepackaged filesystems have a root account with password 'root'
407 and a user account with password 'user'. The login banner will
408 generally tell you how to log in. So, you log in and you will find
409 yourself inside a little virtual machine. Our filesystems have a
410 variety of commands and utilities installed (and it is fairly easy to
411 add more), so you will have a lot of tools with which to poke around
412 the system.
413
414 There are a couple of other ways to log in:
415
416 - On a virtual console
417
418
419
420 Each virtual console that is configured (i.e. the device exists in
421 /dev and /etc/inittab runs a getty on it) will come up in its own
422 xterm. If you get tired of the xterms, read
423 :ref:`setting_up_serial_lines_and_consoles` to see how to attach
424 the consoles to something else, like host ptys.
425
426
427
428 - Over the serial line
429
430
431 In the boot output, find a line that looks like::
432
433
434
435 serial line 0 assigned pty /dev/ptyp1
436
437
438
439
440 Attach your favorite terminal program to the corresponding tty. I.e.
441 for minicom, the command would be::
442
443
444 host% minicom -o -p /dev/ttyp1
445
446
447
448
449
450
451 - Over the net
452
453
454 If the network is running, then you can telnet to the virtual
455 machine and log in to it. See :ref:`Setting_up_the_network` to learn
456 about setting up a virtual network.
457
458 When you're done using it, run halt, and the kernel will bring itself
459 down and the process will exit.
460
461
4623.3. Examples
463--------------
464
465 Here are some examples of UML in action:
466
467 - A login session http://user-mode-linux.sourceforge.net/old/login.html
468
469 - A virtual network http://user-mode-linux.sourceforge.net/old/net.html
470
471
472
473
474
475.. _UML_on_2G/2G_hosts:
476
4774. UML on 2G/2G hosts
478======================
479
480
481
482
4834.1. Introduction
484------------------
485
486
487 Most Linux machines are configured so that the kernel occupies the
488 upper 1G (0xc0000000 - 0xffffffff) of the 4G address space and
489 processes use the lower 3G (0x00000000 - 0xbfffffff). However, some
490 machine are configured with a 2G/2G split, with the kernel occupying
491 the upper 2G (0x80000000 - 0xffffffff) and processes using the lower
492 2G (0x00000000 - 0x7fffffff).
493
494
495
496
4974.2. The problem
498-----------------
499
500
501 The prebuilt UML binaries on this site will not run on 2G/2G hosts
502 because UML occupies the upper .5G of the 3G process address space
503 (0xa0000000 - 0xbfffffff). Obviously, on 2G/2G hosts, this is right
504 in the middle of the kernel address space, so UML won't even load - it
505 will immediately segfault.
506
507
508
509
5104.3. The solution
511------------------
512
513
514 The fix for this is to rebuild UML from source after enabling
515 CONFIG_HOST_2G_2G (under 'General Setup'). This will cause UML to
516 load itself in the top .5G of that smaller process address space,
517 where it will run fine. See :ref:`Compiling_the_kernel_and_modules` if
518 you need help building UML from source.
519
520
521
522
523
524
525
526.. _setting_up_serial_lines_and_consoles:
527
528
5295. Setting up serial lines and consoles
530========================================
531
532
533 It is possible to attach UML serial lines and consoles to many types
534 of host I/O channels by specifying them on the command line.
535
536
537 You can attach them to host ptys, ttys, file descriptors, and ports.
538 This allows you to do things like:
539
540 - have a UML console appear on an unused host console,
541
542 - hook two virtual machines together by having one attach to a pty
543 and having the other attach to the corresponding tty
544
545 - make a virtual machine accessible from the net by attaching a
546 console to a port on the host.
547
548
549 The general format of the command line option is ``device=channel``.
550
551
552
5535.1. Specifying the device
554---------------------------
555
556 Devices are specified with "con" or "ssl" (console or serial line,
557 respectively), optionally with a device number if you are talking
558 about a specific device.
559
560
561 Using just "con" or "ssl" describes all of the consoles or serial
562 lines. If you want to talk about console #3 or serial line #10, they
563 would be "con3" and "ssl10", respectively.
564
565
566 A specific device name will override a less general "con=" or "ssl=".
567 So, for example, you can assign a pty to each of the serial lines
568 except for the first two like this::
569
570
571 ssl=pty ssl0=tty:/dev/tty0 ssl1=tty:/dev/tty1
572
573
574
575
576 The specificity of the device name is all that matters; order on the
577 command line is irrelevant.
578
579
580
5815.2. Specifying the channel
582----------------------------
583
584 There are a number of different types of channels to attach a UML
585 device to, each with a different way of specifying exactly what to
586 attach to.
587
588 - pseudo-terminals - device=pty pts terminals - device=pts
589
590
591 This will cause UML to allocate a free host pseudo-terminal for the
592 device. The terminal that it got will be announced in the boot
593 log. You access it by attaching a terminal program to the
594 corresponding tty:
595
596 - screen /dev/pts/n
597
598 - screen /dev/ttyxx
599
600 - minicom -o -p /dev/ttyxx - minicom seems not able to handle pts
601 devices
602
603 - kermit - start it up, 'open' the device, then 'connect'
604
605
606
607
608
609 - terminals - device=tty:tty device file
610
611
612 This will make UML attach the device to the specified tty (i.e::
613
614
615 con1=tty:/dev/tty3
616
617
618
619
620 will attach UML's console 1 to the host's /dev/tty3). If the tty that
621 you specify is the slave end of a tty/pty pair, something else must
622 have already opened the corresponding pty in order for this to work.
623
624
625
626
627
628 - xterms - device=xterm
629
630
631 UML will run an xterm and the device will be attached to it.
632
633
634
635
636
637 - Port - device=port:port number
638
639
640 This will attach the UML devices to the specified host port.
641 Attaching console 1 to the host's port 9000 would be done like
642 this::
643
644
645 con1=port:9000
646
647
648
649
650 Attaching all the serial lines to that port would be done similarly::
651
652
653 ssl=port:9000
654
655
656
657
658 You access these devices by telnetting to that port. Each active
659 telnet session gets a different device. If there are more telnets to a
660 port than UML devices attached to it, then the extra telnet sessions
661 will block until an existing telnet detaches, or until another device
662 becomes active (i.e. by being activated in /etc/inittab).
663
664 This channel has the advantage that you can both attach multiple UML
665 devices to it and know how to access them without reading the UML boot
666 log. It is also unique in allowing access to a UML from remote
667 machines without requiring that the UML be networked. This could be
668 useful in allowing public access to UMLs because they would be
669 accessible from the net, but wouldn't need any kind of network
670 filtering or access control because they would have no network access.
671
672
673 If you attach the main console to a portal, then the UML boot will
674 appear to hang. In reality, it's waiting for a telnet to connect, at
675 which point the boot will proceed.
676
677
678
679
680
681 - already-existing file descriptors - device=file descriptor
682
683
684 If you set up a file descriptor on the UML command line, you can
685 attach a UML device to it. This is most commonly used to put the
686 main console back on stdin and stdout after assigning all the other
687 consoles to something else::
688
689
690 con0=fd:0,fd:1 con=pts
691
692
693
694
695
696
697
698
699 - Nothing - device=null
700
701
702 This allows the device to be opened, in contrast to 'none', but
703 reads will block, and writes will succeed and the data will be
704 thrown out.
705
706
707
708
709
710 - None - device=none
711
712
713 This causes the device to disappear.
714
715
716
717 You can also specify different input and output channels for a device
718 by putting a comma between them::
719
720
721 ssl3=tty:/dev/tty2,xterm
722
723
724
725
726 will cause serial line 3 to accept input on the host's /dev/tty2 and
727 display output on an xterm. That's a silly example - the most common
728 use of this syntax is to reattach the main console to stdin and stdout
729 as shown above.
730
731
732 If you decide to move the main console away from stdin/stdout, the
733 initial boot output will appear in the terminal that you're running
734 UML in. However, once the console driver has been officially
735 initialized, then the boot output will start appearing wherever you
736 specified that console 0 should be. That device will receive all
737 subsequent output.
738
739
740
7415.3. Examples
742--------------
743
744 There are a number of interesting things you can do with this
745 capability.
746
747
748 First, this is how you get rid of those bleeding console xterms by
749 attaching them to host ptys::
750
751
752 con=pty con0=fd:0,fd:1
753
754
755
756
757 This will make a UML console take over an unused host virtual console,
758 so that when you switch to it, you will see the UML login prompt
759 rather than the host login prompt::
760
761
762 con1=tty:/dev/tty6
763
764
765
766
767 You can attach two virtual machines together with what amounts to a
768 serial line as follows:
769
770 Run one UML with a serial line attached to a pty::
771
772
773 ssl1=pty
774
775
776
777
778 Look at the boot log to see what pty it got (this example will assume
779 that it got /dev/ptyp1).
780
781 Boot the other UML with a serial line attached to the corresponding
782 tty::
783
784
785 ssl1=tty:/dev/ttyp1
786
787
788
789
790 Log in, make sure that it has no getty on that serial line, attach a
791 terminal program like minicom to it, and you should see the login
792 prompt of the other virtual machine.
793
794
795.. _setting_up_the_network:
796
7976. Setting up the network
798==========================
799
800
801
802 This page describes how to set up the various transports and to
803 provide a UML instance with network access to the host, other machines
804 on the local net, and the rest of the net.
805
806
807 As of 2.4.5, UML networking has been completely redone to make it much
808 easier to set up, fix bugs, and add new features.
809
810
811 There is a new helper, uml_net, which does the host setup that
812 requires root privileges.
813
814
815 There are currently five transport types available for a UML virtual
816 machine to exchange packets with other hosts:
817
818 - ethertap
819
820 - TUN/TAP
821
822 - Multicast
823
824 - a switch daemon
825
826 - slip
827
828 - slirp
829
830 - pcap
831
832 The TUN/TAP, ethertap, slip, and slirp transports allow a UML
833 instance to exchange packets with the host. They may be directed
834 to the host or the host may just act as a router to provide access
835 to other physical or virtual machines.
836
837
838 The pcap transport is a synthetic read-only interface, using the
839 libpcap binary to collect packets from interfaces on the host and
840 filter them. This is useful for building preconfigured traffic
841 monitors or sniffers.
842
843
844 The daemon and multicast transports provide a completely virtual
845 network to other virtual machines. This network is completely
846 disconnected from the physical network unless one of the virtual
847 machines on it is acting as a gateway.
848
849
850 With so many host transports, which one should you use? Here's when
851 you should use each one:
852
853 - ethertap - if you want access to the host networking and it is
854 running 2.2
855
856 - TUN/TAP - if you want access to the host networking and it is
857 running 2.4. Also, the TUN/TAP transport is able to use a
858 preconfigured device, allowing it to avoid using the setuid uml_net
859 helper, which is a security advantage.
860
861 - Multicast - if you want a purely virtual network and you don't want
862 to set up anything but the UML
863
864 - a switch daemon - if you want a purely virtual network and you
865 don't mind running the daemon in order to get somewhat better
866 performance
867
868 - slip - there is no particular reason to run the slip backend unless
869 ethertap and TUN/TAP are just not available for some reason
870
871 - slirp - if you don't have root access on the host to setup
872 networking, or if you don't want to allocate an IP to your UML
873
874 - pcap - not much use for actual network connectivity, but great for
875 monitoring traffic on the host
876
877 Ethertap is available on 2.4 and works fine. TUN/TAP is preferred
878 to it because it has better performance and ethertap is officially
879 considered obsolete in 2.4. Also, the root helper only needs to
880 run occasionally for TUN/TAP, rather than handling every packet, as
881 it does with ethertap. This is a slight security advantage since
882 it provides fewer opportunities for a nasty UML user to somehow
883 exploit the helper's root privileges.
884
885
8866.1. General setup
887-------------------
888
889 First, you must have the virtual network enabled in your UML. If are
890 running a prebuilt kernel from this site, everything is already
891 enabled. If you build the kernel yourself, under the "Network device
892 support" menu, enable "Network device support", and then the three
893 transports.
894
895
896 The next step is to provide a network device to the virtual machine.
897 This is done by describing it on the kernel command line.
898
899 The general format is::
900
901
902 eth <n> = <transport> , <transport args>
903
904
905
906
907 For example, a virtual ethernet device may be attached to a host
908 ethertap device as follows::
909
910
911 eth0=ethertap,tap0,fe:fd:0:0:0:1,192.168.0.254
912
913
914
915
916 This sets up eth0 inside the virtual machine to attach itself to the
917 host /dev/tap0, assigns it an ethernet address, and assigns the host
918 tap0 interface an IP address.
919
920
921
922 Note that the IP address you assign to the host end of the tap device
923 must be different than the IP you assign to the eth device inside UML.
924 If you are short on IPs and don't want to consume two per UML, then
925 you can reuse the host's eth IP address for the host ends of the tap
926 devices. Internally, the UMLs must still get unique IPs for their eth
927 devices. You can also give the UMLs non-routable IPs (192.168.x.x or
928 10.x.x.x) and have the host masquerade them. This will let outgoing
929 connections work, but incoming connections won't without more work,
930 such as port forwarding from the host.
931 Also note that when you configure the host side of an interface, it is
932 only acting as a gateway. It will respond to pings sent to it
933 locally, but is not useful to do that since it's a host interface.
934 You are not talking to the UML when you ping that interface and get a
935 response.
936
937
938 You can also add devices to a UML and remove them at runtime. See the
939 :ref:`The_Management_Console` page for details.
940
941
942 The sections below describe this in more detail.
943
944
945 Once you've decided how you're going to set up the devices, you boot
946 UML, log in, configure the UML side of the devices, and set up routes
947 to the outside world. At that point, you will be able to talk to any
948 other machines, physical or virtual, on the net.
949
950
951 If ifconfig inside UML fails and the network refuses to come up, run
952 tell you what went wrong.
953
954
955
9566.2. Userspace daemons
957-----------------------
958
959 You will likely need the setuid helper, or the switch daemon, or both.
960 They are both installed with the RPM and deb, so if you've installed
961 either, you can skip the rest of this section.
962
963
964 If not, then you need to check them out of CVS, build them, and
965 install them. The helper is uml_net, in CVS /tools/uml_net, and the
966 daemon is uml_switch, in CVS /tools/uml_router. They are both built
967 with a plain 'make'. Both need to be installed in a directory that's
968 in your path - /usr/bin is recommend. On top of that, uml_net needs
969 to be setuid root.
970
971
972
9736.3. Specifying ethernet addresses
974-----------------------------------
975
976 Below, you will see that the TUN/TAP, ethertap, and daemon interfaces
977 allow you to specify hardware addresses for the virtual ethernet
978 devices. This is generally not necessary. If you don't have a
979 specific reason to do it, you probably shouldn't. If one is not
980 specified on the command line, the driver will assign one based on the
981 device IP address. It will provide the address fe:fd:nn:nn:nn:nn
982 where nn.nn.nn.nn is the device IP address. This is nearly always
983 sufficient to guarantee a unique hardware address for the device. A
984 couple of exceptions are:
985
986 - Another set of virtual ethernet devices are on the same network and
987 they are assigned hardware addresses using a different scheme which
988 may conflict with the UML IP address-based scheme
989
990 - You aren't going to use the device for IP networking, so you don't
991 assign the device an IP address
992
993 If you let the driver provide the hardware address, you should make
994 sure that the device IP address is known before the interface is
995 brought up. So, inside UML, this will guarantee that::
996
997
998
999 UML#
1000 ifconfig eth0 192.168.0.250 up
1001
1002
1003
1004
1005 If you decide to assign the hardware address yourself, make sure that
1006 the first byte of the address is even. Addresses with an odd first
1007 byte are broadcast addresses, which you don't want assigned to a
1008 device.
1009
1010
1011
10126.4. UML interface setup
1013-------------------------
1014
1015 Once the network devices have been described on the command line, you
1016 should boot UML and log in.
1017
1018
1019 The first thing to do is bring the interface up::
1020
1021
1022 UML# ifconfig ethn ip-address up
1023
1024
1025
1026
1027 You should be able to ping the host at this point.
1028
1029
1030 To reach the rest of the world, you should set a default route to the
1031 host::
1032
1033
1034 UML# route add default gw host ip
1035
1036
1037
1038
1039 Again, with host ip of 192.168.0.4::
1040
1041
1042 UML# route add default gw 192.168.0.4
1043
1044
1045
1046
1047 This page used to recommend setting a network route to your local net.
1048 This is wrong, because it will cause UML to try to figure out hardware
1049 addresses of the local machines by arping on the interface to the
1050 host. Since that interface is basically a single strand of ethernet
1051 with two nodes on it (UML and the host) and arp requests don't cross
1052 networks, they will fail to elicit any responses. So, what you want
1053 is for UML to just blindly throw all packets at the host and let it
1054 figure out what to do with them, which is what leaving out the network
1055 route and adding the default route does.
1056
1057
1058 Note: If you can't communicate with other hosts on your physical
1059 ethernet, it's probably because of a network route that's
1060 automatically set up. If you run 'route -n' and see a route that
1061 looks like this::
1062
1063
1064
1065
1066 Destination Gateway Genmask Flags Metric Ref Use Iface
1067 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
1068
1069
1070
1071
1072 with a mask that's not 255.255.255.255, then replace it with a route
1073 to your host::
1074
1075
1076 UML#
1077 route del -net 192.168.0.0 dev eth0 netmask 255.255.255.0
1078
1079
1080 UML#
1081 route add -host 192.168.0.4 dev eth0
1082
1083
1084
1085
1086 This, plus the default route to the host, will allow UML to exchange
1087 packets with any machine on your ethernet.
1088
1089
1090
10916.5. Multicast
1092---------------
1093
1094 The simplest way to set up a virtual network between multiple UMLs is
1095 to use the mcast transport. This was written by Harald Welte and is
1096 present in UML version 2.4.5-5um and later. Your system must have
1097 multicast enabled in the kernel and there must be a multicast-capable
1098 network device on the host. Normally, this is eth0, but if there is
1099 no ethernet card on the host, then you will likely get strange error
1100 messages when you bring the device up inside UML.
1101
1102
1103 To use it, run two UMLs with::
1104
1105
1106 eth0=mcast
1107
1108
1109
1110
1111 on their command lines. Log in, configure the ethernet device in each
1112 machine with different IP addresses::
1113
1114
1115 UML1# ifconfig eth0 192.168.0.254
1116
1117
1118 UML2# ifconfig eth0 192.168.0.253
1119
1120
1121
1122
1123 and they should be able to talk to each other.
1124
1125 The full set of command line options for this transport are::
1126
1127
1128
1129 ethn=mcast,ethernet address,multicast
1130 address,multicast port,ttl
1131
1132
1133
1134 There is also a related point-to-point only "ucast" transport.
1135 This is useful when your network does not support multicast, and
1136 all network connections are simple point to point links.
1137
1138 The full set of command line options for this transport are::
1139
1140
1141 ethn=ucast,ethernet address,remote address,listen port,remote port
1142
1143
1144
1145
11466.6. TUN/TAP with the uml_net helper
1147-------------------------------------
1148
1149 TUN/TAP is the preferred mechanism on 2.4 to exchange packets with the
1150 host. The TUN/TAP backend has been in UML since 2.4.9-3um.
1151
1152
1153 The easiest way to get up and running is to let the setuid uml_net
1154 helper do the host setup for you. This involves insmod-ing the tun.o
1155 module if necessary, configuring the device, and setting up IP
1156 forwarding, routing, and proxy arp. If you are new to UML networking,
1157 do this first. If you're concerned about the security implications of
1158 the setuid helper, use it to get up and running, then read the next
1159 section to see how to have UML use a preconfigured tap device, which
1160 avoids the use of uml_net.
1161
1162
1163 If you specify an IP address for the host side of the device, the
1164 uml_net helper will do all necessary setup on the host - the only
1165 requirement is that TUN/TAP be available, either built in to the host
1166 kernel or as the tun.o module.
1167
1168 The format of the command line switch to attach a device to a TUN/TAP
1169 device is::
1170
1171
1172 eth <n> =tuntap,,, <IP address>
1173
1174
1175
1176
1177 For example, this argument will attach the UML's eth0 to the next
1178 available tap device and assign an ethernet address to it based on its
1179 IP address::
1180
1181
1182 eth0=tuntap,,,192.168.0.254
1183
1184
1185
1186
1187
1188
1189 Note that the IP address that must be used for the eth device inside
1190 UML is fixed by the routing and proxy arp that is set up on the
1191 TUN/TAP device on the host. You can use a different one, but it won't
1192 work because reply packets won't reach the UML. This is a feature.
1193 It prevents a nasty UML user from doing things like setting the UML IP
1194 to the same as the network's nameserver or mail server.
1195
1196
1197 There are a couple potential problems with running the TUN/TAP
1198 transport on a 2.4 host kernel
1199
1200 - TUN/TAP seems not to work on 2.4.3 and earlier. Upgrade the host
1201 kernel or use the ethertap transport.
1202
1203 - With an upgraded kernel, TUN/TAP may fail with::
1204
1205
1206 File descriptor in bad state
1207
1208
1209
1210
1211 This is due to a header mismatch between the upgraded kernel and the
1212 kernel that was originally installed on the machine. The fix is to
1213 make sure that /usr/src/linux points to the headers for the running
1214 kernel.
1215
1216 These were pointed out by Tim Robinson <timro at trkr dot net> in the past.
1217
1218
1219
12206.7. TUN/TAP with a preconfigured tap device
1221---------------------------------------------
1222
1223 If you prefer not to have UML use uml_net (which is somewhat
1224 insecure), with UML 2.4.17-11, you can set up a TUN/TAP device
1225 beforehand. The setup needs to be done as root, but once that's done,
1226 there is no need for root assistance. Setting up the device is done
1227 as follows:
1228
1229 - Create the device with tunctl (available from the UML utilities
1230 tarball)::
1231
1232
1233
1234
1235 host# tunctl -u uid
1236
1237
1238
1239
1240 where uid is the user id or username that UML will be run as. This
1241 will tell you what device was created.
1242
1243 - Configure the device IP (change IP addresses and device name to
1244 suit)::
1245
1246
1247
1248
1249 host# ifconfig tap0 192.168.0.254 up
1250
1251
1252
1253
1254
1255 - Set up routing and arping if desired - this is my recipe, there are
1256 other ways of doing the same thing::
1257
1258
1259 host#
1260 bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
1261
1262 host#
1263 route add -host 192.168.0.253 dev tap0
1264
1265 host#
1266 bash -c 'echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp'
1267
1268 host#
1269 arp -Ds 192.168.0.253 eth0 pub
1270
1271
1272
1273
1274 Note that this must be done every time the host boots - this configu-
1275 ration is not stored across host reboots. So, it's probably a good
1276 idea to stick it in an rc file. An even better idea would be a little
1277 utility which reads the information from a config file and sets up
1278 devices at boot time.
1279
1280 - Rather than using up two IPs and ARPing for one of them, you can
1281 also provide direct access to your LAN by the UML by using a
1282 bridge::
1283
1284
1285 host#
1286 brctl addbr br0
1287
1288
1289 host#
1290 ifconfig eth0 0.0.0.0 promisc up
1291
1292
1293 host#
1294 ifconfig tap0 0.0.0.0 promisc up
1295
1296
1297 host#
1298 ifconfig br0 192.168.0.1 netmask 255.255.255.0 up
1299
1300
1301 host#
1302 brctl stp br0 off
1303
1304
1305 host#
1306 brctl setfd br0 1
1307
1308
1309 host#
1310 brctl sethello br0 1
1311
1312
1313 host#
1314 brctl addif br0 eth0
1315
1316
1317 host#
1318 brctl addif br0 tap0
1319
1320
1321
1322
1323 Note that 'br0' should be setup using ifconfig with the existing IP
1324 address of eth0, as eth0 no longer has its own IP.
1325
1326 -
1327
1328
1329 Also, the /dev/net/tun device must be writable by the user running
1330 UML in order for the UML to use the device that's been configured
1331 for it. The simplest thing to do is::
1332
1333
1334 host# chmod 666 /dev/net/tun
1335
1336
1337
1338
1339 Making it world-writable looks bad, but it seems not to be
1340 exploitable as a security hole. However, it does allow anyone to cre-
1341 ate useless tap devices (useless because they can't configure them),
1342 which is a DOS attack. A somewhat more secure alternative would to be
1343 to create a group containing all the users who have preconfigured tap
1344 devices and chgrp /dev/net/tun to that group with mode 664 or 660.
1345
1346
1347 - Once the device is set up, run UML with 'eth0=tuntap,device name'
1348 (i.e. 'eth0=tuntap,tap0') on the command line (or do it with the
1349 mconsole config command).
1350
1351 - Bring the eth device up in UML and you're in business.
1352
1353 If you don't want that tap device any more, you can make it non-
1354 persistent with::
1355
1356
1357 host# tunctl -d tap device
1358
1359
1360
1361
1362 Finally, tunctl has a -b (for brief mode) switch which causes it to
1363 output only the name of the tap device it created. This makes it
1364 suitable for capture by a script::
1365
1366
1367 host# TAP=`tunctl -u 1000 -b`
1368
1369
1370
1371
1372
1373
13746.8. Ethertap
1375--------------
1376
1377 Ethertap is the general mechanism on 2.2 for userspace processes to
1378 exchange packets with the kernel.
1379
1380
1381
1382 To use this transport, you need to describe the virtual network device
1383 on the UML command line. The general format for this is::
1384
1385
1386 eth <n> =ethertap, <device> , <ethernet address> , <tap IP address>
1387
1388
1389
1390
1391 So, the previous example::
1392
1393
1394 eth0=ethertap,tap0,fe:fd:0:0:0:1,192.168.0.254
1395
1396
1397
1398
1399 attaches the UML eth0 device to the host /dev/tap0, assigns it the
1400 ethernet address fe:fd:0:0:0:1, and assigns the IP address
1401 192.168.0.254 to the tap device.
1402
1403
1404
1405 The tap device is mandatory, but the others are optional. If the
1406 ethernet address is omitted, one will be assigned to it.
1407
1408
1409 The presence of the tap IP address will cause the helper to run and do
1410 whatever host setup is needed to allow the virtual machine to
1411 communicate with the outside world. If you're not sure you know what
1412 you're doing, this is the way to go.
1413
1414
1415 If it is absent, then you must configure the tap device and whatever
1416 arping and routing you will need on the host. However, even in this
1417 case, the uml_net helper still needs to be in your path and it must be
1418 setuid root if you're not running UML as root. This is because the
1419 tap device doesn't support SIGIO, which UML needs in order to use
1420 something as a source of input. So, the helper is used as a
1421 convenient asynchronous IO thread.
1422
1423 If you're using the uml_net helper, you can ignore the following host
1424 setup - uml_net will do it for you. You just need to make sure you
1425 have ethertap available, either built in to the host kernel or
1426 available as a module.
1427
1428
1429 If you want to set things up yourself, you need to make sure that the
1430 appropriate /dev entry exists. If it doesn't, become root and create
1431 it as follows::
1432
1433
1434 mknod /dev/tap <minor> c 36 <minor> + 16
1435
1436
1437
1438
1439 For example, this is how to create /dev/tap0::
1440
1441
1442 mknod /dev/tap0 c 36 0 + 16
1443
1444
1445
1446
1447 You also need to make sure that the host kernel has ethertap support.
1448 If ethertap is enabled as a module, you apparently need to insmod
1449 ethertap once for each ethertap device you want to enable. So,::
1450
1451
1452 host#
1453 insmod ethertap
1454
1455
1456
1457
1458 will give you the tap0 interface. To get the tap1 interface, you need
1459 to run::
1460
1461
1462 host#
1463 insmod ethertap unit=1 -o ethertap1
1464
1465
1466
1467
1468
1469
1470
14716.9. The switch daemon
1472-----------------------
1473
1474 Note: This is the daemon formerly known as uml_router, but which was
1475 renamed so the network weenies of the world would stop growling at me.
1476
1477
1478 The switch daemon, uml_switch, provides a mechanism for creating a
1479 totally virtual network. By default, it provides no connection to the
1480 host network (but see -tap, below).
1481
1482
1483 The first thing you need to do is run the daemon. Running it with no
1484 arguments will make it listen on a default pair of unix domain
1485 sockets.
1486
1487
1488 If you want it to listen on a different pair of sockets, use::
1489
1490
1491 -unix control socket data socket
1492
1493
1494
1495
1496
1497 If you want it to act as a hub rather than a switch, use::
1498
1499
1500 -hub
1501
1502
1503
1504
1505
1506 If you want the switch to be connected to host networking (allowing
1507 the umls to get access to the outside world through the host), use::
1508
1509
1510 -tap tap0
1511
1512
1513
1514
1515
1516 Note that the tap device must be preconfigured (see "TUN/TAP with a
1517 preconfigured tap device", above). If you're using a different tap
1518 device than tap0, specify that instead of tap0.
1519
1520
1521 uml_switch can be backgrounded as follows::
1522
1523
1524 host%
1525 uml_switch [ options ] < /dev/null > /dev/null
1526
1527
1528
1529
1530 The reason it doesn't background by default is that it listens to
1531 stdin for EOF. When it sees that, it exits.
1532
1533
1534 The general format of the kernel command line switch is::
1535
1536
1537
1538 ethn=daemon,ethernet address,socket
1539 type,control socket,data socket
1540
1541
1542
1543
1544 You can leave off everything except the 'daemon'. You only need to
1545 specify the ethernet address if the one that will be assigned to it
1546 isn't acceptable for some reason. The rest of the arguments describe
1547 how to communicate with the daemon. You should only specify them if
1548 you told the daemon to use different sockets than the default. So, if
1549 you ran the daemon with no arguments, running the UML on the same
1550 machine with::
1551
1552 eth0=daemon
1553
1554
1555
1556
1557 will cause the eth0 driver to attach itself to the daemon correctly.
1558
1559
1560
15616.10. Slip
1562-----------
1563
1564 Slip is another, less general, mechanism for a process to communicate
1565 with the host networking. In contrast to the ethertap interface,
1566 which exchanges ethernet frames with the host and can be used to
1567 transport any higher-level protocol, it can only be used to transport
1568 IP.
1569
1570
1571 The general format of the command line switch is::
1572
1573
1574
1575 ethn=slip,slip IP
1576
1577
1578
1579
1580 The slip IP argument is the IP address that will be assigned to the
1581 host end of the slip device. If it is specified, the helper will run
1582 and will set up the host so that the virtual machine can reach it and
1583 the rest of the network.
1584
1585
1586 There are some oddities with this interface that you should be aware
1587 of. You should only specify one slip device on a given virtual
1588 machine, and its name inside UML will be 'umn', not 'eth0' or whatever
1589 you specified on the command line. These problems will be fixed at
1590 some point.
1591
1592
1593
15946.11. Slirp
1595------------
1596
1597 slirp uses an external program, usually /usr/bin/slirp, to provide IP
1598 only networking connectivity through the host. This is similar to IP
1599 masquerading with a firewall, although the translation is performed in
1600 user-space, rather than by the kernel. As slirp does not set up any
1601 interfaces on the host, or changes routing, slirp does not require
1602 root access or setuid binaries on the host.
1603
1604
1605 The general format of the command line switch for slirp is::
1606
1607
1608
1609 ethn=slirp,ethernet address,slirp path
1610
1611
1612
1613
1614 The ethernet address is optional, as UML will set up the interface
1615 with an ethernet address based upon the initial IP address of the
1616 interface. The slirp path is generally /usr/bin/slirp, although it
1617 will depend on distribution.
1618
1619
1620 The slirp program can have a number of options passed to the command
1621 line and we can't add them to the UML command line, as they will be
1622 parsed incorrectly. Instead, a wrapper shell script can be written or
1623 the options inserted into the /.slirprc file. More information on
1624 all of the slirp options can be found in its man pages.
1625
1626
1627 The eth0 interface on UML should be set up with the IP 10.2.0.15,
1628 although you can use anything as long as it is not used by a network
1629 you will be connecting to. The default route on UML should be set to
1630 use::
1631
1632
1633 UML#
1634 route add default dev eth0
1635
1636
1637
1638
1639 slirp provides a number of useful IP addresses which can be used by
1640 UML, such as 10.0.2.3 which is an alias for the DNS server specified
1641 in /etc/resolv.conf on the host or the IP given in the 'dns' option
1642 for slirp.
1643
1644
1645 Even with a baudrate setting higher than 115200, the slirp connection
1646 is limited to 115200. If you need it to go faster, the slirp binary
1647 needs to be compiled with FULL_BOLT defined in config.h.
1648
1649
1650
16516.12. pcap
1652-----------
1653
1654 The pcap transport is attached to a UML ethernet device on the command
1655 line or with uml_mconsole with the following syntax::
1656
1657
1658
1659 ethn=pcap,host interface,filter
1660 expression,option1,option2
1661
1662
1663
1664
1665 The expression and options are optional.
1666
1667
1668 The interface is whatever network device on the host you want to
1669 sniff. The expression is a pcap filter expression, which is also what
1670 tcpdump uses, so if you know how to specify tcpdump filters, you will
1671 use the same expressions here. The options are up to two of
1672 'promisc', control whether pcap puts the host interface into
1673 promiscuous mode. 'optimize' and 'nooptimize' control whether the pcap
1674 expression optimizer is used.
1675
1676
1677 Example::
1678
1679
1680
1681 eth0=pcap,eth0,tcp
1682
1683 eth1=pcap,eth0,!tcp
1684
1685
1686
1687 will cause the UML eth0 to emit all tcp packets on the host eth0 and
1688 the UML eth1 to emit all non-tcp packets on the host eth0.
1689
1690
1691
16926.13. Setting up the host yourself
1693-----------------------------------
1694
1695 If you don't specify an address for the host side of the ethertap or
1696 slip device, UML won't do any setup on the host. So this is what is
1697 needed to get things working (the examples use a host-side IP of
1698 192.168.0.251 and a UML-side IP of 192.168.0.250 - adjust to suit your
1699 own network):
1700
1701 - The device needs to be configured with its IP address. Tap devices
1702 are also configured with an mtu of 1484. Slip devices are
1703 configured with a point-to-point address pointing at the UML ip
1704 address::
1705
1706
1707 host# ifconfig tap0 arp mtu 1484 192.168.0.251 up
1708
1709
1710 host#
1711 ifconfig sl0 192.168.0.251 pointopoint 192.168.0.250 up
1712
1713
1714
1715
1716
1717 - If a tap device is being set up, a route is set to the UML IP::
1718
1719
1720 UML# route add -host 192.168.0.250 gw 192.168.0.251
1721
1722
1723
1724
1725
1726 - To allow other hosts on your network to see the virtual machine,
1727 proxy arp is set up for it::
1728
1729
1730 host# arp -Ds 192.168.0.250 eth0 pub
1731
1732
1733
1734
1735
1736 - Finally, the host is set up to route packets::
1737
1738
1739 host# echo 1 > /proc/sys/net/ipv4/ip_forward
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
17507. Sharing Filesystems between Virtual Machines
1751================================================
1752
1753
1754
1755
17567.1. A warning
1757---------------
1758
1759 Don't attempt to share filesystems simply by booting two UMLs from the
1760 same file. That's the same thing as booting two physical machines
1761 from a shared disk. It will result in filesystem corruption.
1762
1763
1764
17657.2. Using layered block devices
1766---------------------------------
1767
1768 The way to share a filesystem between two virtual machines is to use
1769 the copy-on-write (COW) layering capability of the ubd block driver.
1770 As of 2.4.6-2um, the driver supports layering a read-write private
1771 device over a read-only shared device. A machine's writes are stored
1772 in the private device, while reads come from either device - the
1773 private one if the requested block is valid in it, the shared one if
1774 not. Using this scheme, the majority of data which is unchanged is
1775 shared between an arbitrary number of virtual machines, each of which
1776 has a much smaller file containing the changes that it has made. With
1777 a large number of UMLs booting from a large root filesystem, this
1778 leads to a huge disk space saving. It will also help performance,
1779 since the host will be able to cache the shared data using a much
1780 smaller amount of memory, so UML disk requests will be served from the
1781 host's memory rather than its disks.
1782
1783
1784
1785
1786 To add a copy-on-write layer to an existing block device file, simply
1787 add the name of the COW file to the appropriate ubd switch::
1788
1789
1790 ubd0=root_fs_cow,root_fs_debian_22
1791
1792
1793
1794
1795 where 'root_fs_cow' is the private COW file and 'root_fs_debian_22' is
1796 the existing shared filesystem. The COW file need not exist. If it
1797 doesn't, the driver will create and initialize it. Once the COW file
1798 has been initialized, it can be used on its own on the command line::
1799
1800
1801 ubd0=root_fs_cow
1802
1803
1804
1805
1806 The name of the backing file is stored in the COW file header, so it
1807 would be redundant to continue specifying it on the command line.
1808
1809
1810
18117.3. Note!
1812-----------
1813
1814 When checking the size of the COW file in order to see the gobs of
1815 space that you're saving, make sure you use 'ls -ls' to see the actual
1816 disk consumption rather than the length of the file. The COW file is
1817 sparse, so the length will be very different from the disk usage.
1818 Here is a 'ls -l' of a COW file and backing file from one boot and
1819 shutdown::
1820
1821 host% ls -l cow.debian debian2.2
1822 -rw-r--r-- 1 jdike jdike 492504064 Aug 6 21:16 cow.debian
1823 -rwxrw-rw- 1 jdike jdike 537919488 Aug 6 20:42 debian2.2
1824
1825
1826
1827
1828 Doesn't look like much saved space, does it? Well, here's 'ls -ls'::
1829
1830
1831 host% ls -ls cow.debian debian2.2
1832 880 -rw-r--r-- 1 jdike jdike 492504064 Aug 6 21:16 cow.debian
1833 525832 -rwxrw-rw- 1 jdike jdike 537919488 Aug 6 20:42 debian2.2
1834
1835
1836
1837
1838 Now, you can see that the COW file has less than a meg of disk, rather
1839 than 492 meg.
1840
1841
1842
18437.4. Another warning
1844---------------------
1845
1846 Once a filesystem is being used as a readonly backing file for a COW
1847 file, do not boot directly from it or modify it in any way. Doing so
1848 will invalidate any COW files that are using it. The mtime and size
1849 of the backing file are stored in the COW file header at its creation,
1850 and they must continue to match. If they don't, the driver will
1851 refuse to use the COW file.
1852
1853
1854
1855
1856 If you attempt to evade this restriction by changing either the
1857 backing file or the COW header by hand, you will get a corrupted
1858 filesystem.
1859
1860
1861
1862
1863 Among other things, this means that upgrading the distribution in a
1864 backing file and expecting that all of the COW files using it will see
1865 the upgrade will not work.
1866
1867
1868
1869
18707.5. uml_moo : Merging a COW file with its backing file
1871--------------------------------------------------------
1872
1873 Depending on how you use UML and COW devices, it may be advisable to
1874 merge the changes in the COW file into the backing file every once in
1875 a while.
1876
1877
1878
1879
1880 The utility that does this is uml_moo. Its usage is::
1881
1882
1883 host% uml_moo COW file new backing file
1884
1885
1886
1887
1888 There's no need to specify the backing file since that information is
1889 already in the COW file header. If you're paranoid, boot the new
1890 merged file, and if you're happy with it, move it over the old backing
1891 file.
1892
1893
1894
1895
1896 uml_moo creates a new backing file by default as a safety measure. It
1897 also has a destructive merge option which will merge the COW file
1898 directly into its current backing file. This is really only usable
1899 when the backing file only has one COW file associated with it. If
1900 there are multiple COWs associated with a backing file, a -d merge of
1901 one of them will invalidate all of the others. However, it is
1902 convenient if you're short of disk space, and it should also be
1903 noticeably faster than a non-destructive merge.
1904
1905
1906
1907
1908 uml_moo is installed with the UML deb and RPM. If you didn't install
1909 UML from one of those packages, you can also get it from the UML
1910 utilities http://user-mode-linux.sourceforge.net/utilities tar file
1911 in tools/moo.
1912
1913
1914
1915
1916
1917
1918
1919
19208. Creating filesystems
1921========================
1922
1923
1924 You may want to create and mount new UML filesystems, either because
1925 your root filesystem isn't large enough or because you want to use a
1926 filesystem other than ext2.
1927
1928
1929 This was written on the occasion of reiserfs being included in the
1930 2.4.1 kernel pool, and therefore the 2.4.1 UML, so the examples will
1931 talk about reiserfs. This information is generic, and the examples
1932 should be easy to translate to the filesystem of your choice.
1933
1934
19358.1. Create the filesystem file
1936================================
1937
1938 dd is your friend. All you need to do is tell dd to create an empty
1939 file of the appropriate size. I usually make it sparse to save time
1940 and to avoid allocating disk space until it's actually used. For
1941 example, the following command will create a sparse 100 meg file full
1942 of zeroes::
1943
1944
1945 host%
1946 dd if=/dev/zero of=new_filesystem seek=100 count=1 bs=1M
1947
1948
1949
1950
1951
1952
1953 8.2. Assign the file to a UML device
1954
1955 Add an argument like the following to the UML command line::
1956
1957 ubd4=new_filesystem
1958
1959
1960
1961
1962 making sure that you use an unassigned ubd device number.
1963
1964
1965
1966 8.3. Creating and mounting the filesystem
1967
1968 Make sure that the filesystem is available, either by being built into
1969 the kernel, or available as a module, then boot up UML and log in. If
1970 the root filesystem doesn't have the filesystem utilities (mkfs, fsck,
1971 etc), then get them into UML by way of the net or hostfs.
1972
1973
1974 Make the new filesystem on the device assigned to the new file::
1975
1976
1977 host# mkreiserfs /dev/ubd/4
1978
1979
1980 <----------- MKREISERFSv2 ----------->
1981
1982 ReiserFS version 3.6.25
1983 Block size 4096 bytes
1984 Block count 25856
1985 Used blocks 8212
1986 Journal - 8192 blocks (18-8209), journal header is in block 8210
1987 Bitmaps: 17
1988 Root block 8211
1989 Hash function "r5"
1990 ATTENTION: ALL DATA WILL BE LOST ON '/dev/ubd/4'! (y/n)y
1991 journal size 8192 (from 18)
1992 Initializing journal - 0%....20%....40%....60%....80%....100%
1993 Syncing..done.
1994
1995
1996
1997
1998 Now, mount it::
1999
2000
2001 UML#
2002 mount /dev/ubd/4 /mnt
2003
2004
2005
2006
2007 and you're in business.
2008
2009
2010
2011
2012
2013
2014
2015
2016
20179. Host file access
2018====================
2019
2020
2021 If you want to access files on the host machine from inside UML, you
2022 can treat it as a separate machine and either nfs mount directories
2023 from the host or copy files into the virtual machine with scp or rcp.
2024 However, since UML is running on the host, it can access those
2025 files just like any other process and make them available inside the
2026 virtual machine without needing to use the network.
2027
2028
2029 This is now possible with the hostfs virtual filesystem. With it, you
2030 can mount a host directory into the UML filesystem and access the
2031 files contained in it just as you would on the host.
2032
2033
20349.1. Using hostfs
2035------------------
2036
2037 To begin with, make sure that hostfs is available inside the virtual
2038 machine with::
2039
2040
2041 UML# cat /proc/filesystems
2042
2043
2044
2045 . hostfs should be listed. If it's not, either rebuild the kernel
2046 with hostfs configured into it or make sure that hostfs is built as a
2047 module and available inside the virtual machine, and insmod it.
2048
2049
2050 Now all you need to do is run mount::
2051
2052
2053 UML# mount none /mnt/host -t hostfs
2054
2055
2056
2057
2058 will mount the host's / on the virtual machine's /mnt/host.
2059
2060
2061 If you don't want to mount the host root directory, then you can
2062 specify a subdirectory to mount with the -o switch to mount::
2063
2064
2065 UML# mount none /mnt/home -t hostfs -o /home
2066
2067
2068
2069
2070 will mount the hosts's /home on the virtual machine's /mnt/home.
2071
2072
2073
20749.2. hostfs as the root filesystem
2075-----------------------------------
2076
2077 It's possible to boot from a directory hierarchy on the host using
2078 hostfs rather than using the standard filesystem in a file.
2079
2080 To start, you need that hierarchy. The easiest way is to loop mount
2081 an existing root_fs file::
2082
2083
2084 host# mount root_fs uml_root_dir -o loop
2085
2086
2087
2088
2089 You need to change the filesystem type of / in etc/fstab to be
2090 'hostfs', so that line looks like this::
2091
2092 /dev/ubd/0 / hostfs defaults 1 1
2093
2094
2095
2096
2097 Then you need to chown to yourself all the files in that directory
2098 that are owned by root. This worked for me::
2099
2100
2101 host# find . -uid 0 -exec chown jdike {} \;
2102
2103
2104
2105
2106 Next, make sure that your UML kernel has hostfs compiled in, not as a
2107 module. Then run UML with the boot device pointing at that directory::
2108
2109
2110 ubd0=/path/to/uml/root/directory
2111
2112
2113
2114
2115 UML should then boot as it does normally.
2116
2117
21189.3. Building hostfs
2119---------------------
2120
2121 If you need to build hostfs because it's not in your kernel, you have
2122 two choices:
2123
2124
2125
2126 - Compiling hostfs into the kernel:
2127
2128
2129 Reconfigure the kernel and set the 'Host filesystem' option under
2130
2131
2132 - Compiling hostfs as a module:
2133
2134
2135 Reconfigure the kernel and set the 'Host filesystem' option under
2136 be in arch/um/fs/hostfs/hostfs.o. Install that in
2137 ``/lib/modules/$(uname -r)/fs`` in the virtual machine, boot it up, and::
2138
2139
2140 UML# insmod hostfs
2141
2142
2143.. _The_Management_Console:
2144
214510. The Management Console
2146===========================
2147
2148
2149
2150 The UML management console is a low-level interface to the kernel,
2151 somewhat like the i386 SysRq interface. Since there is a full-blown
2152 operating system under UML, there is much greater flexibility possible
2153 than with the SysRq mechanism.
2154
2155
2156 There are a number of things you can do with the mconsole interface:
2157
2158 - get the kernel version
2159
2160 - add and remove devices
2161
2162 - halt or reboot the machine
2163
2164 - Send SysRq commands
2165
2166 - Pause and resume the UML
2167
2168
2169 You need the mconsole client (uml_mconsole) which is present in CVS
2170 (/tools/mconsole) in 2.4.5-9um and later, and will be in the RPM in
2171 2.4.6.
2172
2173
2174 You also need CONFIG_MCONSOLE (under 'General Setup') enabled in UML.
2175 When you boot UML, you'll see a line like::
2176
2177
2178 mconsole initialized on /home/jdike/.uml/umlNJ32yL/mconsole
2179
2180
2181
2182
2183 If you specify a unique machine id one the UML command line, i.e.::
2184
2185
2186 umid=debian
2187
2188
2189
2190
2191 you'll see this::
2192
2193
2194 mconsole initialized on /home/jdike/.uml/debian/mconsole
2195
2196
2197
2198
2199 That file is the socket that uml_mconsole will use to communicate with
2200 UML. Run it with either the umid or the full path as its argument::
2201
2202
2203 host% uml_mconsole debian
2204
2205
2206
2207
2208 or::
2209
2210
2211 host% uml_mconsole /home/jdike/.uml/debian/mconsole
2212
2213
2214
2215
2216 You'll get a prompt, at which you can run one of these commands:
2217
2218 - version
2219
2220 - halt
2221
2222 - reboot
2223
2224 - config
2225
2226 - remove
2227
2228 - sysrq
2229
2230 - help
2231
2232 - cad
2233
2234 - stop
2235
2236 - go
2237
2238
223910.1. version
2240--------------
2241
2242 This takes no arguments. It prints the UML version::
2243
2244
2245 (mconsole) version
2246 OK Linux usermode 2.4.5-9um #1 Wed Jun 20 22:47:08 EDT 2001 i686
2247
2248
2249
2250
2251 There are a couple actual uses for this. It's a simple no-op which
2252 can be used to check that a UML is running. It's also a way of
2253 sending an interrupt to the UML. This is sometimes useful on SMP
2254 hosts, where there's a bug which causes signals to UML to be lost,
2255 often causing it to appear to hang. Sending such a UML the mconsole
2256 version command is a good way to 'wake it up' before networking has
2257 been enabled, as it does not do anything to the function of the UML.
2258
2259
2260
226110.2. halt and reboot
2262----------------------
2263
2264 These take no arguments. They shut the machine down immediately, with
2265 no syncing of disks and no clean shutdown of userspace. So, they are
2266 pretty close to crashing the machine::
2267
2268
2269 (mconsole) halt
2270 OK
2271
2272
2273
2274
2275
2276
227710.3. config
2278-------------
2279
2280 "config" adds a new device to the virtual machine. Currently the ubd
2281 and network drivers support this. It takes one argument, which is the
2282 device to add, with the same syntax as the kernel command line::
2283
2284
2285
2286
2287 (mconsole)
2288 config ubd3=/home/jdike/incoming/roots/root_fs_debian22
2289
2290 OK
2291 (mconsole) config eth1=mcast
2292 OK
2293
2294
2295
2296
2297
2298
229910.4. remove
2300-------------
2301
2302 "remove" deletes a device from the system. Its argument is just the
2303 name of the device to be removed. The device must be idle in whatever
2304 sense the driver considers necessary. In the case of the ubd driver,
2305 the removed block device must not be mounted, swapped on, or otherwise
2306 open, and in the case of the network driver, the device must be down::
2307
2308
2309 (mconsole) remove ubd3
2310 OK
2311 (mconsole) remove eth1
2312 OK
2313
2314
2315
2316
2317
2318
231910.5. sysrq
2320------------
2321
2322 This takes one argument, which is a single letter. It calls the
2323 generic kernel's SysRq driver, which does whatever is called for by
2324 that argument. See the SysRq documentation in
2325 Documentation/admin-guide/sysrq.rst in your favorite kernel tree to
2326 see what letters are valid and what they do.
2327
2328
2329
233010.6. help
2331-----------
2332
2333 "help" returns a string listing the valid commands and what each one
2334 does.
2335
2336
2337
233810.7. cad
2339----------
2340
2341 This invokes the Ctl-Alt-Del action on init. What exactly this ends
2342 up doing is up to /etc/inittab. Normally, it reboots the machine.
2343 With UML, this is usually not desired, so if a halt would be better,
2344 then find the section of inittab that looks like this::
2345
2346
2347 # What to do when CTRL-ALT-DEL is pressed.
2348 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
2349
2350
2351
2352
2353 and change the command to halt.
2354
2355
2356
235710.8. stop
2358-----------
2359
2360 This puts the UML in a loop reading mconsole requests until a 'go'
2361 mconsole command is received. This is very useful for making backups
2362 of UML filesystems, as the UML can be stopped, then synced via 'sysrq
2363 s', so that everything is written to the filesystem. You can then copy
2364 the filesystem and then send the UML 'go' via mconsole.
2365
2366
2367 Note that a UML running with more than one CPU will have problems
2368 after you send the 'stop' command, as only one CPU will be held in a
2369 mconsole loop and all others will continue as normal. This is a bug,
2370 and will be fixed.
2371
2372
2373
237410.9. go
2375---------
2376
2377 This resumes a UML after being paused by a 'stop' command. Note that
2378 when the UML has resumed, TCP connections may have timed out and if
2379 the UML is paused for a long period of time, crond might go a little
2380 crazy, running all the jobs it didn't do earlier.
2381
2382
2383
2384
2385
2386
2387.. _Kernel_debugging:
2388
238911. Kernel debugging
2390=====================
2391
2392
2393 Note: The interface that makes debugging, as described here, possible
2394 is present in 2.4.0-test6 kernels and later.
2395
2396
2397 Since the user-mode kernel runs as a normal Linux process, it is
2398 possible to debug it with gdb almost like any other process. It is
2399 slightly different because the kernel's threads are already being
2400 ptraced for system call interception, so gdb can't ptrace them.
2401 However, a mechanism has been added to work around that problem.
2402
2403
2404 In order to debug the kernel, you need build it from source. See
2405 :ref:`Compiling_the_kernel_and_modules` for information on doing that.
2406 Make sure that you enable CONFIG_DEBUGSYM and CONFIG_PT_PROXY during
2407 the config. These will compile the kernel with ``-g``, and enable the
2408 ptrace proxy so that gdb works with UML, respectively.
2409
2410
2411
2412
241311.1. Starting the kernel under gdb
2414------------------------------------
2415
2416 You can have the kernel running under the control of gdb from the
2417 beginning by putting 'debug' on the command line. You will get an
2418 xterm with gdb running inside it. The kernel will send some commands
2419 to gdb which will leave it stopped at the beginning of start_kernel.
2420 At this point, you can get things going with 'next', 'step', or
2421 'cont'.
2422
2423
2424 There is a transcript of a debugging session here <debug-
2425 session.html> , with breakpoints being set in the scheduler and in an
2426 interrupt handler.
2427
2428
242911.2. Examining sleeping processes
2430-----------------------------------
2431
2432
2433 Not every bug is evident in the currently running process. Sometimes,
2434 processes hang in the kernel when they shouldn't because they've
2435 deadlocked on a semaphore or something similar. In this case, when
2436 you ^C gdb and get a backtrace, you will see the idle thread, which
2437 isn't very relevant.
2438
2439
2440 What you want is the stack of whatever process is sleeping when it
2441 shouldn't be. You need to figure out which process that is, which is
2442 generally fairly easy. Then you need to get its host process id,
2443 which you can do either by looking at ps on the host or at
2444 task.thread.extern_pid in gdb.
2445
2446
2447 Now what you do is this:
2448
2449 - detach from the current thread::
2450
2451
2452 (UML gdb) det
2453
2454
2455
2456
2457
2458 - attach to the thread you are interested in::
2459
2460
2461 (UML gdb) att <host pid>
2462
2463
2464
2465
2466
2467 - look at its stack and anything else of interest::
2468
2469
2470 (UML gdb) bt
2471
2472
2473
2474
2475 Note that you can't do anything at this point that requires that a
2476 process execute, e.g. calling a function
2477
2478 - when you're done looking at that process, reattach to the current
2479 thread and continue it::
2480
2481
2482 (UML gdb)
2483 att 1
2484
2485
2486 (UML gdb)
2487 c
2488
2489
2490
2491
2492 Here, specifying any pid which is not the process id of a UML thread
2493 will cause gdb to reattach to the current thread. I commonly use 1,
2494 but any other invalid pid would work.
2495
2496
2497
249811.3. Running ddd on UML
2499-------------------------
2500
2501 ddd works on UML, but requires a special kludge. The process goes
2502 like this:
2503
2504 - Start ddd::
2505
2506
2507 host% ddd linux
2508
2509
2510
2511
2512
2513 - With ps, get the pid of the gdb that ddd started. You can ask the
2514 gdb to tell you, but for some reason that confuses things and
2515 causes a hang.
2516
2517 - run UML with 'debug=parent gdb-pid=<pid>' added to the command line
2518 - it will just sit there after you hit return
2519
2520 - type 'att 1' to the ddd gdb and you will see something like::
2521
2522
2523 0xa013dc51 in __kill ()
2524
2525
2526 (gdb)
2527
2528
2529
2530
2531
2532 - At this point, type 'c', UML will boot up, and you can use ddd just
2533 as you do on any other process.
2534
2535
2536
253711.4. Debugging modules
2538------------------------
2539
2540
2541 gdb has support for debugging code which is dynamically loaded into
2542 the process. This support is what is needed to debug kernel modules
2543 under UML.
2544
2545
2546 Using that support is somewhat complicated. You have to tell gdb what
2547 object file you just loaded into UML and where in memory it is. Then,
2548 it can read the symbol table, and figure out where all the symbols are
2549 from the load address that you provided. It gets more interesting
2550 when you load the module again (i.e. after an rmmod). You have to
2551 tell gdb to forget about all its symbols, including the main UML ones
2552 for some reason, then load then all back in again.
2553
2554
2555 There's an easy way and a hard way to do this. The easy way is to use
2556 the umlgdb expect script written by Chandan Kudige. It basically
2557 automates the process for you.
2558
2559
2560 First, you must tell it where your modules are. There is a list in
2561 the script that looks like this::
2562
2563 set MODULE_PATHS {
2564 "fat" "/usr/src/uml/linux-2.4.18/fs/fat/fat.o"
2565 "isofs" "/usr/src/uml/linux-2.4.18/fs/isofs/isofs.o"
2566 "minix" "/usr/src/uml/linux-2.4.18/fs/minix/minix.o"
2567 }
2568
2569
2570
2571
2572 You change that to list the names and paths of the modules that you
2573 are going to debug. Then you run it from the toplevel directory of
2574 your UML pool and it basically tells you what to do::
2575
2576
2577 ******** GDB pid is 21903 ********
2578 Start UML as: ./linux <kernel switches> debug gdb-pid=21903
2579
2580
2581
2582 GNU gdb 5.0rh-5 Red Hat Linux 7.1
2583 Copyright 2001 Free Software Foundation, Inc.
2584 GDB is free software, covered by the GNU General Public License, and you are
2585 welcome to change it and/or distribute copies of it under certain conditions.
2586 Type "show copying" to see the conditions.
2587 There is absolutely no warranty for GDB. Type "show warranty" for details.
2588 This GDB was configured as "i386-redhat-linux"...
2589 (gdb) b sys_init_module
2590 Breakpoint 1 at 0xa0011923: file module.c, line 349.
2591 (gdb) att 1
2592
2593
2594
2595
2596 After you run UML and it sits there doing nothing, you hit return at
2597 the 'att 1' and continue it::
2598
2599
2600 Attaching to program: /home/jdike/linux/2.4/um/./linux, process 1
2601 0xa00f4221 in __kill ()
2602 (UML gdb) c
2603 Continuing.
2604
2605
2606
2607
2608 At this point, you debug normally. When you insmod something, the
2609 expect magic will kick in and you'll see something like::
2610
2611
2612 *** Module hostfs loaded ***
2613 Breakpoint 1, sys_init_module (name_user=0x805abb0 "hostfs",
2614 mod_user=0x8070e00) at module.c:349
2615 349 char *name, *n_name, *name_tmp = NULL;
2616 (UML gdb) finish
2617 Run till exit from #0 sys_init_module (name_user=0x805abb0 "hostfs",
2618 mod_user=0x8070e00) at module.c:349
2619 0xa00e2e23 in execute_syscall (r=0xa8140284) at syscall_kern.c:411
2620 411 else res = EXECUTE_SYSCALL(syscall, regs);
2621 Value returned is $1 = 0
2622 (UML gdb)
2623 p/x (int)module_list + module_list->size_of_struct
2624
2625 $2 = 0xa9021054
2626 (UML gdb) symbol-file ./linux
2627 Load new symbol table from "./linux"? (y or n) y
2628 Reading symbols from ./linux...
2629 done.
2630 (UML gdb)
2631 add-symbol-file /home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o 0xa9021054
2632
2633 add symbol table from file "/home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o" at
2634 .text_addr = 0xa9021054
2635 (y or n) y
2636
2637 Reading symbols from /home/jdike/linux/2.4/um/arch/um/fs/hostfs/hostfs.o...
2638 done.
2639 (UML gdb) p *module_list
2640 $1 = {size_of_struct = 84, next = 0xa0178720, name = 0xa9022de0 "hostfs",
2641 size = 9016, uc = {usecount = {counter = 0}, pad = 0}, flags = 1,
2642 nsyms = 57, ndeps = 0, syms = 0xa9023170, deps = 0x0, refs = 0x0,
2643 init = 0xa90221f0 <init_hostfs>, cleanup = 0xa902222c <exit_hostfs>,
2644 ex_table_start = 0x0, ex_table_end = 0x0, persist_start = 0x0,
2645 persist_end = 0x0, can_unload = 0, runsize = 0, kallsyms_start = 0x0,
2646 kallsyms_end = 0x0,
2647 archdata_start = 0x1b855 <Address 0x1b855 out of bounds>,
2648 archdata_end = 0xe5890000 <Address 0xe5890000 out of bounds>,
2649 kernel_data = 0xf689c35d <Address 0xf689c35d out of bounds>}
2650 >> Finished loading symbols for hostfs ...
2651
2652
2653
2654
2655 That's the easy way. It's highly recommended. The hard way is
2656 described below in case you're interested in what's going on.
2657
2658
2659 Boot the kernel under the debugger and load the module with insmod or
2660 modprobe. With gdb, do::
2661
2662
2663 (UML gdb) p module_list
2664
2665
2666
2667
2668 This is a list of modules that have been loaded into the kernel, with
2669 the most recently loaded module first. Normally, the module you want
2670 is at module_list. If it's not, walk down the next links, looking at
2671 the name fields until find the module you want to debug. Take the
2672 address of that structure, and add module.size_of_struct (which in
2673 2.4.10 kernels is 96 (0x60)) to it. Gdb can make this hard addition
2674 for you :-)::
2675
2676
2677
2678 (UML gdb)
2679 printf "%#x\n", (int)module_list module_list->size_of_struct
2680
2681
2682
2683
2684 The offset from the module start occasionally changes (before 2.4.0,
2685 it was module.size_of_struct + 4), so it's a good idea to check the
2686 init and cleanup addresses once in a while, as describe below. Now
2687 do::
2688
2689
2690 (UML gdb)
2691 add-symbol-file /path/to/module/on/host that_address
2692
2693
2694
2695
2696 Tell gdb you really want to do it, and you're in business.
2697
2698
2699 If there's any doubt that you got the offset right, like breakpoints
2700 appear not to work, or they're appearing in the wrong place, you can
2701 check it by looking at the module structure. The init and cleanup
2702 fields should look like::
2703
2704
2705 init = 0x588066b0 <init_hostfs>, cleanup = 0x588066c0 <exit_hostfs>
2706
2707
2708
2709
2710 with no offsets on the symbol names. If the names are right, but they
2711 are offset, then the offset tells you how much you need to add to the
2712 address you gave to add-symbol-file.
2713
2714
2715 When you want to load in a new version of the module, you need to get
2716 gdb to forget about the old one. The only way I've found to do that
2717 is to tell gdb to forget about all symbols that it knows about::
2718
2719
2720 (UML gdb) symbol-file
2721
2722
2723
2724
2725 Then reload the symbols from the kernel binary::
2726
2727
2728 (UML gdb) symbol-file /path/to/kernel
2729
2730
2731
2732
2733 and repeat the process above. You'll also need to re-enable break-
2734 points. They were disabled when you dumped all the symbols because
2735 gdb couldn't figure out where they should go.
2736
2737
2738
273911.5. Attaching gdb to the kernel
2740----------------------------------
2741
2742 If you don't have the kernel running under gdb, you can attach gdb to
2743 it later by sending the tracing thread a SIGUSR1. The first line of
2744 the console output identifies its pid::
2745
2746 tracing thread pid = 20093
2747
2748
2749
2750
2751 When you send it the signal::
2752
2753
2754 host% kill -USR1 20093
2755
2756
2757
2758
2759 you will get an xterm with gdb running in it.
2760
2761
2762 If you have the mconsole compiled into UML, then the mconsole client
2763 can be used to start gdb::
2764
2765
2766 (mconsole) (mconsole) config gdb=xterm
2767
2768
2769
2770
2771 will fire up an xterm with gdb running in it.
2772
2773
2774
277511.6. Using alternate debuggers
2776--------------------------------
2777
2778 UML has support for attaching to an already running debugger rather
2779 than starting gdb itself. This is present in CVS as of 17 Apr 2001.
2780 I sent it to Alan for inclusion in the ac tree, and it will be in my
2781 2.4.4 release.
2782
2783
2784 This is useful when gdb is a subprocess of some UI, such as emacs or
2785 ddd. It can also be used to run debuggers other than gdb on UML.
2786 Below is an example of using strace as an alternate debugger.
2787
2788
2789 To do this, you need to get the pid of the debugger and pass it in
2790 with the
2791
2792
2793 If you are using gdb under some UI, then tell it to 'att 1', and
2794 you'll find yourself attached to UML.
2795
2796
2797 If you are using something other than gdb as your debugger, then
2798 you'll need to get it to do the equivalent of 'att 1' if it doesn't do
2799 it automatically.
2800
2801
2802 An example of an alternate debugger is strace. You can strace the
2803 actual kernel as follows:
2804
2805 - Run the following in a shell::
2806
2807
2808 host%
2809 sh -c 'echo pid=$$; echo -n hit return; read x; exec strace -p 1 -o strace.out'
2810
2811
2812
2813 - Run UML with 'debug' and 'gdb-pid=<pid>' with the pid printed out
2814 by the previous command
2815
2816 - Hit return in the shell, and UML will start running, and strace
2817 output will start accumulating in the output file.
2818
2819 Note that this is different from running::
2820
2821
2822 host% strace ./linux
2823
2824
2825
2826
2827 That will strace only the main UML thread, the tracing thread, which
2828 doesn't do any of the actual kernel work. It just oversees the vir-
2829 tual machine. In contrast, using strace as described above will show
2830 you the low-level activity of the virtual machine.
2831
2832
2833
2834
2835
283612. Kernel debugging examples
2837==============================
2838
283912.1. The case of the hung fsck
2840--------------------------------
2841
2842 When booting up the kernel, fsck failed, and dropped me into a shell
2843 to fix things up. I ran fsck -y, which hung::
2844
2845
2846 Setting hostname uml [ OK ]
2847 Checking root filesystem
2848 /dev/fhd0 was not cleanly unmounted, check forced.
2849 Error reading block 86894 (Attempt to read block from filesystem resulted in short read) while reading indirect blocks of inode 19780.
2850
2851 /dev/fhd0: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
2852 (i.e., without -a or -p options)
2853 [ FAILED ]
2854
2855 *** An error occurred during the file system check.
2856 *** Dropping you to a shell; the system will reboot
2857 *** when you leave the shell.
2858 Give root password for maintenance
2859 (or type Control-D for normal startup):
2860
2861 [root@uml /root]# fsck -y /dev/fhd0
2862 fsck -y /dev/fhd0
2863 Parallelizing fsck version 1.14 (9-Jan-1999)
2864 e2fsck 1.14, 9-Jan-1999 for EXT2 FS 0.5b, 95/08/09
2865 /dev/fhd0 contains a file system with errors, check forced.
2866 Pass 1: Checking inodes, blocks, and sizes
2867 Error reading block 86894 (Attempt to read block from filesystem resulted in short read) while reading indirect blocks of inode 19780. Ignore error? yes
2868
2869 Inode 19780, i_blocks is 1548, should be 540. Fix? yes
2870
2871 Pass 2: Checking directory structure
2872 Error reading block 49405 (Attempt to read block from filesystem resulted in short read). Ignore error? yes
2873
2874 Directory inode 11858, block 0, offset 0: directory corrupted
2875 Salvage? yes
2876
2877 Missing '.' in directory inode 11858.
2878 Fix? yes
2879
2880 Missing '..' in directory inode 11858.
2881 Fix? yes
2882
2883
2884 The standard drill in this sort of situation is to fire up gdb on the
2885 signal thread, which, in this case, was pid 1935. In another window,
2886 I run gdb and attach pid 1935::
2887
2888
2889 ~/linux/2.3.26/um 1016: gdb linux
2890 GNU gdb 4.17.0.11 with Linux support
2891 Copyright 1998 Free Software Foundation, Inc.
2892 GDB is free software, covered by the GNU General Public License, and you are
2893 welcome to change it and/or distribute copies of it under certain conditions.
2894 Type "show copying" to see the conditions.
2895 There is absolutely no warranty for GDB. Type "show warranty" for details.
2896 This GDB was configured as "i386-redhat-linux"...
2897
2898 (gdb) att 1935
2899 Attaching to program `/home/dike/linux/2.3.26/um/linux', Pid 1935
2900 0x100756d9 in __wait4 ()
2901
2902
2903 Let's see what's currently running::
2904
2905
2906
2907 (gdb) p current_task.pid
2908 $1 = 0
2909
2910
2911
2912
2913
2914 It's the idle thread, which means that fsck went to sleep for some
2915 reason and never woke up.
2916
2917
2918 Let's guess that the last process in the process list is fsck::
2919
2920
2921
2922 (gdb) p current_task.prev_task.comm
2923 $13 = "fsck.ext2\000\000\000\000\000\000"
2924
2925
2926
2927
2928
2929 It is, so let's see what it thinks it's up to::
2930
2931
2932
2933 (gdb) p current_task.prev_task.thread
2934 $14 = {extern_pid = 1980, tracing = 0, want_tracing = 0, forking = 0,
2935 kernel_stack_page = 0, signal_stack = 1342627840, syscall = {id = 4, args = {
2936 3, 134973440, 1024, 0, 1024}, have_result = 0, result = 50590720},
2937 request = {op = 2, u = {exec = {ip = 1350467584, sp = 2952789424}, fork = {
2938 regs = {1350467584, 2952789424, 0 <repeats 15 times>}, sigstack = 0,
2939 pid = 0}, switch_to = 0x507e8000, thread = {proc = 0x507e8000,
2940 arg = 0xaffffdb0, flags = 0, new_pid = 0}, input_request = {
2941 op = 1350467584, fd = -1342177872, proc = 0, pid = 0}}}}
2942
2943
2944
2945 The interesting things here are the fact that its .thread.syscall.id
2946 is __NR_write (see the big switch in arch/um/kernel/syscall_kern.c or
2947 the defines in include/asm-um/arch/unistd.h), and that it never
2948 returned. Also, its .request.op is OP_SWITCH (see
2949 arch/um/include/user_util.h). These mean that it went into a write,
2950 and, for some reason, called schedule().
2951
2952
2953 The fact that it never returned from write means that its stack should
2954 be fairly interesting. Its pid is 1980 (.thread.extern_pid). That
2955 process is being ptraced by the signal thread, so it must be detached
2956 before gdb can attach it::
2957
2958
2959
2960 (gdb) call detach(1980)
2961
2962 Program received signal SIGSEGV, Segmentation fault.
2963 <function called from gdb>
2964 The program being debugged stopped while in a function called from GDB.
2965 When the function (detach) is done executing, GDB will silently
2966 stop (instead of continuing to evaluate the expression containing
2967 the function call).
2968 (gdb) call detach(1980)
2969 $15 = 0
2970
2971
2972 The first detach segfaults for some reason, and the second one
2973 succeeds.
2974
2975
2976 Now I detach from the signal thread, attach to the fsck thread, and
2977 look at its stack::
2978
2979
2980 (gdb) det
2981 Detaching from program: /home/dike/linux/2.3.26/um/linux Pid 1935
2982 (gdb) att 1980
2983 Attaching to program `/home/dike/linux/2.3.26/um/linux', Pid 1980
2984 0x10070451 in __kill ()
2985 (gdb) bt
2986 #0 0x10070451 in __kill ()
2987 #1 0x10068ccd in usr1_pid (pid=1980) at process.c:30
2988 #2 0x1006a03f in _switch_to (prev=0x50072000, next=0x507e8000)
2989 at process_kern.c:156
2990 #3 0x1006a052 in switch_to (prev=0x50072000, next=0x507e8000, last=0x50072000)
2991 at process_kern.c:161
2992 #4 0x10001d12 in schedule () at core.c:777
2993 #5 0x1006a744 in __down (sem=0x507d241c) at semaphore.c:71
2994 #6 0x1006aa10 in __down_failed () at semaphore.c:157
2995 #7 0x1006c5d8 in segv_handler (sc=0x5006e940) at trap_user.c:174
2996 #8 0x1006c5ec in kern_segv_handler (sig=11) at trap_user.c:182
2997 #9 <signal handler called>
2998 #10 0x10155404 in errno ()
2999 #11 0x1006c0aa in segv (address=1342179328, is_write=2) at trap_kern.c:50
3000 #12 0x1006c5d8 in segv_handler (sc=0x5006eaf8) at trap_user.c:174
3001 #13 0x1006c5ec in kern_segv_handler (sig=11) at trap_user.c:182
3002 #14 <signal handler called>
3003 #15 0xc0fd in ?? ()
3004 #16 0x10016647 in sys_write (fd=3,
3005 buf=0x80b8800 <Address 0x80b8800 out of bounds>, count=1024)
3006 at read_write.c:159
3007 #17 0x1006d5b3 in execute_syscall (syscall=4, args=0x5006ef08)
3008 at syscall_kern.c:254
3009 #18 0x1006af87 in really_do_syscall (sig=12) at syscall_user.c:35
3010 #19 <signal handler called>
3011 #20 0x400dc8b0 in ?? ()
3012
3013
3014
3015
3016
3017 The interesting things here are:
3018
3019 - There are two segfaults on this stack (frames 9 and 14)
3020
3021 - The first faulting address (frame 11) is 0x50000800::
3022
3023 (gdb) p (void *)1342179328
3024 $16 = (void *) 0x50000800
3025
3026
3027
3028
3029
3030 The initial faulting address is interesting because it is on the idle
3031 thread's stack. I had been seeing the idle thread segfault for no
3032 apparent reason, and the cause looked like stack corruption. In hopes
3033 of catching the culprit in the act, I had turned off all protections
3034 to that stack while the idle thread wasn't running. This apparently
3035 tripped that trap.
3036
3037
3038 However, the more immediate problem is that second segfault and I'm
3039 going to concentrate on that. First, I want to see where the fault
3040 happened, so I have to go look at the sigcontent struct in frame 8::
3041
3042
3043
3044 (gdb) up
3045 #1 0x10068ccd in usr1_pid (pid=1980) at process.c:30
3046 30 kill(pid, SIGUSR1);
3047 (gdb)
3048 #2 0x1006a03f in _switch_to (prev=0x50072000, next=0x507e8000)
3049 at process_kern.c:156
3050 156 usr1_pid(getpid());
3051 (gdb)
3052 #3 0x1006a052 in switch_to (prev=0x50072000, next=0x507e8000, last=0x50072000)
3053 at process_kern.c:161
3054 161 _switch_to(prev, next);
3055 (gdb)
3056 #4 0x10001d12 in schedule () at core.c:777
3057 777 switch_to(prev, next, prev);
3058 (gdb)
3059 #5 0x1006a744 in __down (sem=0x507d241c) at semaphore.c:71
3060 71 schedule();
3061 (gdb)
3062 #6 0x1006aa10 in __down_failed () at semaphore.c:157
3063 157 }
3064 (gdb)
3065 #7 0x1006c5d8 in segv_handler (sc=0x5006e940) at trap_user.c:174
3066 174 segv(sc->cr2, sc->err & 2);
3067 (gdb)
3068 #8 0x1006c5ec in kern_segv_handler (sig=11) at trap_user.c:182
3069 182 segv_handler(sc);
3070 (gdb) p *sc
3071 Cannot access memory at address 0x0.
3072
3073
3074
3075
3076 That's not very useful, so I'll try a more manual method::
3077
3078
3079 (gdb) p *((struct sigcontext *) (&sig + 1))
3080 $19 = {gs = 0, __gsh = 0, fs = 0, __fsh = 0, es = 43, __esh = 0, ds = 43,
3081 __dsh = 0, edi = 1342179328, esi = 1350378548, ebp = 1342630440,
3082 esp = 1342630420, ebx = 1348150624, edx = 1280, ecx = 0, eax = 0,
3083 trapno = 14, err = 4, eip = 268480945, cs = 35, __csh = 0, eflags = 66118,
3084 esp_at_signal = 1342630420, ss = 43, __ssh = 0, fpstate = 0x0, oldmask = 0,
3085 cr2 = 1280}
3086
3087
3088
3089 The ip is in handle_mm_fault::
3090
3091
3092 (gdb) p (void *)268480945
3093 $20 = (void *) 0x1000b1b1
3094 (gdb) i sym $20
3095 handle_mm_fault + 57 in section .text
3096
3097
3098
3099
3100
3101 Specifically, it's in pte_alloc::
3102
3103
3104 (gdb) i line *$20
3105 Line 124 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3106 starts at address 0x1000b1b1 <handle_mm_fault+57>
3107 and ends at 0x1000b1b7 <handle_mm_fault+63>.
3108
3109
3110
3111
3112
3113 To find where in handle_mm_fault this is, I'll jump forward in the
3114 code until I see an address in that procedure::
3115
3116
3117
3118 (gdb) i line *0x1000b1c0
3119 Line 126 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3120 starts at address 0x1000b1b7 <handle_mm_fault+63>
3121 and ends at 0x1000b1c3 <handle_mm_fault+75>.
3122 (gdb) i line *0x1000b1d0
3123 Line 131 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3124 starts at address 0x1000b1d0 <handle_mm_fault+88>
3125 and ends at 0x1000b1da <handle_mm_fault+98>.
3126 (gdb) i line *0x1000b1e0
3127 Line 61 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3128 starts at address 0x1000b1da <handle_mm_fault+98>
3129 and ends at 0x1000b1e1 <handle_mm_fault+105>.
3130 (gdb) i line *0x1000b1f0
3131 Line 134 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3132 starts at address 0x1000b1f0 <handle_mm_fault+120>
3133 and ends at 0x1000b200 <handle_mm_fault+136>.
3134 (gdb) i line *0x1000b200
3135 Line 135 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3136 starts at address 0x1000b200 <handle_mm_fault+136>
3137 and ends at 0x1000b208 <handle_mm_fault+144>.
3138 (gdb) i line *0x1000b210
3139 Line 139 of "/home/dike/linux/2.3.26/um/include/asm/pgalloc.h"
3140 starts at address 0x1000b210 <handle_mm_fault+152>
3141 and ends at 0x1000b219 <handle_mm_fault+161>.
3142 (gdb) i line *0x1000b220
3143 Line 1168 of "memory.c" starts at address 0x1000b21e <handle_mm_fault+166>
3144 and ends at 0x1000b222 <handle_mm_fault+170>.
3145
3146
3147
3148
3149
3150 Something is apparently wrong with the page tables or vma_structs, so
3151 lets go back to frame 11 and have a look at them::
3152
3153
3154
3155 #11 0x1006c0aa in segv (address=1342179328, is_write=2) at trap_kern.c:50
3156 50 handle_mm_fault(current, vma, address, is_write);
3157 (gdb) call pgd_offset_proc(vma->vm_mm, address)
3158 $22 = (pgd_t *) 0x80a548c
3159
3160
3161
3162
3163
3164 That's pretty bogus. Page tables aren't supposed to be in process
3165 text or data areas. Let's see what's in the vma::
3166
3167
3168 (gdb) p *vma
3169 $23 = {vm_mm = 0x507d2434, vm_start = 0, vm_end = 134512640,
3170 vm_next = 0x80a4f8c, vm_page_prot = {pgprot = 0}, vm_flags = 31200,
3171 vm_avl_height = 2058, vm_avl_left = 0x80a8c94, vm_avl_right = 0x80d1000,
3172 vm_next_share = 0xaffffdb0, vm_pprev_share = 0xaffffe63,
3173 vm_ops = 0xaffffe7a, vm_pgoff = 2952789626, vm_file = 0xafffffec,
3174 vm_private_data = 0x62}
3175 (gdb) p *vma.vm_mm
3176 $24 = {mmap = 0x507d2434, mmap_avl = 0x0, mmap_cache = 0x8048000,
3177 pgd = 0x80a4f8c, mm_users = {counter = 0}, mm_count = {counter = 134904288},
3178 map_count = 134909076, mmap_sem = {count = {counter = 135073792},
3179 sleepers = -1342177872, wait = {lock = <optimized out or zero length>,
3180 task_list = {next = 0xaffffe63, prev = 0xaffffe7a},
3181 __magic = -1342177670, __creator = -1342177300}, __magic = 98},
3182 page_table_lock = {}, context = 138, start_code = 0, end_code = 0,
3183 start_data = 0, end_data = 0, start_brk = 0, brk = 0, start_stack = 0,
3184 arg_start = 0, arg_end = 0, env_start = 0, env_end = 0, rss = 1350381536,
3185 total_vm = 0, locked_vm = 0, def_flags = 0, cpu_vm_mask = 0, swap_cnt = 0,
3186 swap_address = 0, segments = 0x0}
3187
3188
3189
3190 This also pretty bogus. With all of the 0x80xxxxx and 0xaffffxxx
3191 addresses, this is looking like a stack was plonked down on top of
3192 these structures. Maybe it's a stack overflow from the next page::
3193
3194
3195 (gdb) p vma
3196 $25 = (struct vm_area_struct *) 0x507d2434
3197
3198
3199
3200 That's towards the lower quarter of the page, so that would have to
3201 have been pretty heavy stack overflow::
3202
3203
3204 (gdb) x/100x $25
3205 0x507d2434: 0x507d2434 0x00000000 0x08048000 0x080a4f8c
3206 0x507d2444: 0x00000000 0x080a79e0 0x080a8c94 0x080d1000
3207 0x507d2454: 0xaffffdb0 0xaffffe63 0xaffffe7a 0xaffffe7a
3208 0x507d2464: 0xafffffec 0x00000062 0x0000008a 0x00000000
3209 0x507d2474: 0x00000000 0x00000000 0x00000000 0x00000000
3210 0x507d2484: 0x00000000 0x00000000 0x00000000 0x00000000
3211 0x507d2494: 0x00000000 0x00000000 0x507d2fe0 0x00000000
3212 0x507d24a4: 0x00000000 0x00000000 0x00000000 0x00000000
3213 0x507d24b4: 0x00000000 0x00000000 0x00000000 0x00000000
3214 0x507d24c4: 0x00000000 0x00000000 0x00000000 0x00000000
3215 0x507d24d4: 0x00000000 0x00000000 0x00000000 0x00000000
3216 0x507d24e4: 0x00000000 0x00000000 0x00000000 0x00000000
3217 0x507d24f4: 0x00000000 0x00000000 0x00000000 0x00000000
3218 0x507d2504: 0x00000000 0x00000000 0x00000000 0x00000000
3219 0x507d2514: 0x00000000 0x00000000 0x00000000 0x00000000
3220 0x507d2524: 0x00000000 0x00000000 0x00000000 0x00000000
3221 0x507d2534: 0x00000000 0x00000000 0x507d25dc 0x00000000
3222 0x507d2544: 0x00000000 0x00000000 0x00000000 0x00000000
3223 0x507d2554: 0x00000000 0x00000000 0x00000000 0x00000000
3224 0x507d2564: 0x00000000 0x00000000 0x00000000 0x00000000
3225 0x507d2574: 0x00000000 0x00000000 0x00000000 0x00000000
3226 0x507d2584: 0x00000000 0x00000000 0x00000000 0x00000000
3227 0x507d2594: 0x00000000 0x00000000 0x00000000 0x00000000
3228 0x507d25a4: 0x00000000 0x00000000 0x00000000 0x00000000
3229 0x507d25b4: 0x00000000 0x00000000 0x00000000 0x00000000
3230
3231
3232
3233 It's not stack overflow. The only "stack-like" piece of this data is
3234 the vma_struct itself.
3235
3236
3237 At this point, I don't see any avenues to pursue, so I just have to
3238 admit that I have no idea what's going on. What I will do, though, is
3239 stick a trap on the segfault handler which will stop if it sees any
3240 writes to the idle thread's stack. That was the thing that happened
3241 first, and it may be that if I can catch it immediately, what's going
3242 on will be somewhat clearer.
3243
3244
324512.2. Episode 2: The case of the hung fsck
3246-------------------------------------------
3247
3248 After setting a trap in the SEGV handler for accesses to the signal
3249 thread's stack, I reran the kernel.
3250
3251
3252 fsck hung again, this time by hitting the trap::
3253
3254
3255
3256 Setting hostname uml [ OK ]
3257 Checking root filesystem
3258 /dev/fhd0 contains a file system with errors, check forced.
3259 Error reading block 86894 (Attempt to read block from filesystem resulted in short read) while reading indirect blocks of inode 19780.
3260
3261 /dev/fhd0: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
3262 (i.e., without -a or -p options)
3263 [ FAILED ]
3264
3265 *** An error occurred during the file system check.
3266 *** Dropping you to a shell; the system will reboot
3267 *** when you leave the shell.
3268 Give root password for maintenance
3269 (or type Control-D for normal startup):
3270
3271 [root@uml /root]# fsck -y /dev/fhd0
3272 fsck -y /dev/fhd0
3273 Parallelizing fsck version 1.14 (9-Jan-1999)
3274 e2fsck 1.14, 9-Jan-1999 for EXT2 FS 0.5b, 95/08/09
3275 /dev/fhd0 contains a file system with errors, check forced.
3276 Pass 1: Checking inodes, blocks, and sizes
3277 Error reading block 86894 (Attempt to read block from filesystem resulted in short read) while reading indirect blocks of inode 19780. Ignore error? yes
3278
3279 Pass 2: Checking directory structure
3280 Error reading block 49405 (Attempt to read block from filesystem resulted in short read). Ignore error? yes
3281
3282 Directory inode 11858, block 0, offset 0: directory corrupted
3283 Salvage? yes
3284
3285 Missing '.' in directory inode 11858.
3286 Fix? yes
3287
3288 Missing '..' in directory inode 11858.
3289 Fix? yes
3290
3291 Untested (4127) [100fe44c]: trap_kern.c line 31
3292
3293
3294
3295
3296
3297 I need to get the signal thread to detach from pid 4127 so that I can
3298 attach to it with gdb. This is done by sending it a SIGUSR1, which is
3299 caught by the signal thread, which detaches the process::
3300
3301
3302 kill -USR1 4127
3303
3304
3305
3306
3307
3308 Now I can run gdb on it::
3309
3310
3311 ~/linux/2.3.26/um 1034: gdb linux
3312 GNU gdb 4.17.0.11 with Linux support
3313 Copyright 1998 Free Software Foundation, Inc.
3314 GDB is free software, covered by the GNU General Public License, and you are
3315 welcome to change it and/or distribute copies of it under certain conditions.
3316 Type "show copying" to see the conditions.
3317 There is absolutely no warranty for GDB. Type "show warranty" for details.
3318 This GDB was configured as "i386-redhat-linux"...
3319 (gdb) att 4127
3320 Attaching to program `/home/dike/linux/2.3.26/um/linux', Pid 4127
3321 0x10075891 in __libc_nanosleep ()
3322
3323
3324
3325
3326
3327 The backtrace shows that it was in a write and that the fault address
3328 (address in frame 3) is 0x50000800, which is right in the middle of
3329 the signal thread's stack page::
3330
3331
3332 (gdb) bt
3333 #0 0x10075891 in __libc_nanosleep ()
3334 #1 0x1007584d in __sleep (seconds=1000000)
3335 at ../sysdeps/unix/sysv/linux/sleep.c:78
3336 #2 0x1006ce9a in stop () at user_util.c:191
3337 #3 0x1006bf88 in segv (address=1342179328, is_write=2) at trap_kern.c:31
3338 #4 0x1006c628 in segv_handler (sc=0x5006eaf8) at trap_user.c:174
3339 #5 0x1006c63c in kern_segv_handler (sig=11) at trap_user.c:182
3340 #6 <signal handler called>
3341 #7 0xc0fd in ?? ()
3342 #8 0x10016647 in sys_write (fd=3, buf=0x80b8800 "R.", count=1024)
3343 at read_write.c:159
3344 #9 0x1006d603 in execute_syscall (syscall=4, args=0x5006ef08)
3345 at syscall_kern.c:254
3346 #10 0x1006af87 in really_do_syscall (sig=12) at syscall_user.c:35
3347 #11 <signal handler called>
3348 #12 0x400dc8b0 in ?? ()
3349 #13 <signal handler called>
3350 #14 0x400dc8b0 in ?? ()
3351 #15 0x80545fd in ?? ()
3352 #16 0x804daae in ?? ()
3353 #17 0x8054334 in ?? ()
3354 #18 0x804d23e in ?? ()
3355 #19 0x8049632 in ?? ()
3356 #20 0x80491d2 in ?? ()
3357 #21 0x80596b5 in ?? ()
3358 (gdb) p (void *)1342179328
3359 $3 = (void *) 0x50000800
3360
3361
3362
3363 Going up the stack to the segv_handler frame and looking at where in
3364 the code the access happened shows that it happened near line 110 of
3365 block_dev.c::
3366
3367
3368
3369 (gdb) up
3370 #1 0x1007584d in __sleep (seconds=1000000)
3371 at ../sysdeps/unix/sysv/linux/sleep.c:78
3372 ../sysdeps/unix/sysv/linux/sleep.c:78: No such file or directory.
3373 (gdb)
3374 #2 0x1006ce9a in stop () at user_util.c:191
3375 191 while(1) sleep(1000000);
3376 (gdb)
3377 #3 0x1006bf88 in segv (address=1342179328, is_write=2) at trap_kern.c:31
3378 31 KERN_UNTESTED();
3379 (gdb)
3380 #4 0x1006c628 in segv_handler (sc=0x5006eaf8) at trap_user.c:174
3381 174 segv(sc->cr2, sc->err & 2);
3382 (gdb) p *sc
3383 $1 = {gs = 0, __gsh = 0, fs = 0, __fsh = 0, es = 43, __esh = 0, ds = 43,
3384 __dsh = 0, edi = 1342179328, esi = 134973440, ebp = 1342631484,
3385 esp = 1342630864, ebx = 256, edx = 0, ecx = 256, eax = 1024, trapno = 14,
3386 err = 6, eip = 268550834, cs = 35, __csh = 0, eflags = 66070,
3387 esp_at_signal = 1342630864, ss = 43, __ssh = 0, fpstate = 0x0, oldmask = 0,
3388 cr2 = 1342179328}
3389 (gdb) p (void *)268550834
3390 $2 = (void *) 0x1001c2b2
3391 (gdb) i sym $2
3392 block_write + 1090 in section .text
3393 (gdb) i line *$2
3394 Line 209 of "/home/dike/linux/2.3.26/um/include/asm/arch/string.h"
3395 starts at address 0x1001c2a1 <block_write+1073>
3396 and ends at 0x1001c2bf <block_write+1103>.
3397 (gdb) i line *0x1001c2c0
3398 Line 110 of "block_dev.c" starts at address 0x1001c2bf <block_write+1103>
3399 and ends at 0x1001c2e3 <block_write+1139>.
3400
3401
3402
3403 Looking at the source shows that the fault happened during a call to
3404 copy_from_user to copy the data into the kernel::
3405
3406
3407 107 count -= chars;
3408 108 copy_from_user(p,buf,chars);
3409 109 p += chars;
3410 110 buf += chars;
3411
3412
3413
3414 p is the pointer which must contain 0x50000800, since buf contains
3415 0x80b8800 (frame 8 above). It is defined as::
3416
3417
3418 p = offset + bh->b_data;
3419
3420
3421
3422
3423
3424 I need to figure out what bh is, and it just so happens that bh is
3425 passed as an argument to mark_buffer_uptodate and mark_buffer_dirty a
3426 few lines later, so I do a little disassembly::
3427
3428
3429 (gdb) disas 0x1001c2bf 0x1001c2e0
3430 Dump of assembler code from 0x1001c2bf to 0x1001c2d0:
3431 0x1001c2bf <block_write+1103>: addl %eax,0xc(%ebp)
3432 0x1001c2c2 <block_write+1106>: movl 0xfffffdd4(%ebp),%edx
3433 0x1001c2c8 <block_write+1112>: btsl $0x0,0x18(%edx)
3434 0x1001c2cd <block_write+1117>: btsl $0x1,0x18(%edx)
3435 0x1001c2d2 <block_write+1122>: sbbl %ecx,%ecx
3436 0x1001c2d4 <block_write+1124>: testl %ecx,%ecx
3437 0x1001c2d6 <block_write+1126>: jne 0x1001c2e3 <block_write+1139>
3438 0x1001c2d8 <block_write+1128>: pushl $0x0
3439 0x1001c2da <block_write+1130>: pushl %edx
3440 0x1001c2db <block_write+1131>: call 0x1001819c <__mark_buffer_dirty>
3441 End of assembler dump.
3442
3443
3444
3445
3446
3447 At that point, bh is in %edx (address 0x1001c2da), which is calculated
3448 at 0x1001c2c2 as %ebp + 0xfffffdd4, so I figure exactly what that is,
3449 taking %ebp from the sigcontext_struct above::
3450
3451
3452 (gdb) p (void *)1342631484
3453 $5 = (void *) 0x5006ee3c
3454 (gdb) p 0x5006ee3c+0xfffffdd4
3455 $6 = 1342630928
3456 (gdb) p (void *)$6
3457 $7 = (void *) 0x5006ec10
3458 (gdb) p *((void **)$7)
3459 $8 = (void *) 0x50100200
3460
3461
3462
3463
3464
3465 Now, I look at the structure to see what's in it, and particularly,
3466 what its b_data field contains::
3467
3468
3469 (gdb) p *((struct buffer_head *)0x50100200)
3470 $13 = {b_next = 0x50289380, b_blocknr = 49405, b_size = 1024, b_list = 0,
3471 b_dev = 15872, b_count = {counter = 1}, b_rdev = 15872, b_state = 24,
3472 b_flushtime = 0, b_next_free = 0x501001a0, b_prev_free = 0x50100260,
3473 b_this_page = 0x501001a0, b_reqnext = 0x0, b_pprev = 0x507fcf58,
3474 b_data = 0x50000800 "", b_page = 0x50004000,
3475 b_end_io = 0x10017f60 <end_buffer_io_sync>, b_dev_id = 0x0,
3476 b_rsector = 98810, b_wait = {lock = <optimized out or zero length>,
3477 task_list = {next = 0x50100248, prev = 0x50100248}, __magic = 1343226448,
3478 __creator = 0}, b_kiobuf = 0x0}
3479
3480
3481
3482
3483
3484 The b_data field is indeed 0x50000800, so the question becomes how
3485 that happened. The rest of the structure looks fine, so this probably
3486 is not a case of data corruption. It happened on purpose somehow.
3487
3488
3489 The b_page field is a pointer to the page_struct representing the
3490 0x50000000 page. Looking at it shows the kernel's idea of the state
3491 of that page::
3492
3493
3494
3495 (gdb) p *$13.b_page
3496 $17 = {list = {next = 0x50004a5c, prev = 0x100c5174}, mapping = 0x0,
3497 index = 0, next_hash = 0x0, count = {counter = 1}, flags = 132, lru = {
3498 next = 0x50008460, prev = 0x50019350}, wait = {
3499 lock = <optimized out or zero length>, task_list = {next = 0x50004024,
3500 prev = 0x50004024}, __magic = 1342193708, __creator = 0},
3501 pprev_hash = 0x0, buffers = 0x501002c0, virtual = 1342177280,
3502 zone = 0x100c5160}
3503
3504
3505
3506
3507
3508 Some sanity-checking: the virtual field shows the "virtual" address of
3509 this page, which in this kernel is the same as its "physical" address,
3510 and the page_struct itself should be mem_map[0], since it represents
3511 the first page of memory::
3512
3513
3514
3515 (gdb) p (void *)1342177280
3516 $18 = (void *) 0x50000000
3517 (gdb) p mem_map
3518 $19 = (mem_map_t *) 0x50004000
3519
3520
3521
3522
3523
3524 These check out fine.
3525
3526
3527 Now to check out the page_struct itself. In particular, the flags
3528 field shows whether the page is considered free or not::
3529
3530
3531 (gdb) p (void *)132
3532 $21 = (void *) 0x84
3533
3534
3535
3536
3537
3538 The "reserved" bit is the high bit, which is definitely not set, so
3539 the kernel considers the signal stack page to be free and available to
3540 be used.
3541
3542
3543 At this point, I jump to conclusions and start looking at my early
3544 boot code, because that's where that page is supposed to be reserved.
3545
3546
3547 In my setup_arch procedure, I have the following code which looks just
3548 fine::
3549
3550
3551
3552 bootmap_size = init_bootmem(start_pfn, end_pfn - start_pfn);
3553 free_bootmem(__pa(low_physmem) + bootmap_size, high_physmem - low_physmem);
3554
3555
3556
3557
3558
3559 Two stack pages have already been allocated, and low_physmem points to
3560 the third page, which is the beginning of free memory.
3561 The init_bootmem call declares the entire memory to the boot memory
3562 manager, which marks it all reserved. The free_bootmem call frees up
3563 all of it, except for the first two pages. This looks correct to me.
3564
3565
3566 So, I decide to see init_bootmem run and make sure that it is marking
3567 those first two pages as reserved. I never get that far.
3568
3569
3570 Stepping into init_bootmem, and looking at bootmem_map before looking
3571 at what it contains shows the following::
3572
3573
3574
3575 (gdb) p bootmem_map
3576 $3 = (void *) 0x50000000
3577
3578
3579
3580
3581
3582 Aha! The light dawns. That first page is doing double duty as a
3583 stack and as the boot memory map. The last thing that the boot memory
3584 manager does is to free the pages used by its memory map, so this page
3585 is getting freed even its marked as reserved.
3586
3587
3588 The fix was to initialize the boot memory manager before allocating
3589 those two stack pages, and then allocate them through the boot memory
3590 manager. After doing this, and fixing a couple of subsequent buglets,
3591 the stack corruption problem disappeared.
3592
3593
3594
3595
3596
359713. What to do when UML doesn't work
3598=====================================
3599
3600
3601
3602
360313.1. Strange compilation errors when you build from source
3604------------------------------------------------------------
3605
3606 As of test11, it is necessary to have "ARCH=um" in the environment or
3607 on the make command line for all steps in building UML, including
3608 clean, distclean, or mrproper, config, menuconfig, or xconfig, dep,
3609 and linux. If you forget for any of them, the i386 build seems to
3610 contaminate the UML build. If this happens, start from scratch with::
3611
3612
3613 host%
3614 make mrproper ARCH=um
3615
3616
3617
3618
3619 and repeat the build process with ARCH=um on all the steps.
3620
3621
3622 See :ref:`Compiling_the_kernel_and_modules` for more details.
3623
3624
3625 Another cause of strange compilation errors is building UML in
3626 /usr/src/linux. If you do this, the first thing you need to do is
3627 clean up the mess you made. The /usr/src/linux/asm link will now
3628 point to /usr/src/linux/asm-um. Make it point back to
3629 /usr/src/linux/asm-i386. Then, move your UML pool someplace else and
3630 build it there. Also see below, where a more specific set of symptoms
3631 is described.
3632
3633
3634
363513.3. A variety of panics and hangs with /tmp on a reiserfs filesystem
3636-----------------------------------------------------------------------
3637
3638 I saw this on reiserfs 3.5.21 and it seems to be fixed in 3.5.27.
3639 Panics preceded by::
3640
3641
3642 Detaching pid nnnn
3643
3644
3645
3646 are diagnostic of this problem. This is a reiserfs bug which causes a
3647 thread to occasionally read stale data from a mmapped page shared with
3648 another thread. The fix is to upgrade the filesystem or to have /tmp
3649 be an ext2 filesystem.
3650
3651
3652
3653 13.4. The compile fails with errors about conflicting types for
3654 'open', 'dup', and 'waitpid'
3655
3656 This happens when you build in /usr/src/linux. The UML build makes
3657 the include/asm link point to include/asm-um. /usr/include/asm points
3658 to /usr/src/linux/include/asm, so when that link gets moved, files
3659 which need to include the asm-i386 versions of headers get the
3660 incompatible asm-um versions. The fix is to move the include/asm link
3661 back to include/asm-i386 and to do UML builds someplace else.
3662
3663
3664
366513.5. UML doesn't work when /tmp is an NFS filesystem
3666------------------------------------------------------
3667
3668 This seems to be a similar situation with the ReiserFS problem above.
3669 Some versions of NFS seems not to handle mmap correctly, which UML
3670 depends on. The workaround is have /tmp be a non-NFS directory.
3671
3672
367313.6. UML hangs on boot when compiled with gprof support
3674---------------------------------------------------------
3675
3676 If you build UML with gprof support and, early in the boot, it does
3677 this::
3678
3679
3680 kernel BUG at page_alloc.c:100!
3681
3682
3683
3684
3685 you have a buggy gcc. You can work around the problem by removing
3686 UM_FASTCALL from CFLAGS in arch/um/Makefile-i386. This will open up
3687 another bug, but that one is fairly hard to reproduce.
3688
3689
3690
369113.7. syslogd dies with a SIGTERM on startup
3692---------------------------------------------
3693
3694 The exact boot error depends on the distribution that you're booting,
3695 but Debian produces this::
3696
3697
3698 /etc/rc2.d/S10sysklogd: line 49: 93 Terminated
3699 start-stop-daemon --start --quiet --exec /sbin/syslogd -- $SYSLOGD
3700
3701
3702
3703
3704 This is a syslogd bug. There's a race between a parent process
3705 installing a signal handler and its child sending the signal.
3706
3707
3708
370913.8. TUN/TAP networking doesn't work on a 2.4 host
3710----------------------------------------------------
3711
3712 There are a couple of problems which were reported by
3713 Tim Robinson <timro at trkr dot net>
3714
3715 - It doesn't work on hosts running 2.4.7 (or thereabouts) or earlier.
3716 The fix is to upgrade to something more recent and then read the
3717 next item.
3718
3719 - If you see::
3720
3721
3722 File descriptor in bad state
3723
3724
3725
3726 when you bring up the device inside UML, you have a header mismatch
3727 between the original kernel and the upgraded one. Make /usr/src/linux
3728 point at the new headers. This will only be a problem if you build
3729 uml_net yourself.
3730
3731
3732
373313.9. You can network to the host but not to other machines on the net
3734=======================================================================
3735
3736 If you can connect to the host, and the host can connect to UML, but
3737 you cannot connect to any other machines, then you may need to enable
3738 IP Masquerading on the host. Usually this is only experienced when
3739 using private IP addresses (192.168.x.x or 10.x.x.x) for host/UML
3740 networking, rather than the public address space that your host is
3741 connected to. UML does not enable IP Masquerading, so you will need
3742 to create a static rule to enable it::
3743
3744
3745 host%
3746 iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
3747
3748
3749
3750
3751 Replace eth0 with the interface that you use to talk to the rest of
3752 the world.
3753
3754
3755 Documentation on IP Masquerading, and SNAT, can be found at
3756 http://www.netfilter.org.
3757
3758
3759 If you can reach the local net, but not the outside Internet, then
3760 that is usually a routing problem. The UML needs a default route::
3761
3762
3763 UML#
3764 route add default gw gateway IP
3765
3766
3767
3768
3769 The gateway IP can be any machine on the local net that knows how to
3770 reach the outside world. Usually, this is the host or the local net-
3771 work's gateway.
3772
3773
3774 Occasionally, we hear from someone who can reach some machines, but
3775 not others on the same net, or who can reach some ports on other
3776 machines, but not others. These are usually caused by strange
3777 firewalling somewhere between the UML and the other box. You track
3778 this down by running tcpdump on every interface the packets travel
3779 over and see where they disappear. When you find a machine that takes
3780 the packets in, but does not send them onward, that's the culprit.
3781
3782
3783
378413.10. I have no root and I want to scream
3785===========================================
3786
3787 Thanks to Birgit Wahlich for telling me about this strange one. It
3788 turns out that there's a limit of six environment variables on the
3789 kernel command line. When that limit is reached or exceeded, argument
3790 processing stops, which means that the 'root=' argument that UML
3791 usually adds is not seen. So, the filesystem has no idea what the
3792 root device is, so it panics.
3793
3794
3795 The fix is to put less stuff on the command line. Glomming all your
3796 setup variables into one is probably the best way to go.
3797
3798
3799
380013.11. UML build conflict between ptrace.h and ucontext.h
3801==========================================================
3802
3803 On some older systems, /usr/include/asm/ptrace.h and
3804 /usr/include/sys/ucontext.h define the same names. So, when they're
3805 included together, the defines from one completely mess up the parsing
3806 of the other, producing errors like::
3807
3808 /usr/include/sys/ucontext.h:47: parse error before
3809 `10`
3810
3811
3812
3813
3814 plus a pile of warnings.
3815
3816
3817 This is a libc botch, which has since been fixed, and I don't see any
3818 way around it besides upgrading.
3819
3820
3821
382213.12. The UML BogoMips is exactly half the host's BogoMips
3823------------------------------------------------------------
3824
3825 On i386 kernels, there are two ways of running the loop that is used
3826 to calculate the BogoMips rating, using the TSC if it's there or using
3827 a one-instruction loop. The TSC produces twice the BogoMips as the
3828 loop. UML uses the loop, since it has nothing resembling a TSC, and
3829 will get almost exactly the same BogoMips as a host using the loop.
3830 However, on a host with a TSC, its BogoMips will be double the loop
3831 BogoMips, and therefore double the UML BogoMips.
3832
3833
3834
383513.13. When you run UML, it immediately segfaults
3836--------------------------------------------------
3837
3838 If the host is configured with the 2G/2G address space split, that's
3839 why. See ref:`UML_on_2G/2G_hosts` for the details on getting UML to
3840 run on your host.
3841
3842
3843
384413.14. xterms appear, then immediately disappear
3845-------------------------------------------------
3846
3847 If you're running an up to date kernel with an old release of
3848 uml_utilities, the port-helper program will not work properly, so
3849 xterms will exit straight after they appear. The solution is to
3850 upgrade to the latest release of uml_utilities. Usually this problem
3851 occurs when you have installed a packaged release of UML then compiled
3852 your own development kernel without upgrading the uml_utilities from
3853 the source distribution.
3854
3855
3856
385713.15. Any other panic, hang, or strange behavior
3858--------------------------------------------------
3859
3860 If you're seeing truly strange behavior, such as hangs or panics that
3861 happen in random places, or you try running the debugger to see what's
3862 happening and it acts strangely, then it could be a problem in the
3863 host kernel. If you're not running a stock Linus or -ac kernel, then
3864 try that. An early version of the preemption patch and a 2.4.10 SuSE
3865 kernel have caused very strange problems in UML.
3866
3867
3868 Otherwise, let me know about it. Send a message to one of the UML
3869 mailing lists - either the developer list - user-mode-linux-devel at
3870 lists dot sourceforge dot net (subscription info) or the user list -
3871 user-mode-linux-user at lists dot sourceforge do net (subscription
3872 info), whichever you prefer. Don't assume that everyone knows about
3873 it and that a fix is imminent.
3874
3875
3876 If you want to be super-helpful, read :ref:`Diagnosing_Problems` and
3877 follow the instructions contained therein.
3878
3879.. _Diagnosing_Problems:
3880
388114. Diagnosing Problems
3882========================
3883
3884
3885 If you get UML to crash, hang, or otherwise misbehave, you should
3886 report this on one of the project mailing lists, either the developer
3887 list - user-mode-linux-devel at lists dot sourceforge dot net
3888 (subscription info) or the user list - user-mode-linux-user at lists
3889 dot sourceforge dot net (subscription info). When you do, it is
3890 likely that I will want more information. So, it would be helpful to
3891 read the stuff below, do whatever is applicable in your case, and
3892 report the results to the list.
3893
3894
3895 For any diagnosis, you're going to need to build a debugging kernel.
3896 The binaries from this site aren't debuggable. If you haven't done
3897 this before, read about :ref:`Compiling_the_kernel_and_modules` and
3898 :ref:`Kernel_debugging` UML first.
3899
3900
390114.1. Case 1 : Normal kernel panics
3902------------------------------------
3903
3904 The most common case is for a normal thread to panic. To debug this,
3905 you will need to run it under the debugger (add 'debug' to the command
3906 line). An xterm will start up with gdb running inside it. Continue
3907 it when it stops in start_kernel and make it crash. Now ``^C gdb`` and
3908
3909
3910 If the panic was a "Kernel mode fault", then there will be a segv
3911 frame on the stack and I'm going to want some more information. The
3912 stack might look something like this::
3913
3914
3915 (UML gdb) backtrace
3916 #0 0x1009bf76 in __sigprocmask (how=1, set=0x5f347940, oset=0x0)
3917 at ../sysdeps/unix/sysv/linux/sigprocmask.c:49
3918 #1 0x10091411 in change_sig (signal=10, on=1) at process.c:218
3919 #2 0x10094785 in timer_handler (sig=26) at time_kern.c:32
3920 #3 0x1009bf38 in __restore ()
3921 at ../sysdeps/unix/sysv/linux/i386/sigaction.c:125
3922 #4 0x1009534c in segv (address=8, ip=268849158, is_write=2, is_user=0)
3923 at trap_kern.c:66
3924 #5 0x10095c04 in segv_handler (sig=11) at trap_user.c:285
3925 #6 0x1009bf38 in __restore ()
3926
3927
3928
3929
3930 I'm going to want to see the symbol and line information for the value
3931 of ip in the segv frame. In this case, you would do the following::
3932
3933
3934 (UML gdb) i sym 268849158
3935
3936
3937
3938
3939 and::
3940
3941
3942 (UML gdb) i line *268849158
3943
3944
3945
3946
3947 The reason for this is the __restore frame right above the segv_han-
3948 dler frame is hiding the frame that actually segfaulted. So, I have
3949 to get that information from the faulting ip.
3950
3951
395214.2. Case 2 : Tracing thread panics
3953-------------------------------------
3954
3955 The less common and more painful case is when the tracing thread
3956 panics. In this case, the kernel debugger will be useless because it
3957 needs a healthy tracing thread in order to work. The first thing to
3958 do is get a backtrace from the tracing thread. This is done by
3959 figuring out what its pid is, firing up gdb, and attaching it to that
3960 pid. You can figure out the tracing thread pid by looking at the
3961 first line of the console output, which will look like this::
3962
3963
3964 tracing thread pid = 15851
3965
3966
3967
3968
3969 or by running ps on the host and finding the line that looks like
3970 this::
3971
3972
3973 jdike 15851 4.5 0.4 132568 1104 pts/0 S 21:34 0:05 ./linux [(tracing thread)]
3974
3975
3976
3977
3978 If the panic was 'segfault in signals', then follow the instructions
3979 above for collecting information about the location of the seg fault.
3980
3981
3982 If the tracing thread flaked out all by itself, then send that
3983 backtrace in and wait for our crack debugging team to fix the problem.
3984
3985
3986 14.3. Case 3 : Tracing thread panics caused by other threads
3987
3988 However, there are cases where the misbehavior of another thread
3989 caused the problem. The most common panic of this type is::
3990
3991
3992 wait_for_stop failed to wait for <pid> to stop with <signal number>
3993
3994
3995
3996
3997 In this case, you'll need to get a backtrace from the process men-
3998 tioned in the panic, which is complicated by the fact that the kernel
3999 debugger is defunct and without some fancy footwork, another gdb can't
4000 attach to it. So, this is how the fancy footwork goes:
4001
4002 In a shell::
4003
4004
4005 host% kill -STOP pid
4006
4007
4008
4009
4010 Run gdb on the tracing thread as described in case 2 and do::
4011
4012
4013 (host gdb) call detach(pid)
4014
4015
4016 If you get a segfault, do it again. It always works the second time.
4017
4018 Detach from the tracing thread and attach to that other thread::
4019
4020
4021 (host gdb) detach
4022
4023
4024
4025
4026
4027
4028 (host gdb) attach pid
4029
4030
4031
4032
4033 If gdb hangs when attaching to that process, go back to a shell and
4034 do::
4035
4036
4037 host%
4038 kill -CONT pid
4039
4040
4041
4042
4043 And then get the backtrace::
4044
4045
4046 (host gdb) backtrace
4047
4048
4049
4050
4051
405214.4. Case 4 : Hangs
4053---------------------
4054
4055 Hangs seem to be fairly rare, but they sometimes happen. When a hang
4056 happens, we need a backtrace from the offending process. Run the
4057 kernel debugger as described in case 1 and get a backtrace. If the
4058 current process is not the idle thread, then send in the backtrace.
4059 You can tell that it's the idle thread if the stack looks like this::
4060
4061
4062 #0 0x100b1401 in __libc_nanosleep ()
4063 #1 0x100a2885 in idle_sleep (secs=10) at time.c:122
4064 #2 0x100a546f in do_idle () at process_kern.c:445
4065 #3 0x100a5508 in cpu_idle () at process_kern.c:471
4066 #4 0x100ec18f in start_kernel () at init/main.c:592
4067 #5 0x100a3e10 in start_kernel_proc (unused=0x0) at um_arch.c:71
4068 #6 0x100a383f in signal_tramp (arg=0x100a3dd8) at trap_user.c:50
4069
4070
4071
4072
4073 If this is the case, then some other process is at fault, and went to
4074 sleep when it shouldn't have. Run ps on the host and figure out which
4075 process should not have gone to sleep and stayed asleep. Then attach
4076 to it with gdb and get a backtrace as described in case 3.
4077
4078
4079
4080
4081
4082
408315. Thanks
4084===========
4085
4086
4087 A number of people have helped this project in various ways, and this
4088 page gives recognition where recognition is due.
4089
4090
4091 If you're listed here and you would prefer a real link on your name,
4092 or no link at all, instead of the despammed email address pseudo-link,
4093 let me know.
4094
4095
4096 If you're not listed here and you think maybe you should be, please
4097 let me know that as well. I try to get everyone, but sometimes my
4098 bookkeeping lapses and I forget about contributions.
4099
4100
410115.1. Code and Documentation
4102-----------------------------
4103
4104 Rusty Russell <rusty at linuxcare.com.au> -
4105
4106 - wrote the HOWTO
4107 http://user-mode-linux.sourceforge.net/old/UserModeLinux-HOWTO.html
4108
4109 - prodded me into making this project official and putting it on
4110 SourceForge
4111
4112 - came up with the way cool UML logo
4113 http://user-mode-linux.sourceforge.net/uml-small.png
4114
4115 - redid the config process
4116
4117
4118 Peter Moulder <reiter at netspace.net.au> - Fixed my config and build
4119 processes, and added some useful code to the block driver
4120
4121
4122 Bill Stearns <wstearns at pobox.com> -
4123
4124 - HOWTO updates
4125
4126 - lots of bug reports
4127
4128 - lots of testing
4129
4130 - dedicated a box (uml.ists.dartmouth.edu) to support UML development
4131
4132 - wrote the mkrootfs script, which allows bootable filesystems of
4133 RPM-based distributions to be cranked out
4134
4135 - cranked out a large number of filesystems with said script
4136
4137
4138 Jim Leu <jleu at mindspring.com> - Wrote the virtual ethernet driver
4139 and associated usermode tools
4140
4141 Lars Brinkhoff http://lars.nocrew.org/ - Contributed the ptrace
4142 proxy from his own project to allow easier kernel debugging
4143
4144
4145 Andrea Arcangeli <andrea at suse.de> - Redid some of the early boot
4146 code so that it would work on machines with Large File Support
4147
4148
4149 Chris Emerson - Did the first UML port to Linux/ppc
4150
4151
4152 Harald Welte <laforge at gnumonks.org> - Wrote the multicast
4153 transport for the network driver
4154
4155
4156 Jorgen Cederlof - Added special file support to hostfs
4157
4158
4159 Greg Lonnon <glonnon at ridgerun dot com> - Changed the ubd driver
4160 to allow it to layer a COW file on a shared read-only filesystem and
4161 wrote the iomem emulation support
4162
4163
4164 Henrik Nordstrom http://hem.passagen.se/hno/ - Provided a variety
4165 of patches, fixes, and clues
4166
4167
4168 Lennert Buytenhek - Contributed various patches, a rewrite of the
4169 network driver, the first implementation of the mconsole driver, and
4170 did the bulk of the work needed to get SMP working again.
4171
4172
4173 Yon Uriarte - Fixed the TUN/TAP network backend while I slept.
4174
4175
4176 Adam Heath - Made a bunch of nice cleanups to the initialization code,
4177 plus various other small patches.
4178
4179
4180 Matt Zimmerman - Matt volunteered to be the UML Debian maintainer and
4181 is doing a real nice job of it. He also noticed and fixed a number of
4182 actually and potentially exploitable security holes in uml_net. Plus
4183 the occasional patch. I like patches.
4184
4185
4186 James McMechan - James seems to have taken over maintenance of the ubd
4187 driver and is doing a nice job of it.
4188
4189
4190 Chandan Kudige - wrote the umlgdb script which automates the reloading
4191 of module symbols.
4192
4193
4194 Steve Schmidtke - wrote the UML slirp transport and hostaudio drivers,
4195 enabling UML processes to access audio devices on the host. He also
4196 submitted patches for the slip transport and lots of other things.
4197
4198
4199 David Coulson http://davidcoulson.net -
4200
4201 - Set up the http://usermodelinux.org site,
4202 which is a great way of keeping the UML user community on top of
4203 UML goings-on.
4204
4205 - Site documentation and updates
4206
4207 - Nifty little UML management daemon UMLd
4208
4209 - Lots of testing and bug reports
4210
4211
4212
4213
421415.2. Flushing out bugs
4215------------------------
4216
4217
4218
4219 - Yuri Pudgorodsky
4220
4221 - Gerald Britton
4222
4223 - Ian Wehrman
4224
4225 - Gord Lamb
4226
4227 - Eugene Koontz
4228
4229 - John H. Hartman
4230
4231 - Anders Karlsson
4232
4233 - Daniel Phillips
4234
4235 - John Fremlin
4236
4237 - Rainer Burgstaller
4238
4239 - James Stevenson
4240
4241 - Matt Clay
4242
4243 - Cliff Jefferies
4244
4245 - Geoff Hoff
4246
4247 - Lennert Buytenhek
4248
4249 - Al Viro
4250
4251 - Frank Klingenhoefer
4252
4253 - Livio Baldini Soares
4254
4255 - Jon Burgess
4256
4257 - Petru Paler
4258
4259 - Paul
4260
4261 - Chris Reahard
4262
4263 - Sverker Nilsson
4264
4265 - Gong Su
4266
4267 - johan verrept
4268
4269 - Bjorn Eriksson
4270
4271 - Lorenzo Allegrucci
4272
4273 - Muli Ben-Yehuda
4274
4275 - David Mansfield
4276
4277 - Howard Goff
4278
4279 - Mike Anderson
4280
4281 - John Byrne
4282
4283 - Sapan J. Batia
4284
4285 - Iris Huang
4286
4287 - Jan Hudec
4288
4289 - Voluspa
4290
4291
4292
4293
429415.3. Buglets and clean-ups
4295----------------------------
4296
4297
4298
4299 - Dave Zarzycki
4300
4301 - Adam Lazur
4302
4303 - Boria Feigin
4304
4305 - Brian J. Murrell
4306
4307 - JS
4308
4309 - Roman Zippel
4310
4311 - Wil Cooley
4312
4313 - Ayelet Shemesh
4314
4315 - Will Dyson
4316
4317 - Sverker Nilsson
4318
4319 - dvorak
4320
4321 - v.naga srinivas
4322
4323 - Shlomi Fish
4324
4325 - Roger Binns
4326
4327 - johan verrept
4328
4329 - MrChuoi
4330
4331 - Peter Cleve
4332
4333 - Vincent Guffens
4334
4335 - Nathan Scott
4336
4337 - Patrick Caulfield
4338
4339 - jbearce
4340
4341 - Catalin Marinas
4342
4343 - Shane Spencer
4344
4345 - Zou Min
4346
4347
4348 - Ryan Boder
4349
4350 - Lorenzo Colitti
4351
4352 - Gwendal Grignou
4353
4354 - Andre' Breiler
4355
4356 - Tsutomu Yasuda
4357
4358
4359
436015.4. Case Studies
4361-------------------
4362
4363
4364 - Jon Wright
4365
4366 - William McEwan
4367
4368 - Michael Richardson
4369
4370
4371
437215.5. Other contributions
4373--------------------------
4374
4375
4376 Bill Carr <Bill.Carr at compaq.com> made the Red Hat mkrootfs script
4377 work with RH 6.2.
4378
4379 Michael Jennings <mikejen at hevanet.com> sent in some material which
4380 is now gracing the top of the index page
4381 http://user-mode-linux.sourceforge.net/ of this site.
4382
4383 SGI (and more specifically Ralf Baechle <ralf at
4384 uni-koblenz.de> ) gave me an account on oss.sgi.com.
4385 The bandwidth there made it possible to
4386 produce most of the filesystems available on the project download
4387 page.
4388
4389 Laurent Bonnaud <Laurent.Bonnaud at inpg.fr> took the old grotty
4390 Debian filesystem that I've been distributing and updated it to 2.2.
4391 It is now available by itself here.
4392
4393 Rik van Riel gave me some ftp space on ftp.nl.linux.org so I can make
4394 releases even when Sourceforge is broken.
4395
4396 Rodrigo de Castro looked at my broken pte code and told me what was
4397 wrong with it, letting me fix a long-standing (several weeks) and
4398 serious set of bugs.
4399
4400 Chris Reahard built a specialized root filesystem for running a DNS
4401 server jailed inside UML. It's available from the download
4402 http://user-mode-linux.sourceforge.net/old/dl-sf.html page in the Jail
4403 Filesystems section.