i'm curious as to how to examine a running kernel to see what it has in the way of kvm support.
i can see that "make menuconfig" gives me the options:
KVM (KVM) KVM for Intel (KVM_INTEL) KVM for AMD (KVM_AMD)
first question: technically, i can select generic KVM support without selecting either INTEL or AMD support. can i assume that that's a pointless thing to do? the help text for CONFIG_KVM does seem to suggest that you really need to additionally select a processor module to make any sense; i was just wondering if there's some obscure scenario where having only that generic KVM support had any value.
next, regardless of whether kvm support is built-in or whether it's modular and the modules have been loaded, is there some indication -- say under /proc or /sys -- that shows the current state of kvm support in the kernel?
if i had the config file for the running kernel, i could of course look at that, but let's assume that i have no such thing, and that kvm support is built-in so i can't even check for, say, /sys/module/kvm. is there a userspace way to probe and determine kvm support?
rday
p.s. just to be clear, kvm support in the kernel doesn't count if that kernel is running on a system without HW virt support, for which kvm support obviously has no value since it can't be used. in a case like that, i'd like to get the answer that there is *no* support.
======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca Linked In: http://www.linkedin.com/in/rpjday Twitter: http://twitter.com/rpjday ========================================================================
On Wed, Apr 08, 2009 at 04:05:41PM -0400, Robert P. J. Day wrote:
i'm curious as to how to examine a running kernel to see what it has in the way of kvm support.
i can see that "make menuconfig" gives me the options:
KVM (KVM) KVM for Intel (KVM_INTEL) KVM for AMD (KVM_AMD)first question: technically, i can select generic KVM support without selecting either INTEL or AMD support. can i assume that that's a pointless thing to do? the help text for CONFIG_KVM does seem to suggest that you really need to additionally select a processor module to make any sense; i was just wondering if there's some obscure scenario where having only that generic KVM support had any value.
Yes, it is meaningless to select only KVM without any processor support. You will just waste memory.
next, regardless of whether kvm support is built-in or whether it's modular and the modules have been loaded, is there some indication -- say under /proc or /sys -- that shows the current state of kvm support in the kernel?
if i had the config file for the running kernel, i could of course look at that, but let's assume that i have no such thing, and that kvm support is built-in so i can't even check for, say, /sys/module/kvm. is there a userspace way to probe and determine kvm support?
You can try looking at /sys/class/misc/kvm.
Inside qemu, you can run the "info kvm" monitor command to make sure kvm support is really working on your qemu instance.
rday
p.s. just to be clear, kvm support in the kernel doesn't count if that kernel is running on a system without HW virt support, for which kvm support obviously has no value since it can't be used. in a case like that, i'd like to get the answer that there is *no* support.
The kvm modules fail to load if there is no hardware support, so if you have /sys/class/misc/kvm, you should have hardware virt support working.
On Wed, 8 Apr 2009, Eduardo Habkost wrote:
On Wed, Apr 08, 2009 at 04:05:41PM -0400, Robert P. J. Day wrote:
regardless of whether kvm support is built-in or whether it's modular and the modules have been loaded, is there some indication -- say under /proc or /sys -- that shows the current state of kvm support in the kernel?
if i had the config file for the running kernel, i could of course look at that, but let's assume that i have no such thing, and that kvm support is built-in so i can't even check for, say, /sys/module/kvm. is there a userspace way to probe and determine kvm support?
You can try looking at /sys/class/misc/kvm.
and /dev/kvm as well, as glauber pointed out. i took a quick look at the kernel source file virt/kvm/kvm_main.c, and i can see the kvm_init() routine which contains the snippet:
=====
... r = kvm_arch_hardware_setup(); if (r < 0) goto out_free_0a; ...
r = sysdev_class_register(&kvm_sysdev_class); if (r) goto out_free_3;
r = sysdev_register(&kvm_sysdev); if (r) goto out_free_4;
...
kvm_chardev_ops.owner = module; kvm_vm_fops.owner = module; kvm_vcpu_fops.owner = module;
r = misc_register(&kvm_dev); if (r) { printk(KERN_ERR "kvm: misc device register failed\n"); goto out_free; } ...
=====
just to clarify, those last few lines appear to create the device file /dev/kvm, while the ones above involving sysdev_class_register() and sysdev_register() will handle /sys/class/misc/kvm, correct? just being curious and nosing around the kernel code.
rday --
======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca Linked In: http://www.linkedin.com/in/rpjday Twitter: http://twitter.com/rpjday ========================================================================
On Thu, Apr 09, 2009 at 12:03:18PM -0400, Robert P. J. Day wrote:
On Wed, 8 Apr 2009, Eduardo Habkost wrote:
On Wed, Apr 08, 2009 at 04:05:41PM -0400, Robert P. J. Day wrote:
regardless of whether kvm support is built-in or whether it's modular and the modules have been loaded, is there some indication -- say under /proc or /sys -- that shows the current state of kvm support in the kernel?
if i had the config file for the running kernel, i could of course look at that, but let's assume that i have no such thing, and that kvm support is built-in so i can't even check for, say, /sys/module/kvm. is there a userspace way to probe and determine kvm support?
You can try looking at /sys/class/misc/kvm.
and /dev/kvm as well, as glauber pointed out. i took a quick look at the kernel source file virt/kvm/kvm_main.c, and i can see the kvm_init() routine which contains the snippet:
=====
... r = kvm_arch_hardware_setup(); if (r < 0) goto out_free_0a; ...
r = sysdev_class_register(&kvm_sysdev_class); if (r) goto out_free_3; r = sysdev_register(&kvm_sysdev); if (r) goto out_free_4;...
kvm_chardev_ops.owner = module; kvm_vm_fops.owner = module; kvm_vcpu_fops.owner = module; r = misc_register(&kvm_dev); if (r) { printk(KERN_ERR "kvm: misc device register failed\n"); goto out_free; }...
=====
just to clarify, those last few lines appear to create the device file /dev/kvm, while the ones above involving sysdev_class_register() and sysdev_register() will handle /sys/class/misc/kvm, correct? just being curious and nosing around the kernel code.
Both are steps needed for /sys/class/misc/kvm. After that, udev should create /dev/kvm when it is notified about the new device.
On Thu, 9 Apr 2009, Eduardo Habkost wrote:
udev should create /dev/kvm when it is notified about the new device.
really? that suggests that there should be a udev kvm rules file under /etc/udev/rules.d, no? but i don't see one. where is it supposed to come from? what package does it belong to?
rday
p.s. i would be testing a lot of this myself except that i'm still stuck with a non-HW-virt, 64-bit laptop running f11 beta, while staring out my window, waiting for UPS to show up today with my new machine.
--
======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca Linked In: http://www.linkedin.com/in/rpjday Twitter: http://twitter.com/rpjday ========================================================================
On Thu, Apr 09, 2009 at 01:20:24PM -0400, Robert P. J. Day wrote:
On Thu, 9 Apr 2009, Eduardo Habkost wrote:
udev should create /dev/kvm when it is notified about the new device.
really? that suggests that there should be a udev kvm rules file under /etc/udev/rules.d, no? but i don't see one. where is it supposed to come from? what package does it belong to?
I don't know the specifics of the udev rules. But, surely, the /dev/kvm file isn't created by the kernel, but by userspace.
On Thu, 9 Apr 2009, Eduardo Habkost wrote:
On Thu, Apr 09, 2009 at 01:20:24PM -0400, Robert P. J. Day wrote:
On Thu, 9 Apr 2009, Eduardo Habkost wrote:
udev should create /dev/kvm when it is notified about the new device.
really? that suggests that there should be a udev kvm rules file under /etc/udev/rules.d, no? but i don't see one. where is it supposed to come from? what package does it belong to?
I don't know the specifics of the udev rules. But, surely, the /dev/kvm file isn't created by the kernel, but by userspace.
never mind. from what i read here:
http://www.linux-kvm.org/page/FAQ
i only need a udev rule file for kvm if i want to make it runnable by a non-privileged user. or so it seems.
rday --
======================================================================== Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Annoying Kernel Pedantry.
Web page: http://crashcourse.ca Linked In: http://www.linkedin.com/in/rpjday Twitter: http://twitter.com/rpjday ========================================================================
On Wed, Apr 08, 2009 at 04:05:41PM -0400, Robert P. J. Day wrote:
i'm curious as to how to examine a running kernel to see what it has in the way of kvm support.
i can see that "make menuconfig" gives me the options:
KVM (KVM) KVM for Intel (KVM_INTEL) KVM for AMD (KVM_AMD)first question: technically, i can select generic KVM support without selecting either INTEL or AMD support. can i assume that that's a pointless thing to do? the help text for CONFIG_KVM does seem to suggest that you really need to additionally select a processor module to make any sense; i was just wondering if there's some obscure scenario where having only that generic KVM support had any value.
No. You always need one of the two variants.
next, regardless of whether kvm support is built-in or whether it's modular and the modules have been loaded, is there some indication -- say under /proc or /sys -- that shows the current state of kvm support in the kernel?
plenty. You'll have a /dev/kvm, for instance.
if i had the config file for the running kernel, i could of course look at that, but let's assume that i have no such thing, and that kvm support is built-in so i can't even check for, say, /sys/module/kvm. is there a userspace way to probe and determine kvm support?
check for the existence of /dev/kvm
rday
p.s. just to be clear, kvm support in the kernel doesn't count if that kernel is running on a system without HW virt support, for which kvm support obviously has no value since it can't be used. in a case like that, i'd like to get the answer that there is *no* support.
for that, you'll probably need a mixture of checking processor flags + the aforementioned method
On Wed, 2009-04-08 at 16:05 -0400, Robert P. J. Day wrote:
i'm curious as to how to examine a running kernel to see what it has in the way of kvm support.
Just for completeness' sake: the most supportable and portable way to check for that is to use libvirt's virConnectGetCapabilities[1] (or 'virsh capabilities')
Programs that need to know whether kvm is enabled, shouldn't go poking around /sys etc. - look at the capabilities XML instead. And if there's info missing that you need, ask on libvir-list and it'll happen somehow.
David