* [Qemu-devel] [PATCH RFC 0/2] Add guest cpu entitlement reporting
@ 2012-08-23 23:15 Michael Wolf
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline Michael Wolf
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 2/2] Add an ioctl to pass the entitlement information from qemu to the hypervisor Michael Wolf
0 siblings, 2 replies; 4+ messages in thread
From: Michael Wolf @ 2012-08-23 23:15 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mtosatti, stefanha, avi
User can be confused by stealtime when running a guest in either a capped or
overcommitted cpu environment. The user has concerns that they are not
receiving their full cpu allotment when steal time shows up in the accounting
tools. So add a cpu entitlement. This entitlement will be used to compute the
amount of steal time display by the accounting tools.
Michael Wolf (2):
The cpu entitlement value will be passed to qemu as part of the cpu
parameters.
Add an ioctl to pass the entitlement information from qemu to the
hypervisor.
---
cpu-defs.h | 1 +
cpus.c | 1 +
cpus.h | 1 +
kvm-all.c | 1 +
linux-headers/linux/kvm.h | 2 ++
qemu-options.hx | 7 +++++--
vl.c | 22 +++++++++++++++++++++-
7 files changed, 32 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline.
2012-08-23 23:15 [Qemu-devel] [PATCH RFC 0/2] Add guest cpu entitlement reporting Michael Wolf
@ 2012-08-23 23:15 ` Michael Wolf
2012-08-25 7:54 ` Blue Swirl
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 2/2] Add an ioctl to pass the entitlement information from qemu to the hypervisor Michael Wolf
1 sibling, 1 reply; 4+ messages in thread
From: Michael Wolf @ 2012-08-23 23:15 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mtosatti, stefanha, avi
The cpu entitlement value will be passed to qemu as part of the cpu parameters.
Add cpu_parse to read this value from the commandline.
Signed-off-by: Michael Wolf <mjw@linux.vnet.ibm.com>
---
qemu-options.hx | 7 +++++--
vl.c | 23 ++++++++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 3c411c4..d13aa24 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -64,9 +64,12 @@ HXCOMM Deprecated by -machine
DEF("M", HAS_ARG, QEMU_OPTION_M, "", QEMU_ARCH_ALL)
DEF("cpu", HAS_ARG, QEMU_OPTION_cpu,
- "-cpu cpu select CPU (-cpu ? for list)\n", QEMU_ARCH_ALL)
+ "-cpu cpu[,entitlement=cpu use entitlement %]\n"
+ "select CPU (-cpu ? for list)\n"
+ "entitlement= percentage of cpu that the guest can expect to utilize\n",
+ QEMU_ARCH_ALL)
STEXI
-@item -cpu @var{model}
+@item -cpu @var{model}[,entitlement=@var{entitlement}]
@findex -cpu
Select CPU model (-cpu ? for list and additional feature selection)
ETEXI
diff --git a/vl.c b/vl.c
index 7c577fa..8f0c12a 100644
--- a/vl.c
+++ b/vl.c
@@ -205,6 +205,8 @@ CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
int win2k_install_hack = 0;
int usb_enabled = 0;
int singlestep = 0;
+const char *cpu_model;
+int cpu_entitlement = 100;
int smp_cpus = 1;
int max_cpus = 0;
int smp_cores = 1;
@@ -1026,6 +1028,25 @@ static void numa_add(const char *optarg)
return;
}
+static void cpu_parse(const char *optarg)
+{
+ char option[128];
+ char *endptr;
+
+ endptr = (char *) get_opt_name(option, 128, optarg, ',');
+ *endptr = '\0';
+ endptr++;
+ if (get_param_value(option, 128, "entitlement", endptr) != 0) {
+ cpu_entitlement = strtoull(option, NULL, 10);
+ }
+ /* Make sure that the entitlement is within 1 - 100 */
+ if (cpu_entitlement < 1 || cpu_entitlement > 100) {
+ fprintf(stderr, "cpu_entitlement=%d is invalid. "
+ "Valid range is 1 - 100\n", cpu_entitlement);
+ cpu_entitlement = 100;
+ }
+}
+
static void smp_parse(const char *optarg)
{
int smp, sockets = 0, threads = 0, cores = 0;
@@ -2359,7 +2380,6 @@ int main(int argc, char **argv, char **envp)
const char *optarg;
const char *loadvm = NULL;
QEMUMachine *machine;
- const char *cpu_model;
const char *vga_model = "none";
const char *pid_file = NULL;
const char *incoming = NULL;
@@ -2472,6 +2492,7 @@ int main(int argc, char **argv, char **envp)
break;
case QEMU_OPTION_cpu:
/* hw initialization will check this */
+ cpu_parse(optarg);
cpu_model = optarg;
break;
case QEMU_OPTION_hda:
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH RFC 2/2] Add an ioctl to pass the entitlement information from qemu to the hypervisor.
2012-08-23 23:15 [Qemu-devel] [PATCH RFC 0/2] Add guest cpu entitlement reporting Michael Wolf
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline Michael Wolf
@ 2012-08-23 23:15 ` Michael Wolf
1 sibling, 0 replies; 4+ messages in thread
From: Michael Wolf @ 2012-08-23 23:15 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, mtosatti, stefanha, avi
Add KVM_SET_ENTITLEMENT ioctl to pass the entitlement to the hypervisor.
Signed-off-by: Michael Wolf <mjw@linux.vnet.ibm.com>
---
cpu-defs.h | 1 +
cpus.c | 1 +
cpus.h | 1 +
kvm-all.c | 1 +
| 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) {
--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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline.
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline Michael Wolf
@ 2012-08-25 7:54 ` Blue Swirl
0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2012-08-25 7:54 UTC (permalink / raw)
To: Michael Wolf; +Cc: avi, aliguori, mtosatti, qemu-devel, stefanha
On Thu, Aug 23, 2012 at 11:15 PM, Michael Wolf <mjw@linux.vnet.ibm.com> wrote:
> The cpu entitlement value will be passed to qemu as part of the cpu parameters.
> Add cpu_parse to read this value from the commandline.
>
> Signed-off-by: Michael Wolf <mjw@linux.vnet.ibm.com>
> ---
> qemu-options.hx | 7 +++++--
> vl.c | 23 ++++++++++++++++++++++-
> 2 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 3c411c4..d13aa24 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -64,9 +64,12 @@ HXCOMM Deprecated by -machine
> DEF("M", HAS_ARG, QEMU_OPTION_M, "", QEMU_ARCH_ALL)
>
> DEF("cpu", HAS_ARG, QEMU_OPTION_cpu,
> - "-cpu cpu select CPU (-cpu ? for list)\n", QEMU_ARCH_ALL)
> + "-cpu cpu[,entitlement=cpu use entitlement %]\n"
> + "select CPU (-cpu ? for list)\n"
> + "entitlement= percentage of cpu that the guest can expect to utilize\n",
> + QEMU_ARCH_ALL)
> STEXI
> -@item -cpu @var{model}
> +@item -cpu @var{model}[,entitlement=@var{entitlement}]
> @findex -cpu
> Select CPU model (-cpu ? for list and additional feature selection)
> ETEXI
> diff --git a/vl.c b/vl.c
> index 7c577fa..8f0c12a 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -205,6 +205,8 @@ CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
> int win2k_install_hack = 0;
> int usb_enabled = 0;
> int singlestep = 0;
> +const char *cpu_model;
> +int cpu_entitlement = 100;
Missing 'static' for the above. I'd merge this patch with the other
patch which uses the variable.
> int smp_cpus = 1;
> int max_cpus = 0;
> int smp_cores = 1;
> @@ -1026,6 +1028,25 @@ static void numa_add(const char *optarg)
> return;
> }
>
> +static void cpu_parse(const char *optarg)
> +{
> + char option[128];
> + char *endptr;
> +
> + endptr = (char *) get_opt_name(option, 128, optarg, ',');
> + *endptr = '\0';
> + endptr++;
> + if (get_param_value(option, 128, "entitlement", endptr) != 0) {
> + cpu_entitlement = strtoull(option, NULL, 10);
strtoul() should be enough.
> + }
> + /* Make sure that the entitlement is within 1 - 100 */
> + if (cpu_entitlement < 1 || cpu_entitlement > 100) {
> + fprintf(stderr, "cpu_entitlement=%d is invalid. "
> + "Valid range is 1 - 100\n", cpu_entitlement);
Exit or tell user that value of 100 is actually used.
> + cpu_entitlement = 100;
> + }
This block belongs inside the previous 'if' block, it's useless to
check the value if the option hasn't been used.
> +}
> +
> static void smp_parse(const char *optarg)
> {
> int smp, sockets = 0, threads = 0, cores = 0;
> @@ -2359,7 +2380,6 @@ int main(int argc, char **argv, char **envp)
> const char *optarg;
> const char *loadvm = NULL;
> QEMUMachine *machine;
> - const char *cpu_model;
> const char *vga_model = "none";
> const char *pid_file = NULL;
> const char *incoming = NULL;
> @@ -2472,6 +2492,7 @@ int main(int argc, char **argv, char **envp)
> break;
> case QEMU_OPTION_cpu:
> /* hw initialization will check this */
> + cpu_parse(optarg);
> cpu_model = optarg;
> break;
> case QEMU_OPTION_hda:
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-08-25 7:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-23 23:15 [Qemu-devel] [PATCH RFC 0/2] Add guest cpu entitlement reporting Michael Wolf
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline Michael Wolf
2012-08-25 7:54 ` Blue Swirl
2012-08-23 23:15 ` [Qemu-devel] [PATCH RFC 2/2] Add an ioctl to pass the entitlement information from qemu to the hypervisor Michael Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).