Commit 9f0bed88 authored by Maria Matejka's avatar Maria Matejka

many fixes, nic hotplug

parent 6da6090e
......@@ -9,7 +9,7 @@ if [ -z "$NAME" ] || [ -z "$ID" ]; then
exit 2
fi
socat UNIX-CONNECT:$ROOT/run/$NAME.sock - <<EOF
socat UNIX-CONNECT:$ROOT/run/$NAME.sock - >/dev/null <<EOF
netdev_add type=tap,id=$ID,ifname=$ID,script=no
device_add e1000,netdev=$ID
EOF
#!/bin/bash
. $(dirname $(readlink -f $0))/virt-lib
NAME=$1
ID=$2
if [ -z "$NAME" ] || [ -z "$ID" ]; then
echo "Usage: $0 NAME ID"
exit 2
fi
socat UNIX-CONNECT:$ROOT/run/$NAME.sock - >/dev/null <<EOF
netdev_del $ID
device_del e1000,netdev=$ID
EOF
#!/bin/bash
. $(dirname $(readlink -f $0))/virt-lib
NAME=$1
if [ -z "$NAME" ]; then
echo "Usage: $0 NAME"
exit 2
fi
$SOCAT READLINE,history=$ROOT/run/$NAME.mon-history UNIX-CONNECT:$ROOT/run/$NAME.sock
#!/bin/bash
. $(dirname $(readlink -f $0))/virt-lib
HOST=$2
TYPE=$1
case ${TYPE^^} of
FREEBSD)
# OPENBSD)
# NETBSD)
HOST=$1
if ! gethost $HOST; then
echo "Unknown host: $HOST"
exit 2
fi
case ${HOSTTYPE^^} in
FREEBSD) ;&
OPENBSD) ;&
NETBSD)
FSTAB="192.168.192.1:/var/lib/virt/nfs /mnt/nfs nfs rw 0 0"
;;
LINUX)
type=${type,,}
FSTAB="192.168.192.1:/var/lib/virt/nfs /mnt/nfs nfs defaults,intr,_netdev 0 0"
;;
*)
echo "Unknown type of host: $TYPE"
......@@ -18,29 +24,39 @@ case ${TYPE^^} of
esac
gethost $HOST
AUTH=`mktemp`
cat /home/birdlab/.ssh/authorized_keys > $AUTH
cat /root/.ssh/virt-rsa.pub >> $AUTH
cat >$AUTH <<EOF
mkdir -p /root/.ssh
cat >/root/.ssh/authorized_keys <<EOC
EOF
scp $AUTH root@$HOST_IP4:/root/.ssh/authorized_keys
cat /home/birdlab/.ssh/authorized_keys >> $AUTH
cat /root/.ssh/virt-rsa.pub >>$AUTH
SCRIPT=`mktemp`
echo EOC >>$AUTH
ssh root@$HOSTIP4 <$AUTH
FSTAB_FREEBSD="192.168.192.1:/var/lib/virt/nfs /mnt/nfs nfs rw 0 0"
FSTAB_LINUX="192.168.192.1:/var/lib/virt/nfs /mnt/nfs nfs defaults,intr,_netdev 0 0"
FSTAB=${FSTAB_${TYPE^^}}
SCRIPT=`mktemp`
cat >$SCRIPT <<EOF
echo "$FSTAB" >> /etc/fstab
mkdir -p /mnt/nfs
mount /mnt/nfs
if egrep -q '/mnt/nfs\s+nfs\s+' /etc/fstab; then
( egrep -q '/mnt/nfs\s+nfs\s+' /etc/fstab ; echo "$FSTAB") > /etc/fstab.new
mv /etc/fstab.new /etc/fstab
mkdir -p /mnt/nfs
mount -o remount /mnt/nfs
else
echo "$FSTAB" >> /etc/fstab
mkdir -p /mnt/nfs
mount /mnt/nfs
fi
EOF
ssh root@$HOST_IP4 <$SCRIPT
ssh root@$HOSTIP4 <$SCRIPT
rm $SCRIPT
rm $AUTH
File added
#!/bin/bash
. $(dirname $(readlink -f $0))/virt-lib
NAME=$1
if [ -z "$NAME" ]; then
echo "Usage: $0 NAME"
exit 2
fi
gethost $NAME
ssh -i /root/.ssh/virt-rsa root@$HOSTIP4
......@@ -35,7 +35,7 @@ fi
#echo -e "IP4:\t\t$HOSTIP4"
#echo -e "TAP:\t\t$HOSTTAP"
qemu-system-$HOSTARCH -enable-kvm -m $HOSTMEMORY ${HOSTCDROM:+-cdrom $ROOT/iso/$HOSTCDROM -boot d} -hda $ROOT/img/$HOSTIMAGE $HOSTCOW -display none ${HOSTVNCID:+-vnc 10.0.0.11:$HOSTVNCID} -netdev tap,id=ctl,ifname=$HOSTTAP,script=no -device e1000,netdev=ctl,mac=$HOSTMAC -pidfile $ROOT/run/$NAME.pid -monitor unix:$ROOT/run/$NAME.sock,server,nowait -daemonize
qemu-system-$HOSTARCH -enable-kvm -m $HOSTMEMORY ${HOSTCDROM:+-cdrom $ROOT/iso/$HOSTCDROM -boot d} -hda $ROOT/img/$HOSTIMAGE $HOSTCOW -display none ${HOSTVNCID:+-vnc 10.0.0.11:$HOSTVNCID} -netdev tap,id=ctl,ifname=$HOSTTAP,script=no -device e1000,netdev=ctl,mac=$HOSTMAC -pidfile $ROOT/run/$NAME.pid -monitor unix:$ROOT/run/$NAME.sock,server,nowait -daemonize "$@"
#-runas $VIRTUSER
ip link set $HOSTTAP up
......
......@@ -14,7 +14,6 @@ function ok() {
rm -f $ROOT/run/$NAME.sock $ROOT/run/$NAME.pid
if gethost $NAME; then
vsctl del-port $VIRTBR $HOSTTAP
virtns ip link del $HOSTTAP
else
echo "Warning: Config not found for this host"
fi
......
......@@ -45,6 +45,7 @@ function gethost() {
HOSTMAC=
HOSTNIC=()
HOSTNICCMD=
HOSTTYPE=
NAME=$1
_HOST_READING=false
......@@ -62,6 +63,7 @@ function gethost() {
COW) HOSTCOW="$value" ;;
VNC) HOSTVNCID="$value" ;;
NIC) HOSTNIC+=("$value")
TYPE) HOSTTYPE="$value" ;;
esac
else
if [ "${item^^}" = "HOST" ] \
......@@ -95,3 +97,5 @@ function hostdefaults() {
read HOSTTAP HOSTMAC HOSTIP4 <<<"$HOSTNETWORK"
return 0
}
SOCAT=$ROOT/bin/socat
......@@ -4,6 +4,7 @@ Host freebsd10-install
Memory 512M
# Cdrom freebsd10.iso
VNC 51
Type freebsd
Host debian8-install
Image debian8
......@@ -11,6 +12,7 @@ Host debian8-install
Memory 512M
# Cdrom debian8.iso
VNC 11
Type linux
Host debian5-install
Image debian5
......@@ -18,6 +20,7 @@ Host debian5-install
Memory 512M
# Cdrom debian5.iso
VNC 12
Type linux
Host fb10-1
Image freebsd10
......@@ -25,32 +28,32 @@ Host fb10-1
Memory 128M
VNC 101
Cow yes
Type freebsd
Host fb10-2
Image freebsd10
Network tci-fb10-2 00:11:22:00:15:02 192.168.200.2
Memory 2G
VNC 102
Cow yes
Type freebsd
Host d8-1
Image debian8
Network tcd8-1 00:11:22:00:11:01 192.168.210.1
Memory 128M
VNC 121
Type linux
Cow yes
Host d8-2
Image debian8
Network tcd8-2 00:11:22:00:11:11 192.168.210.2
Memory 128M
VNC 122
Type linux
Cow yes
Host d8-3
Image debian8
Network tcd8-3 00:11:22:00:11:21 192.168.210.3
Memory 128M
VNC 123
Type linux
Cow yes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment