Bug 1969

Summary: Can't launch multiple qemu using nfs
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Hongna Xu <hongnax.xu>
Component: meta-yoctoAssignee: Scott Garman <scott.a.garman>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: corneliux.stoicescu, jessica.zhang, jiajun.xu, lianhao.lu, poky.bs.watcher, poky.watcher, rudolf.streif, sgw, song.liu
Version: 1.2   
Target Milestone: 1.3 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Hongna Xu 2012-02-08 19:34:01 UTC
On the yocto build tree, when i run: runqemu ${KERNEL} ${ROOTFS} to launch a second qemu, I got:
****************************************************
xuhongna@xu:~/workspace/poky/build-1.2M2$ runqemu tmp/deploy/images/zImage-qemuarm.bin ~/test-yocto/1.2M2/arm/
Assuming /home/xuhongna/test-yocto/1.2M2/arm/ is an nfs rootfs
Set MACHINE to [qemuarm] based on kernel [tmp/deploy/images/zImage-qemuarm.bin]

Continuing with the following parameters:
KERNEL: [tmp/deploy/images/zImage-qemuarm.bin]
ROOTFS: [/home/xuhongna/test-yocto/1.2M2/arm/]
FSTYPE: [nfs]
Acquiring lockfile for tap0...
Setting up tap interface under sudo
[sudo] password for xuhongna: 
Acquiring lockfile for tap1...
runqemu-export-rootfs restart /home/xuhongna/test-yocto/1.2M2/arm/
No PID file, not stopping rpc.mountd
No PID file, not stopping rpc.nfsd
Removing exports file
Creating exports file...
Starting User Mode rpc.mountd
  /opt/poky/1.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/bin/pseudo -P /opt/poky/1.1+snapshot/sysroots/x86_64-pokysdk-linux/usr /opt/poky/1.1+snapshot/sysroots/x86_64-pokysdk-linux/usr/sbin/rpc.mountd --allow-non-root --mount-pid /home/xuhongna/.runqemu-sdk/mount1.pid -f /home/xuhongna/.runqemu-sdk/exports1 --rmtab /home/xuhongna/.runqemu-sdk/rmtab1 --prog 21112 -r -P 3049
=====================
Error starting MOUNTD
=====================
  If you see an error above that says:
    RPC: Authentication error; why = Client credential too weak
  You need to change the startup of rpcbind
  on your host by doing the following as root:
===============================================
  According to /etc/sysconfig/rpcbind, then 
    echo RPCBIND_ARGS=-i >> /etc/sysconfig/rpcbind
  or
    echo RPCBIND_OPTIONS=-i >> /etc/sysconfig/rpcbind
    /etc/init.d/rpcbind restart
===============================================
For Ubuntu 11.10 hosts
Add OPTIONS="-i -w"  to /etc/default/rpcbind
sudo service portmap restart
Set 'tap1' nonpersistent
Releasing lockfile of preconfigured tap device 'tap1'
**************************************************************
and it doesn't work by the advice in the log above.
Comment 1 Scott Garman 2012-10-03 16:09:05 UTC
I have been looking into this, so far I've determined that it is mountd that is in fact failing. mountd simply returns -1 and the command has no other options for more verbose output, so it's going to take some further research to find out why.
Comment 2 Scott Garman 2012-10-03 16:10:02 UTC
Also, this is reproducible in both master and denzil 7.0.1, so the bug has existed for some time.
Comment 3 Rudolf J Streif 2012-10-03 20:20:47 UTC
I discovered this issue during a training class three weeks ago with 7.0.1. I just did not get around to enter a bug report (and a solution). The root cause is that the script runqemu-export-rootfs launches the user-space mountd listening on port

MOUNT_PORT=$[ 3048 + $NFS_INSTANCE ]

and the user-space nfsd listening on port

NFS_PORT=$[ 3049 + $NFS_INSTANCE ]

NFS_INSTANCE is derived from the sequential number of the TAP interface. For the first instance of QEMU this is 0, for the second it is 1. With the above variable setting this means that the MOUNT_PORT of the second instance will collide with NFS_PORT of the first instance. The error message is somewhat misleading since the script only checks the return value and makes an 'educated' assumption about the root cause.

The fix is relatively easy. In runqemu-export-rootfs and runqemu-internal just change MOUNT_PORT and NFS_PORT to 

MOUNT_PORT=$[ 3048 + 2 * $NFS_INSTANCE ]
NFS_PORT=$[ 3049 + 2 * $NFS_INSTANCE ]

Now, I would submit a patch for that if I just could find the GIT repo where these scripts are maintained.
Comment 4 Scott Garman 2012-10-03 20:32:30 UTC
Nothing like a fresh set of eyes to look at something - thanks Rudolf! I'll submit a patch for this, crediting you, and get it out to the oe-core ML this afternoon.
Comment 5 Scott Garman 2012-10-04 20:05:35 UTC
Fixed in oe-core and poky master as of:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=ee76b805f96f00aec386a1c34d176eea7d66f526
Comment 6 Stoicescu Cornel 2012-10-05 14:01:18 UTC
Verified in master, commit: ee76b805f96f00aec386a1c34d176eea7d66f526