From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4gcX-0003up-I4 for qemu-devel@nongnu.org; Thu, 23 Aug 2012 19:15:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4gcW-00055M-AA for qemu-devel@nongnu.org; Thu, 23 Aug 2012 19:15:25 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:47188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4gcW-00054R-5t for qemu-devel@nongnu.org; Thu, 23 Aug 2012 19:15:24 -0400 Received: from /spool/local by e6.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Aug 2012 19:15:23 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 6395E6E8039 for ; Thu, 23 Aug 2012 19:15:21 -0400 (EDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7NNFKLV162636 for ; Thu, 23 Aug 2012 19:15:21 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7NNFK3w022129 for ; Thu, 23 Aug 2012 17:15:20 -0600 From: Michael Wolf Date: Thu, 23 Aug 2012 18:15:18 -0500 Message-ID: <20120823231518.11904.84997.stgit@lambeau> In-Reply-To: <20120823231454.11904.35222.stgit@lambeau> References: <20120823231454.11904.35222.stgit@lambeau> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, mtosatti@redhat.com, stefanha@linux.vnet.ibm.com, avi@redhat.com 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 --- 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: