Introduction
I found this note about a issue I faced some time ago and noticed I forgot to post here on blog, so I doing this now, it is better late than never.
I was trying to modify a VM configuration created with KVM on Oracle Linux used as the OS Host and Guest. The goal to this configuration was to enable the Hugepages at the OS Host and start the VM using Hugepages. To achieve this, I changed the XML for that VM including the hugepages tag like this:
<memory unit='KiB'>402653184</memory>
<currentMemory unit='KiB'>402653184</currentMemory>
<memoryBacking>
<hugepages/>
</memoryBacking>
But when I tried to start the VM, the startup failed with the following error:
[root@KVM01 kvm]# virsh start ORA01 error: Failed to start domain 'ORA01' error: internal error: QEMU unexpectedly closed the monitor (vm='ORA01'): 2025-03-08T03:14:13.508799Z qemu-kvm: unable to map backing store for guest RAM: Cannot allocate memory
Problem
When we use the flag for Hugepage in the VM definination, this works similar to “use_large_parges=ONLY” in the Oracle Database, which means we need to have the available Hugepages to accommodate the configured memory totally in Hugepages.
So checking the hugepage stats at host, I noticed the available hugepages was not sufficient for the VM memory configuration.
The VM was configured to use 400 GB, but the available Hugepages at host was close to 190 GB:
[root@KVM01 kvm]# grep Huge /proc/meminfo AnonHugePages: 1294336 kB ShmemHugePages: 0 kB FileHugePages: 94763008 kB HugePages_Total: 97663 << this is 190 GB HugePages_Free: 97663 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 200013824 kB
The issue occurred because I tried to setup the hugepages in advance before shutdown the VM, and the OS had no available RAM to reserve the Hugepages.
Solution
After the VM was shutdown, I just executed the sysctl -p command to force the OS rto eload the sysctl.conf again and reserve the hugepages properly:
[root@KVM01 kvm]# sysctl -p vm.swappiness = 1 vm.nr_hugepages = 256000
Checking the available hugepages again, and the host shows 500 GB of RAM, which should be fine to start the VM safely:
[root@KVM01 kvm]# grep Huge /proc/meminfo AnonHugePages: 1294336 kB ShmemHugePages: 0 kB FileHugePages: 94763008 kB HugePages_Total: 256000 << that is 500 GB for RAM HugePages_Free: 256000 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 524288000 kB
And starting the VM with no errors:
[root@KVM01 kvm]# virsh start ORA01 Domain 'ORA01' started
Conclusion
Please note this case was not in a OLVM environment, which usually should be done using the OLVM Engine Manager. This was specific case where the environment was using Standalone KVM.