Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
libvirt: -enable-kvm missing
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
bitozoid
n00b
n00b


Joined: 20 Apr 2008
Posts: 67

PostPosted: Thu Jun 05, 2014 11:07 am    Post subject: libvirt: -enable-kvm missing Reply with quote

I have just upgraded to qemu 2.0, with the following message from portage:
Code:
"The /usr/bin/kvm and /usr/bin/qemu-kvm wrappers are no longer"
"installed.  In order to use kvm acceleration, pass the flag"
"-enable-kvm when running your system target."

So that I changed in my libvirt xml file
Code:
-    <emulator>/usr/bin/qemu-kvm</emulator>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>

restarted libvirtd, started my qemu virtual machine, and issued:
Code:
ps aux | grep qemu

However, I can't see the -enable-kvm parameter:
Code:
qemu     24208 91.3  0.6 4947948 55856 ?       Sl   11:52   0:07 /usr/bin/qemu-system-x86_64 -name 20140205-win7 -S -machine pc-i440fx-1.5,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 8143daf4-1183-7943-b58e-78fc38c004bd -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/20140205-win7.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x7 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/var/lib/libvirt/images/w7amd64.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/var/lib/libvirt/images/virtio-win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw,cache=none -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=19,id=hostnet0,vhost=on,vhostfd=20 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:f5:69:1c,bus=pci.0,addr=0x6 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -k es -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x3 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5


I assume libvirt detects qemu capabilities. Why is it missing?
Back to top
View user's profile Send private message
kikko
Apprentice
Apprentice


Joined: 29 Apr 2014
Posts: 261
Location: Milan, IT

PostPosted: Fri Jun 06, 2014 9:13 pm    Post subject: Reply with quote

Hi!
for what I can see, you have "accel=kvm" enabled in your command line options:
Quote:

qemu 24208 91.3 0.6 4947948 55856 ? Sl 11:52 0:07 /usr/bin/qemu-system-x86_64 -name 20140205-win7 -S -machine pc-i440fx-1.5,accel=kvm,usb=off -m 4096 -realtime mlock=off -smp 2,sockets=2,cores=1,threads=1 -uuid 8143daf4-1183-7943-b58e-78fc38c004bd -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/20140205-win7.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x7 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x4 -drive file=/var/lib/libvirt/images/w7amd64.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=writeback -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/var/lib/libvirt/images/virtio-win-0.1-74.iso,if=none,id=drive-ide0-1-0,readonly=on,format=raw,cache=none -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=19,id=hostnet0,vhost=on,vhostfd=20 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:f5:69:1c,bus=pci.0,addr=0x6 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on -k es -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x3 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5

Since you have edited the XML file from libvirtd, this may be the only proof that KVM is enabled
Back to top
View user's profile Send private message
dmoulding
n00b
n00b


Joined: 03 Jun 2014
Posts: 18

PostPosted: Sat Jun 07, 2014 8:15 pm    Post subject: Hmmm... where do command-line arguments go in the XML? Reply with quote

I'm facing the same situation. The message from emerge says:
Quote:
Please update your configs in /etc/libvirt/qemu/ to use the -enable-kvm flag and the right system binary (e.g. qemu-system-x86_64).

It's easy to see in the XML where the binary goes (just search for qemu-kvm), but it's not obvious where arguments to the emulator are supposed to go. Neither the libvirt "Domain XML format" documentation nor "man virsh" have provided me with any illumination. Anybody know how to specify emulator command-line arguments in libvirt domain XML?
Back to top
View user's profile Send private message
dmoulding
n00b
n00b


Joined: 03 Jun 2014
Posts: 18

PostPosted: Sat Jun 07, 2014 8:31 pm    Post subject: Maybe figured it out .... Reply with quote

More browsing of the libvirt documentation led me here: http://libvirt.org/drvqemu.html#xmlimport

