Talk:KVM

From ArchWiki
Latest comment: 15 November 2020 by Thewall in topic Memory limits for huge pages

Enabling huge pages

With systemd, hugetlbfs is mounted on /dev/hugepages by default, but with mode 0755 and root's uid and gid.

I'm giving this a try right now. Rbellamy (talk) 03:39, 27 January 2015 (UTC)Reply

And not so much... seems I can't access the hugetlbfs as I should.

Jan 26 19:57:59 eanna libvirtd[619]: Unable to read from monitor: Connection reset by peer
Jan 26 19:57:59 eanna libvirtd[619]: internal error: early end of file from monitor: possible problem:
                                     2015-01-27T03:57:59.072699Z qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
Jan 26 19:57:59 eanna kernel: virbr0: port 2(vnet0) entered disabled state
Jan 26 19:57:59 eanna kernel: device vnet0 left promiscuous mode
Jan 26 19:57:59 eanna kernel: virbr0: port 2(vnet0) entered disabled state
Jan 26 19:57:59 eanna avahi-daemon[669]: Withdrawing workstation service for vnet0.
Jan 26 19:57:59 eanna NetworkManager[576]: <info> (virbr0): link disconnected
Jan 26 19:57:59 eanna systemd-coredump[894]: Process 870 (qemu-system-x86) of user 99 dumped core.
Jan 26 19:57:59 eanna systemd-machined[871]: Machine qemu-prometheus terminated.
Jan 26 19:57:59 eanna gnome-session[711]: Gjs-Message: JS LOG: Failed to launch ibus-daemon: Failed to execute child process "ibus-daemon" (No such file or  directory)
Jan 26 19:57:59 eanna dbus[571]: [system] Activating via systemd: service name='org.freedesktop.GeoClue2' unit='geoclue.service'
Jan 26 19:57:59 eanna libvirtd[619]: error from service: TerminateMachine: No machine 'qemu-prometheus' known
Jan 26 19:57:59 eanna libvirtd[619]: Failed to autostart VM 'prometheus': internal error: early end of file from monitor: possible problem:
                                     2015-01-27T03:57:59.072699Z qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory
