qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Akihiko Odaki" <akihiko.odaki@daynix.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Sriram Yagnaraman" <sriram.yagnaraman@ericsson.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Markus Armbruster" <armbru@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v10 11/12] hw/pci: Convert rom_bar into OnOffAuto
Date: Wed, 3 Jul 2024 09:35:56 -0400	[thread overview]
Message-ID: <20240703092451-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <f056b470-a95c-1696-4276-a60eb92fced0@eik.bme.hu>

On Wed, Jul 03, 2024 at 01:00:21PM +0200, BALATON Zoltan wrote:
> On Wed, 3 Jul 2024, Michael S. Tsirkin wrote:
> > On Wed, Jul 03, 2024 at 04:15:23AM +0200, BALATON Zoltan wrote:
> > > On Tue, 2 Jul 2024, Michael S. Tsirkin wrote:
> > > > On Thu, Jun 27, 2024 at 03:08:00PM +0900, Akihiko Odaki wrote:
> > > > > rom_bar is tristate but was defined as uint32_t so convert it into
> > > > > OnOffAuto.
> > > > > 
> > > > > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> > > > 
> > > > Commit log should explain why this is an improvement,
> > > > not just what's done.
> > > > 
> > > > 
> > > > > diff --git a/docs/igd-assign.txt b/docs/igd-assign.txt
> > > > > index e17bb50789ad..35c6c8e28493 100644
> > > > > --- a/docs/igd-assign.txt
> > > > > +++ b/docs/igd-assign.txt
> > > > > @@ -35,7 +35,7 @@ IGD has two different modes for assignment using vfio-pci:
> > > > >        ISA/LPC bridge device (vfio-pci-igd-lpc-bridge) on the root bus at
> > > > >        PCI address 1f.0.
> > > > >      * The IGD device must have a VGA ROM, either provided via the romfile
> > > > > -      option or loaded automatically through vfio (standard).  rombar=0
> > > > > +      option or loaded automatically through vfio (standard).  rombar=off
> > > > >        will disable legacy mode support.
> > > > >      * Hotplug of the IGD device is not supported.
> > > > >      * The IGD device must be a SandyBridge or newer model device.
> > > > 
> > > > ...
> > > > 
> > > > > diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
> > > > > index 39dae72497e0..0e920ed0691a 100644
> > > > > --- a/hw/vfio/pci-quirks.c
> > > > > +++ b/hw/vfio/pci-quirks.c
> > > > > @@ -33,7 +33,7 @@
> > > > >   * execution as noticed with the BCM 57810 card for lack of a
> > > > >   * more better way to handle such issues.
> > > > >   * The  user can still override by specifying a romfile or
> > > > > - * rombar=1.
> > > > > + * rombar=on.
> > > > >   * Please see https://bugs.launchpad.net/qemu/+bug/1284874
> > > > >   * for an analysis of the 57810 card hang. When adding
> > > > >   * a new vendor id/device id combination below, please also add
> > > > 
> > > > 
> > > > So we are apparently breaking a bunch of users who followed
> > > > documentation to the dot. Why is this a good idea?
> > > 
> > > On/off is clearer than 1/0. But isn't 1/0 a synonym for on/off so previous
> > > command lines would still work?
> > > 
> > > Regards,
> > > BALATON Zoltan
> > 
> > I see nothing in code that would make it so:
> > 
> > 
> > const QEnumLookup OnOffAuto_lookup = {
> >    .array = (const char *const[]) {
> >        [ON_OFF_AUTO_AUTO] = "auto",
> >        [ON_OFF_AUTO_ON] = "on",
> >        [ON_OFF_AUTO_OFF] = "off",
> >    },
> >    .size = ON_OFF_AUTO__MAX
> > };
> > 
> > I also tried with an existing property:
> > 
> > $ ./qemu-system-x86_64 -device intel-hda,msi=0
> > qemu-system-x86_64: -device intel-hda,msi=0: Parameter 'msi' does not accept value '0'
> 
> Then it was probably bit properties that also accept 0/1, on/off,
> true/false.

I mean, the code is open, why do you keep guessing?


No, these reuse the bool parsing logic:

static void prop_get_bit(Object *obj, Visitor *v, const char *name,
                         void *opaque, Error **errp)
{
    Property *prop = opaque;
    uint32_t *p = object_field_prop_ptr(obj, prop);
    bool value = (*p & qdev_get_prop_mask(prop)) != 0;

    visit_type_bool(v, name, &value, errp);
}

and that never accepted 0 or 1:


bool qapi_bool_parse(const char *name, const char *value, bool *obj, Error **errp)
{       
    if (g_str_equal(value, "on") ||
        g_str_equal(value, "yes") ||
        g_str_equal(value, "true") ||
        g_str_equal(value, "y")) {
        *obj = true; 
        return true;
    }
    if (g_str_equal(value, "off") ||
        g_str_equal(value, "no") ||
        g_str_equal(value, "false") ||
        g_str_equal(value, "n")) {
        *obj = false;
        return true;
    }
    
    error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
               "'on' or 'off'");
    return false;
}



> Maybe similar aliases could be added to on/off/auto?

Could be, but even then switching to that would mean that user sets 1
but query returns "on".  Might or might not surprise some users.

Adding true/false yes/no y/n aliases to on/off/auto might make sense
though, for consistency. Donnu if QAPI guys will agree, though,
and not directly related to this patchset.

One other idea is to add a generic way to detect that a property is set
by user. This requirement comes up, once in a while.




> In any case when I first saw rombar I thought it would set the BAR of the
> ROM so wondered why it's 1 and not 5 or 6 or an offset. So on/off is clearer
> in this case.
> 
> Regards,
> BALATON Zoltan


I agree here, but it's been here for a long time.

-- 
MST



  reply	other threads:[~2024-07-03 13:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-27  6:07 [PATCH v10 00/12] hw/pci: SR-IOV related fixes and improvements Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 01/12] hw/pci: Rename has_power to enabled Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 02/12] hw/ppc/spapr_pci: Do not create DT for disabled PCI device Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 03/12] hw/ppc/spapr_pci: Do not reject VFs created after a PF Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 04/12] pcie_sriov: Do not manually unrealize Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 05/12] pcie_sriov: Ensure VF function number does not overflow Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 06/12] pcie_sriov: Reuse SR-IOV VF device instances Akihiko Odaki
2024-07-10  6:37   ` Cédric Le Goater
2024-07-10 10:52     ` Michael S. Tsirkin
2024-07-13 12:45       ` Akihiko Odaki
2024-07-20 19:11         ` Michael S. Tsirkin
2024-06-27  6:07 ` [PATCH v10 07/12] pcie_sriov: Release VFs failed to realize Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 08/12] pcie_sriov: Remove num_vfs from PCIESriovPF Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 09/12] pcie_sriov: Register VFs after migration Akihiko Odaki
2024-06-27  6:07 ` [PATCH v10 10/12] hw/pci: Replace -1 with UINT32_MAX for romsize Akihiko Odaki
2024-06-27  6:08 ` [PATCH v10 11/12] hw/pci: Convert rom_bar into OnOffAuto Akihiko Odaki
2024-07-02 13:58   ` Michael S. Tsirkin
2024-07-03  2:15     ` BALATON Zoltan
2024-07-03  6:00       ` Michael S. Tsirkin
2024-07-03 11:00         ` BALATON Zoltan
2024-07-03 13:35           ` Michael S. Tsirkin [this message]
2024-07-03 14:56           ` Alex Williamson
2024-06-27  6:08 ` [PATCH v10 12/12] hw/qdev: Remove opts member Akihiko Odaki

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=20240703092451-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=balaton@eik.bme.hu \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=eduardo@habkost.net \
    --cc=its@irrelevant.dk \
    --cc=jasowang@redhat.com \
    --cc=kbusch@kernel.org \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sriram.yagnaraman@ericsson.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).