-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtual_machines.py
More file actions
128 lines (117 loc) · 3.32 KB
/
Copy pathvirtual_machines.py
File metadata and controls
128 lines (117 loc) · 3.32 KB
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
from contextlib import contextmanager
from qemu import PcieDevicePassthrough
from resources import acquire_resource_lock, release_resource_lock
# use fixed pci addresses on all devices to prevent collisions when other devices are attached before the igpu
intel_devices = {
"igpu": [
# params from https://github.com/LongQT-sea/intel-igpu-passthru#other-linux-distributions-qemukvm
PcieDevicePassthrough(
host_address="00:02.0",
x_igd_lpc=True,
id="hostpci0",
bus="pci.0",
addr="02.0", # has to use this address to prevent errors
romfile="firmware/ARL_MTL_GOPv22_igd.rom",
)
],
"gtx780": [
# gpu
PcieDevicePassthrough(
host_address="81:00.0",
x_vga=True,
multifunction=True,
bus="pci.0",
addr="03.0",
),
# audio
PcieDevicePassthrough(
host_address="81:00.1",
bus="pci.0",
addr="03.1",
),
],
"npu": [
PcieDevicePassthrough(
host_address="00:0b.0",
bus="pci.0",
addr="0b.0",
)
],
"vega56": [
# gpu
PcieDevicePassthrough(
host_address="04:00.0",
multifunction=True,
bus="pci.0",
addr="04.0",
),
# audio
PcieDevicePassthrough(
host_address="04:00.1",
bus="pci.0",
addr="04.1",
),
],
}
mac_pool = {
"desktop-intel": {
"52:54:00:00:00:01": "10.100.1.241",
"52:54:00:00:00:02": "10.100.1.240",
"52:54:00:00:00:03": "10.100.1.239",
"52:54:00:00:00:04": "10.100.1.238",
"52:54:00:00:00:05": "10.100.1.237",
"52:54:00:00:00:06": "10.100.1.236",
}
}
def _get_mac_address_from_pool(host: str):
for mac, ip in mac_pool[host].items():
try:
acquire_resource_lock(host, mac)
return mac, ip
except Exception:
pass
raise Exception("Could not get mac address from pool")
@contextmanager
def use_mac_address_from_pool(host: str):
mac, ip = _get_mac_address_from_pool(host)
try:
yield mac, ip
finally:
release_resource_lock(host, mac)
virtual_machines = {
"win11+intel": {
"host": "desktop-intel",
"os": "windows",
"user": "bugbakery",
"password": "admin",
"available_devices": intel_devices,
"vm_config": {
"harddrive_file": "virtual-drives/win11/win11-main@HEAD.qcow2",
"cpu_args": [
"host",
# hide kvm, to workaround nvidia driver blocking VMs
"kvm=off",
"hv_vendor_id=0",
"hv_passthrough",
"-hypervisor",
"level=35",
"+vmx",
"guest-phys-bits=41",
],
},
},
"ubuntu+intel": {
"host": "desktop-intel",
"os": "linux",
"user": "bugbakery",
"password": "admin",
"available_devices": intel_devices,
"vm_config": {
"harddrive_file": "virtual-drives/ubuntu/ubuntu-main@HEAD.qcow2",
"cpu_args": [
"host",
"guest-phys-bits=41",
],
},
},
}