I'm trying to set up a VM using libvirt and KVM through virt-manager (and virsh command line) with hugepages support and I get an error when enabling the option in the domain XML. Don't know where the problem is.I'm using Ubuntu 14.04 upgraded to 14.10 with the following package versions:libvirt-bin 1.2.8-0ubuntu11qemu-kvm 2.1+dfsg-4ubuntu6SpecificsI have configured hugepages following this guide. Here is some info about current configuration:$ hugeadm --explainTotal System Memory: 15808 MBMount Point          Options/dev/hugepages       rw,relatime,mode=1770,gid=126Huge page pools:      Size  Minimum  Current  Maximum  Default   2097152     2176     2176     2176        *Huge page sizes with configured pools:2097152$ getent group kvmkvm:x:126:chaicko$ cat /proc/meminfo | grep HugeAnonHugePages:    591872 kBHugePages_Total:    2176HugePages_Free:     2176HugePages_Rsvd:        0HugePages_Surp:        0Hugepagesize:       2048 kBThis is the domain XML:<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>  <name>win8</name>  <uuid>b85bbb9a-745f-4293-a990-1e1726240ef0</uuid>  <memory unit='KiB'>4194304</memory>  <currentMemory unit='KiB'>4194304</currentMemory>  <memoryBacking>    <hugepages/>  </memoryBacking>  <vcpu placement='static'>4</vcpu>  <os>    <type arch='x86_64' machine='pc-i440fx-utopic'>hvm</type>  </os>  <features>    <acpi/>    <apic/>    <pae/>  </features>  <cpu mode='custom' match='exact'>    <model fallback='allow'>Haswell</model>  </cpu>  <clock offset='localtime'>    <timer name='rtc' tickpolicy='catchup'/>    <timer name='pit' tickpolicy='delay'/>    <timer name='hpet' present='no'/>  </clock>  <on_poweroff>destroy</on_poweroff>  <on_reboot>restart</on_reboot>  <on_crash>restart</on_crash>  <pm>    <suspend-to-mem enabled='no'/>    <suspend-to-disk enabled='no'/>  </pm>  <devices>    <emulator>/usr/bin/qemu-system-x86_64</emulator>    <disk type='block' device='disk'>      <driver name='qemu' type='raw' cache='none' io='native'/>      <source dev='/dev/vmvg/win8'/>      <target dev='vda' bus='virtio'/>      <boot order='2'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>    </disk>    <disk type='file' device='cdrom'>      <driver name='qemu' type='raw'/>      <source file='/home/chaicko/Downloads/virtio-win-0.1-81.iso'/>      <target dev='hda' bus='ide'/>      <readonly/>      <address type='drive' controller='0' bus='0' target='0' unit='0'/>    </disk>    <disk type='file' device='cdrom'>      <driver name='qemu' type='raw'/>      <source file='/home/chaicko/Downloads/WINDOWS_8.1_Pro_X64/Windows_8.1_Pro_X64.iso'/>      <target dev='hdb' bus='ide'/>      <readonly/>      <boot order='1'/>      <address type='drive' controller='0' bus='0' target='0' unit='1'/>    </disk>    <controller type='usb' index='0' model='ich9-ehci1'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>    </controller>    <controller type='usb' index='0' model='ich9-uhci1'>      <master startport='0'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>    </controller>    <controller type='usb' index='0' model='ich9-uhci2'>      <master startport='2'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>    </controller>    <controller type='usb' index='0' model='ich9-uhci3'>      <master startport='4'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>    </controller>    <controller type='pci' index='0' model='pci-root'/>    <controller type='ide' index='0'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>    </controller>    <controller type='virtio-serial' index='0'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>    </controller>    <controller type='scsi' index='0'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>    </controller>    <interface type='network'>      <mac address='52:54:00:48:ca:09'/>      <source network='default'/>      <model type='virtio'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>    </interface>    <serial type='pty'>      <target port='0'/>    </serial>    <console type='pty'>      <target type='serial' port='0'/>    </console>    <channel type='spicevmc'>      <target type='virtio' name='com.redhat.spice.0'/>      <address type='virtio-serial' controller='0' bus='0' port='1'/>    </channel>    <input type='tablet' bus='usb'/>    <input type='mouse' bus='ps2'/>    <input type='keyboard' bus='ps2'/>    <graphics type='spice' autoport='yes'/>    <sound model='ich6'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>    </sound>    <video>      <model type='qxl' ram='65536' vram='65536' heads='1'/>      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>    </video>    <hostdev mode='subsystem' type='pci' managed='yes'>      <source>        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>      </source>      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>    </hostdev>    <hostdev mode='subsystem' type='pci' managed='yes'>      <source>        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>      </source>      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>    </hostdev>    <redirdev bus='usb' type='spicevmc'>    </redirdev>    <redirdev bus='usb' type='spicevmc'>    </redirdev>    <redirdev bus='usb' type='spicevmc'>    </redirdev>    <redirdev bus='usb' type='spicevmc'>    </redirdev>    <memballoon model='virtio'>      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>    </memballoon>  </devices>  <qemu:commandline>    <qemu:arg value='-drive'/>    <qemu:arg value='if=pflash,readonly,format=raw,file=/usr/share/qemu/OVMF.fd'/>  </qemu:commandline></domain>QuestionsIf I remove the <memoryBacking> option then it works but if not it fails with the the following error:error: internal error: process exited while connecting to monitor: Also I've uncommented the following line in /etc/libvirt/qemu.conf:hugetlbfs_mount = /dev/hugepagesRunning qemu through the shell instructing to use the hugepages do actually work (-mem-path /dev/hugepages).What am I doing wrong? Any help is appreciated.
libvirt error when enabling hugepages for guest
kvm
Answering my own question, in order to use hugepages with libvirt in Ubuntu, you just have to set KVM_HUGEPAGES=1 in the file /etc/default/qemu-kvm and restart.This is related with this bugfix.