-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-qemu.sh
executable file
·38 lines (31 loc) · 1.04 KB
/
run-qemu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
BASE_NAME=alpine-fred
BASE_IP=192.168.1.2
NETMASK="24"
VM_IMG=alpine.qcow
if [ -z $1 ]
then
VM_ID=0
VM_NAME=${BASE_NAME}
VM_IP=${BASE_IP}${VM_ID}/$NETMASK
else
VM_ID=$1
VM_NAME=${BASE_NAME}-$1
VM_IP=${BASE_IP}${VM_ID}/$NETMASK
fi
AUTOCONF_SCRIPT=http://192.168.1.100:8087/autoconf/${VM_NAME}/
MACADDR=00:16:3E:00:$(printf '%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256)))
reset
qemu-system-x86_64 -m 512M -enable-kvm \
-name ${VM_NAME} \
-vga cirrus -cpu host \
-smbios type=1,serial="$VM_IP",version="$VM_NAME" \
-smbios type=2,location="$VM_IP",serial="$VM_NAME",asset="$AUTOCONF_SCRIPT" \
-netdev user,id=net0 -device virtio-net,netdev=net0 \
-netdev tap,id=net1,ifname=tap${VM_ID},script=no,downscript=no \
-device virtio-net,netdev=net1,mac=$MACADDR \
-serial mon:stdio -nographic \
-drive media=cdrom,file="/data/VMs/alpine-custom-BADGE-x86_64.iso",if=virtio \
-boot d
# -netdev socket,id=net1,connect=:1234 \
#-drive file="/data/VMs/alpine.qcow",format=qcow2,if=virtio,boot=off \