From 75f067664109fd4ba8ae53189dcb1bb0ad5b00f3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 7 Jan 2018 17:00:37 +0200 Subject: Add test-machine helper script --- test-machine | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 test-machine (limited to 'test-machine') diff --git a/test-machine b/test-machine new file mode 100755 index 0000000..55df723 --- /dev/null +++ b/test-machine @@ -0,0 +1,74 @@ +#! /usr/bin/env bash + +# Test a virtual machine with KVM. +# +usage="usage: $0 [...]" + +owd="$(pwd)" +trap "{ cd '$owd'; exit 1; }" ERR +set -o errtrace # Trap in functions. + +function info () { echo "$*" 1>&2; } +function error () { info "$*"; exit 1; } + +dir="${1%/}" +shift + +if [ -z "$dir" ]; then + error "missing machine directory" +fi + +br=br0 +mac="de:ad:be:ef:b8:da" + +tap=tap0 + +sudo ip tuntap delete "$tap" mode tap || true +sudo ip tuntap add "$tap" mode tap user "$(whoami)" +sudo ip link set "$tap" up +#sleep 0.5s +sudo ip link set "$tap" master "$br" + +kvm \ + -m 8G \ + -cpu host -smp "8,sockets=1,cores=4,threads=2" \ + -netdev "tap,id=net0,ifname=$tap,script=no" \ + -device "virtio-net-pci,netdev=net0,mac=$mac" \ + -drive "if=none,id=disk0,file=$dir/disk.img,format=raw" \ + -device "virtio-blk-pci,scsi=off,drive=disk0" \ + -boot c "$@" + +# -device "virtio-blk-pci,scsi=off,drive=disk0" +# +# -device "virtio-scsi-pci,id=scsi" \ +# -device "scsi-hd,drive=disk0" \ + +# -vnc "localhost:1" \ +# -monitor "telnet::5555,server,nowait" + +# -vnc "localhost:1" - 5901 +# vncviewer localhost:5901 + +#-vnc "unix:$dir/vnc" \ +#-monitor "unix:$dir/monitor,server,nowait" + +sudo ip tuntap delete "$tap" mode tap + +exit 0 + +sudo kvm \ + -m 8G \ + -cpu host -smp "sockets=1,cores=4,threads=2" \ + -device "virtio-net-pci,netdev=net0,mac=$mac" \ + -netdev "tap,id=net0,script=./qemu-ifup" \ + -device "virtio-scsi-pci,id=scsi" \ + -device "scsi-hd,drive=disk1" \ + -drive "if=none,id=disk1,file=$dir/disk.img,format=raw" \ + -boot c + +# -kernel buildos-image -initrd buildos-initrd \ +# -append "buildos.smtp_relay=build2.org buildos.admin_email=admin@build2.org" + +#/usr/bin/kvm-spice -name windows10-vc15rc2 -S -machine pc-i440fx-wily,accel=kvm,usb=off -cpu Broadwell,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff -m 4096 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 16237884-61fb-4000-bdca-5c86bb83fe1a -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-windows10-vc15rc2/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 -drive file=/home/vm/windows10-vc15rc2.img,format=raw,if=none,id=drive-virtio-disk0 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -netdev tap,fd=26,id=hostnet0,vhost=on,vhostfd=28 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:8f:c4:d5,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:0 -device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on + +#/usr/bin/kvm-spice -name debian8 -S -machine pc-i440fx-xenial,accel=kvm,usb=off -cpu Broadwell -m 4096 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid eb483372-8ffe-4c60-8ad9-9c89cb74e314 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-debian8/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x5.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x5 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x5.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x5.0x2 -drive file=/btrfs/boris/machines/linux_debian_8-gcc_4.9-1.0/disk.img,format=raw,if=none,id=drive-virtio-disk0 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=27,id=hostnet0,vhost=on,vhostfd=29 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:52:2e:fb,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0 -vnc 127.0.0.1:1 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -msg timestamp=on -- cgit v1.1