qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, stefanha@redhat.com,
	mst@redhat.com, hutao@cn.fujitsu.com, stefanb@linux.vnet.ibm.com,
	mjt@tls.msk.ru, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com,
	vasilis.liaskovitis@profitbricks.com, quintela@redhat.com,
	kraxel@redhat.com, aliguori@amazon.com, pbonzini@redhat.com,
	marcel.a@redhat.com, lcapitulino@redhat.com, chegu_vinod@hp.com,
	afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse()
Date: Wed, 27 Nov 2013 16:28:33 +0100	[thread overview]
Message-ID: <20131127162833.5cdbbc53@nial.usersys.redhat.com> (raw)
In-Reply-To: <874n6x7w0y.fsf@blackfin.pond.sub.org>

On Wed, 27 Nov 2013 15:35:09 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> Igor Mammedov <imammedo@redhat.com> writes:
> 
> > On Tue, 26 Nov 2013 15:49:05 +0100
> > Markus Armbruster <armbru@redhat.com> wrote:
> >
> >> Igor Mammedov <imammedo@redhat.com> writes:
> >> 
> >> > On Thu, 21 Nov 2013 11:12:43 +0100
> >> > Markus Armbruster <armbru@redhat.com> wrote:
> >> >
> >> >> Igor Mammedov <imammedo@redhat.com> writes:
> >> >> 
> > [...]
> >> Two separate issues here:
> >> 
> >> 1. The "no qemu_mem_opts have been specified" case
> >> 
> >>    This is equivalent to "empty options".  Therefore, the case can be
> >>    eliminated by pre-creating empty options.  No objection.
> >> 
> >>    The three existing merge_lists users don't do that.  Perhaps they
> >>    should.
> >> 
> >> 2. How to provide default values
> >> 
> >>    Supplying defaults is left to the caller of qemu_opt_get_FOO() by
> >>    design.
> >> 
> >>    Pre-creating option parameters deviates from that pattern.  You
> >>    justify it by saying it "eliminates need to pepper code with
> >>    DEFAULT_RAM_SIZE * 1024 * 1024".  How many occurrences?
> > beside of vl.c for:
> >   mem & maxmem 1 in hw/i386/pc.c
> >   slots - 6 in several files
> 
> Could the common code be factored out the old-fashioned way?
replacing one one-liner with another might help a little but
won't change a thing in general. It will be essentially the same.

> 
> Precedence: qemu_get_machine_opts() encapsulates some QemuOpts-related
> details, so its many users don't have to deal with them.
> 
> > see below for continuation:
> >
> >> 
> >>    Drawback: you lose the ability to see whether the user gave a value.
> >>    See below.
> >> 
> > [...]
> >> >> Ugly.
> >> >> 
> >> >> Why is the variable called 'end'?
> >> > would be 'suffix' better?
> >> 
> >> end points to the whole value string, not the end of anything, and
> >> neither to a suffix of anything.
> > Any suggestions?
> 
> What about val?
I've replaced it with "mem_str" see
"[PATCH 04/28] vl: convert -m to QemuOpts"

