[solved]Manjaro|qemu: problem assigning video card to VM via PCI passthrough

So I installed Manjaro, then installed kernel 313 from the repos. That worked fine until I noticed pci-stub missing for some reason. I then proceeded to download the kernel source from kernel.org, unpack it to /usr/src and generate a .config with make menuconfig. I then used make all to compile the kernel. Then I used make modules_install install and copied the kernel bzImage to /boot, as well as the System.map. I then try and generate the initramfs with mkinitcpio -k 3.13.0mira_sioclya -c /etc/mkinitcpio.conf -g /boot/initramfs-3.13.0mira_sioclya.img . But then I get the error "WARNING: No modules were added to the image. This is probably not what you want."

I'm running Manjaro off of a BTRFS drive. The kernel is compiled with modules for BTRFS, XFS, ext2/3/4, FAT, NTFS, iso, joliet, udf, AMD IOMMU v2, pci_stub, pretty much all of the virtualization features except Hyper-V guests, and support for AES and Serpent as well as pretty much all hashing algorithms.

I really want to pass my HD7950 through to my Windows kvm guest, and aside from hosting a Kubuntu guest beside that, the system doesn't need to do anything else.

mhwd-kernel is the correct way to switch kernel in manjaro. it will also automatically update your kernel modules for you

you've been overthinking it lol, all you have to do is sudo mhwd-kernel -linux313

all virtualization headers are checked in the standard kernel (including the 20000 lines of Hyper-V code lol)

Thanks for the explanation, Zoltan. Could you then provide me with a verbose tutorial on how to set up pci passthrough? I seem to not really be successful in doing that at the moment (system hangs in the moment in which I turn the vm with the passthrough video card on).

 

It depends on your system, so this is only tentative, but here it goes:

1. make sure your passthrough GPU is not your primary video adapter, this should be no problem for iGPU/APU machines, but if it's not such a machine, put the passthrough card in the second high bandwidth PCI slot or simply change your configuration if you only have one high bandwidth card (this is not simple stuff, and I can't even begin to write something that would help you, as it's very system specific)

2. you're running kvm/qemu as virtualization engine. You have livirtd enabled as a service

3. switch your linux host to the primary graphics adapter, and disable the output from the passthrough adapter in arandr/xrandr (just to not have any surprises, not really necessary)

4. connect both cards to your monitor(s), so that you can see both outputs or switch between them

5. fire up virt-manager, and just install your windows guest like you normally would install windows, make the overlay file big enough for your games to have plenty of space. Important here is to cancel the screen with the authentication code for windows, it won't work if you try to enter something there, windows runs in a virtual environment without authentication code, and it's perfectly legal to run windows like that on one machine. To authenticate, the Windows guest will not "phone home", but will check the install-DVD. More about that later.

6. do not update or install drivers in windows, let it run on the standard VESA driver the first time around

7. after installing windows, quit it and go to the settings in virt-manager, where you add a PCI adapter to the windows guest. That would be in the left column of the GUI. Select the correct PCI slot where your passthrough adapter is in (it's identified by address, so you'll have to run lspci in terminal to get a list and see to which pci slot the passthrough adapter is connected). That will bind this adapter to your guest. As soon as you start up the windows guest, windows will tell you it has found a new video card, and then you can install the drivers for it and update the system. Important: this will unbind the passthrough adapter from your host system, but only when the guest is started, so if you use proprietary drivers for that adapter in your host, X will crash when kvm unbinds it. You HAVE to use a KMS driver for that adapter, so only open source drivers! The primary adapter can run whatever you like for PCI passthrough. For VGA passthrough, it can't, you also have to use a KMS driver because the primary adapter will be unbound from the host as soon as the guest is started. Very important: set the host to run in full-screen mode at start, or it won't work.

8. if the windows guest works as it should, mount the image of the windows install DVD to a mounting point on your host, so that you don't need to use the DVD each time you fire up the Windows guest. It's a sad waste of 8.5 GB of space (so don't mount it on an SSD!), but you gain more than that by stripping Windows to the bare minimum in your virtual container.

9. in virt-manager, configure a shared folder on your host, where your Windows games can store the game data, so that when your Windows box crashes and has to be restored, your data are safe on the host storage. If you don't trust windows enough to even share storage space in a directory of your /home folder, you can also autosync the game data folder over smb to a folder on your host (that's the way I do it).

10. when everything works like you would expect, snapshot the Windows guest so that you can restore easily in case of breakage.

System as in Hardware? I thought that's what the profile page is for, so I didn't bother copy-pasting it here. I run an AMD FX-8320 on a Gigabyte GA-990FXA-UD5 with a Gigabyte Radeon HD6670 as the main graphics adapter (open source R600 driver), plus a Sapphire HD7950 I'm trying to bind a virtual Windows. I have 8GB of RAM.

When I do configure it in virt-manager and try to start the virtual windows, the system locks up completely and I can't do anything (I don't get any output on the screen connected to the HD7950).

I also have a strange issue where after restarting a VM several times, at some point qemu can't allocate the necessary amoutn of RAM (sure enough it can't, but looking at what programs are running the system shouldn't be using more than 2GB... is this definitely qemu related or probably an issue from some other part of the system?).

You can't run kvm in manjaro with kernel 3.13 yet, arch hasn't implemented the necessary patches yet.

The fact that your available assignable RAM reduces is due to not quitting your previously run containers properly. This may be a bug related to a missing kvm patch in Manjaro, but it may also be user error.

If your system locks up when you fire up the host, that means that the PCI adapter is already bound. That has to do with the same thing, somehow the previously fired up container is still running. Other possibility is that you haven't set the guest to run full-screen, that would yield a similar phenomenon.

Thanks for clearing that up. I'll be using kernel 3.12 then (I suppose that'd work?).

Yup, no problem. The new kvm packages were rolled out for Fedora release last weekend, so Arch should probably roll them out this weekend, so a couple of days later, Manjaro will have them also. There is almost no delay in implementation between bleeding edge distros as far as release (stable) packages are concerned, maximum about two weeks, so you'll be able to play around with the DPM enhancements of kernel 3.13 soon enough lol...