From patchwork Mon Jun 8 16:00:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11593477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E6C992A for ; Mon, 8 Jun 2020 16:01:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDD89206A4 for ; Mon, 8 Jun 2020 16:01:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZJ1bmmLC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD89206A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jiKCt-0003dK-LZ; Mon, 08 Jun 2020 16:01:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jiKCs-0003dF-Pj for xen-devel@lists.xenproject.org; Mon, 08 Jun 2020 16:01:03 +0000 X-Inumbo-ID: 40430748-a9a1-11ea-b292-12813bfff9fa Received: from us-smtp-1.mimecast.com (unknown [205.139.110.61]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 40430748-a9a1-11ea-b292-12813bfff9fa; Mon, 08 Jun 2020 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591632062; 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=5qtqeym41wYPVUNcQP0hBuZd3ZN8CptiJr597zGfRw0=; b=ZJ1bmmLC8MzdFyhdJ/AYRnrDCyOMjqlp8Q3RNPHP7aw673+RFfO7MAjat4egBPWFlRoMh5 KlHhjiLzfymReJojXx53IxMXyUGhDC0Q6sYBvyofF8yCZCYEuoHuDCuVigj6NumCRljMpS QBJbsDReAANM/DWECAyami/OuifkIMs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-10-C-IMLKm3NzqOEfEVx2yPtQ-1; Mon, 08 Jun 2020 12:01:00 -0400 X-MC-Unique: C-IMLKm3NzqOEfEVx2yPtQ-1 Received: by mail-wm1-f72.google.com with SMTP id u15so5404wmm.5 for ; Mon, 08 Jun 2020 09:01:00 -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=5qtqeym41wYPVUNcQP0hBuZd3ZN8CptiJr597zGfRw0=; b=T/CW8MhPLSTsSekEBE7TOoMqN2r8RLgDznvRKxD5Gn+lBgqSd+7f4s846wxkuScrmH 5ghQoXHzNUtx0t6pAutF8m6ZnKtZlYpnchEBeuXd68H079NZ8tDcZ9L+IINj4qeoqNnH DpR/NW9KKd/8P2kbCbms/IylTTcwD9v2VhlLlE1F565m2z3EJWK5iJVKu1XwgDOQ3lxT OU8IcUxgzHoFSJt2gWSl0NPByO5RoS7/jfx7ZdYQCyvmgSWherHScZjdZhtoQK2JgsBD 1VK10V1OjiTcr0ahfRB4FRNlML4yUwS1MY76dUYDTo0Icfr02wumoS4UFjVDrTSCNGOf NBug== X-Gm-Message-State: AOAM532O2A1NqDkp5rSc6oevguzjV6OtQiTWa6qKFehDQ1KyB4EgU0e0 uLNs8IBUtE7Wq5sKgq7uJAOEQeTlsxC1RFYt2rdrCZ2rZCWNCzze8o6Vs7blkWRubjpzyi61mQA dcEc9NWxaq2r2ZgBNEcBiG08wrxU= X-Received: by 2002:adf:de0b:: with SMTP id b11mr24236310wrm.346.1591632059271; Mon, 08 Jun 2020 09:00:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCLkZjArfyp0BDfLlr7paJJyNdZb8aPEICM5cLMV+w6rNjL53A+D/YIALTIycqApB88KkdKg== X-Received: by 2002:adf:de0b:: with SMTP id b11mr24236267wrm.346.1591632059025; Mon, 08 Jun 2020 09:00:59 -0700 (PDT) Received: from localhost.localdomain (181.red-88-10-103.dynamicip.rima-tde.net. [88.10.103.181]) by smtp.gmail.com with ESMTPSA id z12sm227313wrg.9.2020.06.08.09.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2020 09:00:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 02/35] hw/core/qdev: Add qdev_warn_deprecated_function_used() helper Date: Mon, 8 Jun 2020 18:00:11 +0200 Message-Id: <20200608160044.15531-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200608160044.15531-1-philmd@redhat.com> References: <20200608160044.15531-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Sagar Karandikar , "Michael S. Tsirkin" , Mark Cave-Ayland , Max Filippov , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Stefano Stabellini , Paul Durrant , Magnus Damm , Markus Armbruster , Marcel Apfelbaum , Anthony Perard , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , David Gibson , Andrzej Zaborowski , Eduardo Habkost , Alistair Francis , qemu-arm@nongnu.org, xen-devel@lists.xenproject.org, qemu-riscv@nongnu.org, Stafford Horne , Palmer Dabbelt , Richard Henderson , "Daniel P . Berrange" , Thomas Huth , Bastian Koppelmann , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Michael Walle , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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é --- 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 597e909b53..9b7a8927c6 100755 --- a/configure +++ b/configure @@ -434,6 +434,7 @@ edk2_blobs="no" pkgversion="" pie="" qom_cast_debug="yes" +qdev_deprecation_warning="no" trace_backends="log" trace_file="trace" spice="" @@ -1114,6 +1115,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" @@ -1882,6 +1885,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 @@ -6723,6 +6727,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" @@ -7345,6 +7350,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 9e5538aeae..901fa93657 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" @@ -819,6 +820,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);