summaryrefslogtreecommitdiffstats
path: root/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
blob: d29fac20d4dd2758826576c9c68dcfbd5a4530ac (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
################################################################################
# Include: Set hardware limitations determined by the guest os type            #
################################################################################

set_hardware_limits() {

	# support shared folders by default, disable it if guest OS doesn't support it
	declare -g SHARED_FOLDERS="TRUE"
	
	# set some base configuration depending on the guest operating system
	# NOTE: list supported OS type with: VBoxManage list ostypes
	case "${VM_OS_TYPE}" in
		Windows31)
			MAXCORES="1"
			MAXMEM="32"
			MAXVRAM="16"
			SHARED_FOLDERS="FALSE"
			;;
		WindowsNT*)
			MAXCORES="4"
			MAXMEM="1024"
			MAXVRAM="32"
			SHARED_FOLDERS="FALSE"
			;;
		Windows95)
			MAXCORES="1"
			MAXMEM="128"
			MAXVRAM="32"
			SHARED_FOLDERS="FALSE"
			;;
		Windows98)
			MAXCORES="1"
			MAXMEM="256"
			MAXVRAM="64"
			;;
		WindowsMe)
			MAXCORES="1"
			MAXMEM="384"
			MAXVRAM="64"
			;;
		Windows2000|Windows2003)
			MAXCORES="4"
			MAXMEM="4000"
			MAXVRAM="128"
			;;
		Windows2003_64|WindowsXP_64)
			MAXCORES="4"
			MAXMEM="8000"
			MAXVRAM="128"
			;;
		WindowsXP)
			MAXCORES="4"
			MAXMEM="4000"
			MAXVRAM="128"
			;;
		WindowsVista)
			MAXCORES="4"
			MAXMEM="4000"
			MAXVRAM="128"
			;;
		WindowsVista_64)
			MAXCORES="4"
			MAXMEM="16000"
			MAXVRAM="128"
			;;
		Windows7|Windows8|Windows81|Windows10)
			MAXCORES="4"
			MAXMEM="4000"
			MAXVRAM="128"
			;;
		Windows7_64|Windows8_64|Windows81_64|Windows10_64)
			MAXCORES="4"
			MAXMEM="32000"
			MAXVRAM="128"
			;;
		ArchLinux|Debian|OpenSUSE|Fedora|Gentoo|Mandriva|RedHat|Turbolinux|Ubuntu)
			MAXCORES="4"
			MAXMEM="4000"
			MAXVRAM="128"
			;;
		ArchLinux_64|Debian_64|OpenSUSE_64|Fedora_64|Gentoo_64|Mandriva_64|RedHat_64|Turbolinux_64|Ubuntu_64)
			MAXCORES="8"
			MAXMEM="32000"
			MAXVRAM="128"
			;;
		*Linux*)
			MAXCORES="4"
			MAXMEM="1024"
			MAXVRAM="32"
			;;
		*Linux*64)
			MAXCORES="8"
			MAXMEM="8000"
			MAXVRAM="128"
			;;
		OS2eCS)
			MAXMEM="256"
			MAXCORES=1
	    ;;
	  *)
			MAXMEM="512"
			MAXCORES="1"
		;;
		# TODO: FreeBSD, NetBSD, MacOS*, Solaris, Oracle, ...
	esac

	# use HW_CORES not HW_THREADS since virtualbox does not
	# seem to handle hyperthreading all too well...
	declare -g CPU_CORES="${HW_CORES:-1}"
	[ "${CPU_CORES}" -gt "{MAXCORES}" ] && CPU_CORES="${MAXCORES}"
	[ "${VM_MEM}" -gt "${MAXMEM}" ] && VM_MEM="${MAXMEM}"

	# currently not used, keep the VRAMSize setting from the uploaded configuration
	declare -rg GUESTVRAM=$MAXVRAM

	# check if shared folders should be activated according
	# to SHARE_REMAP_MODE set by /opt/openslx/inc/shares
	VBOX_SHARED_FOLDERS=
	if [ "x$SHARED_FOLDERS" != "xFALSE" ] && [ "$SHARE_REMAP_MODE" -gt 1 ]; then
		declare -rg VBOX_SHARED_FOLDERS="1"
	fi
	return 0
}

call_post_source set_hardware_limits