Patchwork [08/20] kvm: Add fake KVM constants to avoid #ifdefs on KVM-specific code

login
register
mail settings
Submitter Andreas Färber
Date Jan. 15, 2013, 9:27 a.m.
Message ID <1358242058-1404-9-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/212061/
State New
Headers show

Comments

Andreas Färber - Jan. 15, 2013, 9:27 a.m.
From: Eduardo Habkost <ehabkost@redhat.com>

Any KVM-specific code that use these constants must check if
kvm_enabled() is true before using them.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/sysemu/kvm.h |   14 ++++++++++++++
 1 Datei geändert, 14 Zeilen hinzugefügt(+)

Patch

diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 2fe8f8a..6bdd513 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -22,6 +22,20 @@ 
 #ifdef CONFIG_KVM
 #include <linux/kvm.h>
 #include <linux/kvm_para.h>
+#else
+/* These constants must never be used at runtime if kvm_enabled() is false.
+ * They exist so we don't need #ifdefs around KVM-specific code that already
+ * checks kvm_enabled() properly.
+ */
+#define KVM_CPUID_SIGNATURE      0
+#define KVM_CPUID_FEATURES       0
+#define KVM_FEATURE_CLOCKSOURCE  0
+#define KVM_FEATURE_NOP_IO_DELAY 0
+#define KVM_FEATURE_MMU_OP       0
+#define KVM_FEATURE_CLOCKSOURCE2 0
+#define KVM_FEATURE_ASYNC_PF     0
+#define KVM_FEATURE_STEAL_TIME   0
+#define KVM_FEATURE_PV_EOI       0
 #endif
 
 extern int kvm_allowed;