qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH RFC 1/2] Parse the cpu entitlement from the qemu commandline.
Date: Sat, 25 Aug 2012 07:54:13 +0000

On Thu, Aug 23, 2012 at 11:15 PM, Michael Wolf <address@hidden> 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 <address@hidden>
> ---
>  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
> address@hidden -cpu @var{model}
> address@hidden -cpu @var{model}[,address@hidden
>  @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:
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]