From patchwork Mon Jan 9 22:54:16 2023 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: 13094485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD9FEC5479D for ; Mon, 9 Jan 2023 22:54:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF12J-0004kU-6J; Mon, 09 Jan 2023 17:54:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF12G-0004it-Ec for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:33 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF12D-0007iY-3V for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:31 -0500 Received: by mail-wm1-x329.google.com with SMTP id m26-20020a05600c3b1a00b003d9811fcaafso8467487wms.5 for ; Mon, 09 Jan 2023 14:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YYqX/y2WSbzyv4/4voOdSyLCRImF1qkdyFcZzZnQoeE=; b=Dq7fc4x5FZ1XWqZnc6T4Crb+TaPfYsYP6/UfphB8+x3XH0s9JvcVR9FKqek7MH2JSB cmOqUUEodUX9tF55KNRortWRvrHqLjrK+o2bMsQh4xDZax9MlD5htzPtdcWpDoecrWuJ 4xZmtNRJJh4VYg0luJfMOLDtn8BG1xGI8qwHZ0va8TJx4gySm98922rBwyInTVVRex6x 7zp9bArJmxr3cBM7QlOJLI8LMivvntJEv1XCHgp0gFdDmUI6WLwakTl/iZYviidfGx3e n/iRAnuDXxWTdIrxJAnOfmyjG6+kJqemXB/ewKL13fUVvyvNqj63f6C3xZj4g2f0hbq6 obdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YYqX/y2WSbzyv4/4voOdSyLCRImF1qkdyFcZzZnQoeE=; b=bmfWVylhUtTlixU5UA/XxDi4H8/E7BqtSCTu2YANKdxoFAfIpEIrTZXn0Y17K4ABrO 9Lw54OV3VcTqTHs2y0DxGib1xs+rsUoLqOtMJro/d646MvMWM/f3eaTvJZkV1UNKrd/b 8u9zdMDoKGtneNwO0Up9pS2Dw83z7jf+yGzIIapUB7HnMrjJ0MQsjF1QaE0c/0wZ/XXa MFNgVKc1gFP2Nb8NNWBZSs9HHXTefr2cvdGheeYYJeuj6ptIG42aAyqIXplqkGp4WANI Qy3Xpz97bn9A3hPtBKHncH5zglp783k573WBDQW+KovZ7Vge52g4WtTNC/sC/lwvF0+A 3w3Q== X-Gm-Message-State: AFqh2kqlEnGnCfFgDiVLWDG/WdJPUUodXOBEpA8ACCfiVwh1FxzOSV3D hu33zjI8dVmvXQnGkupJEOixKxoYBrXTxxWB X-Google-Smtp-Source: AMrXdXuFsx7zPGMau2/twXFH+qCYunDa0HlXe9ougrCXYOEZVMbANU5HyuVcuZ7884JAXmN3RCktSg== X-Received: by 2002:a05:600c:1d98:b0:3d3:3d51:7d4b with SMTP id p24-20020a05600c1d9800b003d33d517d4bmr48804528wms.29.1673304867632; Mon, 09 Jan 2023 14:54:27 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id 16-20020a05600c22d000b003b4a699ce8esm16335702wmg.6.2023.01.09.14.54.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 14:54:27 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost , Markus Armbruster , "Daniel P . Berrange" Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org, Paolo Bonzini , Hanna Reitz Subject: [RFC PATCH 1/4] qom: Introduce object_class_property_deprecate() Date: Mon, 9 Jan 2023 23:54:16 +0100 Message-Id: <20230109225419.22621-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109225419.22621-1-philmd@linaro.org> References: <20230109225419.22621-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce object_class_property_deprecate() to register a QOM property as deprecated. When this property's getter / setter is called, a deprecation warning is displayed on the monitor. Inspired-by: Daniel P. Berrange Signed-off-by: Philippe Mathieu-Daudé --- include/qom/object.h | 17 +++++++++++++++++ qom/object.c | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index ef7258a5e1..b76724292c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -97,6 +97,7 @@ struct ObjectProperty ObjectPropertyInit *init; void *opaque; QObject *defval; + const char *deprecation_reason; }; /** @@ -1075,6 +1076,22 @@ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *name, ObjectPropertyRelease *release, void *opaque); +/** + * object_class_property_deprecate: + * @klass: the class to add a property to + * @name: the name of the property. This can contain any character except for + * a forward slash. In general, you should use hyphens '-' instead of + * underscores '_' when naming properties. + * @reason: the deprecation reason. + * @version_major: the major version since this property is deprecated. + * @version_minor: the minor version since this property is deprecated. + * + * Deprecate a class property. + */ +void object_class_property_deprecate(ObjectClass *klass, + const char *name, const char *reason, + int version_major, int version_minor); + /** * object_property_set_default_bool: * @prop: the property to set diff --git a/qom/object.c b/qom/object.c index e25f1e96db..05b97cd424 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1293,6 +1293,16 @@ object_class_property_add(ObjectClass *klass, return prop; } +void object_class_property_deprecate(ObjectClass *klass, + const char *name, const char *reason, + int version_major, int version_minor) +{ + ObjectProperty *prop = object_class_property_find(klass, name); + + assert(prop); + prop->deprecation_reason = reason; +} + ObjectProperty *object_property_find(Object *obj, const char *name) { ObjectProperty *prop; @@ -1382,6 +1392,17 @@ void object_property_del(Object *obj, const char *name) g_hash_table_remove(obj->properties, name); } +static void object_property_check_deprecation(const Object *obj, + const char *name, + const ObjectProperty *prop) +{ + if (!prop->deprecation_reason) { + return; + } + warn_report("Property '%s.%s' is deprecated (%s).", + object_get_typename(obj), name, prop->deprecation_reason); +} + bool object_property_get(Object *obj, const char *name, Visitor *v, Error **errp) { @@ -1392,6 +1413,7 @@ bool object_property_get(Object *obj, const char *name, Visitor *v, return false; } + object_property_check_deprecation(obj, name, prop); if (!prop->get) { error_setg(errp, "Property '%s.%s' is not readable", object_get_typename(obj), name); @@ -1412,6 +1434,7 @@ bool object_property_set(Object *obj, const char *name, Visitor *v, return false; } + object_property_check_deprecation(obj, name, prop); if (!prop->set) { error_setg(errp, "Property '%s.%s' is not writable", object_get_typename(obj), name); From patchwork Mon Jan 9 22:54:17 2023 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: 13094486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B7F5C5479D for ; Mon, 9 Jan 2023 22:54:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF12M-0004tt-M5; Mon, 09 Jan 2023 17:54:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF12K-0004nA-V3 for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:36 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF12I-0007jB-9a for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:35 -0500 Received: by mail-wm1-x32b.google.com with SMTP id p1-20020a05600c1d8100b003d8c9b191e0so8465065wms.4 for ; Mon, 09 Jan 2023 14:54:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TEIyfTZu5Mi/i+A1aDFcrn/cc8NYJ3wg49JfcYmsmDE=; b=HRpR2jNZdY5XRSuS9ewBPJgZWnUTfB4+X7CL7Wjorn0m9hjGS+ybnj6+y1aaGN1/on XttWwAu4n+dMXqBcGV30NcDYylXasFl3jFD2O54JMN0Tzj0ZL3Q0/q0sgJw9vhfRQgNm Q6QlS1DSO898Bl1sl7DPWincv85QzOBjgb9kOPvebGCXlPA2Wu5qmVGc9AkrU06BNgKK 6tSeDgTlK6q8fJw/jAyx7glmEDfKI2F3gSdvJfG3Id1wEUVeBoPuSSlcO+IjfFuZB6zI esnuw602lJzOIEQwbtvadyU5iQTP4ApZnHn4GUWcykOiOsCfb1Ea+4t6cnT1AN70B8Yg K1RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TEIyfTZu5Mi/i+A1aDFcrn/cc8NYJ3wg49JfcYmsmDE=; b=y4+mhGiasIk3wYspYvTumtUKRKnZYsQzViUmeO4i1zJkd+RCMC5DkYwrvJ5QFh0O4g kxY8q2oOE/A6HJrNtWUXVADdhHb/SR/kIrlVHHRlrE++0+eE2ko3B8CgZYOpkzwOvKA6 nwDxRyVDPd+gAiUSfaWpyFdb1Qtd6Jita/lM7y13NHqVlsLfZDApK5Prdss/IAhNrqnm HqWA2sariBmZfgCbnL2xHjSviK1YfqQw80gDHpWr7d+UJjZ1oXxWbQxCCGhNvHPNS8EX D+dNt9PU6yheI6/2m6y0W9XXtB7zN9KvJsSUMiPQPZVS8eguj0hoqYDdtcSiMe7AjgY8 60sg== X-Gm-Message-State: AFqh2krcrsuUWWfYfEnNb+8QN4QZ3lAMJ8jqNr9Y9YGjrImoomRaNrAW VRHyvrC4O51skomZNza2QMn6qxG106l8ZpNp X-Google-Smtp-Source: AMrXdXtcqYFauBKrqFI1URfmJh1PJVo0GZ01N/0aVvbSt/0ZSUIYVDbK5LVZ6tgSqA4cyE+X2OcIgA== X-Received: by 2002:a05:600c:35ca:b0:3d1:f2de:195a with SMTP id r10-20020a05600c35ca00b003d1f2de195amr50942726wmq.32.1673304872811; Mon, 09 Jan 2023 14:54:32 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id t9-20020a05600c198900b003d9e74dd9b2sm9273003wmq.9.2023.01.09.14.54.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 14:54:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost , Markus Armbruster , "Daniel P . Berrange" Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org, Paolo Bonzini , Hanna Reitz Subject: [RFC PATCH 2/4] hw/block: Rename TYPE_PFLASH_CFI02 'width' property as 'device-width' Date: Mon, 9 Jan 2023 23:54:17 +0100 Message-Id: <20230109225419.22621-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109225419.22621-1-philmd@linaro.org> References: <20230109225419.22621-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use the same property name than the TYPE_PFLASH_CFI01 model. Deprecate the current 'width' property and add the 'device-width' property pointing to the same field in PFlashCFI02. Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi02.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 2a99b286b0..bbf78ad1e4 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -950,6 +950,7 @@ static Property pflash_cfi02_properties[] = { DEFINE_PROP_UINT32("num-blocks3", PFlashCFI02, nb_blocs[3], 0), DEFINE_PROP_UINT32("sector-length3", PFlashCFI02, sector_len[3], 0), DEFINE_PROP_UINT8("width", PFlashCFI02, width, 0), + DEFINE_PROP_UINT8("device-width", PFlashCFI02, width, 0), DEFINE_PROP_UINT8("mappings", PFlashCFI02, mappings, 0), DEFINE_PROP_UINT8("big-endian", PFlashCFI02, be, 0), DEFINE_PROP_UINT16("id0", PFlashCFI02, ident0, 0), @@ -978,6 +979,11 @@ static void pflash_cfi02_class_init(ObjectClass *klass, void *data) dc->unrealize = pflash_cfi02_unrealize; device_class_set_props(dc, pflash_cfi02_properties); set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + + object_class_property_deprecate(klass, "width", + "renamed as '" + TYPE_PFLASH_CFI02 ".device-width'", + 8, 0); } static const TypeInfo pflash_cfi02_info = { @@ -1014,7 +1020,7 @@ PFlashCFI02 *pflash_cfi02_register(hwaddr base, assert(QEMU_IS_ALIGNED(size, sector_len)); qdev_prop_set_uint32(dev, "num-blocks", size / sector_len); qdev_prop_set_uint32(dev, "sector-length", sector_len); - qdev_prop_set_uint8(dev, "width", width); + qdev_prop_set_uint8(dev, "device-width", width); qdev_prop_set_uint8(dev, "mappings", nb_mappings); qdev_prop_set_uint8(dev, "big-endian", !!be); qdev_prop_set_uint16(dev, "id0", id0); From patchwork Mon Jan 9 22:54:18 2023 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: 13094492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B49FC5479D for ; Mon, 9 Jan 2023 22:56:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF12T-00058X-4L; Mon, 09 Jan 2023 17:54:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF12Q-00051R-4W for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:42 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF12N-0007jm-Pd for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:41 -0500 Received: by mail-wm1-x32a.google.com with SMTP id bi26-20020a05600c3d9a00b003d3404a89faso80472wmb.1 for ; Mon, 09 Jan 2023 14:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zmsiOvblx944I2vPr/ngo2q8F1qd2s6a6mFL2ICxK8U=; b=zBOlBtqPleDHf0VdO+y+cAIUshMH5wpIxsHdQ1/8Ysxewl1rpAxa0IohtYijfMmaFw 40lem8oQt0rbRt/u2PfxdcX4BcBBwHjzc+wxi3ZRb9IsSaLQo/xy79kali1Dz6fL+ZQ2 hHz8RwTTfKtBo/Tx9734tp7U+oNJCzbf8oStlbk6YwLz/dHpvKD5mAVLxCvkJ4GZ0N8K J5GdZjwR+HXN+tQXNgFjYi5gad0a4O2rHEWnotR8WsqfCrIrYmwryxDbYttxM2Jt/sNY B/0NZ2z+4RxUMOuGB4mEXhgTKJyKtzuV/FkJutV8BuwExV6ehmXhuhxJKMJyUExeWOPx 69BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zmsiOvblx944I2vPr/ngo2q8F1qd2s6a6mFL2ICxK8U=; b=pEwmIVELwcwbF3VbHDWl0eNfTNcWu0XfvHrbSkOZ9xPuy9cEvh0CQHlzn57jRRP/1x yep/E25EEa2gzmWQU7r/LlXoImv3z/Z5P6OhcbY6xkTzSdoZSCmBtPQxhC+ZSBmA7nL3 4UKhYXdO2HIuFbPl4f/QGQ8h4EO/IpeQrGQM5P/3cs/NjpVnysAX2DkrYY4x3T2AM28K 1/eJW/PLpOTWWFs56t9q0BMuvZZqBkQdBj7USljqH/77aj524eMbd4Rnm+jQrtYtDTzq 4Omq4Hp0KUq8CWMyCFhmor8k1D2H4HxiR+cIKPPvJvfOr7mAq0KzAOdpMIRIEMNPMrBq JueQ== X-Gm-Message-State: AFqh2kpxzgxbt9fG/x+eJ7+jf8grRRUs1z/q4MgDwJV/JE23SzvlnWuu LUQCWgl93g02JvnsGFPZC7+KxXCRVaDLMRDT X-Google-Smtp-Source: AMrXdXsRlLkZ/9H9ds1U559l3BgFirCYACmlt9POcIPyTcDQV0jWonAf/J5tZ2lcZSmbU/CpDqRsgg== X-Received: by 2002:a05:600c:348b:b0:3d2:2a72:2577 with SMTP id a11-20020a05600c348b00b003d22a722577mr46677666wmq.27.1673304878167; Mon, 09 Jan 2023 14:54:38 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id m25-20020a05600c3b1900b003d9ed49ee2bsm7266879wms.1.2023.01.09.14.54.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 14:54:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost , Markus Armbruster , "Daniel P . Berrange" Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org, Paolo Bonzini , Hanna Reitz Subject: [RFC PATCH 3/4] util: Introduce helpers to compare QEMU versions Date: Mon, 9 Jan 2023 23:54:18 +0100 Message-Id: <20230109225419.22621-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109225419.22621-1-philmd@linaro.org> References: <20230109225419.22621-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add qemu_version_delta() to compare 2 QEMU versions, and qemu_version_delta_current() to compare with the current QEMU version. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/qemu-version.h | 36 ++++++++++++++++++++++++++++++++++++ util/meson.build | 1 + util/qemu-version.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 include/qemu/qemu-version.h create mode 100644 util/qemu-version.c diff --git a/include/qemu/qemu-version.h b/include/qemu/qemu-version.h new file mode 100644 index 0000000000..c9274bfaf0 --- /dev/null +++ b/include/qemu/qemu-version.h @@ -0,0 +1,36 @@ +/* + * Utility function around QEMU release version + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_UTIL_VERSION_H +#define QEMU_UTIL_VERSION_H + +/** + * qemu_version_delta - Return delta between two release versions ('A' and 'B'). + * @version_major_a: Version 'A' major number + * @version_minor_a: Version 'A' minor number + * @version_major_b: Version 'B' major number + * @version_minor_b: Version 'B' minor number + * + * Returns a negative number is returned if 'A' is older than 'B', or positive + * if 'A' is newer than 'B'. The number represents the number of minor versions. + */ +int qemu_version_delta(unsigned version_major_a, unsigned version_minor_a, + unsigned version_major_b, unsigned version_minor_b); + +/** + * qemu_version_delta_current - Return delta with current QEMU release version. + * @version_major: The major version + * @version_minor: The minor version + * + * Returns the number of minor versions between the current released + * version and the requested $major.$minor. A negative number is returned + * for older versions and positive for newer. + */ +int qemu_version_delta_current(unsigned version_major, unsigned version_minor); + +#endif diff --git a/util/meson.build b/util/meson.build index d8d109ff84..655debeec1 100644 --- a/util/meson.build +++ b/util/meson.build @@ -58,6 +58,7 @@ util_ss.add(files('yank.c')) util_ss.add(files('int128.c')) util_ss.add(files('memalign.c')) util_ss.add(files('interval-tree.c')) +util_ss.add(files('qemu-version.c')) if have_user util_ss.add(files('selfmap.c')) diff --git a/util/qemu-version.c b/util/qemu-version.c new file mode 100644 index 0000000000..d409a6e574 --- /dev/null +++ b/util/qemu-version.c @@ -0,0 +1,37 @@ +/* + * Utility function around QEMU release version + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/qemu-version.h" +#include "config-host.h" + +#define QEMU_FIRST_MAJOR_VERSION_SUPPORTED 4 +#define QEMU_MINOR_VERSIONS_PER_MAJOR 3 + +int qemu_version_delta(unsigned version_major_a, unsigned version_minor_a, + unsigned version_major_b, unsigned version_minor_b) +{ + int delta; + + assert(version_major_a >= QEMU_FIRST_MAJOR_VERSION_SUPPORTED); + assert(version_major_b >= QEMU_FIRST_MAJOR_VERSION_SUPPORTED); + assert(version_minor_a < QEMU_MINOR_VERSIONS_PER_MAJOR); + assert(version_minor_b < QEMU_MINOR_VERSIONS_PER_MAJOR); + + delta = version_major_b - version_major_a; + delta *= QEMU_MINOR_VERSIONS_PER_MAJOR; + delta += version_minor_b - version_minor_a; + + return delta; +} + +int qemu_version_delta_current(unsigned version_major, unsigned version_minor) +{ + return qemu_version_delta(QEMU_VERSION_MAJOR, QEMU_VERSION_MINOR, + version_major, version_minor); +} From patchwork Mon Jan 9 22:54:19 2023 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: 13094488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9B0CC5479D for ; Mon, 9 Jan 2023 22:55:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pF12W-0005Is-H5; Mon, 09 Jan 2023 17:54:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pF12U-0005Eh-Lb for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:46 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pF12S-0007j9-7h for qemu-devel@nongnu.org; Mon, 09 Jan 2023 17:54:46 -0500 Received: by mail-wm1-x32f.google.com with SMTP id g19-20020a05600c4ed300b003d9eb1dbc0aso5509072wmq.3 for ; Mon, 09 Jan 2023 14:54:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xA2zJhQFDWndGaehXTKSbGgxfQUNaxn1ECLWbGBrK7I=; b=ZiWawKgdap3V5zfR9jF6GYBvUIOaaNpcUKjMu0EgoEgehQ7RnKMffxlDsQHXnIuJEt Aau+SlfpAipUv5lqgt+GFGfogYu3dYt8IkjLseUWaWJXhfpHZaMVQcGAlgvb4BMszdfl T1eDCNDUWq/yH1YFc+c14ypDaPyxgRYI3Dk2G8TOPoGobQQb3v6L2/vhyVv3v1vftWhj vVRoXEklPmz8MN7UiYgZgC/MFkzCKv6Erz061b0BwZvxf6t9YOp8xfQkQnukiIyfuORK brvG7uD46HxxmgN/Re+E0jwL35sXxrejEoU2Bb5f+GaoBZo96wl0nDKz+eoSvW6Qz6ha /HYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xA2zJhQFDWndGaehXTKSbGgxfQUNaxn1ECLWbGBrK7I=; b=rnhdtZHePjzz42dl1oz2NuUT5RSTVMJQVKXuNlfPFEUDXgdGhj3pS/nuR4TdoP1ml6 loaxmSMrUoYaeVE6XfTkchtvZh6Ce8rxme9ACdhJHSRYgoJzVTKhY3r92oXtMEUhWorh OUgaOBhhPoT5hwepqbo4LMwTKm4XxRwirKrZvq05mV+bFVYuS5ClbFuyDeo+SCF6bZ/B kT/xDjsgIcXXrBhwyZLRe3X9q0gqUm+BPMFNefQ4WR1dES8yby8m4DZUohTMjErJIctz L7m+IuBf6Pj5k6oF2k9Iih0odi/RN7C+EnkITrbkRTY9MpSkisd3tO4wS5zcVMgjm2EO kQcg== X-Gm-Message-State: AFqh2krYyGIhKlATtEs11qlindrw8H2P11HO88TqxMDjVuS9DrrYrGRi RYw0aRsYjpAy+S3yi7hN1VVtOPk4VlM9b8ZP X-Google-Smtp-Source: AMrXdXu8SMmg22G2XydIBvjetIYSm+D+KPKmr0kRjceSZsQRqxmZmxzkM64qJRkWiZP6OCEIwlioyA== X-Received: by 2002:a1c:4c0e:0:b0:3d9:f836:3728 with SMTP id z14-20020a1c4c0e000000b003d9f8363728mr219439wmf.11.1673304883369; Mon, 09 Jan 2023 14:54:43 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id n23-20020a05600c3b9700b003cf71b1f66csm14602830wms.0.2023.01.09.14.54.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 14:54:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost , Markus Armbruster , "Daniel P . Berrange" Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Stefan Hajnoczi , Kevin Wolf , qemu-block@nongnu.org, Paolo Bonzini , Hanna Reitz Subject: [RFC PATCH 4/4] qom: Warn when deprecated class property can be removed Date: Mon, 9 Jan 2023 23:54:19 +0100 Message-Id: <20230109225419.22621-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109225419.22621-1-philmd@linaro.org> References: <20230109225419.22621-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.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é --- 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; }