in lguest · plan9

Configure plan9 with the lguest hypervisor

Introduction

  • Plan9 from Bell Labs is the operating system created by the same laboratories that invented Unix. It can run natively on different architectures, or also as a virtual machine with Qemu, Xen or Lguest.
  • Lguest is integrated in the linux kernel from version 2.6.23-git13 onwards. To write the article it has been tested with the latest kernel 2.6.25.

Configuring Lguest

The kernel has to be prepared to have lguest support and to enable several options.

It is not the aim of this article to explain how the kernel is configured or compiled, but you can use “make menuconfig” to select the following options:

  "General setup":
     "Prompt for development and/or incomplete code/drivers" = Y
        (CONFIG_EXPERIMENTAL=y)

  "Processor type and features":
     "Paravirtualized guest support" = Y
        "Lguest guest support" = Y
     "High Memory Support" = off/4GB
     "Alignment value to which kernel should be aligned" = 0x100000
        (CONFIG_PARAVIRT=y, CONFIG_LGUEST_GUEST=y, CONFIG_HIGHMEM64G=n and
         CONFIG_PHYSICAL_ALIGN=0x100000)

  "Device Drivers":
     "Block devices"
        "Virtio block driver (EXPERIMENTAL)" = M/Y
     "Network device support"
        "Universal TUN/TAP device driver support" = M/Y
        "Virtio network driver (EXPERIMENTAL)" = M/Y
           (CONFIG_VIRTIO_BLK=m, CONFIG_VIRTIO_NET=m and CONFIG_TUN=m)

  "Virtualization"
     "Linux hypervisor example code" = M/Y
        (CONFIG_LGUEST=m)

Configuring the network support (Bridging or NAT)

The virtual machine will use a virtual network interface, through bridging or NAT.

In this case, we will use NAT, for which we will also need NAT support in the kernel if we did not have it:

Networking  ---->
  Networking options  ---->
   Network packet filtering framework (Netfilter)--->
    Core Netfilter Configuration ---->
     <*> Netfilter connection tracking support
     <*> Netfilter Xtables support (required for ip_tables)
     <*>   "NFLOG" target support
     <*>   "conntrack" connection tracking match support
     <*>   "state" match support
   IP: Netfilter Configuration --->
     <*> IPv4 connection tracking support (required for NAT)
     <*> IP tables support (required for filtering/masq/NAT)
     <*>   Packet Filtering
     <*>     REJECT target support
     <*>   Full NAT
     <*>     MASQUERADE target support

We compile the kernel: make We install the kernel: make install We install the modules: make modules_install

Compiling the lguest binary

Under the directory tree where we have the linux sources (in my case it is /usr/src/fuentes/linux), we go to the following subdirectory:

cd Documentation/lguest/

and we run “make” to generate the lguest executable binary.

vejeta:/usr/src/fuentes/linux/Documentation/lguest# make
cc -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include    lguest.c  -lz -o lguest

Get the modified kernel and the Plan9 image for lguest (THNX)

  • 9lguestcpu.2.6.25.elf. It is the modified kernel to boot Plan9 under lguest.

 

wget http://sirviente.9grid.es/sources/contrib/rminnich/lguest/9lguestcpu.2.6.25.elf
  • THNX – “Tiny Horrible NOT Xen” is the preinstalled Plan9 image that was created by Ron Minnich to run under lguest. (300Mb compressed, 1.6Gb when decompressed)

 

wget http://usuarios.lycos.es/vejeta/plan9/thx9.img.bz2

Decompress:

bzip2 -d thx9.img.bz2

Doing NAT for the tap0 network interface

Create the script: NATME with the following lines and run it.

iptables --append FORWARD --in-interface tap0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface  eth0  -j MASQUERADE
iptables -t nat --list
echo 1 > /proc/sys/net/ipv4/ip_forward

Booting Plan 9 with lguest

The computer has to be rebooted to boot with the new kernel and then we can start lguest.

First we load the lguest module with the parameters indicated.

modprobe lg syscall_vector=64

Starting lguest with Plan9 virtualised.

/usr/src/fuentes/linux/Documentation/lguest/lguest 256 /usr/local/tmp/plan9/lguest/9lguestcpu.2.6.25.elf \
--tunnet=192.168.19.1 \
--block=/usr/local/tmp/plan9/lguest/thx9.img \
'venti=#S/sd00/arenas;bootdisk=local!#S/sd00/fossil;bootargs=local!#S/sd00/fossil;lguestnetwork=NAT;'
  • 256 indicates the RAM that the virtual machine will have.

 

  • 9lguestcpu.2.6.25.elf. It is the kernel that the virtual machine will run.

 

  • –tunnet=192.168.19.1. Configures a “tap” network device with the indicated IP address.
  • –block=/usr/local/tmp/plan9/lguest/thx9.img. It is the block device which in this case contains the preinstalled plan9 image.

The Plan9 image is prepared to work as a “cpu”; it is a Plan9 server which serves Plan9 terminals.

Connecting to the Plan9 virtual machine with drawterm

If you do not have a Plan9 terminal yet, you can use drawterm by compiling the sources, or by using an executable binary for your operating system.

drawterm -u bootes -a 192.168.19.2 -c 192.168.19.2

The key or password is: lguestgood

The following image shows the drawterm window, with the abaco browser and acme. In the background you can see the terminal where we started lguest.

 

 

 

 

 

—

I hope you like it

Zoperman – Vejeta