<<DRAFT>> GPU and NVME SSD Passthrough with virtmanager and KVM as user ( qemu:///session )

Hi

I have tried finding a solution for my problem in some passthrough tutorials but they don’t deal with the error message ( EM ), that I get.
I am trying to install Windows 10 in a VM, that I want to pass the GPU and NVME drive to.

currently I got the following problems:

  1. NVME SSD → #NVME#
  2. network bridge I’ll get to that later

CPU: Ryzen 5950X
Mainboard: MSI X570-A Pro
GPU: AMD Radeon RX 590
2 NVME SSDs:

  1. WD Blue SN850 1TB 4x PCIe 4.0 CPU (Win10 VM)
  2. WD Blue SN550 2TB 4x PCIe 3.0 Chipset (Linux + Extra Storage)

What I write here is supposed to be documenting comprehensibly how I setup the VM.
Currently it’s just a draft, because I still have some problemswith the VM.

Before you continue any further it is wise to check if your CPU even supports virtualization.
VT-d is Intel jargon.
AMD-v or SVM for AMD.
You might have to check in the BIOS / UEFI if it is enabled.
If you don’t know what the BIOS and UEFI are or don’t know how to get there you might want to enlist the help of your local Linux user group.
Here are the commands for checking if it is enabled:
AMD:

dmesg | grep AMD-Vi

or

cat /proc/cpuinfo | grep svm

Intel:

 dmesg | grep "Virtualization Technology for Directed I/O"

Output for AMD is simillar to:

[...]
AMD-Vi: Enabling IOMMU at 0000:00:00.2 cap 0x40
AMD-Vi: Lazy IO/TLB flushing enabled
AMD-Vi: Initialized for Passthrough Mode
[...]

Output for Intel is simmillar to:

[ 0.902214] DMAR: Intel(R) Virtualization Technology for Directed I/O

Edit GRUB with the following command:

nano /etc/default/grub

For Intel CPUs use:
intel_iommu=on

And for AMD CPUs use:
amd_iommu=on

GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt kvm.ignore_msrs=1 vfio-pci.ids="15b7:5011,1002:67df,1002:aaf0"

After that you have to execute the following command to save the changes you made to GRUB:

update-grub

or:

grub-mkconfig -o /boot/grub/grub.cfg

It is currently throwing an error message (EM) on my machine:

/usr/sbin/grub-mkconfig: 33: /etc/default/grub: Syntax error: EOF in backquote substitution

I scoured through the whole file with a hex editor to check the whitespace to no avail. There is no EOF and I did not change the line with the backquotes.

I found the problem. Missing doublequotes at the end of the IOMMU line:
GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt kvm.ignore_msrs=1 vfio-pci.ids=“15b7:5011,1002:67df,1002:aaf0"”

!!!Warning possible security risk!!!
It is recommended that you temporarily add the user you want to setup the VM with as a sudoer:

usermod -aG sudo username

To choose the editor for changing the sudoers file change the environment variable:

EDITOR=nano visudo

To permanently add the useraccount as a sudoer edit following file ( /etc/sudoers ) with this command:

visudo

At the end of the file add the following line and use the desired username:

[...]
username  ALL=(ALL) NOPASSWD:ALL

In case you get stuck at any spot maybe a restart helps?
Save everything and type:

shutdown -r now

###PACKAGES###
Unless mentioned otherwise everything has to be done as root, so better keep a root and a user console ready.
Before I we really get going we’ll start by installing the necessary pakets:

apt install virt-manager qemu-kvm libvirt-clients quemu-system qemu-system-x86 libvirt-daemon-system bridge-utils virtinst libvirt-daemon ovmf pciutils ebtables dnsmasq

##expl##
ebtables and dnsmasq are otional. ebtables is an ethernet rule management command and dnsmasq is is a DNS forwarder, a DHCP server and a name cache optimized for dialup connections.
After the installation you should test if the libvirt service is running:

systemctl status libvirtd.service

Output:

[...]
[...] active (running) [...]
[...]

The string above is usually highlighted.

These commands load the vfio-pci kernel module and verify that it is loaded:

#start vfio
modprobe vfio-pci

#test if vfio is on
lsmod | grep vfio

This command adds the string ‘vfio-pci’ to the file vfio-pci.conf at the location
/etc/modules-load.d/
which gets the module loaded at every system start.
It’s possible that the module is integrated into the Debian kernel or maybe not.

echo 'vfio-pci' > /etc/modules-load.d/vfio-pci.conf

Show IOMMU groups:

for d in /sys/kernel/iommu_groups/*/devices/*;
do n=${d#*/iommu_groups/*};
n=${n%%/*}; 
printf 'IOMMU Group %s ' "$n";
lspci -nns "${d##*/}";
done;

Output:

[...]
IOMMU Group 14 01:00.0 Non-Volatile memory controller [0108]: Sandisk Corp WD Black SN850 [15b7:5011] (rev 01)
[...]
IOMMU Group 27 2d:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] [1002:67df] (rev e1)
IOMMU Group 27 2d:00.1 Audio device [0403]: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] [1002:aaf0]
[...]

Every graphics card has a sound card in the same IOMMU group for HDMI and Display Port (DP) so you get sound through the loudspeakers of your monitor if it is supported by the monitor. You can use both connection types without an extra cable because all of them have an integrated sound channel.

I still get an error when trying to start the VM and the EM is further down, jump to #EM# to read it now.
I already tried:

newgrp libvirt
sudo usermod -a -G libvirt $(whoami)
newgrp kvm
sudo usermod -a -G kvm $(whoami)
newgrp qemu
sudo usermod -a -G qemu $(whoami)
newgrp audio
sudo usermod -a -G audio $(whoami)
newgrp kvm
sudo usermod -a -G kvm $(whoami)

More permissions for qemu:

nano /etc/udev/rules.d/10-qemu-hw-users.rules

Append or change if present:

[...]
SUBSYSTEM=="vfio", OWNER="root", GROUP="kvm"

I tried this too to get rid of the EM:

SUBSYSTEM=="pci", ATTR{idVendor}=="15b7", ATTR{idProduct}=="5011" OWNER="root", GROUP="kvm"
SUBSYSTEM=="pci", ATTR{idVendor}=="1002", ATTR{idProduct}=="67df" OWNER="root", GROUP="kvm"
SUBSYSTEM=="pci", ATTR{idVendor}=="1002", ATTR{idProduct}=="aaf0" OWNER="root", GROUP="kvm"

To make the changes take effect:

sudo udevadm control --reload-rules
sudo udevadm trigger

Check to see if it worked:

ls -la /dev/vfio
ls -la /dev/bus/pci/*

Output1:

[...]
crw-rw----  1 root kvm  244,   0 Feb  8 16:13 1

Output:

ls: access to '/dev/bus/pci/*' not possible: file or directory not found

I was editing Apparmor to try and see if that worked:

nano /etc/apparmor.d/abstractions/libvirt-qemu
[...]
/dev/vfio/* rw,

Load new settings:

sudo /etc/init.d/apparmor restart

Output:

Restarting apparmor (via systemctl): apparmor.service.

Tried setting new qemu permissions:

nano /etc/libvirt/qemu.conf

Pasting at the right spot:

[...]
cgroup_device_acl = [
    "/dev/null", "/dev/full", "/dev/zero",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
    "/dev/rtc","/dev/hpet", "/dev/vfio/vfio",
    "/dev/vfio/1"
]
[...]

#NVME#

Trying to change permissions for the GPU vfio group 1 maybe and group 2 for GPU HDMI Audio). The NVME / M.2 SSD is in group 3.

The vfio groups seem to be missing at the moment but they were present.
I think I have to run chown and chmod, anyway according to the VFIO article (/dev/vfio/$GROUP).
So:

chown username /dev/vfio/14
chown username /dev/vfio/27
chmod 700 /dev/vfio/14
chmod 700 /dev/vfio/27

Output:

chown: access to '/dev/vfio/14' not possible: File or directory not found
chmod: access to '/dev/vfio/14' not possible: File or directory not found

Maybe I did not unbind the NVME SSD driver?

So I read the IOMMU article again to find the commands (root?):
lspci -nnk #Shows all devices.
lspci -nkks 01:00.0 #Only shows device with ID “01:00.0”
Output:

01:00.0 Non-Volatile memory controller [0108]: Sandisk Corp WD Black SN850 [15b7:5011] (rev 01)
        Subsystem: Sandisk Corp WD Black SN850 [15b7:5011]
        Kernel driver in use: nvme
        Kernel modules: nvme

It obviously can’t work, “Kernel driver in use: nvme” there should be vfio-pci at the end of the line instead of nvme,
also (als root):

echo "0000:01:00.0" > /sys/bus/pci/drivers/nvme/unbind

We test if the unbinding worked with:

lspci -nkks 01:00.0

Output:

01:00.0 0108: 15b7:5011 (rev 01)
        Subsystem: 15b7:5011
        Kernel modules: nvme

“Kernel driver in use: nvme” is disappeared, that means the driver is no longer bound to the device, unfortunately I can’t find the acticle at the moment that mentioned the instructions to permanently bind the vfio-pci driver to the devices.

#EM#:

Error starting the domain: Failed to add driver 'vfio-pci' to driver_override  interface of PCI device '0000:01:00.0': Permission denied

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 101, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1329, in startup
    self._backend.create()
  File "/usr/lib/python3/dist-packages/libvirt.py", line 1353, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: Failed to add driver 'vfio-pci' to driver_override  interface of PCI device '0000:01:00.0': Permission denied

I seam to be missing permissons?

I could finally assign the driver to the NVME SSD:

echo 15b7 5011 > /sys/bus/pci/drivers/vfio-pci/new_id

You just have to use the Subsystem ID instead of the … ID:

[i]01:00.0[/i] 0108: 15b7:5011 (rev 01)
        [b]Subsystem: 15b7:5011[/b]
        Kernel modules: nvme

I thought 01:00.0 worked with the GPU last time but only the Subsystem ID (Subsystem: 15b7:5011) works:

01:00.0 0108: 15b7:5011 (rev 01)
        Subsystem: 15b7:5011
        Kernel driver in use: vfio-pci
        Kernel modules: nvme

I fixed all the errors with the rebinding code.
Just remember to execute that code before starting the VM,
because I haven’t figured out yet how to make it persistent,
that means restarts and shutdowns might reset the binding.
At least I get a new error so off to new horizons^^

##BINDING-AND-UNBINDING##

#what's up with the NVME SSD?
lspci -nkks 01:00.0
#unbind NVME SSD
echo "0000:01:00.0" > /sys/bus/pci/drivers/nvme/unbind
#assign new ID to NVME SSD
echo 15b7 5011 > /sys/bus/pci/drivers/vfio-pci/new_id
#check if NVME is bound
lspci -nkks 01:00.0

#what's up with the GPU
lspci -nkks 2d:00.0
#unbind GPU 
echo "0000:2d:00.0" > /sys/bus/pci/devices/0000:2d:00.0/driver/unbind
#assign new ID to GPU
echo 148c 2391 > /sys/bus/pci/drivers/vfio-pci/new_id
#check if GPU is bound
lspci -nkks 2d:00.0

#what's up with the GPU Audio
lspci -nkks 2d:00.1
#unbind GPU audio device
echo "0000:2d:00.1" > /sys/bus/pci/devices/0000:2d:00.1/driver/unbind
#assign new ID to GPU audio device
echo 148c aaf0 > /sys/bus/pci/drivers/vfio-pci/new_id
#check if Audio is bound
lspci -nkks 2d:00.1

To boldly go where no one has gone before

#at least according to the tutorials I found :wink:

Besides, here is the next ##EM2##, still problems with the PCIe passthrough:

Fehler beim Starten der Domain: internal error: Process exited prior to exec: libvirt:  error : cannot limit locked memory to 35433480192: Operation not permitted

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 101, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1329, in startup
    self._backend.create()
  File "/usr/lib/python3/dist-packages/libvirt.py", line 1353, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: internal error: Process exited prior to exec: libvirt:  error : cannot limit locked memory to 35433480192: Operation not permitted

Looks like libvirt is using 33GiB instead of 32GiB

While trying to resolve the issue with the memory allocation, I stumbled upon another ##EM3##:

Error starting the domain: unsupported configuration: Domain requires KVM, but it is not available. Check that virtualization is enabled in the host BIOS, and host configuration is setup to load the kvm modules.

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 101, in tmpcb
    callback(*args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 57, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1329, in startup
    self._backend.create()
  File "/usr/lib/python3/dist-packages/libvirt.py", line 1353, in create
    raise libvirtError('virDomainCreate() failed')
libvirt.libvirtError: unsupported configuration: Domain requires KVM, but it is not available. Check that virtualization is enabled in the host BIOS, and host configuration is setup to load the kvm modules.

For this error I have to check if SVM Mode is disabled in the UEFI.
The SVM Mode was enabled but the GPU wasn’t listed in the VM PCI devices, so I added it.
Still the same error.
Next I checked in the VM if the right emulator for KVM was listed in the XML file, because I use virt-manager I just had to activate XML editing going to the Virtual Machine Management window and opened the menu item:

Edit → Settings → General → XML-editing activation

Next I had to go back to the VMs window to switch to the XML file and find the emulator entry:

<emulator>/usr/bin/qemu-system-x86_64</emulator>

It showed the wrong thing, but that told me that the kvm_amd kernel module wasn’t present.
I checked it with the code:

lsmod | grep kvm

in a root prompt, nothing. To start the module I typed:

modprobe kvm_amd

and checked again with:

lsmod | grep kvm

This time I got:

[...]
kvm                   921600  1 kvm_amd
[...]

Now I am trying to set a new limit for libvirt as root:

su - @libvirt
ulimit -v 41943040
ulimit -l 41943040

doesn’t work for groups
If anybody can tell me how to set limits for groups with ulimit I am all ears.

I changed the group to kvm and used memlock to allocate memory:

nano /etc/security/limits.conf
[...]
@kvm             hard    memlock                 41943040
# End of file

Now I could at least start the VM but the next error was looming on the horizon.

Clicking through the Windows 10 setup I got as far as the partitioning and then it reared its ugly head.
I also stumbled upon a volume name that don’t know anything about maybe somebody can enlighten us.
I did search for it but to no avail.

CCCOMA_X64FRE_EN-GB_DV9

The error that I got when trying to install was:

Windows can't be installed on this drive. (Show details)

Windows Setup

Windows cannot be installed on this disk. This computer's hardware may not support booting to this disk. Ensure that the disk's controller is enabled in the computer's BIOS menu.

Load driver

No signed device drivers were found. Make sure that the installation media contains the correct drivers, then click OK.

I only found an article mentioning that I have to turn legacy BIOS support (CSM) off for the host, but I can’t because the old VGA adapter does not support it.

So I am stuck ATM.
I also tried loading the vfio driver from Red Hat:

https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/

With another SATA CDROM but the installer said it could not find any signed drivers.

Here is the XML of my VM from virt-manager:

<domain type="kvm">
  <name>win10</name>
  <uuid>ffffffff-ffff-ffff-ffff-ffffffffffff</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">33554432</memory>
  <currentMemory unit="KiB">33554432</currentMemory>

  <vcpu placement="static">16</vcpu>

  **<os firmware="efi">**
**    <type arch="x86_64" machine="pc-q35-5.2">hvm</type>**
**    <loader secure="yes"/>**
**    <boot dev="cdrom"/>**
**  </os>**
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>
    <vmport state="off"/>
  </features>
  <cpu mode="host-model" check="partial"/>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/benutzer/Downloads/Win10_21H2_EnglishInternational_x64.iso"/>
      <target dev="sda" bus="sata"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/benutzer/Downloads/virtio-win-0.1.215-2_(2022-01-13).iso"/>
      <target dev="sdb" bus="sata"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </controller>
    <controller type="sata" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
    </controller>
    <controller type="pci" index="0" model="pcie-root"/>
    <controller type="pci" index="1" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="1" port="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    </controller>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    </controller>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    </controller>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    </controller>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0x15"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x5"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
    </controller>
    <controller type="fdc" index="0"/>
    <serial type="pty">
      <target type="isa-serial" port="0">
        <model name="isa-serial"/>
      </target>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <channel type="spicevmc">
      <target type="virtio" name="com.redhat.spice.0"/>
      <address type="virtio-serial" controller="0" bus="0" port="1"/>
    </channel>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <graphics type="spice" autoport="yes">
      <listen type="address"/>
      <image compression="off"/>
    </graphics>
    <sound model="ich9">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
    </sound>
    <video>
      <model type="virtio" heads="1" primary="yes">
        <acceleration accel3d="yes"/>
      </model>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
    </video>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </hostdev>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x2d" slot="0x00" function="0x0"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </hostdev>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x2d" slot="0x00" function="0x1"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
    </hostdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    </redirdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    </redirdev>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    </memballoon>
  </devices>
</domain>

It looks like it’s working.
I just added a network adapter and installed the GPU driver without a problem.
Didn’t even had to change anything in the network configuration of my machine.
Just remember that I am running virt-manager in user mode and I deleted the network adapter at the start after the automatic prompt from virt-manager for setting up a VM.
I added it later after I got everything else working.

Here is the XML for the network adapter:

<domain>
[...]
 <devices>
[...]
    <interface type="user">
      <mac address="ff:ff:ff:ff:ff:ff"/>
      <model type="e1000e"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </interface>
<!--Above the serial interface device (com port)-->
[...]
 </devices>
</domain>

If you want to add a PCIe device to your config with virt-manager just click on “add device” => PCI Host-device => choose the right one and click done

Before you start the VMs you have to run the code at:
##BINDING-AND-UNBINDING##
as root and you might have to run other code too.

You might have to change the boot device in the UEFI of the VM too, like:
Find the drive that has the following directory structure and file (fs0 to fs7 or however many file systems the UEFI can find referencing this way will lead to boot problems as soon as you change anything even adding a USB stick or an optical drive but I haven’t figured out how to reference a filesystem by ID, so):
When the UEFI tries to start the startup.nsh press Esc or ESC (escape) to abort loading the startup.nsh. Then check for:
fsN:\efi\boot\BOOTX64.EFI
The N is a number from 0 to ???.
When you changed to that directory with cd, you have to edit the startup.nsh like:
edit startup.nsh
The editor is self-explanatory like nano.
If you want an editor that is not uns vi.
add the line starting with fs to that file if it is empty otherwise you have to search for it on the web for a good explanation of that file.
Good luck with that, you gonna need it as of 27th March 2022.
Maybe it is in the ~300 page manual or the 300 to 400 page books about how to use the UEFI shell.

If your VM has the BIOS as firmware you have to change the opening <os> XML tag to the following <os firmware="efi"> in the overview of the VM that shows all of the XML code or use the code below:

  <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-5.2">hvm</type>
    <loader secure="yes"/>
    <boot dev="cdrom"/>
  </os>

You might have to delete the line:

<boot dev="cdrom"/>

If you want secure boot you can leave the line:

<loader secure="yes"/>

Now I’ll try using lookingglass so I’ll only have to use the monitors connected to the host.

I used B5.0.1 but you better use the more recent versions because they spare you the hassle of scream with ivshem. Just follow the most recent stable how to on:
https:\looking-glass.io

Scream IvShem
If you wanted sound with looking-glass B5.0.1 you either needed to send the audio over the network with scream or use another IO area in RAM like with looking-glass
so follow the tutorial here:
https://looking-glass.io/wiki/Using_Scream_over_IVSHMEM

Installing a virtual monitor in the guest so you don’t have to worry about plugging in a monitor for looking glass to work. But you will be worrying about the output of any plugged in monitor in the guest / passed through GPU:
[GPU Passthrough + Looking Glass + no external monitor/dummy :

!!!WARNING!!! Continue at you own risk! I don’t know how trustworthy this driver is!

If you still want to use a monitor along with the virtual one there might be an issue.
Try setting your power options so your guestOS and display never start to turn off or go to sleep or you might loose the signal until the problem in the following article is resolved:

Which virtual network devices for guests on debian with a qemu kvm VM are behind the host firewall?

Sources:

Explanation in Article ##expl##
https://wiki.ubuntuusers.de/Dnsmasq/

About VFIO with example code (English)
https://www.kernel.org/doc/html/latest/driver-api/vfio.html

Checking and loading the kvm_amd kernel module
Verify if SVM Mode is turned on:

ulimit and quest for setting limits for a group with it:

What is a corefile

memlock source
https://bbs.archlinux.org/viewtopic.php?id=253885

Looking Glass

Looking Glass - Download Looking Glass

Building — Looking Glass B5.0.1 documentation

Installation — Looking Glass B5.0.1 documentation

The list above is not complete, because I forgot some sources.

Additional Trouble Shooting:

1.System Freeze without any error messages (silent fail) or misleading ones:

1 Like