Skip to contentSkip to conversation

runqemu multiple unfs instances fix

PATCH In review Scott Garman 2 participants 5 messages Oct 3, 2012 – Oct 5, 2012

lore
Share & tools
lore
#0 lore raw

cover runqemu multiple unfs instances fix

Hello,

Here's a bugfix to allow multiple instances of unfs-based qemu to run. A bit thank you to Rudolf J Streif for proposing the final commit in this series.

Scott

The following changes since commit ae9dbd0e1e26ba2b35cbd08ec731aee62adedc23:

distrodata: Update distrocheck functions (2012-10-03 17:37:24 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib sgarman/runqemu-unfs-fix-oe
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=sgarman/runqemu-unfs-fix-oe

Scott Garman (3):
runqemu-export-rootfs: use consistent whitespace
runqemu-export-rootfs: improve rpcbind error detection
runqemu: allow multiple unfs instances to run simultaneously

 scripts/runqemu-export-rootfs |  113 +++++++++++++++++++++++------------------
 scripts/runqemu-internal      |    4 +-
 2 files changed, 66 insertions(+), 51 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 runqemu-export-rootfs: use consistent whitespace

---
 scripts/runqemu-export-rootfs |   94 ++++++++++++++++++++---------------------
 1 file changed, 47 insertions(+), 47 deletions(-)
scripts/runqemu-export-rootfs +47 -47
index 3c77dd7..ca79af3 100755
@@ -40,9 +40,9 @@ NFS_EXPORT_DIR=$(cd "$2" && pwd)
 
 SYSROOT_SETUP_SCRIPT=`which oe-find-native-sysroot 2> /dev/null`
 if [ -z "$SYSROOT_SETUP_SCRIPT" ]; then
-    echo "Error: Unable to find the oe-find-native-sysroot script"
-    echo "Did you forget to source your build environment setup script?"
-    exit 1
+	echo "Error: Unable to find the oe-find-native-sysroot script"
+	echo "Did you forget to source your build environment setup script?"
+	exit 1
 fi
 . $SYSROOT_SETUP_SCRIPT
 
@@ -50,9 +50,9 @@ if [ ! -e "$OECORE_NATIVE_SYSROOT/usr/sbin/rpc.mountd" ]; then
 	echo "Error: Unable to find rpc.mountd binary in $OECORE_NATIVE_SYSROOT/usr/sbin/"
 
 	if [ "x$OECORE_DISTRO_VERSION" = "x" ]; then
-	    echo "Have you run 'bitbake meta-ide-support'?"
+		echo "Have you run 'bitbake meta-ide-support'?"
 	else
-	    echo "This shouldn't happen - something is missing from your toolchain installation"
+		echo "This shouldn't happen - something is missing from your toolchain installation"
 	fi
 	exit 1
 fi
@@ -104,53 +104,53 @@ case "$1" in
 	echo "  $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS"
 	$PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS
 	if [ ! $? = 0 ]; then
-	    echo "====================="
-	    echo "Error starting MOUNTD"
-	    echo "====================="
-	    ps -ef | grep -v grep | grep rpcbind 2>&1 > /dev/null
-	    if [ $? = 0 ] ; then
-		echo "  If you see an error above that says:"
-		echo "    RPC: Authentication error; why = Client credential too weak"
-		echo "  You need to change the startup of rpcbind"
-		echo "  on your host by doing the following as root:"
-		echo "==============================================="
-		echo "  According to /etc/sysconfig/rpcbind, then "
-		echo "    echo RPCBIND_ARGS=-i >> /etc/sysconfig/rpcbind"
-		echo "  or"
-		echo "    echo RPCBIND_OPTIONS=-i >> /etc/sysconfig/rpcbind"
-		echo "    /etc/init.d/rpcbind restart"
-		echo "==============================================="
-		echo "For Ubuntu 11.10 hosts"
-		echo "Add OPTIONS=\"-i -w\"  to /etc/default/rpcbind"
-		echo "sudo service portmap restart"
-	    fi
-	    exit 1
+		echo "====================="
+		echo "Error starting MOUNTD"
+		echo "====================="
+		ps -ef | grep -v grep | grep rpcbind 2>&1 > /dev/null
+		if [ $? = 0 ] ; then
+			echo "  If you see an error above that says:"
+			echo "    RPC: Authentication error; why = Client credential too weak"
+			echo "  You need to change the startup of rpcbind"
+			echo "  on your host by doing the following as root:"
+			echo "==============================================="
+			echo "  According to /etc/sysconfig/rpcbind, then "
+			echo "    echo RPCBIND_ARGS=-i >> /etc/sysconfig/rpcbind"
+			echo "  or"
+			echo "    echo RPCBIND_OPTIONS=-i >> /etc/sysconfig/rpcbind"
+			echo "    /etc/init.d/rpcbind restart"
+			echo "==============================================="
+			echo "For Ubuntu 11.10 hosts"
+			echo "Add OPTIONS=\"-i -w\"  to /etc/default/rpcbind"
+			echo "sudo service portmap restart"
+		fi
+		exit 1
 	fi
 	echo "Starting User Mode nfsd"
 	echo "  $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS"
 	$PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS
 	if [ ! $? = 0 ]; then
-	    echo "Error starting nfsd"
-	    exit 1
+		echo "Error starting nfsd"
+		exit 1
 	fi
 	# Check to make sure everything started ok.
 	if [ ! -f $MOUNTPID ]; then
-	    echo "rpc.mountd did not start correctly"
-	    exit 1
+		echo "rpc.mountd did not start correctly"
+		exit 1
 	fi
 	if [ ! -f $NFSPID ]; then
-	    echo "rpc.nfsd did not start correctly"
-	    exit 1
+		echo "rpc.nfsd did not start correctly"
+		exit 1
 	fi
 	ps -fp `cat $MOUNTPID` > /dev/null 2> /dev/null
 	if [ ! $? = 0 ]; then
-	    echo "rpc.mountd did not start correctly"
-	    exit 1
+		echo "rpc.mountd did not start correctly"
+		exit 1
 	fi
 	ps -fp `cat $NFSPID` > /dev/null 2> /dev/null
 	if [ ! $? = 0 ]; then
-	    echo "rpc.nfsd did not start correctly"
-	    exit 1
+		echo "rpc.nfsd did not start correctly"
+		exit 1
 	fi
 	echo " "
 	echo "On your target please remember to add the following options for NFS"
@@ -158,29 +158,29 @@ case "$1" in
 	;;
   stop)
 	if [ -f "$MOUNTPID" ]; then
