Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jrkvy-0002lL-M5 for mharc-qemu-riscv@gnu.org; Sat, 04 Jul 2020 12:22:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkvt-0002jH-Hu; Sat, 04 Jul 2020 12:22:29 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:50256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkvq-0000qv-IK; Sat, 04 Jul 2020 12:22:28 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id DA98374594E; Sat, 4 Jul 2020 18:22:22 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 72A64745702; Sat, 4 Jul 2020 18:22:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 7030A7456F8; Sat, 4 Jul 2020 18:22:22 +0200 (CEST) Date: Sat, 4 Jul 2020 18:22:22 +0200 (CEST) From: BALATON Zoltan To: =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= cc: qemu-devel@nongnu.org, Peter Maydell , Sagar Karandikar , "Michael S. Tsirkin" , Max Filippov , Alistair Francis , Gerd Hoffmann , Yoshinori Sato , Magnus Damm , Palmer Dabbelt , Andrzej Zaborowski , Eduardo Habkost , Alistair Francis , qemu-arm@nongnu.org, =?ISO-8859-15?Q?Marc-Andr=E9_Lureau?= , =?ISO-8859-15?Q?Daniel_P=2E_Berrang=E9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Thomas Huth , Bastian Koppelmann , qemu-ppc@nongnu.org, Paolo Bonzini Subject: Re: [RFC PATCH v2 02/23] hw/core/qdev: Add qdev_warn_deprecated_function_used() helper In-Reply-To: <20200704153908.12118-3-philmd@redhat.com> Message-ID: References: <20200704153908.12118-1-philmd@redhat.com> <20200704153908.12118-3-philmd@redhat.com> User-Agent: Alpine 2.22 (BSF 395 2020-01-19) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3866299591-1579046126-1593879742=:92265" X-Spam-Probability: 9% Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 12:22:23 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jul 2020 16:22:30 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --3866299591-1579046126-1593879742=:92265 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8BIT On Sat, 4 Jul 2020, Philippe Mathieu-Daudé wrote: > When built with --enable-qdev-deprecation-warning, calling > qdev_warn_deprecated_function_used() will emit a warning such: > > $ qemu-system-arm -M verdex ... > qemu-system-arm: warning: use of deprecated non-qdev/non-qom code in pxa2xx_lcdc_init() > qemu-system-arm: warning: use of deprecated non-qdev/non-qom code in pxa2xx_i2s_init() > qemu-system-arm: warning: use of deprecated non-qdev/non-qom code in pxa27x_keypad_init() > > Signed-off-by: Philippe Mathieu-Daudé > --- > I'd rather use --enable-qdev-debug suggested here: > https://www.mail-archive.com/qemu-devel@nongnu.org/msg719802.html > --- > configure | 8 ++++++++ > include/hw/qdev-deprecated.h | 26 ++++++++++++++++++++++++++ > hw/core/qdev.c | 8 ++++++++ > 3 files changed, 42 insertions(+) > create mode 100644 include/hw/qdev-deprecated.h > > diff --git a/configure b/configure > index 8a65240d4a..aac3dc0767 100755 > --- a/configure > +++ b/configure > @@ -441,6 +441,7 @@ edk2_blobs="no" > pkgversion="" > pie="" > qom_cast_debug="yes" > +qdev_deprecation_warning="no" > trace_backends="log" > trace_file="trace" > spice="" > @@ -1124,6 +1125,8 @@ for opt do > ;; > --enable-qom-cast-debug) qom_cast_debug="yes" > ;; > + --enable-qdev-deprecation-warning) qdev_deprecation_warning="yes" > + ;; > --disable-virtfs) virtfs="no" > ;; > --enable-virtfs) virtfs="yes" > @@ -1915,6 +1918,7 @@ disabled with --disable-FEATURE, default is enabled if available: > virglrenderer virgl rendering support > xfsctl xfsctl support > qom-cast-debug cast debugging support > + qdev-deprecation-warning display qdev deprecation warnings > tools build qemu-io, qemu-nbd and qemu-img tools > vxhs Veritas HyperScale vDisk backend support > bochs bochs image format support > @@ -6966,6 +6970,7 @@ echo "gcov enabled $gcov" > echo "TPM support $tpm" > echo "libssh support $libssh" > echo "QOM debugging $qom_cast_debug" > +echo "QDEV deprecation warnings $qdev_deprecation_warning" > echo "Live block migration $live_block_migration" > echo "lzo support $lzo" > echo "snappy support $snappy" > @@ -7594,6 +7599,9 @@ fi > if test "$qom_cast_debug" = "yes" ; then > echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak > fi > +if test "$qdev_deprecation_warning" = "yes" ; then > + echo "CONFIG_QDEV_DEPRECATION_WARNING=y" >> $config_host_mak > +fi > if test "$rbd" = "yes" ; then > echo "CONFIG_RBD=m" >> $config_host_mak > echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak > diff --git a/include/hw/qdev-deprecated.h b/include/hw/qdev-deprecated.h > new file mode 100644 > index 0000000000..b815f62dae > --- /dev/null > +++ b/include/hw/qdev-deprecated.h > @@ -0,0 +1,26 @@ > +/* > + * QEMU QOM qdev deprecation helpers > + * > + * Copyright (c) 2020 Red Hat, Inc. > + * > + * Author: > + * Philippe Mathieu-Daudé > + * > + * SPDX-License-Identifier: GPL-2.0-or-later > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or later. > + * See the COPYING file in the top-level directory. > + */ > +#ifndef HW_QDEV_DEPRECATED_H > +#define HW_QDEV_DEPRECATED_H > + > +/** > + * qdev_warn_deprecated_function_used: > + * > + * Display a warning that deprecated code is used. > + */ > +#define qdev_warn_deprecated_function_used() \ > + qdev_warn_deprecated_function(__func__) > +void qdev_warn_deprecated_function(const char *function); > + > +#endif > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 2131c7f951..1134f46631 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -35,6 +35,7 @@ > #include "hw/hotplug.h" > #include "hw/irq.h" > #include "hw/qdev-properties.h" > +#include "hw/qdev-deprecated.h" > #include "hw/boards.h" > #include "hw/sysbus.h" > #include "hw/qdev-clock.h" > @@ -838,6 +839,13 @@ void qdev_alias_all_properties(DeviceState *target, Object *source) > } while (class != object_class_by_name(TYPE_DEVICE)); > } > > +void qdev_warn_deprecated_function(const char *function) > +{ > +#ifdef CONFIG_QDEV_DEPRECATION_WARNING > + warn_report("use of deprecated non-qdev/non-qom code in %s()", function); > +#endif > +} > + > static bool device_get_realized(Object *obj, Error **errp) > { > DeviceState *dev = DEVICE(obj); > I haven't noticed this series before so sorry that I only comment now. I was first thinking maybe you could use qdev_log_mask with some LOG_* value instead of #ifdef and warn_report so it can be enabled during runtime with some -d option but then I saw that this does not magically detect the sites that should be warned about but has to be added manually everywhere. In that case, it's probably easier to just add a FIXME comment to the places you'd call this function because that's where developers who could convert these will see it and probably more effective than having them to enable an option that they may not even know about and then search for where the warnings are coming from. So likely they'll just see the call in source for which a comment is also suffucient and then you can drop this patch but keep the rest and not throw away the work of identifying all the places that need to be modernised that you've done. Regards, BALATON Zoltan --3866299591-1579046126-1593879742=:92265--