Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
No KVM support with libvirt on AMD Ryzen.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 2:47 pm    Post subject: No KVM support with libvirt on AMD Ryzen. Reply with quote

I'm trying to setup virtual machines on my Gentoo installation.

After installing virt-manager qemu libvirt and deps, and adding libvirtd to default run level, I can start virt-manager and create virtual machine, however there's message "Warning: KVM is not available. This may mean the KVM package is not installed, or the KVM kernel modules are not loaded. Your virtual machines may perform poorly."
Connection QEMU/KVM exists.

I added few config options mentioned on QEMU wiki page. Also support for KVM AMD is enabled (built as part of the kernel).
modprobe kvm and modprobe kvm_amd exit with 0.
There are /sys/module/kvm and /sys/module/kvm_amd.

Hypervisor in the application defaults to QEMU TCQ, and there are no options that seem related to znver1.

Is suport for Zen something that has to be enabled in libvirt? I kinda expected that since 4.10 supports Zen, KVM will be supported also.
Or is it me just doing something incorrectly?

How do I check if KVM is active at all?

Kernel - 4.10.6; libvirt - 3.1.0; virt-manager - 1.4.1; qemu - 2.8.0-r9.
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 3:38 pm    Post subject: Reply with quote

Created virtual machines does not boot - tried win7 installation .iso; USB stick with win7 installation and even bootmenu does not function.

All I get is white cursor blinking on black screen. VM allocates the allotted RAM while generating heavy dual-core load and then just does nothing. Poweroff also does not work - only force shutdown.

Edit:
Also, for some reason created image does not "weigh" anything:
Code:

$ ls -lah /var/lib/libvirt/images/ -i
total 40M
1184220 drwxr-xr-x 2 root root 4.0K Apr  7 01:15 .
1184218 drwxr-xr-x 7 root root 4.0K Apr  6 22:13 ..
1179678 -rw------- 1 root root 251G Apr  7 01:15 win7.qcow2

$ df -h /dev/nvme0n1p3
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p3  470G   22G  425G   5% /

Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 4:58 pm    Post subject: Reply with quote

Somehow this:
Code:
sudo qemu-system-x86_64 -m 4096 -hda /var/lib/libvirt/images/win7games.qcow2 -cdrom /mnt/drv_storage/\@torrents/done/en_windows_7_ultimate_with_sp1_x64_dvd_u_677332.iso  -boot d

Launches the VM fine, even though virt-manager - does not.

Still need to figure out at least proper HW virtualization.
Back to top
View user's profile Send private message
juampii
n00b
n00b


Joined: 23 Oct 2009
Posts: 57
Location: Argentina

PostPosted: Thu Apr 06, 2017 5:12 pm    Post subject: Reply with quote

Hi, maybe this help, im not sure, im a noob and my english is bad.

do you add libvirt-guests also?

/etc/init.d/libvirt-guests start
and your user is in kvm group?

I have a virtual machine running with qemu and virtmanager, i passtrough a gtx980 to the vm and an ssd, also i can boot the same hdd in baremetal, turnf off and boot it in the virtual machine. Games performs the same and windows itself perform "better" in the VM.

Your motherboard supports uefi boot?
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 5:55 pm    Post subject: Reply with quote

Code:

$ sudo strace qemu-system-x86_64 -m 16384 -hda /var/lib/libvirt/images/win7games.qcow2 -cdrom /mnt/drv_storage/\@torrents/done/en_windows_7_ultimate_with_sp1_x64_dvd_u_677332.iso  -boot c -smp cpus=1,maxcpus=1 -cpu host -enable-kvm
...
open("/dev/kvm", O_RDWR|O_CLOEXEC)      = -1 ENOENT (No such file or directory)
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
write(2, "Could not access KVM kernel modu"..., 62Could not access KVM kernel module: No such file or directory
) = 62
write(2, "failed to initialize KVM: No suc"..., 52failed to initialize KVM: No such file or directory
) = 52
close(3)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++



Alright, KVM device does not exist, even though support is builtin. Why could that be?
I'll try to recompile kernel with KVM as a module instead.

juampii wrote:

