diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-12-30 18:13:28 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-12-30 18:13:28 -0200 |
commit | d7c9f7f33eaac99f0c93ff307c7aff1f6b413095 (patch) | |
tree | 1f88d4d23f4f560b7d761736e03306a9d6cba529 | |
parent | b8968859726dcbd504c82ab5d749f4d63f2d9993 (diff) | |
download | kvmx-d7c9f7f33eaac99f0c93ff307c7aff1f6b413095.tar.gz kvmx-d7c9f7f33eaac99f0c93ff307c7aff1f6b413095.tar.bz2 |
Initial bridge support thanks to kvm-manager
-rwxr-xr-x | kvmx | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -371,9 +371,21 @@ function kvmx_up { shared_folders_cache="none" fi + if [ -z "$net" ] || [ "$net" == "user" ]; then + net_opts="user,hostfwd=tcp:127.0.0.1:$SSH-:22,hostfwd=udp:127.0.0.1:$XDMCP_PORT-:177$hostfwd" + elif [ "$net" == "tap" ]; then + # Thanks kvm-manager + tap="${VM}0" + # MAC address is derived from a hash of the host's name and the guest's name: + mac_address="$(printf "02:%s" "$(printf "%s\0%s" "$(hostname)" "${VM}" | sha256sum | sed 's/\(..\)/\1:/g' | cut -f1-5 -d:)")" + bridge="br0" + net_opts="tap,ifname=$tap,script=no,downscript=no,vlan=0,name=hostnet0" + fi + # Run virtual machine # See https://en.wikipedia.org/wiki/Nohup#Overcoming_hanging - nohup kvm -m $memory -name $VM -drive file=$image,if=$drive_interface $graphics $shared \ + nohup kvm -m $memory -name $VM \ + -drive file=$image,if=$drive_interface $graphics $shared \ -spice port=$PORT,addr=127.0.0.1,disable-ticketing,streaming-video=off,jpeg-wan-compression=never,playback-compression=off,zlib-glz-wan-compression=never,image-compression=off \ -device virtio-serial-pci \ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \ @@ -382,7 +394,8 @@ function kvmx_up { -chardev "socket,id=serial0,path=$CONSOLEFILE,server" -device isa-serial,chardev=serial0 \ -smp $smp -soundhw ac97 -cpu host -balloon virtio \ -net nic,model=$nic_model \ - -net user,hostfwd=tcp:127.0.0.1:$SSH-:22,hostfwd=udp:127.0.0.1:$XDMCP_PORT-:177$hostfwd $qemu_opts &> $LOGFILE < /dev/null & + -net $net_opts \ + $qemu_opts &> $LOGFILE < /dev/null & PID="$!" @@ -1384,8 +1397,7 @@ function kvmx_mv { kvmx_rename $* } -# Interface to QEMU monitor -# Thanks kvm-manager for the idea +# Interface to QEMU monitor (thanks kvm-manager) function kvmx_monitor { if ! kvmx_running; then echo "$BASENAME: guest $VM is not running" |