mbox series

[RFC,0/4] qom: Introduce object_class_property_deprecate()

Message ID 20230109225419.22621-1-philmd@linaro.org
Headers show
Series qom: Introduce object_class_property_deprecate() | expand

Message

Philippe Mathieu-Daudé Jan. 9, 2023, 10:54 p.m. UTC
Hi,

There will always be a need to deprecate things. Here I'm
tackling the QOM (class) properties, since they can be set
from some CLI options (-object -device -global ...).

As an experiment, we add object_class_property_deprecate()
to register a class property as deprecated (since some version),
then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
finally as a bonus we emit a warning when the deprecation period
is over, as a reminder. (For that we introduce few 'versions'
helpers).

Output example:

$ qemu-system-arm -M musicpal,accel=qtest -S \
  -drive if=pflash,driver=null-co,read-zeroes=on,size=8M \
  -global driver=cfi.pflash02,property=width,value=2
qemu-system-arm: warning: Property 'cfi.pflash02.width' is deprecated (renamed as 'cfi.pflash02.device-width').

$ qemu-system-arm -M musicpal,accel=qtest -S \
  -drive if=pflash,driver=null-co,read-zeroes=on,size=8M \
  -global driver=cfi.pflash02,property=device-width,value=2
qemu-system-arm: warning: Property 'cfi.pflash02.width' has been deprecated in release v8.0 and can be removed.

Thought?

Regards,

Phil.