do you add libvirt-guests also?

/etc/init.d/libvirt-guests start
and your user is in kvm group?


I run it as root for now, until I see it works at all.

juampii wrote:

Your motherboard supports uefi boot?


Yeah, motherboard is MSI X370 Titanium, it supports UEFI, efivars is builtin and I boot using EFI+GRUB, but virt-manager says UEFI is not available and only offers BIOS boot.
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 6:11 pm    Post subject: Reply with quote

Code:

$ lsmod
Module                  Size  Used by
kvm                   472386  0
irqbypass               2808  1 kvm
nouveau              1458364  3
ccp                    40817  0
ttm                    69345  1 nouveau
$ sudo modprobe kvm
$ echo $?
0
$ locate *kvm*.ko
/lib64/modules/4.10.6-gentoo/kernel/arch/x86/kvm/kvm-amd.ko
/lib64/modules/4.10.6-gentoo/kernel/arch/x86/kvm/kvm.ko
/usr/src/linux-4.10.6-gentoo/arch/x86/kvm/kvm-amd.ko
/usr/src/linux-4.10.6-gentoo/arch/x86/kvm/kvm.ko
$ sudo modprobe kvm-amd
modprobe: ERROR: could not insert 'kvm_amd': Operation not supported
$ ls -lah /dev/kvm*
ls: cannot access '/dev/kvm*': No such file or directory


Now, that's queer...

So, kvm loads, but device is not created. And amd kvm module could not load as a module. modprobe would not return errors when it was builtin.

Also, notice "_" and "-" - how modprobe for kvm-amd complains about kvm_amd.
Back to top
View user's profile Send private message
juampii
n00b
n00b


Joined: 23 Oct 2009
Posts: 57
Location: Argentina

PostPosted: Thu Apr 06, 2017 6:13 pm    Post subject: Reply with quote

Are you interested in pass-trough a VGA to the host?
I think uefi bios is suitable for that.

you can also check the Vm xml file with
#virsh edit nameofthevm
virt-manager uses it to start the vm, i can post mine if you like

you get an error when
#modprobe kvm ?

you try
#rc-update add libvirt-guests default
and
#/etc/init.d/libvirt-guests start

Here is my kernel config if you wanna compare some settings (i have an intel cpu)
https://pastebin.com/89PuBVKw

check KVM_AMD in your kernel


Last edited by juampii on Thu Apr 06, 2017 6:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 6:15 pm    Post subject: Reply with quote

Is it normal that on multilib, directory /usr/src/linux-4.10.6-gentoo/arch/x86/ has a lot of stuff while /usr/src/linux-4.10.6-gentoo/arch/x86_64/ only has boot/bzImage symlinked back to /x86/ ?


juampii wrote:
Are you interested in pass-trough a VGA to the host?

Yes, that' exactly what I want to do.

juampii wrote:

I think uefi bios is suitable for that.

How will UEFI help if KVM support in kernel does not work?


Last edited by Kresp on Thu Apr 06, 2017 6:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1777

PostPosted: Thu Apr 06, 2017 6:17 pm    Post subject: Reply with quote

First, boot mode inside a VM has nothing to do with bare metal boot mode.
Usually it's a better idea to go with old, good bios mode inside that VM just because it's well supported by qemu, and enabling efi boot would require you to patch the VM first.

Second, you don't have KVM there. Typical reasons:
* missing kernel module
* missing hardware support
* disabled hardware support

Check your kernel config for KVM.
Check your bios for virtualization support (yes, I have seen it disabled by default)
You're not likely to own hardware without CPU virtualization, but you may want to check CPU specs too
Back to top
View user's profile Send private message
juampii
n00b
n00b


Joined: 23 Oct 2009
Posts: 57
Location: Argentina

PostPosted: Thu Apr 06, 2017 6:25 pm    Post subject: Reply with quote

Kresp wrote:

How will UEFI help if KVM support in kernel does not work?

You need to fix that before proceding to uefi and passtrough the vga.
Virtualization can be disabled in bios or not supported by your motherboard and/or cpu.