> 
> > [...]
> >> >> If you refrain from putting defaults into opts, you can distinguish the
> >> >> cases "user didn't specify maxmem, so assume mem", and "user specified
> >> >> maxmem, so check it's >= mem".
> >> > So foar, there is no point in distinguishing above cases,
> >> > since maxmem <= mem is invalid value and hotplug should be disabled.
> >> > So setting default maxmem to mem or anything less effectively
> >> > disables hotplug.
> >> 
> >> Yes, setting maxmem < mem is invalid and should be rejected, but not
> >> setting maxmem at all should be accepted even when you set mem.
> >> 
> >> Your patch like this pseudo-code:
> >> 
> >>     mem = DEFAULT_RAM_SIZE * 1024 * 1024
> >>     maxmem = mem
> >> 
> >>     if user specifies mem:
> >>         mem = user's mem
> >>     if user specifes max-mem:
> >>         mem = user's max-mem
> >> 
> >>     if max-mem < mem
> >>         what now?
> >>         should error our if max-mem and mem were specified by the user
> >>         shouldn't if user didn't specify max-mem!
> >>         but can't say whether he did
> >> 
> >> I'd do it this way:
> >> 
> >>     mem = unset
> >>     maxmem = unset
> >> 
> >>     if user specifies mem:
> >>         mem = user's mem
> >>     if user specifes max-mem:
> >>         mem = user's max-mem
> >> 
> >>     if mem != unset && max-mem != unset && max-mem < mem
> >>         error
> >>
> >> I'd use QemuOpts for the user's command line, and no more.  For anything
> >> beyond that, I'd use ordinary variables, such as ram_size.
> > Ok, I'll revert to the old code where options users check for option
> > availability, it's not that much code.
> >
> >
> > As for using QemuOpts as global store for global variables:
> >
> >  * using local variables would require changing of machine init or/and
> >    QEMUMachine and changing functions signature pass them down the stack to
> >    consumers.
> 
> Extending QEMUMachineInitArgs should suffice.  Once you're inside the
> board code, passing stuff around as C parameters is probably an
> improvement over passing around QemuOpts.
> 
> >  * adding "slots" readonly property to i440fx & q35 for consumption in
> >    ACPI hotplug code and building ACPI tables. It would be essentially another
> >    global lookup for i440fx & q35  object and pulling "slots" property,
> >    which is much longer way/complex way to get global value. That's a lot of
> >    boilerplate code for the same outcome.
> 
> Can't say without seeing the code.
> 
> >  * about setting default for "mem" value: if default "mem" is not set and
> >    no -m is provided on CLI, we get case where
> >       ram_size = foo & "mem" unset  
> >    And if I recall correctly there was an effort to provide interface for
> >    currently used QemuOpts to external users. So "mem" would get inconsistent
> >    with what QEMU uses.
> 
> QemuOpts do not record what QEMU uses.  They record what the user asked
> for.
> 
> > To sum up above said:
> >  * I'd like to continue using QemuOpts as global constant value store, it
> >    saves from adding a lot of boilerplate-code that would do the same.
> 
> Keeping the user's configuration just in QemuOpts is fine.  What I don't
> like is messing with it there.  This includes storing defaults.
> 
> Here's another reason: -writeconfig should write out exactly the user's
> configuration.  If you mess with it, it may write out messed up
> configuration, depending on *when* you mess with it.
> 
> >    Doing
> >      "git grep qemu_get_machine_opts"
> >    gets us several precedents that already use it that way.
> 
> Note that it does *not* store defaults in QemuOpts, it only creates
> empty opts.  I'm not sure that was a good idea.
I've dropped completely defaults setting in QemuOpts please see:
 "[PATCH 04/28] vl: convert -m to QemuOpts"
 "[PATCH 05/28] vl.c: extend -m option to support options for memory hotplug"

As for ">it only creates empty opts." I'm confused.
qemu_opt_get(qemu_get_machine_opts(), "foo")  pattern showed by grep  is the same
as I use to get "slots/maxmem":

