[Aboriginal] 9p VirtFS for /home

Rob Landley rob at landley.net
Tue May 24 00:34:41 PDT 2011


On 05/23/2011 01:14 PM, Salman Aljammaz wrote:
> # HG changeset patch
> # User aljamms8 at cs.man.ac.uk
> # Date 1306104988 0
> # Node ID 1a5767c4bdaddffeb39d58b592fe3d1627589268
> # Parent  e948f92964b50679eac300c2842980d4364de9bb
> Use 9p VirtFS for /home and /mnt/host
> 
> diff -r e948f92964b5 -r 1a5767c4bdad sources/baseconfig-linux
> --- a/sources/baseconfig-linux	Wed May 04 02:04:17 2011 -0500
> +++ b/sources/baseconfig-linux	Sun May 22 22:56:28 2011 +0000
> @@ -40,3 +40,13 @@
>  CONFIG_SQUASHFS=y
>  CONFIG_MAGIC_SYSRQ=y
>  CONFIG_DEVTMPFS=y
> +
> +CONFIG_VIRTIO=y
> +CONFIG_VIRTIO_PCI=y
> +CONFIG_VIRTIO_NET=y
> +CONFIG_NET_9P=y
> +CONFIG_NET_9P_VIRTIO=y
> +CONFIG_9P_FS=y
> +CONFIG_9P_FS_POSIX_ACL=y
> +CONFIG_PARAVIRT_GUEST=y
> +CONFIG_VIRTUALIZATION=y

Hmmm, my .config just has:

--- a/sources/baseconfig-linux  Tue May 24 02:00:52 2011 -0500
+++ b/sources/baseconfig-linux  Tue May 24 02:00:56 2011 -0500
@@ -34,9 +34,15 @@
 CONFIG_EXT3_FS=y
 CONFIG_TMPFS=y
 CONFIG_MISC_FILESYSTEMS=y
-CONFIG_NETWORK_FILESYSTEMS=y
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
 CONFIG_SQUASHFS=y
 CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEVTMPFS=y
+
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NET_9P=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_VIRTIO_NET=y
+CONFIG_9P_FS=y
+CONFIG_9P_FS_POSIX_ACL=y

Let's see...

CONFIG_VIRTIO is an internal symbol, it has no prompt but is instead
selected by other symbols.

CONFIG_PARAVIRT_GUEST=y enables optimizations for running under KVM.
(Ok I suppose, but not useful off an x86 host, or under qemu.  In the
circumstances where it's actually useful, so is chroot.)

I must admit your symbol order is a lot prettier than mine. :)

> diff -r e948f92964b5 -r 1a5767c4bdad sources/root-filesystem/sbin/init.sh
> --- a/sources/root-filesystem/sbin/init.sh	Wed May 04 02:04:17 2011 -0500
> +++ b/sources/root-filesystem/sbin/init.sh	Sun May 22 22:56:28 2011 +0000
> @@ -37,12 +37,19 @@
>    [ "$(date +%s)" -lt 1000 ] && rdate 10.0.2.2 # or time-b.nist.gov
>  
>    mount -t tmpfs /tmp /tmp
> +  mount -t tmpfs /mnt /mnt
>  
> -  # If there's a /dev/hdb or /dev/sdb, mount it on home
> +  # if there's a 9p virtual filesystem, mount it on home, otherwise
> +  # check for /dev/hdb or /dev/sdb
>  
>    [ -b /dev/hdb ] && HOMEDEV=/dev/hdb
>    [ -b /dev/sdb ] && HOMEDEV=/dev/sdb
> -  if [ ! -z "$HOMEDEV" ]
> +  if [ -d /sys/bus/virtio/drivers/9pnet_virtio/virtio0 ]
> +  then
> +    mkdir /mnt/host
> +    mount -t 9p -o trans=virtio host /mnt/host
> +    mount -t 9p -o trans=virtio home /home
> +  elif [ ! -z "$HOMEDEV" ]

Hmmm, seems a bit inflexible.

If you mount the host's / somewhere you can then bind mount /home out of
it.  You don't need two virtfs exports.

Specifying where HOME lives is the kind of thing I'd normally use an
environment variable for.  (You can both export them for run-emulator.sh
and feed them to init.sh via QEMU_EXTRA.  If it's going to live in
perhaps system-image-$ARCH/home directory on the host then
dev-environment.sh can trivially add it to QEMU_EXTRA, modulo there
being spaces in the path to get there, but maybe qemu could take a
relative path so that wasn't an issue...)

The real problem is that virtio isn't available on all targets.  This
can't make hdb.img go away. :(

By the way, i've had some discussions on the p9 mailing list about
redoing the mount user interface a bit, so it can autodetect the
transport type and such.  The thread is behind this horrible (and
wordwrapped) URL:

http://sourceforge.net/mailarchive/forum.php?thread_name=4DB08F2B.6070004%40parallels.com&forum_name=v9fs-developer

The meat of it is sort of here:

  http://sourceforge.net/mailarchive/message.php?msg_id=27389405

If I got something like that in, we could specify "10.0.2.2:/path" or
similar...

>    then
>      mount -o noatime $HOMEDEV /home
>    else
> @@ -50,13 +57,14 @@
>      touch /.temp 2>/dev/null
>      [ $? -ne 0 ] && mount -t tmpfs /home /home || rm /.temp
>    fi
> +
>    cd /home
> -
>    [ -b /dev/hdc ] && MNTDEV=/dev/hdc
>    [ -b /dev/sdc ] && MNTDEV=/dev/sdc
>    if [ ! -z "$MNTDEV" ]
>    then
> -    mount -o ro $MNTDEV /mnt
> +    mkdir /mnt/c
> +    mount -o ro $MNTDEV /mnt/c
>    fi

Breaks the existing control images.  (Doable, but annoying.)

>    [ -z "$CONSOLE" ] &&
> diff -r e948f92964b5 -r 1a5767c4bdad system-image.sh
> --- a/system-image.sh	Wed May 04 02:04:17 2011 -0500
> +++ b/system-image.sh	Sun May 22 22:56:28 2011 +0000
> @@ -30,6 +30,8 @@
>  {
>    echo -n "-nographic -no-reboot -kernel $KERNEL \$WITH_HDC \$WITH_HDB"
>    [ "$SYSIMAGE_TYPE" != "initramfs" ] && echo -n " -hda $IMAGE"
> +  echo -n " -virtfs local,path=/,security_model=none,mount_tag=host"
> +  echo -n " -virtfs local,path=\$HOME,security_model=none,mount_tag=home"
>    echo -n " -append \"$(kernel_cmdline)\" \$QEMU_EXTRA"
>  }

Have you tested this on any target _other_ than x86?

Also, it means that a qemu that doesn't support -virtfs will fail to
launch, and most distro qemus don't have it yet...

Rob

 1306222481.0


More information about the Aboriginal mailing list