-	    echo "Stopping rpc.mountd"
-	    kill `cat $MOUNTPID`
-	    rm -f $MOUNTPID
+		echo "Stopping rpc.mountd"
+		kill `cat $MOUNTPID`
+		rm -f $MOUNTPID
 	else
-	    echo "No PID file, not stopping rpc.mountd"
+		echo "No PID file, not stopping rpc.mountd"
 	fi
 	if [ -f "$NFSPID" ]; then
-	    echo "Stopping rpc.nfsd"
-	    kill `cat $NFSPID`
-	    rm -f $NFSPID
+		echo "Stopping rpc.nfsd"
+		kill `cat $NFSPID`
+		rm -f $NFSPID
 	else
-	    echo "No PID file, not stopping rpc.nfsd"
+		echo "No PID file, not stopping rpc.nfsd"
 	fi
 	if [ -f "$EXPORTS" ]; then
-        echo "Removing exports file"
-        rm -f $EXPORTS
+		echo "Removing exports file"
+		rm -f $EXPORTS
 	fi
 	;;
   restart)
 	$0 stop $NFS_EXPORT_DIR
 	$0 start $NFS_EXPORT_DIR 
 	if [ ! $? = 0 ]; then
-	    exit 1
+		exit 1
 	fi
 	;;
   *)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 runqemu-export-rootfs: improve rpcbind error detection

In reply to Scott Garman

mountd requires rpcbind or portmap. Check that one of these services is running before doing anything else, and report a user-friendly error when they are not found.

---
 scripts/runqemu-export-rootfs |   33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)
scripts/runqemu-export-rootfs +24 -9
index ca79af3..90edc8a 100755
@@ -100,6 +100,21 @@ fi
 # See how we were called.
 case "$1" in
   start)
+	PORTMAP_RUNNING=`ps -ef | grep portmap | grep -v grep`
+	RPCBIND_RUNNING=`ps -ef | grep rpcbind | grep -v grep`
+	if [[ "x$PORTMAP_RUNNING" = "x" && "x$RPCBIND_RUNNING" = "x" ]]; then
+		echo "======================================================="
+		echo "Error: neither rpcbind nor portmap appear to be running"
+		echo "Please install and start one of these services first"
+		echo "======================================================="
+		echo "Tip: for recent Ubuntu hosts, run:"
+		echo "  sudo apt-get install rpcbind"
+		echo "Then add OPTIONS=\"-i -w\"  to /etc/default/rpcbind and run"
+		echo "  sudo service portmap restart"
+
+		exit 1
+	fi
+
 	echo "Starting User Mode rpc.mountd"
 	echo "  $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS"
 	$PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS
@@ -107,25 +122,25 @@ case "$1" in
 		echo "====================="
 		echo "Error starting MOUNTD"
 		echo "====================="
-		ps -ef | grep -v grep | grep rpcbind 2>&1 > /dev/null
-		if [ $? = 0 ] ; then
+		if [ ! "x$RPCBIND_RUNNING" = "x" ] ; then
 			echo "  If you see an error above that says:"
 			echo "    RPC: Authentication error; why = Client credential too weak"
