All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: peter.maydell@linaro.org, sbhat@linux.ibm.com, david@redhat.com,
	richard.henderson@linaro.org, qemu-devel@nongnu.org,
	shameerali.kolothum.thodi@huawei.com,
	Markus Armbruster <armbru@redhat.com>,
	Eric Auger <eric.auger@redhat.com>,
	qemu-arm@nongnu.org, pbonzini@redhat.com,
	eric.auger.pro@gmail.com
Subject: Re: [Qemu-devel] [PATCH v2] machine: Move acpi_nvdimm_state into struct MachineState
Date: Thu, 7 Mar 2019 09:44:19 -0300	[thread overview]
Message-ID: <20190307124419.GA8899@habkost.net> (raw)
In-Reply-To: <20190307104859.248a7608@redhat.com>

On Thu, Mar 07, 2019 at 10:48:59AM +0100, Igor Mammedov wrote:
[...]
> > +static void machine_set_nvdimm_persistence(Object *obj, const char *value,
> > +                                               Error **errp)
> > +{
> > +    MachineState *ms = MACHINE(obj);
> > +    AcpiNVDIMMState *nvdimms_state = &ms->nvdimms_state;
> > +
> > +    if (strcmp(value, "cpu") == 0)
> > +        nvdimms_state->persistence = 3;
> we probably should use QAPI enum magic to handle description to value conversion
> but I don't know how to (CCed Markus).

QEMU is not very consistent in this.  I have found at least 3
different methods for registering enum properties:

1) qdev PropertyInfo using set_enum/get_enum.  Examples:
   DEFINE_PROP_ON_OFF_AUTO, DEFINE_PROP_LOSTTICKPOLICY.
2) object_property_add() + visit_type_...().  Examples:
   machine_set_kernel_irqchip(), pc_machine_set_vmport(),
   pc_machine_set_smm().
3) object_property_add_add_enum() and object_class_property_add_enum().  Examples:
   qauthz_list_prop_set_policy(), host_memory_backend_set_policy(),
   qcrypto_secret_prop_set_format(), netfilter_set_direction().

> But since it's just moving existing code, it do not insist and it could be
> done on top later on.

Agreed, but I think we should at least add a TODO comment
indicating the code is not a good example to be followed.

-- 
Eduardo

WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Habkost <ehabkost@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Eric Auger <eric.auger@redhat.com>,
	eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
	qemu-arm@nongnu.org, peter.maydell@linaro.org,
	shameerali.kolothum.thodi@huawei.com, david@redhat.com,
	pbonzini@redhat.com, richard.henderson@linaro.org,
	sbhat@linux.ibm.com, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] machine: Move acpi_nvdimm_state into struct MachineState
Date: Thu, 7 Mar 2019 09:44:19 -0300	[thread overview]
Message-ID: <20190307124419.GA8899@habkost.net> (raw)
In-Reply-To: <20190307104859.248a7608@redhat.com>

On Thu, Mar 07, 2019 at 10:48:59AM +0100, Igor Mammedov wrote:
[...]
> > +static void machine_set_nvdimm_persistence(Object *obj, const char *value,
> > +                                               Error **errp)
> > +{
> > +    MachineState *ms = MACHINE(obj);
> > +    AcpiNVDIMMState *nvdimms_state = &ms->nvdimms_state;
> > +
> > +    if (strcmp(value, "cpu") == 0)
> > +        nvdimms_state->persistence = 3;
> we probably should use QAPI enum magic to handle description to value conversion
> but I don't know how to (CCed Markus).

QEMU is not very consistent in this.  I have found at least 3
different methods for registering enum properties:

1) qdev PropertyInfo using set_enum/get_enum.  Examples:
   DEFINE_PROP_ON_OFF_AUTO, DEFINE_PROP_LOSTTICKPOLICY.
2) object_property_add() + visit_type_...().  Examples:
   machine_set_kernel_irqchip(), pc_machine_set_vmport(),
   pc_machine_set_smm().
3) object_property_add_add_enum() and object_class_property_add_enum().  Examples:
   qauthz_list_prop_set_policy(), host_memory_backend_set_policy(),
   qcrypto_secret_prop_set_format(), netfilter_set_direction().

> But since it's just moving existing code, it do not insist and it could be
> done on top later on.

Agreed, but I think we should at least add a TODO comment
indicating the code is not a good example to be followed.

-- 
Eduardo

  reply	other threads:[~2019-03-07 12:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  9:06 [Qemu-arm] [PATCH v2] machine: Move acpi_nvdimm_state into struct MachineState Eric Auger
2019-03-07  9:06 ` [Qemu-devel] " Eric Auger
2019-03-07  9:48 ` [Qemu-arm] " Igor Mammedov
2019-03-07  9:48   ` [Qemu-devel] " Igor Mammedov
2019-03-07 12:44   ` Eduardo Habkost [this message]
2019-03-07 12:44     ` Eduardo Habkost
2019-03-07 10:56 ` [Qemu-arm] " Philippe Mathieu-Daudé
2019-03-07 10:56   ` Philippe Mathieu-Daudé
2019-03-07 15:15   ` [Qemu-arm] " Auger Eric
2019-03-07 15:15     ` Auger Eric
2019-03-07 15:21     ` [Qemu-arm] " David Hildenbrand
2019-03-07 15:21       ` David Hildenbrand
2019-03-07 15:36       ` Philippe Mathieu-Daudé
2019-03-07 15:51         ` [Qemu-arm] " David Hildenbrand
2019-03-07 15:51           ` David Hildenbrand
2019-03-07 16:58     ` [Qemu-arm] " Eduardo Habkost
2019-03-07 16:58       ` Eduardo Habkost
2019-03-07 17:10       ` Philippe Mathieu-Daudé
2019-03-07 17:10         ` Philippe Mathieu-Daudé
2019-03-07 17:26 ` Eduardo Habkost
2019-03-07 17:26   ` Eduardo Habkost
2019-03-07 17:56   ` Auger Eric
2019-03-07 17:56     ` Auger Eric

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=20190307124419.GA8899@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=david@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sbhat@linux.ibm.com \
    --cc=shameerali.kolothum.thodi@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.