Hot-swapping GPU passthrough to both macOS and Windows guests on Linux host?

I’d like to run a very small Linux host with a ZFS drive array that has both macOS and Windows guests that could accept GPU acceleration passthrough in a hot-swappable fashion.

For example, I would like to have either one of the two scenarios:

  1. control-alt-shift-f2 would simultaneously flip to macOS AND set the macOS guest to receive GPU passthrough access; control-alt-shift-f3 would then do the same for Windows; and control-alt-shift-f1 would do the same back over to Linux host.

OR

  1. Be able to move to any guest and then press some key combo that would change passthrough to that or a key-defined guest vm.

This kind of an arrangement would be incredibly powerful.

I’m not entirely sure what macOS does if it loses a video card… does it panic or can it handle it?

What adds to this curious situation is their support for integrated to discrete (dedicated GPU) dynamic switching in the OS. It would lead me to believe that they do handle these things to some degree.

Perhaps it would require writing a dummy driver that identifies /dev/null (or whatever) as an integrated chipset and then the passthrough GPU as the discrete one. Then a keypress could activate an appropriate system call or such to trigger the flip and cascade to guest OS switch, etc…

Thoughts?

1 Like

Really curious about this as well. This is pretty much my exact use case… :slight_smile: Did you ever figure this out? Anyone able to help?

Last time I played with this on arch and CentOS with 4.0.x kernels and nvidia (proprietary driver), at least the windows side was possible, but unstable. The detach process to release the video card from the guest would fail randomly requiring a re-start of the host. Work 5 times but not a 6th and so on…

Can’t speak to the macOS side, I’ve never tried a hacknitosh guest at all.

Clearly the kernel has made some head-way, but I thought it worth pointing out that “working at all” and “ready for production” may be two different things here. Also, nvidia and AMD may produce wildly different results (though I understand AMD may require a VGA-BIOS update to address current/known reset/release issues on the red-team).

Does this mean that hot swapping is possible when shutting down the host though? I remember last time I tried GPU passthrough I had to blacklist the PCI device on the host… :o That would be a huge improvement for me already!! :smiley:

I was able to attach/detach the device from the driver and deal with 2 1080’s (identical cards), detaching only one with various approaches you can find on Arch wikis.

I did all the driver/device manipulation in run-level 3 (no X running). Then started X only once I had the appropriate cards configured for the host and others removed to avoid confusion.

Even there the process of attaching and detaching the card from the host was not “robust”. Periodically, the nvidia driver would barf and require a host-restart. I will say that happened more when the guest did not start or shutdown cleanly. If I got into windows and shut it down, then the likelyhood that the guest-dedicated GPU would permit further activity went up dramatically.

Things may have improved, but it seems ambitious to say the least to expect to be able to not only get it to work, but seamlessly switch guests. There just isn’t enough mileage (not enough users/demand) on this flow and frankly Nvidia is actively trying to stop consumer cards from being used this way (code 43).

Thread is a 2 month necro. If you wish to continue discussion then feel free to make a thread with a link back to this one