diff mbox series

[RFC,4/4] qom: Warn when deprecated class property can be removed

Message ID 20230109225419.22621-5-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series qom: Introduce object_class_property_deprecate() | expand

Commit Message

Philippe Mathieu-Daudé Jan. 9, 2023, 10:54 p.m. UTC
Per docs/system/deprecated.rst, a deprecated feature can be
removed after 2 releases. Since we commit when a class property
is deprecated, we can warn when the deprecation period is over.

See also commit ef1f5b0a96 ("docs: clarify deprecation schedule").

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 qom/object.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Bernhard Beschow Jan. 10, 2023, 9:34 a.m. UTC | #1
Am 9. Januar 2023 22:54:19 UTC schrieb "Philippe Mathieu-Daudé" <philmd@linaro.org>:
>Per docs/system/deprecated.rst, a deprecated feature can be
>removed after 2 releases. Since we commit when a class property
>is deprecated, we can warn when the deprecation period is over.
>
>See also commit ef1f5b0a96 ("docs: clarify deprecation schedule").
>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>---
> qom/object.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
>diff --git a/qom/object.c b/qom/object.c
>index 05b97cd424..cb829f1e44 100644
>--- a/qom/object.c
>+++ b/qom/object.c
>@@ -17,6 +17,7 @@
> #include "qom/object_interfaces.h"
> #include "qemu/cutils.h"
> #include "qemu/memalign.h"
>+#include "qemu/qemu-version.h"
> #include "qapi/visitor.h"
> #include "qapi/string-input-visitor.h"
> #include "qapi/string-output-visitor.h"
>@@ -1300,6 +1301,12 @@ void object_class_property_deprecate(ObjectClass *klass,
>     ObjectProperty *prop = object_class_property_find(klass, name);
> 
>     assert(prop);
>+    if (qemu_version_delta_current(version_major, version_minor) <= 2) {
>+        warn_report_once("Property '%s.%s' has been deprecated in release"
>+                         " v%u.%u and can be removed.",
>+                         object_class_get_name(klass), name,
>+                         version_major, version_minor);
>+    }
>     prop->deprecation_reason = reason;
> }
> 

Great series!

Perhaps turn object_class_property_deprecate() into a macro and warn at compile time already? That way we won't miss removing any properties and users won't see a warning they can't do anything about.

Best regards,
Bernhard
Daniel P. Berrangé Jan. 10, 2023, 9:49 a.m. UTC | #2
On Mon, Jan 09, 2023 at 11:54:19PM +0100, Philippe Mathieu-Daudé wrote:
> Per docs/system/deprecated.rst, a deprecated feature can be
> removed after 2 releases. Since we commit when a class property
> is deprecated, we can warn when the deprecation period is over.
> 
> See also commit ef1f5b0a96 ("docs: clarify deprecation schedule").
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  qom/object.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 05b97cd424..cb829f1e44 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -17,6 +17,7 @@
>  #include "qom/object_interfaces.h"
>  #include "qemu/cutils.h"
>  #include "qemu/memalign.h"
> +#include "qemu/qemu-version.h"
>  #include "qapi/visitor.h"
>  #include "qapi/string-input-visitor.h"
>  #include "qapi/string-output-visitor.h"
> @@ -1300,6 +1301,12 @@ void object_class_property_deprecate(ObjectClass *klass,
>      ObjectProperty *prop = object_class_property_find(klass, name);
>  
>      assert(prop);
> +    if (qemu_version_delta_current(version_major, version_minor) <= 2) {
> +        warn_report_once("Property '%s.%s' has been deprecated in release"
> +                         " v%u.%u and can be removed.",
> +                         object_class_get_name(klass), name,
> +                         version_major, version_minor);
> +    }

IMHO this is not really appropriate. Removal of deprecated features
is a job for maintainers, but this is printing a message at users.

Maintainers have a record of deprecations in the docs that they can
periodically review to identify stuff that can now be deleted.


With regards,
Daniel
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index 05b97cd424..cb829f1e44 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -17,6 +17,7 @@ 
 #include "qom/object_interfaces.h"
 #include "qemu/cutils.h"
 #include "qemu/memalign.h"
+#include "qemu/qemu-version.h"
 #include "qapi/visitor.h"
 #include "qapi/string-input-visitor.h"
 #include "qapi/string-output-visitor.h"
@@ -1300,6 +1301,12 @@  void object_class_property_deprecate(ObjectClass *klass,
     ObjectProperty *prop = object_class_property_find(klass, name);
 
     assert(prop);
+    if (qemu_version_delta_current(version_major, version_minor) <= 2) {
+        warn_report_once("Property '%s.%s' has been deprecated in release"
+                         " v%u.%u and can be removed.",
+                         object_class_get_name(klass), name,
+                         version_major, version_minor);
+    }
     prop->deprecation_reason = reason;
 }