summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Garman <scott.a.garman@intel.com>2010-10-03 21:16:24 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-10-07 19:55:50 +0100
commite70c8981f250ead9e025ecd27aef94b67d784fc6 (patch)
tree0644d5cfb98596f71e5cce7ff8f1e23508c4a4a2
parent8532405c1d6b2184ca88922506b725110a1f7627 (diff)
downloadpoky-e70c8981f250ead9e025ecd27aef94b67d784fc6.tar.gz
Allow running of multiple QEMU nfs instances
These changes allow multiple instances of the userspace NFS server to run, when brought up by consecutive instances of the poky-qemu control script. This fixes [BUGID #393] Signed-off-by: Scott Garman <scott.a.garman@intel.com>
-rwxr-xr-xscripts/poky-export-rootfs39
-rwxr-xr-xscripts/poky-qemu-internal31
2 files changed, 39 insertions, 31 deletions
diff --git a/scripts/poky-export-rootfs b/scripts/poky-export-rootfs
index ef527dc058..f3552516ad 100755
--- a/scripts/poky-export-rootfs
+++ b/scripts/poky-export-rootfs
@@ -61,11 +61,11 @@ if [ ! -d ~/.poky-sdk ]; then
61 mkdir -p ~/.poky-sdk 61 mkdir -p ~/.poky-sdk
62fi 62fi
63 63
64TARGET_VIRT_INSTANCE=${TARGET_VIRT_INSTANCE:=0} 64NFS_INSTANCE=${NFS_INSTANCE:=0}
65EXPORTS=~/.poky-sdk/exports$TARGET_VIRT_INSTANCE 65EXPORTS=~/.poky-sdk/exports$NFS_INSTANCE
66RMTAB=~/.poky-sdk/rmtab$TARGET_VIRT_INSTANCE 66RMTAB=~/.poky-sdk/rmtab$NFS_INSTANCE
67NFSPID=~/.poky-sdk/nfs$TARGET_VIRT_INSTANCE.pid 67NFSPID=~/.poky-sdk/nfs$NFS_INSTANCE.pid
68MOUNTPID=~/.poky-sdk/mount$TARGET_VIRT_INSTANCE.pid 68MOUNTPID=~/.poky-sdk/mount$NFS_INSTANCE.pid
69 69
70PSEUDO_OPTS="-P $POKY_NATIVE_SYSROOT/usr" 70PSEUDO_OPTS="-P $POKY_NATIVE_SYSROOT/usr"
71PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/var/pseudo" 71PSEUDO_LOCALSTATEDIR="$NFS_EXPORT_DIR/var/pseudo"
@@ -78,15 +78,14 @@ if [ ! -d "$PSEUDO_LOCALSTATEDIR" ]; then
78fi 78fi
79 79
80# rpc.mountd RPC port 80# rpc.mountd RPC port
81NFS_MOUNTPROG="21111" 81NFS_MOUNTPROG=$[ 21111 + $NFS_INSTANCE ]
82# rpc.nfsd RPC port 82# rpc.nfsd RPC port
83NFS_NFSPROG="11111" 83NFS_NFSPROG=$[ 11111 + $NFS_INSTANCE ]
84# NFS port number 84# NFS port number
85NFS_PORT="3049" 85NFS_PORT=$[ 3049 + $NFS_INSTANCE ]
86 86
87## For debugging you would additionally add 87## For debugging you would additionally add
88## --debug all 88## --debug all
89
90MOUNTD_OPTS="--allow-non-root --mount-pid $MOUNTPID -f $EXPORTS --rmtab $RMTAB --prog $NFS_MOUNTPROG -r" 89MOUNTD_OPTS="--allow-non-root --mount-pid $MOUNTPID -f $EXPORTS --rmtab $RMTAB --prog $NFS_MOUNTPROG -r"
91NFSD_OPTS="--allow-non-root --nfs-pid $NFSPID -f $EXPORTS --prog $NFS_NFSPROG -P $NFS_PORT -r" 90NFSD_OPTS="--allow-non-root --nfs-pid $NFSPID -f $EXPORTS --prog $NFS_NFSPROG -P $NFS_PORT -r"
92 91
@@ -102,7 +101,7 @@ case "$1" in
102 echo "Starting User Mode rpc.mountd" 101 echo "Starting User Mode rpc.mountd"
103 echo " $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS" 102 echo " $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS"
104 $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS 103 $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.mountd $MOUNTD_OPTS
105 if [ ! $? = 0 ] ; then 104 if [ ! $? = 0 ]; then
106 echo "=====================" 105 echo "====================="
107 echo "Error starting MOUNTD" 106 echo "Error starting MOUNTD"
108 echo "=====================" 107 echo "====================="
@@ -125,26 +124,26 @@ case "$1" in
125 echo "Starting User Mode nfsd" 124 echo "Starting User Mode nfsd"
126 echo " $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS" 125 echo " $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS"
127 $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS 126 $PSEUDO $PSEUDO_OPTS $POKY_NATIVE_SYSROOT/usr/sbin/rpc.nfsd $NFSD_OPTS
128 if [ ! $? = 0 ] ; then 127 if [ ! $? = 0 ]; then
129 echo "Error starting nfsd" 128 echo "Error starting nfsd"
130 exit 1 129 exit 1
131 fi 130 fi
132 # Check to make sure everything started ok. 131 # Check to make sure everything started ok.
133 if [ ! -f $MOUNTPID ] ; then 132 if [ ! -f $MOUNTPID ]; then
134 echo "rpc.mountd did not start correctly" 133 echo "rpc.mountd did not start correctly"
135 exit 1 134 exit 1
136 fi 135 fi
137 if [ ! -f $NFSPID ] ; then 136 if [ ! -f $NFSPID ]; then
138 echo "rpc.nfsd did not start correctly" 137 echo "rpc.nfsd did not start correctly"
139 exit 1 138 exit 1
140 fi 139 fi
141 ps -fp `cat $MOUNTPID` > /dev/null 2> /dev/null 140 ps -fp `cat $MOUNTPID` > /dev/null 2> /dev/null
142 if [ ! $? = 0 ] ; then 141 if [ ! $? = 0 ]; then
143 echo "rpc.mountd did not start correctly" 142 echo "rpc.mountd did not start correctly"
144 exit 1 143 exit 1
145 fi 144 fi
146 ps -fp `cat $NFSPID` > /dev/null 2> /dev/null 145 ps -fp `cat $NFSPID` > /dev/null 2> /dev/null
147 if [ ! $? = 0 ] ; then 146 if [ ! $? = 0 ]; then
148 echo "rpc.nfsd did not start correctly" 147 echo "rpc.nfsd did not start correctly"
149 exit 1 148 exit 1
150 fi 149 fi
@@ -153,25 +152,29 @@ case "$1" in
153 echo "nfsroot=IP_ADDRESS:$NFS_EXPORT_DIR,nfsvers=2,mountprog=$NFS_MOUNTPROG,nfsprog=$NFS_NFSPROG,udp" 152 echo "nfsroot=IP_ADDRESS:$NFS_EXPORT_DIR,nfsvers=2,mountprog=$NFS_MOUNTPROG,nfsprog=$NFS_NFSPROG,udp"
154 ;; 153 ;;
155 stop) 154 stop)
156 if [ -f "$MOUNTPID" ] ; then 155 if [ -f "$MOUNTPID" ]; then
157 echo "Stopping rpc.mountd" 156 echo "Stopping rpc.mountd"
158 kill `cat $MOUNTPID` 157 kill `cat $MOUNTPID`
159 rm -f $MOUNTPID 158 rm -f $MOUNTPID
160 else 159 else
161 echo "No PID file, not stopping rpc.mountd" 160 echo "No PID file, not stopping rpc.mountd"
162 fi 161 fi
163 if [ -f "$NFSPID" ] ; then 162 if [ -f "$NFSPID" ]; then
164 echo "Stopping rpc.nfsd" 163 echo "Stopping rpc.nfsd"
165 kill `cat $NFSPID` 164 kill `cat $NFSPID`
166 rm -f $NFSPID 165 rm -f $NFSPID
167 else 166 else
168 echo "No PID file, not stopping rpc.nfsd" 167 echo "No PID file, not stopping rpc.nfsd"
169 fi 168 fi
169 if [ -f "$EXPORTS" ]; then
170 echo "Removing exports file"
171 rm -f $EXPORTS
172 fi
170 ;; 173 ;;
171 restart) 174 restart)
172 $0 stop $NFS_EXPORT_DIR 175 $0 stop $NFS_EXPORT_DIR
173 $0 start $NFS_EXPORT_DIR 176 $0 start $NFS_EXPORT_DIR
174 if [ ! $? = 0 ] ; then 177 if [ ! $? = 0 ]; then
175 exit 1 178 exit 1
176 fi 179 fi
177 ;; 180 ;;
diff --git a/scripts/poky-qemu-internal b/scripts/poky-qemu-internal
index 0ea38eef60..532b255da9 100755
--- a/scripts/poky-qemu-internal
+++ b/scripts/poky-qemu-internal
@@ -50,8 +50,9 @@ if [ -z "$QEMU_MEMORY" ]; then
50 50
51fi 51fi
52 52
53# This flag file is created when poky-gen-tapdevs creates a bank of 53# This file is created when poky-gen-tapdevs creates a bank of tap
54# tap devices, indicating that the user does not have sudo privs. 54# devices, indicating that the user should not bring up new ones using
55# sudo.
55NOSUDO_FLAG="/etc/poky-nosudo" 56NOSUDO_FLAG="/etc/poky-nosudo"
56 57
57QEMUIFUP=`which poky-qemu-ifup` 58QEMUIFUP=`which poky-qemu-ifup`
@@ -113,18 +114,17 @@ else
113fi 114fi
114 115
115release_lock() { 116release_lock() {
116 if [ "$LOCKFILE" = "" ]; then 117 if [ ! -e "$NOSUDO_FLAG" ]; then
117 $QEMUIFDOWN $TAP $POKY_NATIVE_SYSROOT 118 $QEMUIFDOWN $TAP $POKY_NATIVE_SYSROOT
118 else
119 echo "Releasing lockfile of preconfigured tap device '$TAP'"
120 lockfile-remove $LOCKFILE
121 fi
122
123 if [ "$NFSRUNNING" = "true" ]; then
124 echo "Shutting down the userspace NFS server:"
125 echo "poky-export-rootfs stop $ROOTFS"
126 poky-export-rootfs stop $ROOTFS
127 fi 119 fi
120 echo "Releasing lockfile of preconfigured tap device '$TAP'"
121 lockfile-remove $LOCKFILE
122
123 if [ "$NFSRUNNING" = "true" ]; then
124 echo "Shutting down the userspace NFS server..."
125 echo "poky-export-rootfs stop $ROOTFS"
126 poky-export-rootfs stop $ROOTFS
127 fi
128} 128}
129 129
130n1=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ] 130n1=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
@@ -136,6 +136,9 @@ QEMU_NETWORK_CMD="-net nic,vlan=0 $QEMU_TAP_CMD"
136KERNCMDLINE="mem=$QEMU_MEMORY" 136KERNCMDLINE="mem=$QEMU_MEMORY"
137QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet" 137QEMU_UI_OPTIONS="-show-cursor -usb -usbdevice wacom-tablet"
138 138
139NFS_INSTANCE=`echo $TAP | sed 's/tap//'`
140export NFS_INSTANCE
141
139SERIALOPTS="" 142SERIALOPTS=""
140if [ "x$SERIAL_LOGFILE" != "x" ]; then 143if [ "x$SERIAL_LOGFILE" != "x" ]; then
141 SERIALOPTS="-serial file:$SERIAL_LOGFILE" 144 SERIALOPTS="-serial file:$SERIAL_LOGFILE"
@@ -172,7 +175,9 @@ fi
172if [ "$FSTYPE" = "nfs" ]; then 175if [ "$FSTYPE" = "nfs" ]; then
173 NFS_SERVER="192.168.7.1" 176 NFS_SERVER="192.168.7.1"
174 NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'` 177 NFS_DIR=`echo $ROOTFS | sed 's/^[^:]*:\(.*\)/\1/'`
175 UNFS_OPTS="nfsvers=2,mountprog=21111,nfsprog=11111,udp" 178 MOUNTD_PORT=$[ 21111 + $NFS_INSTANCE ]
179 NFSD_PORT=$[ 11111 + $NFS_INSTANCE ]
180 UNFS_OPTS="nfsvers=2,mountprog=$MOUNTD_PORT,nfsprog=$NFSD_PORT,udp"
176 181
177 PSEUDO_LOCALSTATEDIR=~/.poky-sdk/pseudo 182 PSEUDO_LOCALSTATEDIR=~/.poky-sdk/pseudo
178 export PSEUDO_LOCALSTATEDIR 183 export PSEUDO_LOCALSTATEDIR