From: Igor Mammedov <imammedo@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: ehabkost@redhat.com, hutao@cn.fujitsu.com, mtosatti@redhat.com,
qemu-devel@nongnu.org, a.motakis@virtualopensystems.com,
Paolo Bonzini <pbonzini@redhat.com>,
gaowanlong@cn.fujitsu.com
Subject: Re: [Qemu-devel] [PATCH 2.1 08/28] vl: convert -m to QemuOpts
Date: Wed, 5 Mar 2014 16:09:31 +0100 [thread overview]
Message-ID: <20140305160931.086242d2@nial.usersys.redhat.com> (raw)
In-Reply-To: <5316F71A.4090004@suse.de>
On Wed, 05 Mar 2014 11:06:18 +0100
Andreas Färber <afaerber@suse.de> wrote:
> Am 04.03.2014 15:00, schrieb Paolo Bonzini:
> > From: Igor Mammedov <imammedo@redhat.com>
> >
> > Adds option to -m
> > "mem" - startup memory amount
>
> Sorry for jumping in late, but assuming that -m is for "memory" already,
> wouldn't it make more sense to name it "size" instead of "mem"?
>
> >
> > For compatibility with legacy CLI if suffix-less number is passed,
> > it assumes amount in Mb.
> >
> > Otherwise user is free to use suffixed number using suffixes b,k/K,M,G
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > qemu-options.hx | 9 +++++---
> > vl.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++-----------
> > 2 files changed, 63 insertions(+), 16 deletions(-)
> >
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index f948f28..98e78ca 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -214,10 +214,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\n"
> > + " configure guest RAM\n"
> > + " mem: initial amount of guest memory (default: "
> > + stringify(DEFAULT_RAM_SIZE) "MiB)\n",
> > + QEMU_ARCH_ALL)
> > STEXI
> > -@item -m @var{megs}
> > +@item -m [mem=]@var{megs}
> > @findex -m
> > Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB. Optionally,
> > a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
> > diff --git a/vl.c b/vl.c
> > index dafe6f6..ac5f425 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -478,6 +478,20 @@ static QemuOptsList qemu_msg_opts = {
> > },
> > };
> >
> > +static QemuOptsList qemu_mem_opts = {
> > + .name = "memory",
> > + .implied_opt_name = "mem",
> > + .head = QTAILQ_HEAD_INITIALIZER(qemu_mem_opts.head),
> > + .merge_lists = true,
> > + .desc = {
> > + {
> > + .name = "mem",
> > + .type = QEMU_OPT_SIZE,
> > + },
> > + { /* end of list */ }
> > + },
> > +};
> > +
> > /**
> > * Get machine options
> > *
> > @@ -2718,6 +2732,7 @@ int main(int argc, char **argv, char **envp)
> > };
> > const char *trace_events = NULL;
> > const char *trace_file = NULL;
> > + const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE * 1024 * 1024;
> >
> > atexit(qemu_run_exit_notifiers);
> > error_set_progname(argv[0]);
> > @@ -2758,6 +2773,7 @@ int main(int argc, char **argv, char **envp)
> > qemu_add_opts(&qemu_realtime_opts);
> > qemu_add_opts(&qemu_msg_opts);
> > qemu_add_opts(&qemu_numa_opts);
> > + qemu_add_opts(&qemu_mem_opts);
> >
> > runstate_init();
> >
> > @@ -2773,7 +2789,7 @@ int main(int argc, char **argv, char **envp)
> > module_call_init(MODULE_INIT_MACHINE);
> > machine = find_default_machine();
> > cpu_model = NULL;
> > - ram_size = 0;
> > + ram_size = default_ram_size;
> > snapshot = 0;
> > cyls = heads = secs = 0;
> > translation = BIOS_ATA_TRANSLATION_AUTO;
> > @@ -3063,20 +3079,50 @@ 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 *mem_str;
> >
> > - value = strtosz(optarg, &end);
> > - if (value < 0 || *end) {
> > - fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
> > - exit(1);
> > + opts = qemu_opts_parse(qemu_find_opts("memory"),
> > + optarg, 1);
> > + if (!opts) {
> > + exit(EXIT_FAILURE);
> > + }
> > +
> > + mem_str = qemu_opt_get(opts, "mem");
> > + if (!mem_str) {
> > + fprintf(stderr, "qemu: invalid -m option, missing "
> > + "'mem' option\n");
>
> error_report(), in particular to fix "qemu: "
>
> > + exit(EXIT_FAILURE);
> > + }
> > + if (!*mem_str) {
> > + fprintf(stderr, "qemu: missing 'mem' option value\n");
>
> error_report()
>
> > + exit(EXIT_FAILURE);
> > + }
> > +
> > + sz = qemu_opt_get_size(opts, "mem", ram_size);
> > +
> > + /* Fix up legacy suffix-less format */
> > + if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) {
> > + uint64_t overflow_check = sz;
> > +
> > + sz <<= 20;
> > + if ((sz >> 20) != overflow_check) {
> > + fprintf(stderr, "qemu: too large 'mem' option "
> > + "value\n");
>
> error_report()
>
> > + exit(EXIT_FAILURE);
> > + }
> > + }
> > +
> > + /* backward compatibility behaviour for case "-m 0" */
> > + if (sz == 0) {
> > + sz = default_ram_size;
> > }
> > - sz = QEMU_ALIGN_UP((uint64_t)value, 8192);
> > +
> > + sz = QEMU_ALIGN_UP(sz, 8192);
> > ram_size = sz;
> > if (ram_size != sz) {
> > fprintf(stderr, "qemu: ram size too large\n");
>
> error_report() while at it?
>
> > - exit(1);
> > + exit(EXIT_FAILURE);
> > }
> > break;
> > }
> > @@ -3921,10 +3967,8 @@ int main(int argc, char **argv, char **envp)
> > exit(1);
> > }
> >
> > - /* init the memory */
> > - if (ram_size == 0) {
> > - ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
> > - }
> > + /* store value for the future use */
> > + qemu_opt_set_number(qemu_find_opts_singleton("memory"), "mem", ram_size);
> >
> > if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, 0)
> > != 0) {
>
> Here's a dependency on the preceding patch - other than that, these two
> could be applied independently of the rest via qemu-trivial?
I'll amend patch according to your notes and resubmit it with its only dependency
CCing trivial-patches this time.
>
> Regards,
> Andreas
>
next prev parent reply other threads:[~2014-03-05 15:10 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 14:00 [Qemu-devel] [PATCH 2.1 00/28] Current state of NUMA series, and hostmem improvements Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 01/28] NUMA: move numa related code to new file numa.c Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 02/28] NUMA: check if the total numa memory size is equal to ram_size Paolo Bonzini
2014-03-04 17:00 ` Eric Blake
2014-03-04 17:19 ` Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 03/28] NUMA: Add numa_info structure to contain numa nodes info Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 04/28] NUMA: convert -numa option to use OptsVisitor Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 05/28] NUMA: expand MAX_NODES from 64 to 128 Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 06/28] man: improve -numa doc Paolo Bonzini
2014-03-11 18:53 ` Eduardo Habkost
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 07/28] qemu-option: introduce qemu_find_opts_singleton Paolo Bonzini
2014-03-05 10:08 ` Andreas Färber
2014-03-07 2:27 ` Hu Tao
2014-03-11 18:55 ` Eduardo Habkost
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 08/28] vl: convert -m to QemuOpts Paolo Bonzini
2014-03-05 10:06 ` Andreas Färber
2014-03-05 10:31 ` Paolo Bonzini
2014-03-05 15:09 ` Igor Mammedov [this message]
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 09/28] vl: redo -object parsing Paolo Bonzini
2014-03-07 2:56 ` Hu Tao
2014-03-07 7:39 ` Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 10/28] qmp: allow object-add completion handler to get canonical path Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 11/28] qmp: improve error reporting for -object and object-add Paolo Bonzini
2014-03-07 3:07 ` Hu Tao
2014-03-07 7:57 ` Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 12/28] pc: pass QEMUMachineInitArgs to pc_memory_init Paolo Bonzini
2014-03-07 3:09 ` Hu Tao
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 13/28] numa: introduce memory_region_allocate_system_memory Paolo Bonzini
2014-03-07 3:18 ` Hu Tao
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 14/28] add memdev backend infrastructure Paolo Bonzini
2014-03-07 3:31 ` Hu Tao
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 15/28] numa: add -numa node, memdev= option Paolo Bonzini
2014-03-04 17:52 ` Eric Blake
2014-03-07 5:33 ` Hu Tao
2014-03-07 7:41 ` Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 16/28] memory: reorganize file-based allocation Paolo Bonzini
2014-03-07 6:09 ` Hu Tao
2014-03-07 6:34 ` Hu Tao
2014-03-07 7:47 ` Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 17/28] memory: move mem_path handling to memory_region_allocate_system_memory Paolo Bonzini
2014-03-11 3:50 ` Hu Tao
2014-03-11 8:03 ` Paolo Bonzini
2014-03-12 2:08 ` Marcelo Tosatti
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 18/28] memory: add error propagation to file-based RAM allocation Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 19/28] memory: move preallocation code out of exec.c Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 20/28] memory: move RAM_PREALLOC_MASK to exec.c, rename Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 21/28] hostmem: add file-based HostMemoryBackend Paolo Bonzini
2014-03-04 17:38 ` Eric Blake
2014-03-04 18:12 ` Paolo Bonzini
2014-03-07 6:57 ` Hu Tao
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 22/28] hostmem: separate allocation from UserCreatable complete method Paolo Bonzini
2014-03-07 7:08 ` Hu Tao
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 23/28] hostmem: add merge and dump properties Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 24/28] hostmem: allow preallocation of any memory region Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 25/28] hostmem: add property to map memory with MAP_SHARED Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 26/28] configure: add Linux libnuma detection Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 27/28] hostmem: add properties for NUMA memory policy Paolo Bonzini
2014-03-04 14:00 ` [Qemu-devel] [PATCH 2.1 28/28] qmp: add query-memdev Paolo Bonzini
2014-03-04 17:37 ` Eric Blake
2014-03-04 18:11 ` Paolo Bonzini
2014-03-05 3:50 ` Hu Tao
2014-03-05 8:17 ` Paolo Bonzini
2014-03-05 3:48 ` Hu Tao
2014-03-05 11:05 ` [Qemu-devel] [PATCH 2.1 00/28] Current state of NUMA series, and hostmem improvements Andreas Färber
2014-03-05 11:30 ` Paolo Bonzini
2014-03-07 11:59 ` Andreas Färber
2014-03-07 12:20 ` Paolo Bonzini
2014-03-07 12:56 ` Igor Mammedov
2014-03-07 13:35 ` Paolo Bonzini
2014-03-07 14:54 ` 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=20140305160931.086242d2@nial.usersys.redhat.com \
--to=imammedo@redhat.com \
--cc=a.motakis@virtualopensystems.com \
--cc=afaerber@suse.de \
--cc=ehabkost@redhat.com \
--cc=gaowanlong@cn.fujitsu.com \
--cc=hutao@cn.fujitsu.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).