-			echo "  You need to change the startup of rpcbind"
-			echo "  on your host by doing the following as root:"
+			echo "  You need to add the -i option when running rpcbind"
 			echo "==============================================="
-			echo "  According to /etc/sysconfig/rpcbind, then "
-			echo "    echo RPCBIND_ARGS=-i >> /etc/sysconfig/rpcbind"
+			echo "For recent Fedora/RedHat hosts:"
+			echo "Add RPCBIND_ARGS=-i to /etc/sysconfig/rpcbind"
 			echo "  or"
-			echo "    echo RPCBIND_OPTIONS=-i >> /etc/sysconfig/rpcbind"
-			echo "    /etc/init.d/rpcbind restart"
+			echo "Add RPCBIND_OPTIONS=-i to /etc/sysconfig/rpcbind"
+			echo "Then run as root: /etc/init.d/rpcbind restart"
 			echo "==============================================="
-			echo "For Ubuntu 11.10 hosts"
+			echo "For recent Debian/Ubuntu hosts:"
 			echo "Add OPTIONS=\"-i -w\"  to /etc/default/rpcbind"
 			echo "sudo service portmap restart"
 		fi
+
 		exit 1
 	fi
+
 	echo "Starting User Mode nfsd"
 	echo "  $PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS"
 	$PSEUDO $PSEUDO_OPTS $OECORE_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 runqemu: allow multiple unfs instances to run simultaneously

In reply to Scott Garman

A miscalculation in the way the port numbers of mountd and nfsd are created was causing conflicts when starting multiple instances of qemu using userspace nfs.

Thanks to Rudolf Streif for proposing this fix!

Fixes [YOCTO #1969]

---
 scripts/runqemu-export-rootfs |    4 ++--
 scripts/runqemu-internal      |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
scripts/runqemu-export-rootfs +2 -2
index 90edc8a..bbdaf5b 100755
@@ -82,9 +82,9 @@ NFS_MOUNTPROG=$[ 21111 + $NFS_INSTANCE ]
 # rpc.nfsd RPC port
 NFS_NFSPROG=$[ 11111 + $NFS_INSTANCE ]
 # NFS port number
-NFS_PORT=$[ 3049 + $NFS_INSTANCE ]
+NFS_PORT=$[ 3049 + 2 * $NFS_INSTANCE ]
 # mountd port number
-MOUNT_PORT=$[ 3048 + $NFS_INSTANCE ]
+MOUNT_PORT=$[ 3048 + 2 * $NFS_INSTANCE ]
 
 ## For debugging you would additionally add
 ## --debug all
scripts/runqemu-internal +2 -2
index 0f07bad..7ca00f8 100755
@@ -277,8 +277,8 @@ if [ "$FSTYPE" = "nfs" ]; then
     NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'`
     MOUNTD_RPCPORT=$[ 21111 + $NFS_INSTANCE ]
     NFSD_RPCPORT=$[ 11111 + $NFS_INSTANCE ]
-    NFSD_PORT=$[ 3049 + $NFS_INSTANCE ]
-    MOUNTD_PORT=$[ 3048 + $NFS_INSTANCE ]
+    NFSD_PORT=$[ 3049 + 2 * $NFS_INSTANCE ]
+    MOUNTD_PORT=$[ 3048 + 2 * $NFS_INSTANCE ]
     UNFS_OPTS="nfsvers=2,mountprog=$MOUNTD_RPCPORT,nfsprog=$NFSD_RPCPORT,udp,port=$NFSD_PORT,mountport=$MOUNTD_PORT"
 
     PSEUDO_LOCALSTATEDIR=~/.runqemu-sdk/pseudo
Signature · 1 line
1.7.9.5
#4 lore raw
In reply to Scott Garman
Quoted 17 lines · Scott Garman

Hello,

Here's a bugfix to allow multiple instances of unfs-based qemu to run. A bit thank you to Rudolf J Streif for proposing the final commit in this series.

Scott

The following changes since commit ae9dbd0e1e26ba2b35cbd08ec731aee62adedc23:

   distrodata: Update distrocheck functions (2012-10-03 17:37:24 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib sgarman/runqemu-unfs-fix-oe
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=sgarman/runqemu-unfs-fix-oe

Quoted 9 lines

Scott Garman (3):
runqemu-export-rootfs: use consistent whitespace
runqemu-export-rootfs: improve rpcbind error detection
runqemu: allow multiple unfs instances to run simultaneously

  scripts/runqemu-export-rootfs |  113 +++++++++++++++++++++++------------------
  scripts/runqemu-internal      |    4 +-
  2 files changed, 66 insertions(+), 51 deletions(-)

Merged these into OE-Core

Thanks
Sau!