Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jrkGM-000146-EM for mharc-qemu-riscv@gnu.org; Sat, 04 Jul 2020 11:39:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrkGJ-0000zK-UC for qemu-riscv@nongnu.org; Sat, 04 Jul 2020 11:39:31 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:45808 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrkGH-0007U2-Vm for qemu-riscv@nongnu.org; Sat, 04 Jul 2020 11:39:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593877169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GuGL8s6Y6URpcSNtr04xteyMjyUSDj0tV/o+btZV9Wk=; b=gQAD4Su3QAYn/HnnmdZ8m7L6td6RXinkyj1+nF0OYI3npbKV8UWa1oWl59MnwnP8/CbImi QRbtO52bkQPkihDpgi9tVxu+49bCD0t49d7G0jCdZy7szWr5/X19bIu8nTZxcUzrQi8hP6 2N/Vf76ILNW070PCa9VPy4vdg8SPXSo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-hzSDQoBIPhGKtnhxDBhYFg-1; Sat, 04 Jul 2020 11:39:23 -0400 X-MC-Unique: hzSDQoBIPhGKtnhxDBhYFg-1 Received: by mail-wr1-f71.google.com with SMTP id z1so6143794wrn.18 for ; Sat, 04 Jul 2020 08:39:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GuGL8s6Y6URpcSNtr04xteyMjyUSDj0tV/o+btZV9Wk=; b=VGT+X6i9kmfa2mGv+ev3sJ8eT8RxsDwTs9douAr/tsNKweXfkrDaTb2ultM6k74Exw w886YvvSEMvSNLin+nmXlsVIEBoWyOo1AI1I8oeXc50OOxk6l7QSwkFbDmbS6IqHHaMH gOYmgNEvAAWQL85JIQpwFYvEHlMUw+SschhmMpzFaYjcEZ7L8RMhEM6E+s0RPUGl904e vTZiII8DW3vOuuaKFk33o/oBjtmMf7g8/6khBOjERJRUGiBaG8s/CDxwX4ATWpUifgzp oG2uzmJ3xTfC5Ssg4udyfsaBTKB/Y5DqzPezaflFApE9vyp9TttgWtOpfT6VXMUROjfz Kmog== X-Gm-Message-State: AOAM532o4GaMmWgoYYqd/jucB9tG1HcUI/KgGzUkzkhNrmOUmHuPq9zG CH5skv7mZ/a7KppZC5I/IvQJ7jgdjJda4ex9yjCF5S4Iaz/QrzLM0fcou7/Jl2bwbk9rbh3C5v+ t4Vb+rTFbFyt5tyk= X-Received: by 2002:adf:fac8:: with SMTP id a8mr12152857wrs.368.1593877162694; Sat, 04 Jul 2020 08:39:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZRv9/lwGDgzqtfWRi8evJQZCpRLoZKGzZD2as3kqahxAbsMaLzXOum5g8F2YJmelnvLmX8Q== X-Received: by 2002:adf:fac8:: with SMTP id a8mr12152843wrs.368.1593877162442; Sat, 04 Jul 2020 08:39:22 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id f16sm16564180wmh.27.2020.07.04.08.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 08:39:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Palmer Dabbelt , "Edgar E. Iglesias" , qemu-riscv@nongnu.org, Peter Maydell , Alistair Francis , Stafford Horne , Max Filippov , Eduardo Habkost , Yoshinori Sato , David Gibson , "Michael S. Tsirkin" , qemu-ppc@nongnu.org, Andrzej Zaborowski , Gerd Hoffmann , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Alistair Francis , Bastian Koppelmann , Paolo Bonzini , Magnus Damm , Sagar Karandikar , Thomas Huth , qemu-arm@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH v2 02/23] hw/core/qdev: Add qdev_warn_deprecated_function_used() helper Date: Sat, 4 Jul 2020 17:38:47 +0200 Message-Id: <20200704153908.12118-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704153908.12118-1-philmd@redhat.com> References: <20200704153908.12118-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8; text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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 15:39:32 -0000 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); -- 2.21.3