-
Notifications
You must be signed in to change notification settings - Fork 2
/
x-run
executable file
·64 lines (52 loc) · 1.62 KB
/
x-run
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Run virt image
if [ "$#" -ne 1 ]; then
echo "Usage: x run <name>"
exit 1
fi
. $HOME/.x-tools
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $DIR/common
USER=$(whoami)
if [ "$USER" == "root" ]; then
echo "Please don't run this script as root, exiting ..."
exit
fi
VNAME=$1
if [ ! -f "$X_BI_DIR/$VNAME.img" ]; then
echo "$X_BI_DIR/$VNAME.img doesn't exist, exiting ...."
exit
fi
DHCP_FILE=/.autodirect/LIT/SCRIPTS/DHCPD/list.html
MAC=""
if [ -f $DHCP_FILE ]; then
# We are running in MLNX network
MAC=`grep $VNAME $DHCP_FILE | cut -d";" -f2 | tr -d " "`
if [ "$MAC" == "" ]; then
echo "Didn't find $VNAME MAC in $DHCP_FILE"
fi
fi
if [ "$MAC" == "" ]; then
# Random
printf -v MAC "52:54:%02x:%02x:%02x:%02x" $(( $RANDOM & 0xff)) $(( $RANDOM & 0xff )) $(( $RANDOM & 0xff)) $(( $RANDOM & 0xff ))
fi
qemu_location $VNAME
QEMU_BIN=$REPLY
is_qemu $VNAME
IS_QEMU=$REPLY
if [ "$IS_QEMU" -eq 0 ]; then
get_simx_devices_line $VNAME
else
mass_vfio_bind $VNAME
get_passthrough_line $VNAME
fi
PCI_IDS_PASS=$REPLY
$QEMU_BIN -enable-kvm \
-machine accel=kvm:tcg -cpu host -smp cpus=2 \
-m 8096 -drive file=$X_BI_DIR/$VNAME.img,format=raw,if=virtio \
-no-reboot -nographic -net bridge,br=br0 \
-net nic,model=virtio,macaddr=$MAC $PCI_IDS_PASS \
-virtfs local,path=$X_BI_MOUNT,mount_tag=host0,security_model=mapped,id=host0 \
-kernel $X_SRC/kernel/arch/x86/boot/bzImage \
-append 'root=/dev/vda4 earlyprintk=serial,ttyS0,115200 console=tty0 console=ttyS0,115200 debug rw systemd.show_status=0 printk.devkmsg=off rootfstype=xfs audit=0 edd=off panic_on_warn' | tee $X_BI_LOGS/$VNAME.serial