If you are going to passtrough a vga you need uefi bios from tianocore and more, iommu support in kernel, vt-d (for intel) in bios, vfio pci, etc.
Can you post your system specs and what are you trying to do

Take a look at http://vfio.blogspot.com.ar/
http://vfio.blogspot.com.ar/2015/05/vfio-gpu-how-to-series-part-1-hardware.html
http://vfio.blogspot.com.ar/2015/05/vfio-gpu-how-to-series-part-2.html
http://vfio.blogspot.com.ar/2015/05/vfio-gpu-how-to-series-part-3-host.html
http://vfio.blogspot.com.ar/2015/05/vfio-gpu-how-to-series-part-4-our-first.html
and https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF

Actually its really simple to setup, check my config and adapt it to AMD, look at vfio, kvm, iommu
And first enable in your motherboard bios virtualization.

Let me know if i can help with something, i manage to do it without initramfs, bootloader and scripts.

Also, another links of interest
https://wiki.installgentoo.com/index.php/PCI_passthrough#Step_3:_Block_access_on_your_physical_OS_to_the_GPU

And here my xml from virsh edit, maybe you get some usefull from there, of course, for reference only
https://pastebin.com/qgjqm2ND
Back to top
View user's profile Send private message
Kresp
n00b
n00b


Joined: 17 Oct 2016
Posts: 73

PostPosted: Thu Apr 06, 2017 6:40 pm    Post subject: Reply with quote

szatox wrote:

Check your bios for virtualization support (yes, I have seen it disabled by default)


Sigh...
That was exactly the case. Apparently, this motherboard defaults SVM to off state, and also resets to defaults on BIOS upgrades.

juampii wrote:

Can you post your system specs and what are you trying to do

AMD R7 1800X; MSI X370 Titanium; GTX 960; GT 9800
I want to run dual monitor and dual GPU setup - normally to use both in linux; but when I start Windows VM, I'll pass main GPU+display to VM, while keeping secondary running X under linux. This is the idea, anyway.

The way I see - I will need to move all the stuff (USB, second SSD, GPU) needed to be passed to one IOMMU group, and then unbind those from drivers using them, before I can use those devices inside VM, right?
Back to top
View user's profile Send private message
juampii
n00b
n00b


Joined: 23 Oct 2009
Posts: 57
Location: Argentina

PostPosted: Thu Apr 06, 2017 6:52 pm    Post subject: Reply with quote

Usb can be passed trough with virt manager, and ssd also (not an option in the gui, but can be done trough the config, and then it shows in the virt-manager window) you need to check if the vga you are going to pass trough is viable (not shared iommu group with another component), and if it is shared, changing it to another pcie slot can solve the issue.

I also recommend you not to put the vm vga in the first pcie-slot, you can put the 960 in pcie 3.0 x8 slot, is enough bandwidth

Later if you are stuck i can post a step by step
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1777

PostPosted: Thu Apr 06, 2017 8:30 pm    Post subject: Reply with quote

Quote:
normally to use both in linux; but when I start Windows VM, I'll pass main GPU+display to VM
Unlikely to happen. AFAIK there is no way to re-initialize that GPU after releasing it from VM, so you can't use both GPUs on host after passing it do the VM. Not quite sure what would happen if you were using both GPUs on host and then decided to unbind it from host's driver. I had to give up on passthrough due to lack of IOMMU.

USB passthough used to work with USB 1.1 mode only, no idea if the devs made any progress on it. I had an idea to pci passthrough the whole USB controller instead, but then - again - I was not able to test it on my hardware. If you want to use passthrough, this little trick may still be worth a shot.
There is hardly any point in passing your hard drive. Virtio provides decent performance and is way more flexible. Qemu doesn't care if you provide an image file or an actual block device to back its virtual disk. It works either way, so you can boot it from another HDD in your host machine, from a partition, LVM volume, (you can even partition it too), raw image file, or more advanced format file like qcow or vmdk. Depending on your choice there are different ways to interact with those images from host's level without interfering with the VM. Pass-through does not allow it. Well, actually using physical drive or partition is not much better, but it will let you dump a powered on machine to a file and restore it (powered on!) later.

Glad you found that KVM killswitch
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum