[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 4/8] qdev-properties: add size32 property type
From: |
Roman Kagan |
Subject: |
Re: [PATCH v7 4/8] qdev-properties: add size32 property type |
Date: |
Fri, 29 May 2020 01:35:14 +0300 |
On Thu, May 28, 2020 at 04:45:19PM -0500, Eric Blake wrote:
> On 5/28/20 4:39 PM, Roman Kagan wrote:
> > Introduce size32 property type which handles size suffixes (k, m) just
> > like size property, but is uint32_t rather than uint64_t.
>
> Does it handle 'g' as well? (even though the set of valid 32-bit sizes with
> a g suffix is rather small ;)
>
> > It's going to
> > be useful for properties that are byte sizes but are inherently 32bit,
> > like BlkConf.opt_io_size or .discard_granularity (they are switched to
> > this new property type in a followup commit).
> >
> > The getter for size32 is left out for a separate patch as its benefit is
> > less obvious, and it affects test output; for now the regular uint32
> > getter is used.
> >
> > Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
> > ---
> >
>
> > +static void set_size32(Object *obj, Visitor *v, const char *name, void
> > *opaque,
> > + Error **errp)
> > +{
> > + DeviceState *dev = DEVICE(obj);
> > + Property *prop = opaque;
> > + uint32_t *ptr = qdev_get_prop_ptr(dev, prop);
> > + uint64_t value;
> > + Error *local_err = NULL;
> > +
> > + if (dev->realized) {
> > + qdev_prop_set_after_realize(dev, name, errp);
> > + return;
> > + }
> > +
> > + visit_type_size(v, name, &value, &local_err);
>
> Yes, it does.
>
> Whether or not the commit message is tweaked,
> Reviewed-by: Eric Blake <eblake@redhat.com>
I did this stupid stringify(UINT32_MAX) here too. It's even uglier
here, with an 'U' appended to the number in the brackets, but somehow it
didn't strike me in the eye while testing.
So I'll fix this too in the respin, and drop the r-b.
Thanks,
Roman.
- [PATCH v7 0/8] block: enhance handling of size-related BlockConf properties, Roman Kagan, 2020/05/28
- [PATCH v7 1/8] virtio-blk: store opt_io_size with correct size, Roman Kagan, 2020/05/28
- [PATCH v7 2/8] block: consolidate blocksize properties consistency checks, Roman Kagan, 2020/05/28
- [PATCH v7 3/8] qdev-properties: blocksize: use same limits in code and description, Roman Kagan, 2020/05/28
- [PATCH v7 4/8] qdev-properties: add size32 property type, Roman Kagan, 2020/05/28
- [PATCH v7 5/8] qdev-properties: make blocksize accept size suffixes, Roman Kagan, 2020/05/28
- [PATCH v7 6/8] block: make BlockConf size props 32bit and accept size suffixes, Roman Kagan, 2020/05/28
- [PATCH v7 8/8] block: lift blocksize property limit to 2 MiB, Roman Kagan, 2020/05/28
- [PATCH v7 7/8] qdev-properties: add getter for size32 and blocksize, Roman Kagan, 2020/05/28