qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Wolf <mjw@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, mtosatti@redhat.com,
	stefanha@linux.vnet.ibm.com, avi@redhat.com
Subject: [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline.
Date: Thu, 23 Aug 2012 18:15:18 -0500	[thread overview]
Message-ID: <20120823231518.11904.84997.stgit@lambeau> (raw)
In-Reply-To: <20120823231454.11904.35222.stgit@lambeau>

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:

  reply	other threads:[~2012-08-23 23:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2012-08-25  7:54   ` [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120823231518.11904.84997.stgit@lambeau \
    --to=mjw@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).