From: miljenko Date: Mon, 28 Apr 2008 11:32:34 +0000 (+0000) Subject: To enable X applications running on virtual nodes we create X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=518b131033c9a030553bb680d57c0b83644a09b5;p=imunes.git To enable X applications running on virtual nodes we create a pair of virtual ethernet interfaces (with shell script startopera), one in "default" and the other in virtual node. If the experiment is terminated while TCP socket (in any virtual node) is in state TIME_WAIT a system will hang and then reboot. To prevent virtual node destruction from rebooting the system a loop checking TIME_WAIT state in all virtual nodes is added as temporary fix. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- diff --git a/editor.tcl b/editor.tcl index 5258df7..8b16424 100755 --- a/editor.tcl +++ b/editor.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: editor.tcl,v 1.88 2008/01/05 18:06:25 marko Exp $ +# $Id: editor.tcl,v 1.89 2008/04/28 11:32:34 miljenko Exp $ #****h* imunes/editor.tcl @@ -1222,6 +1222,8 @@ proc button3node { c x y } { .button3menu.ethereal add command -label $label \ -command "startethereal $node $ifc" } + .button3menu add command -label "Opera Browser" \ + -command "startopera $node" .button3menu add command -label Start \ -command "[typemodel $node].start $eid $node" .button3menu add command -label Stop \ @@ -1229,6 +1231,8 @@ proc button3node { c x y } { } else { .button3menu add cascade -label "Ethereal" \ -menu .button3menu.ethereal -state disabled + .button3menu add command -label "Opera Browser" \ + -state disabled .button3menu add command -label start \ -command "[typemodel $node].start $eid $node" -state disabled .button3menu add command -label stop \ @@ -1300,6 +1304,25 @@ proc startethereal { node iface } { } +#****f* editor.tcl/startopera +# NAME +# startopera -- start opera +# SYNOPSIS +# startopera $node +# FUNCTION +# This procedure starts opera on the specified node +# INPUTS +# * node -- node id +# * iface -- interface name +#**** +proc startopera { node } { + upvar 0 ::cf::[set ::curcfg]::eid eid + + # set interface "$iface@$eid\.$node" + nexec startopera $eid.$node & +} + + #****f* editor.tcl/button1 # NAME # button1 diff --git a/exec.tcl b/exec.tcl index 8f29d8e..82a1a61 100755 --- a/exec.tcl +++ b/exec.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: exec.tcl,v 1.71 2008/01/31 10:56:56 marko Exp $ +# $Id: exec.tcl,v 1.72 2008/04/28 11:32:34 miljenko Exp $ #****f* exec.tcl/nexec @@ -652,6 +652,40 @@ proc vimageCleanup { eid } { set defindex [lsearch $vimages .] set vimages [lreplace $vimages $defindex $defindex] + # Wait for TIME_WAIT timeout in all vimages + set vrti 1 + set sec 60 + + # wm title $wi "Please wait ..." + set w .timewait + catch {destroy $w} + toplevel $w -takefocus 1 + wm geometry $w +150+150 + wm title $w "Please wait ..." + message $w.msg -justify left -aspect 1200 \ + -text "\nDue to the known bug we must wait for TIME_WAIT expiration on virtual nodes (up to 60 sec). +Please don't try killing the process. +(countdown on status line)\n" + pack $w.msg + update + grab $w + + while { $vrti == 1 } { + set vrti 0 + foreach vimage $vimages { + # puts "vimage $vimage...\n" + while { [catch {nexec vimage $eid.$vimage netstat -an -f inet | fgrep "WAIT"} odg] == 0} { + set vrti 1 + # puts "vimage $vimage: \n$odg\n" + after 2000 + set sec [expr $sec - 2] + statline "~ $sec sec ..." + pack $w.msg + update + } + } + } + destroy .timewait # Kill all processes in all vimages foreach vimage $vimages { set stattxt "Terminating processes in vimage $vimage" diff --git a/install.sh b/install.sh index 49058da..2c42221 100755 --- a/install.sh +++ b/install.sh @@ -54,5 +54,8 @@ chmod 755 $ROOTDIR/$BINDIR/quaggaboot.sh cp himage $ROOTDIR/$BINDIR/ chmod 755 $ROOTDIR/$BINDIR/himage +cp startopera $ROOTDIR/$BINDIR/ +chmod 755 $ROOTDIR/$BINDIR/startopera + echo Done! diff --git a/startopera b/startopera new file mode 100755 index 0000000..2463f1a --- /dev/null +++ b/startopera @@ -0,0 +1,64 @@ +#! /bin/sh + +if [ $# -ne 1 ] +then + echo "Usage: $0 hostname_of_X_app_client" + exit 1 +fi + +ifconfig ethx11 > /dev/null 2>&1 +if [ $? -eq 0 ] +then + echo "Only one Opera instance is allowed." + exit 2 +fi + +vimage $1 hostname > /dev/null 2>&1 +if [ $? -ne 0 ] +then + echo "Error! " + echo "Please check that Experiment with node $1 is running" + exit 2 +fi + +###### +# Create virtual ethernet connection between "default" and "remote" hosta +# +remote=$1 +eth_remote=ethx11 +IP_eth_remote="10.255.255.2" + +eth_default=ethx11 +IP_eth_default="10.255.255.1" + +###### +# One ethernet interface is for $remote +ngctl mkpeer eiface ether ether > /dev/null 2>&1 +ngctl mkpeer eiface ether ether > /dev/null 2>&1 +ngctl connect ngeth0: ngeth1: ether ether > /dev/null 2>&1 + +vimage -i $remote ngeth0 $eth_remote > /dev/null 2>&1 +vimage $remote ifconfig $eth_remote link 40:a:b:c:d:01 > /dev/null 2>&1 +vimage $remote ifconfig $eth_remote $IP_eth_remote/24 > /dev/null 2>&1 + +###### +# the other is for "default" +vimage -i . ngeth1 $eth_default > /dev/null 2>&1 +ifconfig $eth_default link 40:a:b:c:d:02 > /dev/null 2>&1 +ifconfig $eth_default $IP_eth_default/24 > /dev/null 2>&1 + +###### +# Allow remote host to access X +xhost +$IP_eth_remote > /dev/null 2>&1 + +###### +# Call Operu on $remote +# +vimage $remote opera -display ${IP_eth_default}:0 + +sleep 2 + +ngctl shutdown ngeth0: > /dev/null 2>&1 +ngctl shutdown ngeth1: > /dev/null 2>&1 +xhost -$IP_eth_remote > /dev/null 2>&1 +