diff options
author | Alexander Graf <agraf@suse.de> | 2014-07-14 12:33:08 -0400 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2014-07-28 09:23:17 -0400 |
commit | 92b591a4c46b103ebd3fc0d03a084e1efd331253 (patch) | |
tree | c42fdfa42d3ed67eb530977768d6f614024815ec /virt | |
parent | 784aa3d7fb6f729c06d5836c9d9569f58e4d05ae (diff) |
KVM: Allow KVM_CHECK_EXTENSION on the vm fd
The KVM_CHECK_EXTENSION is only available on the kvm fd today. Unfortunately
on PPC some of the capabilities change depending on the way a VM was created.
So instead we need a way to expose capabilities as VM ioctl, so that we can
see which VM type we're using (HV or PR). To enable this, add the
KVM_CHECK_EXTENSION ioctl to our vm ioctl portfolio.
Signed-off-by: Alexander Graf <agraf@suse.de>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e28f3caa539d..1b95cc926cfc 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -2324,6 +2324,34 @@ static int kvm_ioctl_create_device(struct kvm *kvm, | |||
2324 | return 0; | 2324 | return 0; |
2325 | } | 2325 | } |
2326 | 2326 | ||
2327 | static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) | ||
2328 | { | ||
2329 | switch (arg) { | ||
2330 | case KVM_CAP_USER_MEMORY: | ||
2331 | case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: | ||
2332 | case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS: | ||
2333 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | ||
2334 | case KVM_CAP_SET_BOOT_CPU_ID: | ||
2335 | #endif | ||
2336 | case KVM_CAP_INTERNAL_ERROR_DATA: | ||
2337 | #ifdef CONFIG_HAVE_KVM_MSI | ||
2338 | case KVM_CAP_SIGNAL_MSI: | ||
2339 | #endif | ||
2340 | #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING | ||
2341 | case KVM_CAP_IRQFD_RESAMPLE: | ||
2342 | #endif | ||
2343 | case KVM_CAP_CHECK_EXTENSION_VM: | ||
2344 | return 1; | ||
2345 | #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING | ||
2346 | case KVM_CAP_IRQ_ROUTING: | ||
2347 | return KVM_MAX_IRQ_ROUTES; | ||
2348 | #endif | ||
2349 | default: | ||
2350 | break; | ||
2351 | } | ||
2352 | return kvm_vm_ioctl_check_extension(kvm, arg); | ||
2353 | } | ||
2354 | |||
2327 | static long kvm_vm_ioctl(struct file *filp, | 2355 | static long kvm_vm_ioctl(struct file *filp, |
2328 | unsigned int ioctl, unsigned long arg) | 2356 | unsigned int ioctl, unsigned long arg) |
2329 | { | 2357 | { |
@@ -2487,6 +2515,9 @@ static long kvm_vm_ioctl(struct file *filp, | |||
2487 | r = 0; | 2515 | r = 0; |
2488 | break; | 2516 | break; |
2489 | } | 2517 | } |
2518 | case KVM_CHECK_EXTENSION: | ||
2519 | r = kvm_vm_ioctl_check_extension_generic(kvm, arg); | ||
2520 | break; | ||
2490 | default: | 2521 | default: |
2491 | r = kvm_arch_vm_ioctl(filp, ioctl, arg); | 2522 | r = kvm_arch_vm_ioctl(filp, ioctl, arg); |
2492 | if (r == -ENOTTY) | 2523 | if (r == -ENOTTY) |
@@ -2571,33 +2602,6 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) | |||
2571 | return r; | 2602 | return r; |
2572 | } | 2603 | } |
2573 | 2604 | ||
2574 | static long kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg) | ||
2575 | { | ||
2576 | switch (arg) { | ||
2577 | case KVM_CAP_USER_MEMORY: | ||
2578 | case KVM_CAP_DESTROY_MEMORY_REGION_WORKS: | ||
2579 | case KVM_CAP_JOIN_MEMORY_REGIONS_WORKS: | ||
2580 | #ifdef CONFIG_KVM_APIC_ARCHITECTURE | ||
2581 | case KVM_CAP_SET_BOOT_CPU_ID: | ||
2582 | #endif | ||
2583 | case KVM_CAP_INTERNAL_ERROR_DATA: | ||
2584 | #ifdef CONFIG_HAVE_KVM_MSI | ||
2585 | case KVM_CAP_SIGNAL_MSI: | ||
2586 | #endif | ||
2587 | #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING | ||
2588 | case KVM_CAP_IRQFD_RESAMPLE: | ||
2589 | #endif | ||
2590 | return 1; | ||
2591 | #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING | ||
2592 | case KVM_CAP_IRQ_ROUTING: | ||
2593 | return KVM_MAX_IRQ_ROUTES; | ||
2594 | #endif | ||
2595 | default: | ||
2596 | break; | ||
2597 | } | ||
2598 | return kvm_vm_ioctl_check_extension(kvm, arg); | ||
2599 | } | ||
2600 | |||
2601 | static long kvm_dev_ioctl(struct file *filp, | 2605 | static long kvm_dev_ioctl(struct file *filp, |
2602 | unsigned int ioctl, unsigned long arg) | 2606 | unsigned int ioctl, unsigned long arg) |
2603 | { | 2607 | { |