|
From: Teto <mat...@gm...> - 2013-08-25 19:32:01
|
Hi, First a bit of context, I am looking for a kernel test & debug platform. I hesitate between QEmu and UML for this but I like the hostfs ability of UML (less complicated than 9p in qemu). As I run those tests on different computers and synchronize things via git, I prefer to do without a root filesystem/any binary. My current technique is to boot the kernel to test with a custom initrd that mounts the host filesystem, chroot to this mounted directory so that I can use my host binaries (custom ip route binaries already installed in my host etc...). I've seen no thread presenting this though it's very practical so I was wondering if that violated some rules (could harm host system for instance ?) or is it because it's not how UML is meant to be used (it aims at isolating). I wondered if I could use my host drive as a root filesystem (read-only, using a qcow2 file to save changes) to boot UML instead of creating/downloading a filesystem ? Best regards MAtt |
|
From: Michael R. <mc...@sa...> - 2013-08-26 16:56:48
|
Teto <mat...@gm...> wrote:
> My current technique is to boot the kernel to test with a custom initrd
> that mounts the host filesystem, chroot to this mounted directory so
> that I can use my host binaries (custom ip route binaries already
> installed in my host etc...). I've seen no thread presenting this
> though it's very practical so I was wondering if that violated some
> rules (could harm host system for instance ?) or is it because it's not
> how UML is meant to be used (it aims at isolating).
I have been doing this since 2001 :-)
I've tried to extract this system into a separate package, see:
https://github.com/mcr/uml-network-testing-infrastructure
(I've decided to call this "UNTI". I hacked a bunch of on the weekend,
let me push from my laptop)
> I wondered if I could use my host drive as a root filesystem
> (read-only, using a qcow2 file to save changes) to boot UML instead of
> creating/downloading a filesystem ?
Yes, you could do this.
I use hostfs for /, and I just mount /usr/share from the host.
--
] Never tell me the odds! | ipv6 mesh networks [
] Michael Richardson, Sandelman Software Works | network architect [
] mc...@sa... http://www.sandelman.ca/ | ruby on rails [
|
|
From: Teto <mat...@gm...> - 2013-08-26 21:24:47
|
Thanks for your answer. > I have been doing this since 2001 :-) > I've tried to extract this system into a separate package, see: > https://github.com/mcr/uml-network-testing-infrastructure That's really cool to put these files online. Moreover I intend to use UML for network testing as well so it's even better. > Yes, you could do this. > I use hostfs for /, and I just mount /usr/share from the host. Could you please detail the procedure since I get lost in your files. And the man page looks ambiguous to me. First how do you launch your uml kernel: just host$ ./uml_kernel initrd=custom_initrd or you add " root=cowtempfile,/dev/sdb5" ? I wish you could explain to me what to mount and when. Your init replace the temporary (/,/dev,/etc etc..) by the host ? I don't really understand the loop option exhibited in the documentation. The author then say to change authorizations to the mounted folder but I am afraid it will change all the authorizations on my host drive :s Best regards Matt > -- > ] Never tell me the odds! | ipv6 mesh networks [ > ] Michael Richardson, Sandelman Software Works | network architect [ > ] mc...@sa... http://www.sandelman.ca/ | ruby on rails [ > |
|
From: Michael R. <mc...@sa...> - 2013-08-26 22:14:32
|
Teto <mat...@gm...> wrote:
>> Yes, you could do this. I use hostfs for /, and I just mount
>> /usr/share from the host.
> Could you please detail the procedure since I get lost in your files.
> And the man page looks ambiguous to me. First how do you launch your
> uml kernel: just host$ ./uml_kernel initrd=custom_initrd or you add "
> root=cowtempfile,/dev/sdb5" ? I wish you could explain to me what to
> mount and when. Your init replace the temporary (/,/dev,/etc etc..) by
High-level explanation of UNTI.
1) You point (via umlsetup.sh) at the kernel source you want, it makes an lndir
link tree (%1) for the kernel, and compiles it.
2) You also point at the UML root tree you want to use.
That's an extracted file system that lives on the host, not a COW or loopback
file. We suggest you put your UML file systems on the same disk as
your reference root file system, as it can use hard links, which is way
faster, and saves piles of disk space.
3) an initrd is created from files in the root file system, and a linuxrc
file is created that:
a) populates a /dev (we used to use devfs, but it went away) into a ramfs.
b) gropes /proc/cmdline to find out where / is on the host, and mounts it
with hostfs.
c) invokes /sbin/init
At some point, hostfs grew caching, which is annoying, because it means that
I have to rm /my/test/program from within the UML, each time before I can
make DESTDIR= install it again from the host, or the file does not update. I
wish I could turn that off.
(%1) since 2.6.x some other make options would let you avoid that, but
in some cases one wants to patch the kernel before compiling, but
not screw with the original kernel source, and anyway, we started
in the 2.4 days.
LOW LEVEL stuff. A script is generated:
00 #!/bin/sh
01
02 if [ -z "${TEST_PURPOSE}" ] && [ -f /uml/umlbuild/.switches.sh ]; then . /uml/umlbuild/.switches.sh; fi
03 # get value from baseconfig
04 . /corp/projects/pandora/unstrung/testing/baseconfigs/net.A.sh
05
06 /uml/umlbuild/plain/vmlinux initrd=/uml/umlbuild/initrd.cpio
umlroot=/uml/umlbuild/A/root
root=/dev/ram0 rw ssl=pty
ssl0=port:1300 ssl1=port:1301
umid=A $net
$UML_DEBUG_OPT $UML_A_OPT
rdinit=/linuxrc $*
07 if [ -n "$UML_SLEEP" ]; then eval $UML_SLEEP; fi
02 - this sucks in some variables that tells net.A.sh, if there is a
uml_netjig (a version of uml_switch that knows how to play back pcap
files), running, or if one should use multicast sockets.
04 - each virtual machine has some network configuration, which looks like:
net_eth0="eth0=mcast,12:00:00:dc:bc:ff,239.192.0.1,21200"
net_eth1="eth1=mcast,12:00:00:64:64:23,239.192.1.2,31200";
net="$net_eth0 $net_eth1"
06 - the kernel to run.
- the initrd in CPIO format.
- umlroot= path to what path on the host to mount as /
- serial port 0 is the current pty, and some additional serial ports.
I use serial ports with gdbattach a lot to let me debug a
process inside the UML from outside. If I'm debugging the kernel
itself, I just gdb attach to the kernel.
- $net from above.
- rdinit=/linuxrc
07 - I tend to run the start.sh script in a fresh xterm -e, and if the kernel
bails, the xterm closes immediately, so "export UMLSLEEP='sleep 60'" helps
here.
https://github.com/mcr/unstrung uses this, as does:
https://github.com/xelerance/openswan
See https://github.com/mcr/unstrung/blob/master/testing/utils/linuxrc-uml.sh
for the linuxrc that I use.
--
] Never tell me the odds! | ipv6 mesh networks [
] Michael Richardson, Sandelman Software Works | network architect [
] mc...@sa... http://www.sandelman.ca/ | ruby on rails [
|
|
From: Teto <mat...@gm...> - 2013-08-27 10:16:42
|
Wow that's a great answer. Thank you to have taken the time to detail thing. It's a lot clearer now. > 1) You point (via umlsetup.sh) at the kernel source you want, it makes an lndir > link tree (%1) for the kernel, and compiles it. I use the "O=<output directory>" switch to compile for different architectures. You can then set different directories for binaries and .config files. True you cannot patch as you want though. I did not know "lndir", reminded me of a character in the lord of the rings : http://lotr.wikia.com/wiki/E%C3%A4rendil ^^ > 2) You also point at the UML root tree you want to use. > That's an extracted file system that lives on the host, not a COW or loopback > file. We suggest you put your UML file systems on the same disk as > your reference root file system, as it can use hard links, which is way > faster, and saves piles of disk space. This is my main interrogation. Why going through the trouble of creating a specific filesystem when there is already one working in the host ? I would like in my init to "UML$mount none /mnt/host -t hostfs" than "UML$chroot /mnt/host" (just discovered the switch_root utility in busybox). I can see problems with /proc and /dev colliding between my initramfs and my host drive. So maybe I could mount all other folders but those from my host "/" into the UML machine ? On top of that I don't see any incentive (at least in my case) to switch_root from the initramfs to a root filesystem ?! (maybe I could embed everything I need in the initramfs) > At some point, hostfs grew caching, which is annoying, because it means that > I have to rm /my/test/program from within the UML, each time before I can > make DESTDIR= install it again from the host, or the file does not update. I > wish I could turn that off. I guess you refer to CONFIG_CLEANCACHE and CONFIG_FRONTSWAP. I've just enabled them in reaction to your warning. > 02 - this sucks in some variables that tells net.A.sh, if there is a > uml_netjig (a version of uml_switch that knows how to play back pcap > files), running, or if one should use multicast sockets. This looks like a custom version. I think I wil rely on tun/tap sytems for networking since I want my VMs to interact with Internet. Btw, unstrung looks like a nice project. Once more thanks for having been through the trouble of explaining all this. It helps a lot. Best regards MAtt |