Add KVM_SET_ENTITLEMENT ioctl to pass the entitlement to the hypervisor. Signed-off-by: Michael Wolf <m...@linux.vnet.ibm.com> --- cpu-defs.h | 1 + cpus.c | 1 + cpus.h | 1 + kvm-all.c | 1 + linux-headers/linux/kvm.h | 2 ++ 5 files changed, 6 insertions(+)
diff --git a/cpu-defs.h b/cpu-defs.h index 4018b88..ae24e8e 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -200,6 +200,7 @@ typedef struct CPUWatchpoint { int numa_node; /* NUMA node this cpu is belonging to */ \ int nr_cores; /* number of cores within this CPU package */ \ int nr_threads;/* number of threads within this CPU */ \ + int cpu_entitlement; /* the % of the pcpu that the vcpu receives */ \ int running; /* Nonzero if cpu is currently running(usermode). */ \ int thread_id; \ /* user data */ \ diff --git a/cpus.c b/cpus.c index e476a3c..ef8b762 100644 --- a/cpus.c +++ b/cpus.c @@ -1042,6 +1042,7 @@ void qemu_init_vcpu(void *_env) env->nr_cores = smp_cores; env->nr_threads = smp_threads; + env->cpu_entitlement = cpu_entitlement; env->stopped = 1; if (kvm_enabled()) { qemu_kvm_start_vcpu(env); diff --git a/cpus.h b/cpus.h index 81bd817..704d6df 100644 --- a/cpus.h +++ b/cpus.h @@ -16,6 +16,7 @@ void qtest_clock_warp(int64_t dest); /* vl.c */ extern int smp_cores; extern int smp_threads; +extern int cpu_entitlement; void set_numa_modes(void); void set_cpu_log(const char *optarg); void set_cpu_log_filename(const char *optarg); diff --git a/kvm-all.c b/kvm-all.c index 34b02c1..dee1b9b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -246,6 +246,7 @@ int kvm_init_vcpu(CPUArchState *env) s->coalesced_mmio_ring = (void *)env->kvm_run + s->coalesced_mmio * PAGE_SIZE; } + kvm_vm_ioctl(s, KVM_SET_ENTITLEMENT, env->cpu_entitlement); ret = kvm_arch_init_vcpu(env); if (ret == 0) { diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 5a9d4e3..46dbde5 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -901,6 +901,8 @@ struct kvm_s390_ucas_mapping { #define KVM_SET_ONE_REG _IOW(KVMIO, 0xac, struct kvm_one_reg) /* VM is being stopped by host */ #define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad) +/* Set the cpu entitlement this will be used to adjust stealtime reporting */ +#define KVM_SET_ENTITLEMENT _IOW(KVMIO, 0xae, unsigned long) #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)