From 2c4954ad249a4ae17f5c0b0e768538b212dc412c Mon Sep 17 00:00:00 2001 From: Reto Buerki Date: Wed, 16 Jan 2013 11:58:01 +0100 Subject: [PATCH] Switch to 'mapped' access mode for hostfs Passthrough mode only works as expected when running as root. On Debian/Ubuntu systems qemu runs as user 'libvirt-qemu' and group 'kvm' so all shared files must be chowned to grant access from guests. Symlinks created on the host are still problematic because the Plan 9 filesystem has no direct notion of symbolic links, see [1]. [1] - http://ericvh.github.com/9p-rfc/rfc9p2000.u.html --- testing/config/kvm/alice.xml | 2 +- testing/config/kvm/bob.xml | 2 +- testing/config/kvm/carol.xml | 2 +- testing/config/kvm/dave.xml | 2 +- testing/config/kvm/moon.xml | 2 +- testing/config/kvm/sun.xml | 2 +- testing/config/kvm/venus.xml | 2 +- testing/config/kvm/winnetou.xml | 2 +- testing/hosts/default/etc/fstab | 2 +- testing/make-testing | 1 + testing/scripts/build-guestkernel | 1 - testing/scripts/build-rootimage | 19 ++++++++----------- testing/start-testing | 5 +++-- testing/testing.conf | 5 ++++- 14 files changed, 25 insertions(+), 24 deletions(-) diff --git a/testing/config/kvm/alice.xml b/testing/config/kvm/alice.xml index 21683b878..6ca78f861 100644 --- a/testing/config/kvm/alice.xml +++ b/testing/config/kvm/alice.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/bob.xml b/testing/config/kvm/bob.xml index e11200802..d9a9b4c05 100644 --- a/testing/config/kvm/bob.xml +++ b/testing/config/kvm/bob.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/carol.xml b/testing/config/kvm/carol.xml index 3bd66f141..fbdabe2e4 100644 --- a/testing/config/kvm/carol.xml +++ b/testing/config/kvm/carol.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/dave.xml b/testing/config/kvm/dave.xml index 526df285a..bfebe9b60 100644 --- a/testing/config/kvm/dave.xml +++ b/testing/config/kvm/dave.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/moon.xml b/testing/config/kvm/moon.xml index 049299312..e019fcea5 100644 --- a/testing/config/kvm/moon.xml +++ b/testing/config/kvm/moon.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/sun.xml b/testing/config/kvm/sun.xml index e60129819..5ed1a47ea 100644 --- a/testing/config/kvm/sun.xml +++ b/testing/config/kvm/sun.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/venus.xml b/testing/config/kvm/venus.xml index bd00aa563..77a333655 100644 --- a/testing/config/kvm/venus.xml +++ b/testing/config/kvm/venus.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/config/kvm/winnetou.xml b/testing/config/kvm/winnetou.xml index a23b2489c..99d5deb99 100644 --- a/testing/config/kvm/winnetou.xml +++ b/testing/config/kvm/winnetou.xml @@ -30,7 +30,7 @@
- +
diff --git a/testing/hosts/default/etc/fstab b/testing/hosts/default/etc/fstab index 1fb00f42e..12747232e 100644 --- a/testing/hosts/default/etc/fstab +++ b/testing/hosts/default/etc/fstab @@ -1 +1 @@ -/hostshare /hostfs 9p trans=virtio,version=9p2000.L 0 0 +/hostshare /root/shared 9p trans=virtio,version=9p2000.L 0 0 diff --git a/testing/make-testing b/testing/make-testing index cac4eddf8..84ac20bf2 100755 --- a/testing/make-testing +++ b/testing/make-testing @@ -4,6 +4,7 @@ DIR=$(dirname `readlink -f $0`) . $DIR/testing.conf rm -f $LOGFILE +mkdir -p $BUILDDIR if [ $ENABLE_BUILD_BASEIMAGE = "yes" ] then diff --git a/testing/scripts/build-guestkernel b/testing/scripts/build-guestkernel index fdd19ac74..66a9fe7a4 100755 --- a/testing/scripts/build-guestkernel +++ b/testing/scripts/build-guestkernel @@ -10,7 +10,6 @@ echo "Building guest kernel version $KERNELVERSION" check_commands bunzip2 bzcat make wget -mkdir -p $BUILDDIR cd $BUILDDIR if [ ! -f "$KERNELTARBALL" ] diff --git a/testing/scripts/build-rootimage b/testing/scripts/build-rootimage index 8f2b3aa1c..8e10ce5f3 100755 --- a/testing/scripts/build-rootimage +++ b/testing/scripts/build-rootimage @@ -28,7 +28,7 @@ check_commands partprobe qemu-img qemu-nbd load_qemu_nbd mkdir -p $LOOPDIR -mkdir -p $ROOTIMGCOMPILEDIR +mkdir -p $SHAREDDIR/compile mkdir -p $IMGDIR log_action "Creating root image $ROOTIMG" @@ -47,24 +47,21 @@ log_action "Mounting proc filesystem to $LOOPDIR/proc" execute "mount -t proc none $LOOPDIR/proc" do_on_exit umount $LOOPDIR/proc -mkdir -p $LOOPDIR/root/compile -log_action "Mounting $ROOTIMGCOMPILEDIR as /root/compile" -execute "mount -o bind $ROOTIMGCOMPILEDIR $LOOPDIR/root/compile" -do_on_exit rm -r $LOOPDIR/root/compile -do_on_exit umount $LOOPDIR/root/compile +mkdir -p $LOOPDIR/root/shared +log_action "Mounting $SHAREDDIR as /root/shared" +execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared" +do_on_exit umount $LOOPDIR/root/shared echo "Installing software from source" RECPDIR=$DIR/recipes RECIPES=`ls $RECPDIR/*.mk | xargs -n1 basename` -execute "cp -r $RECPDIR/patches $LOOPDIR/root/compile" 0 +execute "cp -r $RECPDIR/patches $LOOPDIR/root/shared/compile" 0 for r in $RECIPES do - cp $RECPDIR/$r ${LOOPDIR}/root/compile + cp $RECPDIR/$r ${LOOPDIR}/root/shared/compile log_action "Installing from recipe $r" - execute_chroot "make SWANVERSION=$SWANVERSION -C /root/compile -f $r" + execute_chroot "make SWANVERSION=$SWANVERSION -C /root/shared/compile -f $r" done log_action "Removing /etc/resolv.conf" execute "rm -f $LOOPDIR/etc/resolv.conf" - -mkdir -p $LOOPDIR/hostfs diff --git a/testing/start-testing b/testing/start-testing index e4e00bb1b..9be1f8619 100755 --- a/testing/start-testing +++ b/testing/start-testing @@ -19,8 +19,9 @@ check_commands virsh log_action "Deploying kernel $KERNEL" execute "ln -fs $KNLSRC $KNLTARGET" -log_action "Deploying $ROOTIMGCOMPILEDIR as hostfs" -execute "ln -Tfs $ROOTIMGCOMPILEDIR $HOSTFSTARGET" +log_action "Deploying $SHAREDDIR as hostfs" +execute "chown -R $KVMUSER:$KVMGROUP $SHAREDDIR" 0 +execute "ln -Tfs $SHAREDDIR $HOSTFSTARGET" for net in $NETWORKS do diff --git a/testing/testing.conf b/testing/testing.conf index b8bd3cf1b..960d3f63e 100644 --- a/testing/testing.conf +++ b/testing/testing.conf @@ -29,6 +29,8 @@ SWANVERSION=5.0.2dr4 # Build directory where the guest kernel and images will be built BUILDDIR=$TESTDIR/build +# Directory shared between host and guests +SHAREDDIR=$BUILDDIR/shared # Logfile LOGFILE=$BUILDDIR/testing.log @@ -52,12 +54,13 @@ BASEIMGMIRROR=http://cdn.debian.net/debian # The root image is the origin of all guest images. It is a clone of the base # image and contains additional test-specific software and patches. ROOTIMG=$IMGDIR/root.$IMGEXT -ROOTIMGCOMPILEDIR=$BUILDDIR/compile # libvirt config NBDEV=/dev/nbd0 NBDPARTITION=${NBDEV}p1 VIRTIMGSTORE=/var/lib/libvirt/images +KVMUSER=libvirt-qemu +KVMGROUP=kvm # Directory where test results will be stored TESTRESULTSDIR=$TESTDIR/testresults