Last active
April 14, 2020 03:00
-
-
Save pentateu/f3b0755c2c586a660e8b930d3a8f8e2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Guides | |
https://passthroughpo.st/hackintosh-kvm-guide-high-sierra-using-qemus-i440fx-chipset/ | |
https://github.com/yoonsikp/macos-kvm-pci-passthrough | |
## Tools for Linux | |
# Install GNome Tweak to setup keyboard bindings | |
# Use ubuntu app store | |
# Go to Keyboard & Mouse (left menu) > Additional Layout Options (button) > Ctrl Position > Turn on Swap Left Win with Left Ctrl | |
# Barrier -> mouse / keyboard integration | |
sudo apt install barrier | |
# setup barrier to start on boot and be available before login | |
https://help.ubuntu.com/community/SynergyHowto#Autostart_Synergy_before_logging_in_.28GDM.29 | |
# fucked up my boot :( | |
# Install Tools required for KVM and MACOS | |
sudo apt-get install qemu python python-pip git qemu-kvm qemu-utils seabios ovmf hugepages cpu-checker virt-manager | |
pip install click request | |
# turn on -> iommu with flag intel_iommu=on | |
sudo nano /etc/default/grub | |
... | |
#Add the param intel_iommu=on | |
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on" | |
GRUB_CMDLINE_LINUX="quiet splash intel_iommu=on" | |
.../end of grub file | |
sudo update-grub | |
sudo reboot now | |
# Ater reboot check that iommu is working | |
dmesg | grep "Virtualization Technology for Directed I/O" | |
# Yould see: | |
[ 0.636616] DMAR: Intel(R) Virtualization Technology for Directed I/O | |
# Setup GPU and USB Passthrough | |
#To determine the PCI bus number and PCI IDs, enter: | |
lspci | grep VGA | |
#Result - BigMachine: | |
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06) | |
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1080] (rev a1) | |
# Result - NOte: | |
01:00.0 VGA compatible controller: NVIDIA Corporation Device 2191 (rev a1) | |
# 01:00.0 is what I need! | |
# Find the Audio interface now | |
lspci -nn | grep 01:00. | |
# BiGMac: | |
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104 [GeForce GTX 1080] [10de:1b80] (rev a1) | |
01:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1) | |
#01:00.0 and 01:00.1 are the IDS that I need. | |
## Note ## | |
lspci -nn | grep 01:00. | |
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation Device [10de:2191] (rev a1) | |
01:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:1aeb] (rev a1) | |
01:00.2 USB controller [0c03]: NVIDIA Corporation Device [10de:1aec] (rev a1) | |
01:00.3 Serial bus controller [0c80]: NVIDIA Corporation Device [10de:1aed] (rev a1) | |
# check the address of the USB controller | |
lspci -nn | grep 00:14 | |
00:14.0 USB controller [0c03]: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller [8086:a12f] (rev 31) | |
# Check IOMMU Groups | |
for a in /sys/kernel/iommu_groups/*; do find $a -type l; done | sort --version-sort | |
## Note | |
cat /sys/bus/pci/devices/0000:01:00.0/modalias | |
pci:v000010DEd00002191sv00001458sd00003492bc03sc00i00 | |
➜ macOS git:(step1) ✗ cat /sys/bus/pci/devices/0000:01:00.1/modalias | |
pci:v000010DEd00001AEBsv00001458sd00003492bc04sc03i00 | |
➜ macOS git:(step1) ✗ cat /sys/bus/pci/devices/0000:01:00.2/modalias | |
pci:v000010DEd00001AECsv000010DEsd00000000bc0Csc03i30 | |
➜ macOS git:(step1) ✗ cat /sys/bus/pci/devices/0000:01:00.3/modalias | |
pci:v000010DEd00001AEDsv000010DEsd00000000bc0Csc80i00 | |
## BigMachine | |
cat /sys/bus/pci/devices/0000:01:00.0/modalias | |
pci:v000010DEd00001B80sv00001043sd000085AAbc03sc00i00 | |
cat /sys/bus/pci/devices/0000:01:00.1/modalias | |
pci:v000010DEd000010F0sv00001043sd000085AAbc04sc03i00 | |
# USB controller | |
cat /sys/bus/pci/devices/0000:00:14.0/modalias | |
pci:v00008086d0000A12Fsv00001043sd00008694bc0Csc03i30 | |
# Create the file /etc/modprobe.d/local.conf | |
sudo nano /etc/modprobe.d/local.conf | |
## will use the ids discovered above | |
# Note | |
alias pci:v000010DEd00002191sv00001458sd00003492bc03sc00i00 vfio-pci | |
alias pci:v000010DEd00001AEBsv00001458sd00003492bc04sc03i00 vfio-pci | |
alias pci:v000010DEd00001AECsv000010DEsd00000000bc0Csc03i30 vfio-pci | |
alias pci:v000010DEd00001AEDsv000010DEsd00000000bc0Csc80i00 vfio-pci | |
options vfio-pci ids=10de:2191,10de:1aeb,10de:1aec,10de:1aed | |
options vfio-pci disable_vga=1 | |
# Mac-Max | |
alias pci:v000010DEd00001B80sv00001043sd000085AAbc03sc00i00 vfio-pci | |
alias pci:v000010DEd000010F0sv00001043sd000085AAbc04sc03i00 vfio-pci | |
alias pci:v00008086d0000A12Fsv00001043sd00008694bc0Csc03i30 vfio-pci | |
options vfio-pci ids=10de:1b80,10de:10f0,8086:a12f | |
options vfio-pci disable_vga=1 | |
#To load vfio and other required modules at boot, edit the /etc/initramfs-tools/modules file: | |
sudo nano /etc/initramfs-tools/modules | |
#At the end of the file add in the order listed below: | |
vfio | |
vfio_iommu_type1 | |
vfio_pci | |
vfio_virqfd | |
vhost-net | |
# update initramfs | |
sudo update-initramfs -u | |
# reboot | |
# Check if things are ok now | |
kvm-ok | |
# Result: | |
INFO: /dev/kvm exists | |
KVM acceleration can be used | |
#heck QEMU version it must be at least 2.5 | |
qemu-system-x86_64 --version | |
QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2ubuntu3) | |
Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers | |
#issues trying to access the folder in the Linux mount ? | |
# setup qemu user and group | |
sudo nano /etc/libvirt/qemu.conf | |
# uncoment the user and group | |
user=root | |
group=root | |
#restart libvirtd | |
sudo service libvirtd restart | |
#Check if vfio-pci is bound to the GPU | |
➜ ~ lspci -kn | grep -A 2 01:00 | |
01:00.0 0300: 10de:1b80 (rev a1) | |
Subsystem: 1043:85aa | |
Kernel driver in use: vfio-pci | |
-- | |
01:00.1 0403: 10de:10f0 (rev a1) | |
Subsystem: 1043:85aa | |
Kernel driver in use: vfio-pci | |
# YES > Kernel driver in use: vfio-pci . .. that is what we need to see. | |
# Test MacOS and QEMU is runnig with ~/macOS/basic.sh script | |
# It should start the VM using the a hosted graphics server | |
# start libvirtd | |
sudo systemctl enable libvirtd.service virtlogd.service | |
sudo systemctl start libvirtd.service virtlogd.service | |
# setup network bridge | |
# Network interface Name | |
# -> enp0s31f6 is the name of the ethernet internace | |
# to check yours do | |
ip link | |
# output: | |
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 | |
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 | |
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP mode DEFAULT group default qlen 1000 | |
link/ether 38:d5:47:23:0e:d2 brd ff:ff:ff:ff:ff:ff | |
.... | |
# Replace with the content of the file 01-network-manager-all.yaml | |
sudo nano /etc/netplan/01-network-manager-all.yaml | |
# Let NetworkManager manage all devices on this system | |
network: | |
version: 2 | |
renderer: networkd | |
ethernets: | |
enp0s31f6: | |
dhcp4: no | |
bridges: | |
br0: | |
dhcp4: yes | |
interfaces: | |
- enp0s31f6 | |
# load the mac-max xml config into vir | |
# Start and have fun | |
sudo service network-manager restart | |
# add to libvirt | |
# create the file br0.xml | |
nano br0.xml | |
<network> | |
<name>host-bridge</name> | |
<forward mode="bridge"/> | |
<bridge name="br0"/> | |
</network> | |
# load into libvirt | |
sudo virsh net-define br0.xml | |
sudo virsh net-start br0 | |
sudo virsh net-autostart br0 | |
# check | |
sudo virsh net-list --all | |
# load the mac-max xml config into libvirt | |
# Start and have fun | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment