Want to use gpu for a win11 vm and for hyprland/games

firstly
```
.-------------------------: c2@cachywork
.+=========================. ------------
:++===++==================- :+± OS: CachyOS x86_64
:*++====+++++=============- .==: Host: Laptop 16 (AMD Ryzen AI 300 Series) (A9)
-*+++=====+***++==========: Kernel: Linux 6.19.10-1-cachyos-bore
=*++++========------------: Uptime: 4 hours, 54 mins
=*+++++=====- … Packages: 1597 (pacman), 13 (flatpak)

.++++++=-===: .=+++=: Shell: bash 5.3.9
:++++=====-==: -+ Display (NE160QDM-NZ6): 2560x1600 @ 1.6x in 16", 165 Hz [Built-in]
:++========-=. .=+
+. WM: Hyprland 0.54.2 (Wayland)
.+==========-. . Cursor: Adwaita
:+++++++====- .–==-. Terminal: kitty 0.46.2
:++==========. :+++++++: Terminal Font: NotoSansMono-Regular (11pt)
.-===========. =
**++ CPU: AMD Ryzen AI 9 HX 370 (24) @ 5.16 GHz
.-===========: .++: GPU 1: AMD Radeon 890M Graphics [Integrated]
-=======++++:::::::::::::::::::::::::-: .—: GPU 2: NVIDIA GeForce RTX 5070 Max-Q / Mobile [Discrete]
:======++++====+++
***********=. Memory: 15.31 GiB / 93.58 GiB (16%)
:=====+++==========++++++++++++++
- Swap: 0 B / 109.58 GiB (0%)
.====++==============+++++++++± Disk (/): 1.18 TiB / 1.80 TiB (66%) - xfs
.===+==================+++++++: Disk (/home/c2/ssd2): 35.94 GiB / 1.82 TiB (2%) - xfs
.-=======================+++: Local IP (wlan0): 10.0.0.151/24
… Battery (FRANDBA): 100% [AC Connected]
Locale: en_US.UTF-8

[c2@cachywork ~]$
```
basicaly i want to run a win 11 vm (specifically win11 enterprise with tiny win11 modifications) on my cachy os system, i mainly want this vm for fusion 360 and other autocad products and i would like the vm to have access to my 5070m.

the issue is that windows needs exclusive accesses where nothing else on the os can be using the gpu while windows is, but i also want to use this gpu for display out and games, of course not at the same, either display out and/or games/other software on the gpu or windows vm. the issue is that hyprland is constantly claiming the gpu and the vm can never get exclusive accesses. fyi when i am not using the gpu it goes into d3cold so i know nothing is activity using it.

is there a easy way to make hyprland give up the gpu to the vm or do i have to find something more manual.

I am assuming that you are using/want to use PCI passthrough/IOMMU (otherwise, you would be using a virtual graphics adapter which would naturally be exclusive to the guest, and your physical GPU would always be shared between host and guest).
Citing the Arch Wiki:

However, due to their size and complexity, GPU drivers do not tend to support dynamic rebinding very well, so you cannot just have some GPU you use on the host be transparently passed to a virtual machine without having both drivers conflict with each other. Because of this, it is generally advised to bind those placeholder drivers manually before starting the virtual machine, in order to stop other drivers from attempting to claim it.

The GPU not being available to the VM thus has nothing to do with Hyprland, it is the fact that there is already a driver connected to it, meaning that even if the GPU is idle, it is still technically “in use” and cannot be used by the VM (this is an oversimplification, for more accurate information, refer to the linked article).

Looking at the above quote, assigning your GPU on the fly seems to be possible in theory, but highly not recommended. I would imagine that even IF the driver hot-swapping worked without issue, whatever graphical desktop environment/rendering library you are using (no matter if Hyprland/aquamarine or not) would not appreciate having a GPU just suddenly disappear.

But you seem to be running a laptop. Would it perhaps be easier to just use the regular IOMMU setup as described in the linked article, but also write a script that can toggle it on/off?

Then you could run your demanding applications in the Windows VM + Hyprland on the integrated graphics, once you are done, run the script to switch the dedicated graphics back to the regular driver, reboot, and then run your games. That reboot cycle would probably cost you < 1 minute and it would be a much more stable setup than what you are trying to do.

PS: I just noticed, but why tf do you have 109 GiB of swap? Do you have a hibernation setup?