That taught me about the "domxml-from-native" virsh command. So, trying that out... first without the -enable-kvm option:

Code:
$ virsh domxml-from-native qemu-argv <(echo "/usr/bin/qemu-system-x86_64")
<domain type='qemu'>
  <name>unnamed</name>
  <uuid>0586443e-1960-4227-8c05-f922e3990e96</uuid>
  <memory unit='KiB'>65536</memory>
  <currentMemory unit='KiB'>65536</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <controller type='usb' index='0'/>
    <controller type='pci' index='0' model='pci-root'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='sdl'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
    <memballoon model='virtio'/>
  </devices>
</domain>

Then with the -enable-kvm option:
Code:
$ virsh domxml-from-native qemu-argv <(echo "/usr/bin/qemu-system-x86_64 -enable-kvm")
<domain type='kvm'>
  <name>unnamed</name>
  <uuid>6a1d3d03-4630-45ce-9732-aad149d31754</uuid>
  <memory unit='KiB'>65536</memory>
  <currentMemory unit='KiB'>65536</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <controller type='usb' index='0'/>
    <controller type='pci' index='0' model='pci-root'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='sdl'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
    <memballoon model='virtio'/>
  </devices>
</domain>

That leads me to believe setting the "type" attribute on the "domain" element is the way to do it, which, incidentally, is what's already in the XML I have.

I also noticed that the "qemu-kvm" wrapper script did *not* use the "-enable-kvm" flag, either. It passed "-machine accel=kvm" only.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1765

PostPosted: Sun Jun 08, 2014 6:03 pm    Post subject: Reply with quote

The easiest test ever:
Quote:
$ lsmod | grep kvm
kvm_amd 42845 0
kvm 218141 1 kvm_amd
$ lsmod | grep kvm
kvm_amd 42845 3
kvm 218141 1 kvm_amd

Second one is with a single VM running
Back to top
View user's profile Send private message
bitozoid
n00b
n00b


Joined: 20 Apr 2008
Posts: 67

PostPosted: Mon Jun 09, 2014 8:47 am    Post subject: Reply with quote

It looks like the code reads the 'qemu -help' and sets capabilities.
Code:
cat libvirt-1.2.3/src/qemu/qemu_capabilities.c
...
    if (strstr(help, "-enable-kvm"))
        virQEMUCapsSet(qemuCaps, QEMU_CAPS_ENABLE_KVM);
...
    cmd = virQEMUCapsProbeCommand(qemuCaps->binary, NULL, runUid, runGid);
    virCommandAddArgList(cmd, "-help", NULL);
...

Then, from the capabilities it adds the argument to the command line:
Code:
$ cat libvirt-1.2.3/src/qemu/qemu_command.c
...
        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ENABLE_KVM)) {
            enableKVM = true;
...
    if (enableKVM)
        virCommandAddArg(cmd, "-enable-kvm");
...

So something is missing. I wonder whether some gentoo specific patch is needed.

libvirt-1.2.3/src/qemu/qemu_capabilities.c
Code:
 714     /* qemu-kvm/kvm binaries can only be used if
 715      *  - host & guest arches match
 716      * Or
 717      *  - hostarch is x86_64 and guest arch is i686
 718      * The latter simply needs "-cpu qemu32"
 719      */
 720     if (virQEMUCapsIsValidForKVM(hostarch, guestarch)) {
 721         const char *const kvmbins[] = { "/usr/libexec/qemu-kvm", /* RHEL */
 722                                         "qemu-kvm", /* Fedora */
 723                                         "kvm" }; /* Upstream .spec */
 724
Back to top
View user's profile Send private message
PeeJay
n00b
n00b


Joined: 15 Aug 2004
Posts: 46
Location: Sydney, Australia

PostPosted: Fri Jun 13, 2014 10:35 am    Post subject: Reply with quote

I only added the qemu-system-x86_64 part and libvirt seems to be automagicly using kvm as the hypervisor.
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