Bug 494739 - KVM isn't used by qemu launched by Virtual Machine Manager
Summary: KVM isn't used by qemu launched by Virtual Machine Manager
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: qemu
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: David Woodhouse
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-07 22:49 UTC by Matthias Saou
Modified: 2009-10-05 02:39 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-04-21 08:52:21 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Matthias Saou 2009-04-07 22:49:00 UTC
I've installed Fedora 11 Beta x86_64, updated to development.

kernel-2.6.29.1-46.fc11.x86_64
qemu-0.10-6.fc11.x86_64

I decided to create a RHEL5 virtual server to do some testing. I'm quite familiar with Xen and plain qemu, but hadn't used KVM before.

I used the GNOME VM applet to run the Virtual Machine Manager and create the guest. It installed very slowly. Checking the system, the kvm_intel module wasn't loaded. Even after loading the module, the qemu-system-x86_64 command forked by the Virtual Machine Manager doesn't use /dev/kvm (checked with lsof).

The same command run manually still doesn't use /dev/kvm. But if running qemu-kvm manually (and removing the unrecognised -no-kqemu option), then the virtual server is fast and lsof does report the process having /dev/kvm open at last.

From what I've read in various places, the idea is basically to seamlessly use KVM from qemu. My problem here is that apparently the default way of creating virtual machines does not make use of KVM. Nor do I see an easy way of changing that anywhere in the GUI options or even the xml configuration. My current workaround is to run qemu-kvm from a terminal.

I've checked the open qemu/kvm reports but haven't seen any about this issue, which is why I'm reporting it.

(FWIW, I have also seen an unrelated SDL crash issue, but that one has been reported and apparently a fix should show up tomorrow, which is great news)

Other than that, the virtual machine seems to be working great.

Comment 1 Mark McLoughlin 2009-04-09 15:32:23 UTC
(In reply to comment #0)
> Checking the system, the kvm_intel module wasn't loaded. Even after loading
> the module, the qemu-system-x86_64 command forked by the Virtual Machine 
> Manager doesn't use /dev/kvm (checked with > lsof).

Okay, the first thing to figure out is why kvm_intel isn't loaded at boot time. See /etc/sysconfig/modules/kvm.modules:

  if [ $(grep -c vmx /proc/cpuinfo) -ne 0 ]; then 
      modprobe kvm-intel >/dev/null 2>&1
  fi

What is the content of /proc/cpuinfo?

There is a known issue that libvirtd needs to be re-started if you load kvm_intel after libvirtd has been started. See bug #460649

Comment 2 Matthias Saou 2009-04-09 16:24:35 UTC
(In reply to comment #1)
> Okay, the first thing to figure out is why kvm_intel isn't loaded at boot time.

I think I can easily answer that one :

[root@fusion ~]# rpm -qf /etc/sysconfig/modules/kvm.modules 
qemu-system-x86-0.10-6.fc11.x86_64

I installed qemu, then did all my testing without having rebooted, which explains. I just rebooted now and the module is properly loaded.

Now that this part is understood, I tried running my virtual machine from the Virtual Machine Manager, but it's still horribly slow and lsof confirms that kvm isn't being used. I found nothing in the preferences nor the virtual machine's Details about enabling KVM. I did however edit the virtual machine's xml file in /etc/libvirt/qemu/ in order to switch to "/usr/bin/qemu-kvm" and that fixed everything (after restarting libvirtd just in case).

This all seems quite fragile. I'm assuming the ideal solution would be a single qemu executable which would detect kvm at runtime, as even if libvirtd does it at last, it seems like virtual machines created when kvm wasn't available will keep running without using it.

Thanks for your help! :-) Feel free to do what you want with this report.

Comment 3 Matthias Saou 2009-04-16 21:31:47 UTC
Actually, I still have a problem :

Even though I've now set <emulator>/usr/bin/qemu-kvm</emulator> inside the /etc/libvirt/qemu/vm1.xml file, I found the virtual server to be quite slow, and a quick check shows that qemu-kvm is being run with the -no-kvm option! I've searched a bit everywhere, but didn't manage to find what was causing this.

Again, it seems like there are lots of creation time hardcoded values here and there, which if changed to runtime detections would save a lot of hassles (at least in my case).

Comment 4 Matthias Saou 2009-04-16 21:37:53 UTC
Typical : Search for 1h, nothing, press then Send button here, then find the solution in the next minute.

I just had to replace <domain type='qemu'> with <domain type='kvm'> in the XML file and restart libvirtd. I found no way of doing this using a GUI, though.

Comment 5 Mark McLoughlin 2009-04-19 15:36:04 UTC
There was a bug here after all, fixed with:

 %post system-x86
-%ifarch %{ix86}
+%ifarch %{ix86} x86_64
 # load kvm modules now, so we can make sure no reboot is needed.
 # If there's already a kvm module installed, we don't mess with it
 sh /%{_sysconfdir}/sysconfig/modules/kvm.modules


Thanks Matthias

* Sun Apr 19 2009 Mark McLoughlin <markmc> - 2:0.10-10
- Run sysconfig.modules from %post on x86_64 too (#494739)

Building in dist-f11-updates-candidate, will request it be tagged into dist-f11 soon

Comment 6 Matthias Saou 2009-04-19 17:19:20 UTC
Indeed! And with this fix, the VM I created would have been kvm enabled from the very start, so this does indeed solve the situation which lead to my problems.

Comment 7 Mark McLoughlin 2009-04-21 08:52:21 UTC
qemu-0.10-11.fc11 now tagged in dist-f11


Note You need to log in before you can comment on or make changes to this bug.