Jan 26 19:57:59 eanna dbus[571]: [system] Activating via systemd: service name='fi.w1.wpa_supplicant1' unit='wpa_supplicant.service'
Jan 26 19:57:59 eanna libvirtd[619]: internal error: Unable to find any usable hugetlbfs mount for 16777216 KiB
Jan 26 19:57:59 eanna dbus[571]: [system] Successfully activated service 'fi.w1.wpa_supplicant1'
Jan 26 19:57:59 eanna NetworkManager[576]: <info> wpa_supplicant started
Jan 26 19:57:59 eanna polkitd[598]: Registered Authentication Agent for unix-session:c1 (system bus name :1.29 [gnome-shell --mode=gdm], object path /org/ freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.
Jan 26 19:57:59 eanna dbus[571]: [system] Successfully activated service 'org.freedesktop.GeoClue2'
Jan 26 19:57:59 eanna gnome-session[711]: Gjs-Message: JS LOG: No permission to trigger offline updates: Polkit.Error: GDBus.Error:org.freedesktop. PolicyKit1.Error.Failed: Action org.freedesktop.packagekit.trigg
Jan 26 19:57:59 eanna org.freedesktop.Telepathy.AccountManager[715]: (process:921): libnm-glib-WARNING **: Error in get_property: Method "Get" with  signature "ss" on interface "org.freedesktop.DBus.Properties" d
Jan 26 19:57:59 eanna libvirtd[619]: Failed to autostart VM 'atlas': internal error: Unable to find any usable hugetlbfs mount for 16777216 KiB

Rbellamy (talk) 04:11, 27 January 2015 (UTC)Reply

I think the proper way to manually set hugepage size is with sysctl:
sysctl vm.nr_hugepages=550
Then you can enable it permanently by creating the file "/etc/sysctl.d/40-hugepags.conf" and putting the following inside it:
vm.nr_hugepages=550
Meskarune (talk) 20:53, 14 September 2017 (UTC)Reply
I just wanted to confirm that with default permissions on dev/hugepages, this error happened: https://gist.github.com/meskarune/90a2c561488303a16e67554cc108e47e
Meskarune (talk) 17:57, 4 November 2017 (UTC)Reply

Merge KVM article into QEMU

Because the QEMU-KVM fork of QEMU has been deprecated/obsoleted as of QEMU 1.3 [1] (about 9 months ago as of this writing [2]) and QEMU is now on version 1.6, we should strongly consider merging the KVM article into the main article for QEMU. A separate article for the KVM fork made sense historically, but now that the fork has been merged upstream, we should just keep everything on one page.

Does anyone disagree?
-- Jstjohn (talk) 16:29, 16 September 2013 (UTC)Reply

Good idea, I don't think anybody can disagree, as the main section of this article, KVM#How_to_use_KVM, already just links to QEMU ^^
If then somebody considers QEMU to have become too long, it should be discussed to split it in some other way.
-- Kynikos (talk) 01:06, 18 September 2013 (UTC)Reply
The problems of KVM#Tips_and_tricks should be solved along the way, especially KVM#Live_snapshots which belongs to libvirt and not to QEMU. It should also be clearly stated which features are KVM-specific to avoid confusion.
-- Lahwaacz (talk) 10:44, 22 September 2013 (UTC)Reply
I just merged KVM#Live_snapshots into libvirt.
-- Jstjohn (talk) 01:03, 7 November 2013 (UTC)Reply

Works with "AMD FX(tm)-8350 Eight-Core Processor" using 2013.11.01 64-bit

Using Arch Linux release 2013.11.01 in 64-bit mode... it boots fine. Following the wikis... this is basically the parameters I used

$ /usr/bin/qemu-system-x86_64 -boot d -m 1024 -hda '/home/user/path/to/storage' -cdrom '/path/to/archlinux-2013.11.01-dual.iso' -net nic,vlanx=0 -net user,vlan=0 -localtime -k en-gb -smp 8 -enable-kvm -cpu host &
  • I also booted the Gentoo minimal ISO 20131010 in 64-bit mode (go to gentoo to find out more) using the same parameter but different ISO
$ /usr/bin/qemu-system-x86_64 -boot d -m 1024 -hda '/home/user/path/to/storage' -cdrom '/path/to/install-amd64-minimal-20131010.iso' -net nic,vlan=0 -net user,vlan=0 -localtime -k en-gb -smp 8 -enable-kvm -cpu host &
  • During live CD boot up... I see this error message... which I think is normal...
Failed to access perfctr msr (MSR c0010001 is ffffffffffffffff)
  • You also get errors about not being able to access hardware... obvious why :p (unless I'm wrong)
  • I haven't installed Arch Linux in the guest yet (busy :p) but will get some time to
  • from what I can see, the parameter "nested" is already set to "1" for the kvm_amd module when using the systool command before applying the "nested" parameter myself
  • I found loading kvm or kvm_amd loads both
  • you should say grep svm /proc/cpuinfo for AMD
  • I have another AMD machine which has "AMD Phenom II x4 955" (showing the svm CPU flag from /proc/cpuinfo file which too is using Arch Linux (my server) when I have time... will try it out there
  • I do plan to move to Intel... better drivers... lets get cracking before I move to Intel
  • I'm new to wiki code :p

-- Sinatosk (talk) 22:34, 4 November 2013

Missing virtio_serial

Instructions mention a virtio_serial.

This appears to be missing, the rest in the list exist.

[root@ lib]# find . | grep -i virtio_ | grep ko
./modules/5.5.8-arch1-1/kernel/drivers/block/virtio_blk.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/char/virtio_console.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/crypto/virtio/virtio_crypto.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/net/virtio_net.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/nvdimm/virtio_pmem.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/rpmsg/virtio_rpmsg_bus.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/scsi/virtio_scsi.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/virtio/virtio_balloon.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/virtio/virtio_input.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/virtio/virtio_mmio.ko.xz
./modules/5.5.8-arch1-1/kernel/drivers/virtio/virtio_pci.ko.xz
./modules/5.5.8-arch1-1/kernel/net/vmw_vsock/vmw_vsock_virtio_transport.ko.xz
./modules/5.5.8-arch1-1/kernel/net/vmw_vsock/vmw_vsock_virtio_transport_common.ko.xz
[root@ lib]# 

Beepboo (talk) 21:33, 9 March 2020 (UTC)Reply

Hugepages Troubleshooting

unable to map backing store for guest RAM: Cannot allocate memory

Certify guest memory ram does not exceed the amount allocated to hugepages.

SuperHeroINTJ (talk) 16:50, 1 June 2020 (UTC)Reply

Nested Virtualization With kvm_amd

Works perfectly

[bran@server ~]$ cat /proc/cpuinfo
 processor       : 0
 vendor_id       : AuthenticAMD
 cpu family      : 23
 model           : 8
 model name      : AMD Ryzen Threadripper 2970WX 24-Core Processor
[root@server opt]# modprobe -r kvm_amd
[root@server opt]# modprobe kvm_amd nested=1
[root@server opt]# systool -m kvm_amd -v|grep nested
   nested              = "1"


In VM

truenas# grep -E --color=auto 'vmx|svm' /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr virt_ssbd arat npt nrip_save arch_capabilities

Brando56894 (talk) 18:32, 4 October 2020 (UTC)Reply

Memory limits for huge pages

Folowing section "Enabling huge pages", when trying to set the number of hugepages with

# echo 4096 > /proc/sys/vm/nr_hugepages

I could not get more than ~1200 pages (size per each page 2048 kB). This looked weird because my system has 16GB of RAM. From this guide [3] I set the memory limits to 8GB in /etc/security/limits.conf:

# Lock max 8Gb
soft memlock 8388608
hard memlock 8388608

After rebooting I was able to set the number of hugepages to 4096 without problems. Maybe this should be added to the page but since it is under discussion for merging I opened a discussion first. Also, I'm not an expert.

Thewall (talk) 18:12, 15 November 2020 (UTC)Reply