Red Hat Bugzilla – Bug 662701
Option -enable-kvm should exit when KVM is unavailable
Last modified: 2013-01-09 18:25:13 EST
Description of problem: Upstream qemu exits unsuccessfully when -enable-kvm is given, but KVM is unavailable. RHEL-6's qemu continues with KVM disabled. This is undesirable. libvirt rightly assumes upstream behaviour. How reproducible: Always Steps to Reproduce: 1. chmod 600 /dev/kvm 2. qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -enable-kvm Actual results: open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support [qemu runs with KVM disabled] Expected results: Could not access KVM kernel module: Permission denied failed to initialize KVM: Permission denied [qemu exits unsuccessfully] Additional info: I doubt we need to match the error message exactly, exiting unsuccessfully should suffice.
This seems to leave us in a situation where we have to pass this parameter in order to have any sort of performance, but we'll fail unnecessarily if KVM is not available, and with no way to really tell if KVM will work. I don't think this is the right way to solve this bug, even for libvirt. What we really need here are capabilities.
Until we'll get capabilities and guestfish to use libvirt this is an intermediate solution
This bug is about a difference in behavior between RHEL-6 and upstream. Libvirt is not prepared for this difference; it expects and relies on the upstream behavior. Whether the upstream behavior is ideal for all use cases is a different question, outside the scope of this bug. Discussion of this question belongs upstream. It's pretty much consensus that we could use a structured way to query QEMU "capabilities". But that's also outside the scope of this bug. "Capabilities" need to be developed upstream.
We had some discussion on IRC and it looks like the way we are currently doing it will continue to work even with this change. Go ahead and we'll check it still works in QA.
I tested Upstream | default |-enable-kvm| ----------------+-----------+-----------+ KVM available | disabled | enabled | KVM unavailable | disabled | fail | RHEL-6 | default |-enable-kvm| ----------------+-----------+-----------+ KVM available | enabled* | enabled | KVM unavailable | disabled | disabled* | * deviates from upstream The deviation in the bottom-right case is the one originally reported. The deviation in the top-left case is not covered by the original report. I'd like to realign RHEL-6 with upstream, i.e. remove both deviations. Details: Upstream, KVM available: $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q Upstream, KVM unavailable: $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm Could not access KVM kernel module: Permission denied failed to initialize KVM: Permission denied [Exit 1 ] $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q RHEL-6, KVM available: $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q RHEL-6, KVM unavailable: $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q $ qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q
Comment#6's "upstream" means "upstream QEMU". There's also qemu-kvm. Turns out that it differs from upstream QEMU exactly the same way as RHEL-6. What a mess. Details: Upstream qemu-kvm, KVM available: $ ~/work/qemu-kvm/bld-x86/x86_64-softmmu/qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q $ ~/work/qemu-kvm/bld-x86/x86_64-softmmu/qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q Upstream qemu-kvm, KVM unavailable: $ ~/work/qemu-kvm/bld-x86/x86_64-softmmu/qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q $ ~/work/qemu-kvm/bld-x86/x86_64-softmmu/qemu-system-x86_64 -nodefaults -usb -vnc :0 -S -monitor stdio open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support QEMU 0.13.50 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q
The problem is that qemu-kvm is expecting KVM to be enabled for default, and if we start failing if KVM is not available, it means you can only use qemu-kvm without kvm if you explicitly specify --disable-kvm There are two ways to handle this: 1) Fail qemu-kvm if KVM is not available, independent on whether --enable-kvm is specified. 2) Add an additional internal flag to track whether --enable-kvm was specified on the command line, and fail if it was, when KVM is not enabled. IMHO 2) is really ugly, but I doubt 1) would fly with qemu-kvm maintainers. Jes
Fixed in upstream qemu-kvm commit b724fa4b. qemu-kvm | default |-enable-kvm| -no-kvm ----------------+-----------+-----------+----------- KVM available | enabled* | enabled | disabled KVM unavailable | disabled | fail+ | disabled * still differs from upstream qemu + changed from disabled
*** Bug 661767 has been marked as a duplicate of this bug. ***
Can reproduce on following package: $ rpm -qa|grep qemu qemu-kvm-0.12.1.2-2.147.el6.x86_64 qemu-kvm | default |-enable-kvm| -no-kvm ----------------+-----------+-----------+----------- KVM available | enabled | enabled | disabled KVM unavailable | disabled | disabled | disabled Verified on package: $ rpm -qa|grep qemu qemu-kvm-0.12.1.2-2.148.el6.x86_64 Steps: 1. launch qemu-kvm with kvm available $ ls -l /dev/kvm crw-rw-rw-+ 1 root kvm 10, 232 Feb 22 16:23 /dev/kvm $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q ***Actual Result***: with -enable-kvm, kvm enabled $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: enabled (qemu) q ***Actual Result*** by default, kvm enabled $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -no-kvm Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q ***Actual Result*** with -no-kvm, kvm disabled 2. launch qemu-kvm with kvm unavailable. $ ls -l /dev/kvm crw-------+ 1 root kvm 10, 232 Feb 22 16:23 /dev/kvm $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm open /dev/kvm: Permission denied failed to initialize KVM: Operation not permitted ***Actual Result*** with -enable-kvm, failed $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio open /dev/kvm: Permission denied Could not initialize KVM, will disable KVM support Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q ***Actual Result*** by default, kvm disabled $ /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -no-kvm Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q ***Actual Result*** with -no-kvm, kvm disabled
Renamed /dev/kvm, and verify again. # /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -enable-kvm open /dev/kvm: No such file or directory failed to initialize KVM: Operation not permitted ***Actual Result***: with -enable-kvm, failed. # /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio open /dev/kvm: No such file or directory Could not initialize KVM, will disable KVM support Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q ***Actual Result***: by default, kvm disabled # /usr/libexec/qemu-kvm -nodefaults -usb -vnc :0 -S -monitor stdio -no-kvm Using CPU model "cpu64-rhel6" QEMU 0.12.1 monitor - type 'help' for more information (qemu) info kvm kvm support: disabled (qemu) q ***Actual Result***: with -no-kvm, kvm disabled So, I think this issue got fixed.
move to verified based on comment#16 and comment#19
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2011-0534.html