From patchwork Mon Apr 24 09:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 676553 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2054383wrs; Mon, 24 Apr 2023 02:23:58 -0700 (PDT) X-Google-Smtp-Source: AKy350aBXnRRso6wrOZXhtjm3LEwGi5XRgfr3WnveTUe7+/Jwys67+KW2ofbOafHgSg3gTt2K9HS X-Received: by 2002:a05:6214:5195:b0:5ef:8b9c:aa86 with SMTP id kl21-20020a056214519500b005ef8b9caa86mr21027568qvb.44.1682328238285; Mon, 24 Apr 2023 02:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682328238; cv=none; d=google.com; s=arc-20160816; b=GCrop2/wLbL5KztuSWsLz5BzEAUvjKd7DqKK3ZwZO8x2ELhHLKc1JfqgFw1RHzkypD XBZMadfoW2mMD3+VY/0PshC3fGjmXb0FZ5C0h9AZ2th0HN8GsfTb4LGvxMDeGBsyXKVH FccmK7fM5/J3AbI4ULKKgfNV2GtTwnjHKJRxZ50IzaathpBkDPkBn0bIq6V3UCmoFXY9 wQOkYclMfGHYZZSipXo/ItmYWyrv0dkaMoNvugfg2kTMZfGivedxjutzPqkrePrhHkhi y7Zp0I6WEA6cR0NCxkaoXXKWdAW1n6W3CCNq5bIAWHYLUr+hIWw03EIrNGwl6snktLbm pJFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ymh1KmF1OssFCV8CswQJao0hOIMo+XbhaPHzwGuiKz8=; b=X1OJGO2FB+R2K2wOmIi0EfsvHZUMbcAZ8AkIQzSekSwkAJPE1uP6GMkikE6MlbyX5Y s5CY/KNlUrS07ZEj8h2F8ca6k2QM64t++yGd0UBghyev5m9z2vUXMk1d45Y5N6vMJYnn 8qeo8UvWey5s6vyHP/T8vjSXAFeePPi4HeCs7w2RmeYuplrTT3jkH2zJCTi7hNlVV78R tqNBXkTS14eYJTCQ+RGg0KNj+u0mdxihpVfFdBwLURNcDHhu8wreKNlTIB4endCcvnjO 5h7AoaUnYbBcuMQ8lMxgajNxGzeCf1oNjOUN0TBBZyOryTQo9hunqe60u9knJXfJhemj dKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uT+ZCJ1w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o2-20020ad45c82000000b005e32ca3bf52si7439690qvh.314.2023.04.24.02.23.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Apr 2023 02:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uT+ZCJ1w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqsQ9-0007wi-Ny; Mon, 24 Apr 2023 05:23:41 -0400 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 1pqsPo-0007Oa-1h for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:23:25 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqsPT-0004pG-Hg for qemu-devel@nongnu.org; Mon, 24 Apr 2023 05:23:18 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-2f95231618aso2557679f8f.1 for ; Mon, 24 Apr 2023 02:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682328178; x=1684920178; 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=ymh1KmF1OssFCV8CswQJao0hOIMo+XbhaPHzwGuiKz8=; b=uT+ZCJ1wEBDq7TmrZeZGhrgzO26xURh4c4nX6qGOo4OqKvHcIRxN+uKvYt6GurNkY8 gTC/l1D9NqP1QiKRx97y1emjAxohpMKe6Tyxv3m9DZ8tSREn7E1Hnnw2I+ARAcUPUnuK yDpAZoScYIIZAvWqj5ojfm+j245QGQTxHUegNhZ6cP3ogh5Qbp1ZTlXe/j9zZlsDB1w1 7BjVDcBB3/9OzVxmhAYRLzN6zdrQzq5InrZpQ3pli0T2p+Xlo29WGW1DY8lJOIszhKzO BS1wgS1TsA9W9W6GeGL6ZNks18KfC2dZqGt6NXEcgGHAOlVd3hfOA2bFLOqJxubaAvAJ vxIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682328178; x=1684920178; 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=ymh1KmF1OssFCV8CswQJao0hOIMo+XbhaPHzwGuiKz8=; b=S2/tSE9om5veBkexl8FWi4rGPs57zhXp4y3JUWDLsTk2hPg4gsfLcUrff4Y6gnJO/h 5N8a5FLolxc+a8LqzBZpQnG+NpDYPPmjgrSsATw+Gt4aPC54xJkJrn1DgLehvkjrn3H5 pVRMHN/nFkSFqaFL+L45wxBHP4hYEbspBqd5PdybWGYE5NHfWHh6inUF6rP4sXcWtiIe o/ejLJOqDGPWoHLW22PhLMzIHXYnCNP4Jk9pb7uCt6LZ0pJWyYl7SO21h+wU0ddgw3pU SR+cjMBnjA2wKQuzLDURz9QATjjFtLveB3K86ubGLsBujpqDdnl6ShVpS6RHixD60v4n 9DmA== X-Gm-Message-State: AAQBX9eTE8GkRmhHsPEdWHu6bWOph/L6O7DjBnwciXn7JMjq+3bqxnZ7 OUrjI3+P/UiZJipvw5DrRJa0kA== X-Received: by 2002:a05:6000:8e:b0:304:6d32:d589 with SMTP id m14-20020a056000008e00b003046d32d589mr3845013wrx.18.1682328178209; Mon, 24 Apr 2023 02:22:58 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id w6-20020adfee46000000b002f0442a2d3asm10372906wro.48.2023.04.24.02.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 02:22:56 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6F1B41FFC7; Mon, 24 Apr 2023 10:22:51 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Wainer dos Santos Moschetta , Beraldo Leal , Thomas Huth , =?utf-8?q?Alex_Benn=C3=A9e?= , "Edgar E. Iglesias" , Paolo Bonzini , Aurelien Jarno , Peter Maydell , Juan Quintela , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Richard Henderson , Joel Stanley , Leif Lindholm , Markus Armbruster , Radoslaw Biernacki , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow , Andrew Jeffery , David Hildenbrand , Bastian Koppelmann , Max Filippov , qemu-s390x@nongnu.org, Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Dani?= =?utf-8?q?el_P=2E_Berrang=C3=A9?= , qemu-arm@nongnu.org, Eduardo Habkost , Ilya Leoshkevich , Mark Cave-Ayland Subject: [PATCH 17/18] docs/devel: mention the spacing requirement for QOM Date: Mon, 24 Apr 2023 10:22:48 +0100 Message-Id: <20230424092249.58552-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230424092249.58552-1-alex.bennee@linaro.org> References: <20230424092249.58552-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org We have a more complete document on QOM but we should at least mention the style requirements in the style guide. Signed-off-by: Alex Bennée Cc: Mark Cave-Ayland Reviewed-by: Juan Quintela Message-Id: <20230420155723.1711048-9-alex.bennee@linaro.org> Reviewed-by: Mark Cave-Ayland --- vppr: - use Mark's formulation, briefly mention property separation. --- docs/devel/qom.rst | 2 ++ docs/devel/style.rst | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docs/devel/qom.rst b/docs/devel/qom.rst index 3e34b07c98..c9237950d0 100644 --- a/docs/devel/qom.rst +++ b/docs/devel/qom.rst @@ -1,3 +1,5 @@ +.. _qom: + =========================== The QEMU Object Model (QOM) =========================== diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 5bc6f2f095..e9fce0fc69 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -628,6 +628,46 @@ are still some caveats to beware of QEMU Specific Idioms ******************** +QEMU Object Model Declarations +============================== + +QEMU Object Model Declarations +============================== + +The QEMU Object Model (QOM) provides a framework for handling objects +in the base C language. The first declaration of a storage or class +structure should always be the parent and leave a visual space between +that declaration and the new code. It is also useful to separate +backing for properties (options driven by the user) and internal state +to make navigation easier. + +For a storage structure the first declaration should always be called +"parent_obj" and for a class structure the first member should always +be called "parent_class" as below: + +.. code-block:: c + + struct MyDeviceState { + DeviceState parent_obj; + + /* Properties */ + int prop_a; + char *prop_b; + /* Other stuff */ + int internal_state; + }; + + struct MyDeviceClass { + DeviceClass parent_class; + + void (*new_fn1)(void); + bool (*new_fn2)(CPUState *); + }; + +Note that there is no need to provide typedefs for QOM structures +since these are generated automatically by the QOM declaration macros. +See :ref:`qom` for more details. + Error handling and reporting ============================