summaryrefslogtreecommitdiffstats
path: root/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/set_hardware_legacy.inc
blob: 22718839c148805ce6285699f5e568357e3800d3 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#########################################
# Include: Hardware checks and settings #
#########################################

set_hardware_legacy() {

# use different network card (default e1000, vlance, vmxnet)
if [ -n "${network_card}" ]; then
	network_virtualDev="ethernet0.virtualDev = \"${network_card}\""
else
	network_virtualDev='ethernet0.virtualDev = "e1000"'
fi

# use different network card (default e1000, vlance, vmxnet)
hostdev="/dev/vmnet1"
case "${network_kind}" in
	bridge|bridged)
		hostdev="/dev/vmnet0"
	;;
	nat)
	        hostdev="/dev/vmnet1"
	;;
	hostonly|host-only)
        	hostdev="/dev/vmnet2"
	;;
esac

# set standard sound card, overwrite depending on OS (options sb16, es1371, hdaudio)
sound="es1371"

# set sound card explicitly if there is more than one card in the host system
sound_fileName='sound.fileName = "-1"
sound.autodetect = "TRUE"'

# check for 3D configuration setting
case "$enable3d" in
	true|yes)
		enable3d="TRUE"
	;;
	*)
		enable3d="FALSE"
	;;
esac

# check for whitelisted HW-3D
FORCE3D=""
if [ -n "$SLX_VMWARE_3D" ]; then
	FORCE3D='mks.gl.allowBlacklistedDrivers = "TRUE"'
fi

# serial/parallel port defined (e.g. "ttyS0, lp0" or "autodetect")
case "$serial" in
	tty*)
		if [ -e "/dev/$serial" ]; then
			serialdev="serial0.filename = \"/dev/${serial}\""
			serial="TRUE"
		else
			serialdev="# no serial port configured"
			serial="FALSE"
		fi
	;;
	auto*)
		serialdev="serial0.autodetect = \"TRUE\""
		serial="TRUE"
	;;
	*)
		serialdev="# no serial port configured"
		serial="FALSE"
	;;
esac

case "$parallel" in
	lp*|parport*)
		if [ -e "/dev/$parallel" ]; then
			paraldev="parallel0.filename = \"/dev/${parallel}\""
			paralbidi="TRUE"
			parallel="TRUE"
		else
			paraldev="# no parallel port configured"
			paralbidi="FALSE"
			parallel="FALSE"
		fi
	;;
	auto*)
		paraldev="parallel0.autodetect = \"TRUE\""
		paralbidi="TRUE"
		parallel="TRUE"
	;;
	*)
		paraldev="# no parallel port configured"
		paralbidi="FALSE"
		parallel="FALSE"
	;;
esac

# check if ide/scsi and hwver of image
# read only the first 30 lines to be sure
imghead=$(head -n 30 "${diskfile}")

## Added to handle persistent snapshots.
if [[ "$originalVMDKFilePath" ]]; then
	echo "Select \"${originalVMDKFilePath}\" as information base for \"${diskfile}\"."
	imghead=$(head -n 30 "$originalVMDKFilePath") && \

	# Support suspend mode.
	stateFilePath="$(readlink -f "$(dirname "$diskfile")/"*.vmss)" && \
	if [ -f "$stateFilePath" ]; then
		echo "Found  state file \"$stateFilePath\"." && \
		stateFileConfiguration="
		checkpoint.vmState = \"$stateFilePath\""
	fi
	POSTRUN="stateFilePath=\"\$(readlink -f \"${confdir}/\"*.vmss)\" && memoryFilePath=\"\$(readlink -f \"${confdir}/\"*.vmem)\" && [ -f \"\$stateFilePath\" ] && echo \"Saving state and memory file \\\"\$stateFilePath\\\" and \\\"\$memoryFilePath\\\".\" && mv -f \"\$stateFilePath\" \"$(dirname "$diskfile")/\" && mv -f \"\$memoryFilePath\" \"$(dirname "$diskfile")/\""
fi

##
hwver=$(echo "${imghead}" | grep -m1 -ia "ddb.virtualHWVersion" | awk -F '"' '{print $2}')


if [ -z "$override_hddtype" ]; then
        hddrv=$(echo "${imghead}" | grep -m1 -ia "ddb.adapterType" | awk -F '"' '{print $2}')
else
        hddrv=$override_hddtype
fi

PCIE=
case "${hddrv}" in
	ide)
		ide="TRUE"
		scsi="FALSE"
	;;
	lsisas*)
		ide="FALSE"
		scsi="TRUE"
		PCIE='pciBridge4.present = "TRUE"
		pciBridge4.virtualDev = "pcieRootPort"
		pciBridge4.functions = "8"'
	;;
	lsilogic|buslogic)
		ide="FALSE"
		scsi="TRUE"
	;;
	scsi)
		ide="FALSE"
		scsi="TRUE"
		hddrv="lsilogic"
	;;
	*)
		slxlog "virt-vmware-hdd" "vmware: Unknown HDD adapter type $hddrv"
	;;
esac

}