[PATCH v3 5/5] KVM: refactor asynchronous vcpu ioctl dispatch

Radim Krčmář
2015-08-14T10:11:53Z

I find the switch easier to read and modify.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
v3: precisely #ifdef arch-specific ioctls [Christian]
v2: new

virt/kvm/kvm_main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index dfa2d5f27713..c059c01161fe 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2255,12 +2255,16 @@ static long kvm_vcpu_ioctl(struct file *filp,
* Special cases: vcpu ioctls that are asynchronous to vcpu execution,
* so vcpu_load() would break it.
*/
-#if defined(CONFIG_S390) || defined(CONFIG_PPC) || defined(CONFIG_MIPS)
- if (ioctl == KVM_S390_INTERRUPT || ioctl == KVM_S390_IRQ || ioctl == KVM_INTERRUPT)
- return kvm_arch_vcpu_ioctl(filp, ioctl, arg);
+ switch (ioctl) {
+#if defined(CONFIG_S390)
+ case KVM_S390_INTERRUPT:
+ case KVM_S390_IRQ:
+#elif defined(CONFIG_PPC) || defined(CONFIG_MIPS)
+ case KVM_INTERRUPT:
#endif
- if (ioctl == KVM_USER_EXIT)
+ case KVM_USER_EXIT:
return kvm_arch_vcpu_ioctl(filp, ioctl, arg);
+ }

r = vcpu_load(vcpu);
if (r)
--
2.5.0