[earlier inspiration: https://lore.kernel.org/qemu-devel/Y7wlnqwU+/auE0Jj@redhat.com/]

Philippe Mathieu-Daudé (4):
  qom: Introduce object_class_property_deprecate()
  hw/block: Rename TYPE_PFLASH_CFI02 'width' property as 'device-width'
  util: Introduce helpers to compare QEMU versions
  qom: Warn when deprecated class property can be removed

 hw/block/pflash_cfi02.c     |  8 +++++++-
 include/qemu/qemu-version.h | 36 ++++++++++++++++++++++++++++++++++++
 include/qom/object.h        | 17 +++++++++++++++++
 qom/object.c                | 30 ++++++++++++++++++++++++++++++
 util/meson.build            |  1 +
 util/qemu-version.c         | 37 +++++++++++++++++++++++++++++++++++++
 6 files changed, 128 insertions(+), 1 deletion(-)
 create mode 100644 include/qemu/qemu-version.h
 create mode 100644 util/qemu-version.c

Comments

Kevin Wolf Jan. 10, 2023, 1:02 p.m. UTC | #1
Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
> Hi,
> 
> There will always be a need to deprecate things. Here I'm
> tackling the QOM (class) properties, since they can be set
> from some CLI options (-object -device -global ...).
> 
> As an experiment, we add object_class_property_deprecate()
> to register a class property as deprecated (since some version),
> then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
> finally as a bonus we emit a warning when the deprecation period
> is over, as a reminder. (For that we introduce few 'versions'
> helpers).

The last part means that increasing the version number (i.e. the commit
that opens the development tree for the next release) can change the
output, and this is turn can break test cases.

If we are happy to introduce breakage with a version number change that
will require future commits to open the development tree less trivial
than they are today because they need to fix the breakage, too, why not
make it a build error instead of a different warning message at runtime?

Kevin
Philippe Mathieu-Daudé Jan. 11, 2023, 9:55 a.m. UTC | #2
On 10/1/23 14:02, Kevin Wolf wrote:
> Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
>> Hi,
>>
>> There will always be a need to deprecate things. Here I'm
>> tackling the QOM (class) properties, since they can be set
>> from some CLI options (-object -device -global ...).
>>
>> As an experiment, we add object_class_property_deprecate()
>> to register a class property as deprecated (since some version),
>> then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
>> finally as a bonus we emit a warning when the deprecation period
>> is over, as a reminder. (For that we introduce few 'versions'
>> helpers).
> 
> The last part means that increasing the version number (i.e. the commit
> that opens the development tree for the next release) can change the
> output, and this is turn can break test cases.
> 
> If we are happy to introduce breakage with a version number change that
> will require future commits to open the development tree less trivial
> than they are today because they need to fix the breakage, too, why not
> make it a build error instead of a different warning message at runtime?

To avoid build breakages, maybe it is clever is to store the deprecation
version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
/ report deprecated features?
Daniel P. Berrangé Jan. 11, 2023, 9:59 a.m. UTC | #3
On Wed, Jan 11, 2023 at 10:55:47AM +0100, Philippe Mathieu-Daudé wrote:
> On 10/1/23 14:02, Kevin Wolf wrote:
> > Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
> > > Hi,
> > > 
> > > There will always be a need to deprecate things. Here I'm
> > > tackling the QOM (class) properties, since they can be set
> > > from some CLI options (-object -device -global ...).
> > > 
> > > As an experiment, we add object_class_property_deprecate()
> > > to register a class property as deprecated (since some version),
> > > then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
> > > finally as a bonus we emit a warning when the deprecation period
> > > is over, as a reminder. (For that we introduce few 'versions'
> > > helpers).
> > 
> > The last part means that increasing the version number (i.e. the commit
> > that opens the development tree for the next release) can change the
> > output, and this is turn can break test cases.
> > 
> > If we are happy to introduce breakage with a version number change that
> > will require future commits to open the development tree less trivial
> > than they are today because they need to fix the breakage, too, why not
> > make it a build error instead of a different warning message at runtime?
> 
> To avoid build breakages, maybe it is clever is to store the deprecation
> version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
> / report deprecated features?

I don't think we want the version information in the code nor
introspectable at all.

We want applications to only apply logic based off features that are
actually available, not predicted future versions where something may
or may not be removed. This is why we exposed only a plain 'deprecated'
boolean field in QAPI schema for other deprecations.  This is just a
warning to be ready for something to change in future. If an application
has not been updated they are fine to carry on using the deprecated
feature. If an application has been updated, they should probe for
existance of the new feature and use that if available, in preference
to the deprecated feature. There's no reason for an application to
consider version numbers.

With regards,
Daniel
Philippe Mathieu-Daudé Jan. 11, 2023, 10:08 a.m. UTC | #4
On 11/1/23 10:59, Daniel P. Berrangé wrote:
> On Wed, Jan 11, 2023 at 10:55:47AM +0100, Philippe Mathieu-Daudé wrote:
>> On 10/1/23 14:02, Kevin Wolf wrote:
>>> Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
>>>> Hi,
>>>>
>>>> There will always be a need to deprecate things. Here I'm
>>>> tackling the QOM (class) properties, since they can be set
>>>> from some CLI options (-object -device -global ...).
>>>>
>>>> As an experiment, we add object_class_property_deprecate()
>>>> to register a class property as deprecated (since some version),
>>>> then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
>>>> finally as a bonus we emit a warning when the deprecation period
>>>> is over, as a reminder. (For that we introduce few 'versions'
>>>> helpers).
>>>
>>> The last part means that increasing the version number (i.e. the commit
>>> that opens the development tree for the next release) can change the
>>> output, and this is turn can break test cases.
>>>
>>> If we are happy to introduce breakage with a version number change that
>>> will require future commits to open the development tree less trivial
>>> than they are today because they need to fix the breakage, too, why not
>>> make it a build error instead of a different warning message at runtime?
>>
>> To avoid build breakages, maybe it is clever is to store the deprecation
>> version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
>> / report deprecated features?
> 
> I don't think we want the version information in the code nor
> introspectable at all.
> 
> We want applications to only apply logic based off features that are
> actually available, not predicted future versions where something may
> or may not be removed. This is why we exposed only a plain 'deprecated'
> boolean field in QAPI schema for other deprecations.  This is just a
> warning to be ready for something to change in future. If an application
> has not been updated they are fine to carry on using the deprecated
> feature. If an application has been updated, they should probe for
> existance of the new feature and use that if available, in preference
> to the deprecated feature. There's no reason for an application to
> consider version numbers.

Right, but "applications" can also be developer scripts right? Not
only user / sysadmin.

In particular, some HMP commands are only useful for developers, and
they are implemented over QMP -> QAPI. So we already expose extra
developer information via QAPI.
Daniel P. Berrangé Jan. 11, 2023, 10:29 a.m. UTC | #5
On Wed, Jan 11, 2023 at 11:08:05AM +0100, Philippe Mathieu-Daudé wrote:
> On 11/1/23 10:59, Daniel P. Berrangé wrote:
> > On Wed, Jan 11, 2023 at 10:55:47AM +0100, Philippe Mathieu-Daudé wrote:
> > > On 10/1/23 14:02, Kevin Wolf wrote:
> > > > Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
> > > > > Hi,
> > > > > 
> > > > > There will always be a need to deprecate things. Here I'm
> > > > > tackling the QOM (class) properties, since they can be set
> > > > > from some CLI options (-object -device -global ...).
> > > > > 
> > > > > As an experiment, we add object_class_property_deprecate()
> > > > > to register a class property as deprecated (since some version),
> > > > > then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
> > > > > finally as a bonus we emit a warning when the deprecation period
> > > > > is over, as a reminder. (For that we introduce few 'versions'
> > > > > helpers).
> > > > 
> > > > The last part means that increasing the version number (i.e. the commit
> > > > that opens the development tree for the next release) can change the
> > > > output, and this is turn can break test cases.
> > > > 
> > > > If we are happy to introduce breakage with a version number change that
> > > > will require future commits to open the development tree less trivial
> > > > than they are today because they need to fix the breakage, too, why not
> > > > make it a build error instead of a different warning message at runtime?
> > > 
> > > To avoid build breakages, maybe it is clever is to store the deprecation
> > > version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
> > > / report deprecated features?
> > 
> > I don't think we want the version information in the code nor
> > introspectable at all.
> > 
> > We want applications to only apply logic based off features that are
> > actually available, not predicted future versions where something may
> > or may not be removed. This is why we exposed only a plain 'deprecated'
> > boolean field in QAPI schema for other deprecations.  This is just a
> > warning to be ready for something to change in future. If an application
> > has not been updated they are fine to carry on using the deprecated
> > feature. If an application has been updated, they should probe for
> > existance of the new feature and use that if available, in preference
> > to the deprecated feature. There's no reason for an application to
> > consider version numbers.
> 
> Right, but "applications" can also be developer scripts right? Not
> only user / sysadmin.
> 
> In particular, some HMP commands are only useful for developers, and
> they are implemented over QMP -> QAPI. So we already expose extra
> developer information via QAPI.

Sure, but I still don't think we should expose any version info there.
A deprecated feature isn't gone until it is gone. In the deprecations
doc we only mention the release where it is first deprecated, don't
explicitly state when it will be removed. The 2 cycle timeframe is
a minimum, not an exact removal date, so it would be misleading to
claim we'll remove things in exactly 2 cycles.

With regards,
Daniel
Markus Armbruster Jan. 11, 2023, 11:29 a.m. UTC | #6
Daniel P. Berrangé <berrange@redhat.com> writes:

> On Wed, Jan 11, 2023 at 11:08:05AM +0100, Philippe Mathieu-Daudé wrote:
>> On 11/1/23 10:59, Daniel P. Berrangé wrote:
>> > On Wed, Jan 11, 2023 at 10:55:47AM +0100, Philippe Mathieu-Daudé wrote:
>> > > On 10/1/23 14:02, Kevin Wolf wrote:
>> > > > Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
>> > > > > Hi,
>> > > > > 
>> > > > > There will always be a need to deprecate things. Here I'm
>> > > > > tackling the QOM (class) properties, since they can be set
>> > > > > from some CLI options (-object -device -global ...).
>> > > > > 
>> > > > > As an experiment, we add object_class_property_deprecate()
>> > > > > to register a class property as deprecated (since some version),
>> > > > > then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
>> > > > > finally as a bonus we emit a warning when the deprecation period
>> > > > > is over, as a reminder. (For that we introduce few 'versions'
>> > > > > helpers).
>> > > > 
>> > > > The last part means that increasing the version number (i.e. the commit
>> > > > that opens the development tree for the next release) can change the
>> > > > output, and this is turn can break test cases.
>> > > > 
>> > > > If we are happy to introduce breakage with a version number change that
>> > > > will require future commits to open the development tree less trivial
>> > > > than they are today because they need to fix the breakage, too, why not
>> > > > make it a build error instead of a different warning message at runtime?
>> > > 
>> > > To avoid build breakages, maybe it is clever is to store the deprecation
>> > > version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
>> > > / report deprecated features?
>> > 
>> > I don't think we want the version information in the code nor
>> > introspectable at all.
>> > 
>> > We want applications to only apply logic based off features that are
>> > actually available, not predicted future versions where something may
>> > or may not be removed. This is why we exposed only a plain 'deprecated'
>> > boolean field in QAPI schema for other deprecations.  This is just a
>> > warning to be ready for something to change in future. If an application
>> > has not been updated they are fine to carry on using the deprecated
>> > feature. If an application has been updated, they should probe for
>> > existance of the new feature and use that if available, in preference
>> > to the deprecated feature. There's no reason for an application to
>> > consider version numbers.
>> 
>> Right, but "applications" can also be developer scripts right? Not
>> only user / sysadmin.
>> 
>> In particular, some HMP commands are only useful for developers, and
>> they are implemented over QMP -> QAPI. So we already expose extra
>> developer information via QAPI.
>
> Sure, but I still don't think we should expose any version info there.
> A deprecated feature isn't gone until it is gone. In the deprecations
> doc we only mention the release where it is first deprecated, don't
> explicitly state when it will be removed. The 2 cycle timeframe is
> a minimum, not an exact removal date, so it would be misleading to
> claim we'll remove things in exactly 2 cycles.

I agree with Daniel.

I understand the motivation for making developers aware of expired grace
periods.

A warning is one way to make aware.  It creates another problem, though:
since the grace period is flexible, we need a way to extend the period,
and we need to decide right at the beginning of the development cycle.

I think the existing process for getting rid of deprecated stuff in a
timely manner is good enough: document all deprecations in
docs/about/deprecated.rst, and check the file periodically.

I'd recommend to follow QAPI's lead and add a "deprecated" flag to QOM.

We may want to follow QAPI some more and add an "unstable" flag, too.
See commit a3c45b3e62 'qapi: New special feature flag "unstable"' for
rationale.
Philippe Mathieu-Daudé Jan. 11, 2023, 1:15 p.m. UTC | #7
On 11/1/23 12:29, Markus Armbruster wrote:
> Daniel P. Berrangé <berrange@redhat.com> writes:
> 
>> On Wed, Jan 11, 2023 at 11:08:05AM +0100, Philippe Mathieu-Daudé wrote:
>>> On 11/1/23 10:59, Daniel P. Berrangé wrote:
>>>> On Wed, Jan 11, 2023 at 10:55:47AM +0100, Philippe Mathieu-Daudé wrote:
>>>>> On 10/1/23 14:02, Kevin Wolf wrote:
>>>>>> Am 09.01.2023 um 23:54 hat Philippe Mathieu-Daudé geschrieben:
>>>>>>> Hi,
>>>>>>>
>>>>>>> There will always be a need to deprecate things. Here I'm
>>>>>>> tackling the QOM (class) properties, since they can be set
>>>>>>> from some CLI options (-object -device -global ...).
>>>>>>>
>>>>>>> As an experiment, we add object_class_property_deprecate()
>>>>>>> to register a class property as deprecated (since some version),
>>>>>>> then we deprecate the TYPE_PFLASH_CFI02 'width' property, and
>>>>>>> finally as a bonus we emit a warning when the deprecation period
>>>>>>> is over, as a reminder. (For that we introduce few 'versions'
>>>>>>> helpers).
>>>>>>
>>>>>> The last part means that increasing the version number (i.e. the commit
>>>>>> that opens the development tree for the next release) can change the
>>>>>> output, and this is turn can break test cases.
>>>>>>
>>>>>> If we are happy to introduce breakage with a version number change that
>>>>>> will require future commits to open the development tree less trivial
>>>>>> than they are today because they need to fix the breakage, too, why not
>>>>>> make it a build error instead of a different warning message at runtime?
>>>>>
>>>>> To avoid build breakages, maybe it is clever is to store the deprecation
>>>>> version in ObjectPropertyInfo and let QAPI inspection scripts enumerate
>>>>> / report deprecated features?
>>>>
>>>> I don't think we want the version information in the code nor
>>>> introspectable at all.
>>>>
>>>> We want applications to only apply logic based off features that are
>>>> actually available, not predicted future versions where something may
>>>> or may not be removed. This is why we exposed only a plain 'deprecated'
>>>> boolean field in QAPI schema for other deprecations.  This is just a
>>>> warning to be ready for something to change in future. If an application
>>>> has not been updated they are fine to carry on using the deprecated
>>>> feature. If an application has been updated, they should probe for
>>>> existance of the new feature and use that if available, in preference
>>>> to the deprecated feature. There's no reason for an application to
>>>> consider version numbers.
>>>
>>> Right, but "applications" can also be developer scripts right? Not
>>> only user / sysadmin.
>>>
>>> In particular, some HMP commands are only useful for developers, and
>>> they are implemented over QMP -> QAPI. So we already expose extra
>>> developer information via QAPI.
>>
>> Sure, but I still don't think we should expose any version info there.
>> A deprecated feature isn't gone until it is gone. In the deprecations
>> doc we only mention the release where it is first deprecated, don't
>> explicitly state when it will be removed. The 2 cycle timeframe is
>> a minimum, not an exact removal date, so it would be misleading to
>> claim we'll remove things in exactly 2 cycles.
> 
> I agree with Daniel.
> 
> I understand the motivation for making developers aware of expired grace
> periods.
> 
> A warning is one way to make aware.  It creates another problem, though:
> since the grace period is flexible, we need a way to extend the period,
> and we need to decide right at the beginning of the development cycle.
> 
> I think the existing process for getting rid of deprecated stuff in a
> timely manner is good enough: document all deprecations in
> docs/about/deprecated.rst, and check the file periodically.
> 
> I'd recommend to follow QAPI's lead and add a "deprecated" flag to QOM.
> 
> We may want to follow QAPI some more and add an "unstable" flag, too.
> See commit a3c45b3e62 'qapi: New special feature flag "unstable"' for
> rationale.

I understand breaking the build system is not a welcomed idea and that
the deprecation grace period can be flexible.

I don't understand why storing version information isn't helpful, as
I'd like to run some ./qapi-dump-deprecated-stuff script at least once
between releases, and being able to display this info directly seems
simpler than going to match in deprecated.rst.

But overall the discussion was enlightening, so thanks!

Phil.