qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: vasilis.liaskovitis@profitbricks.com, hutao@cn.fujitsu.com,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/16] vl: convert -m to qemu_opts_parse()
Date: Tue, 23 Jul 2013 19:11:31 +0200	[thread overview]
Message-ID: <51EEB943.7080306@redhat.com> (raw)
In-Reply-To: <1374596592-7027-4-git-send-email-imammedo@redhat.com>

Il 23/07/2013 18:22, Igor Mammedov ha scritto:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  qemu-options.hx |    9 +++++++--
>  vl.c            |   53 +++++++++++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 54 insertions(+), 8 deletions(-)
> 
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 137a39b..f799b3d 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -210,8 +210,13 @@ use is discouraged as it may be removed from future versions.
>  ETEXI
>  
>  DEF("m", HAS_ARG, QEMU_OPTION_m,
> -    "-m megs         set virtual RAM size to megs MB [default="
> -    stringify(DEFAULT_RAM_SIZE) "]\n", QEMU_ARCH_ALL)
> +    "-m [mem=]megs[,slots=n,maxmem=size]\n"
> +    "                set virtual RAM size to megs MB [default="
> +    stringify(DEFAULT_RAM_SIZE) "]\n"
> +    "                mem=start-up memory amount\n"
> +    "                slots=maximum number of hotplug slots\n"
> +    "                maxmem=maximum total amount of memory\n",
> +    QEMU_ARCH_ALL)
>  STEXI
>  @item -m @var{megs}
>  @findex -m
> diff --git a/vl.c b/vl.c
> index bf0c658..16c6f1e 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -516,6 +516,27 @@ static QemuOptsList qemu_realtime_opts = {
>      },
>  };
>  
> +static QemuOptsList qemu_mem_opts = {
> +    .name = "memory-opts",
> +    .implied_opt_name = "mem",
> +    .head = QTAILQ_HEAD_INITIALIZER(qemu_mem_opts.head),

This should have

    .merge_lists = true,

Paolo

> +    .desc = {
> +        {
> +            .name = "mem",
> +            .type = QEMU_OPT_SIZE,
> +        },
> +        {
> +            .name = "slots",
> +            .type = QEMU_OPT_NUMBER,
> +        },
> +        {
> +            .name = "maxmem",
> +            .type = QEMU_OPT_SIZE,
> +        },
> +        { /* end of list */ }
> +    },
> +};
> +
>  const char *qemu_get_vm_name(void)
>  {
>      return qemu_name;
> @@ -2933,6 +2954,7 @@ int main(int argc, char **argv, char **envp)
>      qemu_add_opts(&qemu_object_opts);
>      qemu_add_opts(&qemu_tpmdev_opts);
>      qemu_add_opts(&qemu_realtime_opts);
> +    qemu_add_opts(&qemu_mem_opts);
>  
>      runstate_init();
>  
> @@ -3224,21 +3246,40 @@ int main(int argc, char **argv, char **envp)
>                  exit(0);
>                  break;
>              case QEMU_OPTION_m: {
> -                int64_t value;
>                  uint64_t sz;
> -                char *end;
> +                const char *end;
> +                char *s;
>  
> -                value = strtosz(optarg, &end);
> -                if (value < 0 || *end) {
> -                    fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
> +                opts = qemu_opts_parse(qemu_find_opts("memory-opts"),
> +                                       optarg, 1);
> +                if (!opts) {
>                      exit(1);
>                  }
> -                sz = QEMU_ALIGN_UP((uint64_t)value, 8192);
> +
> +                /* fixup legacy sugffix-less format */
> +                end = qemu_opt_get(opts, "mem");
> +                if (g_ascii_isdigit(end[strlen(end) - 1])) {
> +                    s = g_strconcat(end, "M", NULL);
> +                    qemu_opt_set(opts, "mem", s);
> +                    g_free(s);
> +                }
> +
> +                sz = QEMU_ALIGN_UP(qemu_opt_get_size(opts, "mem", 0), 8192);
>                  ram_size = sz;
>                  if (ram_size != sz) {
>                      fprintf(stderr, "qemu: ram size too large\n");
>                      exit(1);
>                  }
> +                /* store aligned value for future use */
> +                s = g_strdup_printf("%" PRIu64, sz);
> +                qemu_opt_set(opts, "mem", s);
> +                g_free(s);
> +
> +                sz = qemu_opt_get_size(opts, "maxmem", ram_size);
> +                if (sz < ram_size) {
> +                    fprintf(stderr, "qemu: maxmem must be > initial memory\n");
> +                    exit(1);
> +                }
>                  break;
>              }
>  #ifdef CONFIG_TPM
> 

  reply	other threads:[~2013-07-23 17:11 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 16:22 [Qemu-devel] [PATCH 00/16 RFC v6] ACPI memory hotplug Igor Mammedov
2013-07-23 16:22 ` [Qemu-devel] [PATCH 01/16] pc: use pci_hole64 info consistently Igor Mammedov
2013-07-23 16:22 ` [Qemu-devel] [PATCH 02/16] vl: set default ram_size during variable initialization Igor Mammedov
2013-08-02 20:33   ` Andreas Färber
2013-09-09 14:06     ` Igor Mammedov
2013-09-09 14:31       ` Paolo Bonzini
2013-09-09 15:26         ` Igor Mammedov
2013-07-23 16:22 ` [Qemu-devel] [PATCH 03/16] vl: convert -m to qemu_opts_parse() Igor Mammedov
2013-07-23 17:11   ` Paolo Bonzini [this message]
2013-07-24  8:40     ` Igor Mammedov
2013-07-24  9:04       ` Paolo Bonzini
2013-07-24  9:27         ` Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 04/16] qapi: make visit_type_size fallback to type_int Igor Mammedov
2013-07-25  6:41   ` Hu Tao
2013-07-25 11:35     ` Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 05/16] qdev: Add SIZE type to qdev properties Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 06/16] dimm: implement dimm device abstraction Igor Mammedov
2013-07-25  6:52   ` Hu Tao
2013-07-23 16:23 ` [Qemu-devel] [PATCH 07/16] dimm: map DimmDevice into DimBus provided address space Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 08/16] pc: piix: make hotplug memory gap in high memory Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 09/16] pc: i440fx: add DimmBus to chipset and map it into hotplug memory region Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 10/16] dimm: add busy slot check and slot auto-allocation Igor Mammedov
2013-07-23 17:09   ` Paolo Bonzini
2013-07-24  8:36     ` Igor Mammedov
2013-07-24  9:41       ` Paolo Bonzini
2013-07-24 11:34         ` Igor Mammedov
2013-07-24 12:41           ` Paolo Bonzini
2013-07-26  7:38             ` Igor Mammedov
2013-07-26  9:26               ` Paolo Bonzini
2013-07-26 12:51                 ` Igor Mammedov
2013-07-26 14:37                   ` Paolo Bonzini
2013-08-03 13:56                     ` Andreas Färber
2013-09-11 15:12                       ` Igor Mammedov
2013-08-06  7:13                     ` Markus Armbruster
2013-07-23 16:23 ` [Qemu-devel] [PATCH 11/16] dimm: add busy address check and address auto-allocation Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 12/16] dimm: introduce memory added notifier Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 13/16] acpi/piix4: introduce memory hot-plug interface QEMU<->ACPI BIOS Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 14/16] pc: ACPI BIOS: implement memory hotplug interface Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 15/16] pc: update acpi-dsdt.hex.generated and add ssdt-mem.hex.generated Igor Mammedov
2013-07-23 16:23 ` [Qemu-devel] [PATCH 16/16] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole Igor Mammedov
2013-07-24  9:52 ` [Qemu-devel] [PATCH 00/16 RFC v6] ACPI memory hotplug Hu Tao
2013-07-24 10:02   ` Igor Mammedov
2013-07-24 10:58     ` Vasilis Liaskovitis
2013-08-02 12:35 ` Anthony Liguori
2013-08-07 14:14   ` Erlon Cruz
2013-08-09 17:19   ` Anthony Liguori
2013-09-11  4:01 ` Hu Tao
2013-09-17 12:29   ` Igor Mammedov

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=51EEB943.7080306@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vasilis.liaskovitis@profitbricks.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).