exec.c:    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "mem-merge", true)) {
hw/arm/boot.c:    info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
hw/ppc/spapr.c:    const char *drivename = qemu_opt_get(qemu_get_machine_opts(), "nvram");
hw/ppc/virtex_ml507.c:    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
include/sysemu/sysemu.h:QemuOpts *qemu_get_machine_opts(void);
kvm-all.c:    if (!qemu_opt_get_bool(qemu_get_machine_opts(), "kernel_irqchip", true) ||
target-i386/kvm.c:    shadow_mem = qemu_opt_get_size(qemu_get_machine_opts(),

probably it is there because passing them as C parameters is more intrusive than 
just using user supplied values directly.

> >  * I believe that setting default in QemuOpts for "mem" is a good thing that
> >    leads to consistent meaning of "mem" with what QEMU actually uses.
> 
> I'm not sure I got this argument.
I can easily drop this hunk from "[PATCH 04/28] vl: convert -m to QemuOpts",
I've posted tonight as reply to this thread,
since ram_size is already passed to machine_init(), it's not worth arguing.

  reply	other threads:[~2013-11-27 15:29 UTC|newest]

Thread overview: 143+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21  2:38 [Qemu-devel] [PATCH 00/27 RFC v7] ACPI memory hotplug Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 01/27] acpi: factor out common pm_update_sci() into acpi core Igor Mammedov
2013-12-05 12:37   ` Michael S. Tsirkin
2013-12-05 15:11     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 02/27] rename pci_hotplug_fn to hotplug_fn and make it available for other devices Igor Mammedov
2013-11-25 12:49   ` Paolo Bonzini
2013-11-25 13:11     ` Paolo Bonzini
2013-11-25 15:57     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 03/27] pc: add 'etc/reserved-memory-end' fw_cfg interface for SeaBIOS Igor Mammedov
2013-12-19 14:35   ` Michael S. Tsirkin
2013-12-20 12:48     ` Igor Mammedov
2013-12-22 11:20       ` Michael S. Tsirkin
2013-11-21  2:38 ` [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse() Igor Mammedov
2013-11-21  6:01   ` Li Guang
2013-11-21 13:45     ` Igor Mammedov
2013-11-21 10:12   ` Markus Armbruster
2013-11-26 13:17     ` Igor Mammedov
2013-11-26 14:49       ` Markus Armbruster
2013-11-26 16:55         ` Igor Mammedov
2013-11-27 14:35           ` Markus Armbruster
2013-11-27 15:28             ` Igor Mammedov [this message]
2013-11-27 17:31               ` Markus Armbruster
2013-11-27  0:27         ` [Qemu-devel] [PATCH 04/28] vl: convert -m to QemuOpts Igor Mammedov
2013-11-27  0:27           ` [Qemu-devel] [PATCH 05/28] vl.c: extend -m option to support options for memory hotplug Igor Mammedov
2013-12-10  7:23           ` [Qemu-devel] [PATCH 04/28] vl: convert -m to QemuOpts Paolo Bonzini
2013-12-10 10:53             ` Igor Mammedov
2013-11-25 12:51   ` [Qemu-devel] [PATCH 04/27] vl: convert -m to qemu_opts_parse() Paolo Bonzini
2013-11-27  0:32     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor Igor Mammedov
2013-11-21 10:15   ` Markus Armbruster
2013-11-25 15:36     ` Igor Mammedov
2013-11-25 16:04       ` Michael S. Tsirkin
2013-11-25 16:32         ` Paolo Bonzini
2013-11-25 16:43           ` Eric Blake
2013-11-25 17:01             ` Paolo Bonzini
2013-11-27 14:15             ` Markus Armbruster
2013-11-27 15:17               ` Paolo Bonzini
2013-11-27 17:02                 ` Markus Armbruster
2013-11-27 17:10                   ` Paolo Bonzini
2013-12-19 14:40             ` Michael S. Tsirkin
2013-12-19 15:14               ` Markus Armbruster
2013-12-19 15:32                 ` Michael S. Tsirkin
2013-12-19 15:31               ` Paolo Bonzini
2013-12-19 15:40                 ` Michael S. Tsirkin
2013-12-19 15:46                   ` Paolo Bonzini
2013-11-21  2:38 ` [Qemu-devel] [PATCH 06/27] get reference to /backend container via qemu_get_backend() Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 07/27] add memdev backend infrastructure Igor Mammedov
2013-11-25 12:54   ` Paolo Bonzini
2013-11-25 16:01     ` Igor Mammedov
2013-11-25 16:09       ` Paolo Bonzini
2013-11-27 14:37         ` Igor Mammedov
2013-11-27 15:21           ` Paolo Bonzini
2013-11-27 15:57             ` Igor Mammedov
2013-11-27 15:25   ` Eric Blake
2013-11-27 16:09     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 08/27] dimm: implement dimm device abstraction Igor Mammedov
2013-11-25 12:57   ` Paolo Bonzini
2013-11-25 15:10     ` Igor Mammedov
2013-11-25 15:16       ` Paolo Bonzini
2013-11-21  2:38 ` [Qemu-devel] [PATCH 09/27] dimm: map DimmDevice into DimBus provided address space Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 10/27] dimm: add busy slot check and slot auto-allocation Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 11/27] dimm: add busy address check and address auto-allocation Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 12/27] dimm: add hotplug callback to DimmBus Igor Mammedov
2013-11-25 13:01   ` Paolo Bonzini
2013-11-25 14:40     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 13/27] acpi: memory hotplug ACPI hardware implementation Igor Mammedov
2013-11-21  9:42   ` Michael S. Tsirkin
2013-11-21 14:21     ` Igor Mammedov
2013-11-21 14:38       ` Michael S. Tsirkin
2013-11-22 17:14         ` Igor Mammedov
2013-11-24 10:58           ` Michael S. Tsirkin
2013-11-25  7:27             ` Markus Armbruster
2013-11-25 13:45               ` Paolo Bonzini
2013-11-25 14:18                 ` Igor Mammedov
2013-11-25 14:31                   ` Paolo Bonzini
2013-11-25 14:57                     ` Igor Mammedov
2013-11-25 13:56             ` Igor Mammedov
2013-11-27 17:59   ` Eric Blake
2013-11-21  2:38 ` [Qemu-devel] [PATCH 14/27] acpi: initialize memory hotplug ACPI PIIX4 hardware Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 15/27] acpi: piix4: add memory-hotplug-io-base property to piix4_pm Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 16/27] acpi: ich9: allow guest to clear SCI rised by GPE Igor Mammedov
2013-11-21  7:14   ` Michael S. Tsirkin
2013-11-21  8:12     ` Hu Tao
2013-11-21  8:18       ` Li Guang
2013-11-21  8:29         ` Michael S. Tsirkin
2013-11-21  8:32           ` Li Guang
2013-11-21  9:43             ` Michael S. Tsirkin
2013-11-22  0:57               ` Li Guang
2013-11-25 11:13                 ` Igor Mammedov
2013-11-26  0:29                   ` Li Guang
2013-11-26 22:36                     ` Igor Mammedov
2013-11-27  0:15                       ` Li Guang
2013-11-27  0:57                         ` Igor Mammedov
2013-11-27  1:48                           ` Li Guang
2013-11-27  9:43                             ` Paolo Bonzini
2013-11-21 13:19             ` Igor Mammedov
2013-11-22  1:03               ` Li Guang
2013-11-21  8:26       ` Michael S. Tsirkin
2013-11-21  8:28         ` Hu Tao
2013-11-21 13:31           ` Igor Mammedov
2013-11-21 13:21         ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 17/27] acpi: initialize memory hotplug ACPI ICH9 hardware Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 18/27] acpi: ich9: add memory-hotplug-io-base property to ich9_pm Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 19/27] acpi: piix4/ich9: add optional vmstate field for MemHotplugState migration Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 20/27] pc: piix: make PCII440FXState type public Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 21/27] pc: add memory hotplug 440fx machine Igor Mammedov
2013-11-21  5:48   ` Li Guang
2013-11-21 14:13     ` Andreas Färber
2013-11-21 14:34       ` Igor Mammedov
2013-11-21 14:39         ` Michael S. Tsirkin
2013-11-21 16:09         ` Andreas Färber
2013-11-21 16:17           ` Michael S. Tsirkin
2013-11-25 10:41           ` Igor Mammedov
2013-11-25 17:00             ` Andreas Färber
2013-11-26 20:26               ` Igor Mammedov
2013-11-22 14:23   ` Gerd Hoffmann
2013-11-25 11:00     ` Igor Mammedov
2013-11-25 11:39       ` Gerd Hoffmann
2013-11-25 13:34         ` Igor Mammedov
2013-11-25 13:35         ` Paolo Bonzini
2013-11-25 14:24           ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 22/27] pc: add memory hotplug Q35 machine Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 23/27] pc: ACPI BIOS: implement memory hotplug interface Igor Mammedov
2013-11-21  9:37   ` Michael S. Tsirkin
2013-11-25 14:39     ` Igor Mammedov
2013-12-16 19:50       ` Michael S. Tsirkin
2013-12-16 21:42         ` Igor Mammedov
2013-11-25 13:42   ` Paolo Bonzini
2013-11-25 14:26     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 24/27] pc: ACPI BIOS: add ssdt-mem.hex.generated and update ssdt-misc.hex.generated Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 25/27] pc: ACPI BIOS: use enum for defining memory affinity flags Igor Mammedov
2013-11-21  7:20   ` Michael S. Tsirkin
2013-11-25 10:11     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 26/27] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole Igor Mammedov
2013-11-21  7:18   ` Michael S. Tsirkin
2013-11-25 10:11     ` Igor Mammedov
2013-11-21  2:38 ` [Qemu-devel] [PATCH 27/27] pc: ACPI BIOS: make GPE.3 handle memory hotplug event on PIIX and Q35 machines Igor Mammedov
2013-11-21  6:20 ` [Qemu-devel] [PATCH 00/27 RFC v7] ACPI memory hotplug Michael S. Tsirkin
2013-11-21 13:39   ` Igor Mammedov
2013-11-21 13:43     ` Michael S. Tsirkin
2013-11-21 14:37       ` Igor Mammedov
2013-11-21 14:45         ` Michael S. Tsirkin
2013-11-25 10:09           ` 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=20131127162833.5cdbbc53@nial.usersys.redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=chegu_vinod@hp.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mjt@tls.msk.ru \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@redhat.com \
    --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).