From patchwork Thu Oct 25 08:52:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10655645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4971B14DE for ; Thu, 25 Oct 2018 09:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392CB2B271 for ; Thu, 25 Oct 2018 09:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D3602B2B7; Thu, 25 Oct 2018 09:35:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF90F2B271 for ; Thu, 25 Oct 2018 09:35:16 +0000 (UTC) Received: from localhost ([::1]:53406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFc2u-0001Xw-6u for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Oct 2018 05:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFbzT-0007Zu-0a for qemu-devel@nongnu.org; Thu, 25 Oct 2018 05:31:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFbzO-0008Ui-1C for qemu-devel@nongnu.org; Thu, 25 Oct 2018 05:31:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56918) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFbzM-0008Ik-CB for qemu-devel@nongnu.org; Thu, 25 Oct 2018 05:31:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9015230C9EE8 for ; Thu, 25 Oct 2018 09:31:30 +0000 (UTC) Received: from lupin.home.kraxel.org (ovpn-117-207.ams2.redhat.com [10.36.117.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 722A360F80; Thu, 25 Oct 2018 09:31:24 +0000 (UTC) Received: by lupin.home.kraxel.org (Postfix, from userid 1000) id 572FB628B92B; Thu, 25 Oct 2018 10:52:56 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 10:52:54 +0200 Message-Id: <20181025085256.20522-2-kraxel@redhat.com> In-Reply-To: <20181025085256.20522-1-kraxel@redhat.com> References: <20181025085256.20522-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 25 Oct 2018 09:31:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] qdev: add deprecation_reason to DeviceClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libvir-list@redhat.com, Gerd Hoffmann , Prasad J Pandit Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Simliar to deprecated machine types. Print a warning when creating a deprecated device. Add deprecation notice to -device help. TODO: add to intospection. Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé --- hw/core/qdev.c | 9 ++++++++- include/hw/qdev-core.h | 1 + qdev-monitor.c | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 046d8f1..3b27a74 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -133,11 +133,18 @@ DeviceState *qdev_create(BusState *bus, const char *name) DeviceState *qdev_try_create(BusState *bus, const char *type) { + DeviceClass *dc; DeviceState *dev; - if (object_class_by_name(type) == NULL) { + dc = DEVICE_CLASS(object_class_by_name(type)); + if (dc == NULL) { return NULL; } + if (dc->deprecation_reason) { + warn_report("device %s is deprecated (%s)", + type, dc->deprecation_reason); + } + dev = DEVICE(object_new(type)); if (!dev) { return NULL; diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index a24d0dd..a352eaa 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -105,6 +105,7 @@ typedef struct DeviceClass { */ bool user_creatable; bool hotpluggable; + const char *deprecation_reason; /* callbacks */ DeviceReset reset; diff --git a/qdev-monitor.c b/qdev-monitor.c index 802c18a..bbba2bc 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -128,6 +128,9 @@ static void qdev_print_devinfo(DeviceClass *dc) if (!dc->user_creatable) { out_printf(", no-user"); } + if (!dc->deprecation_reason) { + out_printf(", deprecated"); + } out_printf("\n"); } @@ -579,6 +582,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) if (!dc) { return NULL; } + if (dc->deprecation_reason) { + warn_report("device %s is deprecated (%s)", + driver, dc->deprecation_reason); + } /* find bus */ path = qemu_opt_get(opts, "bus");