Skip to contentSkip to conversation

KVM clock - userspace part

PATCH In review Glauber de Oliveira Costa 2 participants 5 messages Jan 11, 2008 – Jan 14, 2008 3 messages not in the archive KVM

lore
Share & tools
lore
#2 lore raw

PATCH 1/2 include kvm_para.h

In reply to a message not in the archive

have qemu-kvm to include kvm_para, allowing access to paravirt definitions

---
 qemu/qemu-kvm-x86.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +1 -0
index c79ca36..21ec112 100644
@@ -14,6 +14,7 @@ extern int kvm_irqchip;
 #include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
+#include <linux/kvm_para.h>
 
 #define MSR_IA32_TSC		0x10
 
Signature · 8 lines
1.5.0.6


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
#4 lore raw

PATCH 2/2 fill cpuid with clocksource information

In reply to a message not in the archive

In this patch, we probe the host checking for clocksource capabilities. In case it is found, it is advertised to the guest through the appropriate cpuid mechanism

---
 qemu/qemu-kvm-x86.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
qemu/qemu-kvm-x86.c +5 -1
index 21ec112..c008cb7 100644
@@ -517,6 +517,10 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     int cpuid_nent = 0;
     CPUState copy;
     uint32_t i, limit;
+    int has_clocksource = 0;
+#ifdef KVM_CAP_CLOCKSOURCE
+    has_clocksource = kvm_check_extension(kvm_context, KVM_CAP_CLOCKSOURCE);
+#endif
 
     copy = *cenv;
 
@@ -534,7 +538,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     pv_ent = &cpuid_ent[cpuid_nent++];
     memset(pv_ent, 0, sizeof(*pv_ent));
     pv_ent->function = KVM_CPUID_FEATURES;
-    pv_ent->eax = 0;
+    pv_ent->eax = (has_clocksource << KVM_FEATURE_CLOCKSOURCE);
 #endif
 
     copy.regs[R_EAX] = 0;
Signature · 8 lines
1.5.0.6


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
#5 lore raw

Re: [PATCH 1/2] include kvm_para.h

In reply to a message not in the archive
Quoted 12 lines · Glauber de Oliveira Costa

have qemu-kvm to include kvm_para, allowing access to paravirt definitions

---
 qemu/qemu-kvm-x86.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +0 -0
index c79ca36..21ec112 100644

qemu/qemu-kvm-x86.c extern int kvm_irqchip; · line 18

Quoted 5 lines
qemu/qemu-kvm-x86.c +1 -0
@@ -14,6 +14,7 @@ extern int kvm_irqchip;
 #include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
+#include <linux/kvm_para.h>
 

IIRC, early versions of kvm_para.h were userspace unfriendly, so we need a version code check (or better, a KVM_CAP_ check) around this.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
#7 lore raw

Re: [PATCH 1/2] include kvm_para.h

In reply to a message not in the archive
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Glauber de Oliveira Costa

have qemu-kvm to include kvm_para, allowing access to paravirt definitions

---
 qemu/qemu-kvm-x86.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Quoted 14 lines

qemu/qemu-kvm-x86.c extern int kvm_irqchip; · line 18

Quoted 10 lines
qemu/qemu-kvm-x86.c +1 -0
index c79ca36..21ec112 100644
@@ -14,6 +14,7 @@ extern int kvm_irqchip;
 #include <libkvm.h>
 #include <pthread.h>
 #include <sys/utsname.h>
+#include <linux/kvm_para.h>
 

IIRC, early versions of kvm_para.h were userspace unfriendly, so we need a version code check (or better, a KVM_CAP_ check) around this.

No need. including kvm_para.h in userspace unfriendly tools won't break anything. Code that handles it userspace is already enclosed in the KVM_CAP_ check.

(well, in reality, I forgot to enclose one line with it. But it's a bug, and will be fixed in the series I'm about to shoot out.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace