Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216911/?format=api
{ "id": 2216911, "url": "http://patchwork.ozlabs.org/api/patches/2216911/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260327111700.795099-3-peter.maydell@linaro.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260327111700.795099-3-peter.maydell@linaro.org>", "list_archive_url": null, "date": "2026-03-27T11:15:57", "name": "[v2,02/65] hw/core: Permit devices to define an array of link properties", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "f3d6744f3bb92e528eaa8e419497a12e8f127a73", "submitter": { "id": 5111, "url": "http://patchwork.ozlabs.org/api/people/5111/?format=api", "name": "Peter Maydell", "email": "peter.maydell@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260327111700.795099-3-peter.maydell@linaro.org/mbox/", "series": [ { "id": 497750, "url": "http://patchwork.ozlabs.org/api/series/497750/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497750", "date": "2026-03-27T11:16:25", "name": "arm: Implement an emulation of GICv5 interrupt controller", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/497750/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216911/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216911/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=w+4rZU36;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhyvC1kC1z1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 22:23:35 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w65Be-0006Md-8S; Fri, 27 Mar 2026 07:17:10 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>)\n id 1w65Bc-0006LI-DU\n for qemu-devel@nongnu.org; Fri, 27 Mar 2026 07:17:08 -0400", "from mail-wr1-x436.google.com ([2a00:1450:4864:20::436])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <peter.maydell@linaro.org>)\n id 1w65BZ-0007WQ-K1\n for qemu-devel@nongnu.org; Fri, 27 Mar 2026 07:17:08 -0400", "by mail-wr1-x436.google.com with SMTP id\n ffacd0b85a97d-43b5bded412so1432102f8f.0\n for <qemu-devel@nongnu.org>; Fri, 27 Mar 2026 04:17:05 -0700 (PDT)", "from lanath.. (wildly.archaic.org.uk. [81.2.115.145])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43b919cf2b2sm15484227f8f.18.2026.03.27.04.17.02\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 27 Mar 2026 04:17:03 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1774610224; x=1775215024; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=4YrZovDto6t0FqJWMN8zdd2dG3ackVIujvm5OvxbxII=;\n b=w+4rZU36cxBSdOuKiyZPG6BP273oRmume/ZPlRiGRLvwJWtEHoOpOv7g/BxdierTbk\n bpMFji5hO6xdXFDtYrcqeMm27SyfnnSec8UfDLW87sFnmY8sBsXkGxwz7beaRU19PJVh\n ISbvki48l3wFm34ADYII8HyAx/W7+0GgNkhIoRbMkJoaCIwoPAenH9gloECf6zPifIii\n p0ouKPjz7Klcpkw9UvCQFWIY3y9QcxAKc+mRdnxIlv/G96zL0+XAmjZIXOMHcxYQ3PVX\n Tuvt+P5ijrFwtRNCPSEnPjCGAzgCugucE1wtSzUh4SGxpr5Q7cwwL4LKfmQ59ySZLRoo\n YmJQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774610224; x=1775215024;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=4YrZovDto6t0FqJWMN8zdd2dG3ackVIujvm5OvxbxII=;\n b=gFGQkQaiiwYXBOb9nVX9TH519i/OHmerECcle/HkRPqwsQNBsXcMpOCMrusGGpS/LI\n ddeI0YuUCMSnbzPBHgXx8kB49htmpwxz34ZiWA2TDBXASo9Hk7QD+jEy8eE5dmxAExDp\n /zqCwbGRPyAwQhU6ctMXuCY91tFUK+tEk1bf/I35zbS5jHp/DQKhecukyr5H8xdY06aY\n TZkuJ53KwNnY4cROWtFv95EfEa2uGfo/zUmbhjSbWAaLStv7oEm6hown063V9G+FcIaP\n LUArrJmux1DwyRmD5iNEPKerkZgMBJoc3Le/+yHnSvBIM3hlHIx/A5vPeS6PjAoWQ/O+\n qW0w==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCUxt5kzZpDGEXwAD3ce+j1ExdCsBb1kaSuTCZpd3CbAU2Hw4H/Bd+wLjuFmoUGP5WeojO6kdqLX+SvQ@nongnu.org", "X-Gm-Message-State": "AOJu0YzmrB6Hg3ahhUplg7+ETpOegzuJBpeGAyPYKSntWYO9a6HNNG+P\n KGHQO+CKZmNHQvbv5bz1ywDtem8vidbRtPnA8k1gtK6Au8mWAgDulJJhpO4dDg65oNg=", "X-Gm-Gg": "ATEYQzwDSlcRJfbN2k3UkQR7/cCNmLV5hDy/jdrSW7ctyhMPzMABSd6XxLnVqHGD4r/\n RSkGS7iwjsIgmEsYwjeUoc5S2zJq4Yt2iSoMFbjwZU0M5ki55BAPowxcP7D32h6EkUA1HzCh0Qd\n LCCngTndugVVK30f6ria1KQcHmgSXFUXcGnVjCLNZ8MqWo7asGM13vYVKcf+SJZ9J+W/lMeZMiK\n bnxqPNgQZUefU1pnjDkJyTqvN3iT27i1cmdvdZxH/1TToIFJksYSWqNgJkqO7yuL+Ij6765LG9Q\n Vt5aOaJB4Ehjep+OsksTLdf5XbYo0b6RRlXAHGwxeumtH/4TQMDqTS0UavO9Ib96SKjK1ORn2TF\n j4WTdR4yJFhy++ZYa+zjCjILYpGoP11GEQ24nvkd84d0CL7NsmltSeRgAPiecrbGvlX2Qyb4hX0\n UW7L9dZoewoomUcptd5VhxnLsqUsfQHsbX1UsFvizAB726RXJJf/wx3Ur/RheYXBm+Ytf1ZAHE0\n j48ETcFNvmoReYC77i6of8RDDVpNi0=", "X-Received": "by 2002:a05:6000:22c2:b0:439:b3bb:2777 with SMTP id\n ffacd0b85a97d-43b9e9eb148mr3219353f8f.22.1774610223787;\n Fri, 27 Mar 2026 04:17:03 -0700 (PDT)", "From": "Peter Maydell <peter.maydell@linaro.org>", "To": "qemu-arm@nongnu.org,\n\tqemu-devel@nongnu.org", "Cc": "Jonathan Cameron <jonathan.cameron@huawei.com>", "Subject": "[PATCH v2 02/65] hw/core: Permit devices to define an array of link\n properties", "Date": "Fri, 27 Mar 2026 11:15:57 +0000", "Message-ID": "<20260327111700.795099-3-peter.maydell@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260327111700.795099-1-peter.maydell@linaro.org>", "References": "<20260327111700.795099-1-peter.maydell@linaro.org>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a00:1450:4864:20::436;\n envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x436.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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Currently we allow devices to define \"link properties\" with\nDEFINE_PROP_LINK(): these are a way to give a device a pointer to\nanother QOM object. (Under the hood this is done by handing it the\ncanonical QOM path for the object.)\n\nWe also allow devices to define \"array properties\" with\nDEFINE_PROP_ARRAY(): these are a way to give a device a\nvariable-length array of properties.\n\nHowever, there is no way to define an array of link properties. If\nyou try to do it by passing qdev_prop_link as the arrayprop argument\nto DEFINE_PROP_ARRAY() you will get a crash because qdev_prop_link\ndoes not provide the .set and .get methods in its PropertyInfo\nstruct.\n\nThis patch implements a new DEFINE_PROP_LINK_ARRAY(). In\na device you can use it like this:\n\nstruct MyDevice {\n ...\n uint32_t num_cpus;\n ARMCPU **cpus;\n}\n\nand in your Property array:\n DEFINE_PROP_LINK_ARRAY(\"cpus\", MyDevice, num_cpus, cpus,\n TYPE_ARM_CPU, ARMCPU *),\n\nThe array property code will fill in s->num_cpus, allocate memory in\ns->cpus, and populate it with pointers.\n\nOn the device-creation side you set the property in the same way as\nthe existing array properties, using the new qlist_append_link()\nfunction to append to the QList:\n\n QList *cpulist = qlist_new();\n for (int i = 0; i < cpus; i++) {\n qlist_append_link(cpulist, OBJECT(cpu[i]));\n }\n qdev_prop_set_array(mydev, \"cpus\", cpulist);\n\nThe implementation is mostly in the provision of the .set and\n.get methods to the qdev_prop_link PropertyInfo struct. The\ncode of these methods parallels the code in\nobject_set_link_property() and object_get_link_property(). We can't\ncompletely share the code with those functions because of differences\nin where we get the information like the target QOM type, but I have\npulled out a new function object_resolve_and_typecheck() for the\nshared \"given a QOM path and a type, give me the object or an error\"\ncode.\n\nSigned-off-by: Peter Maydell <peter.maydell@linaro.org>\nReviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>\n---\n hw/core/qdev-properties.c | 78 +++++++++++++++++++++++++++++++\n include/hw/core/qdev-properties.h | 41 ++++++++++++++++\n 2 files changed, 119 insertions(+)", "diff": "diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c\nindex ba8461e9a4..f8181b0d91 100644\n--- a/hw/core/qdev-properties.c\n+++ b/hw/core/qdev-properties.c\n@@ -669,6 +669,7 @@ static Property array_elem_prop(Object *obj, const Property *parent_prop,\n * being inside the device struct.\n */\n .offset = (uintptr_t)elem - (uintptr_t)obj,\n+ .link_type = parent_prop->link_type,\n };\n }\n \n@@ -950,6 +951,12 @@ void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values)\n qobject_unref(values);\n }\n \n+void qlist_append_link(QList *qlist, Object *obj)\n+{\n+ g_autofree char *path = object_get_canonical_path(obj);\n+ qlist_append_str(qlist, path);\n+}\n+\n static GPtrArray *global_props(void)\n {\n static GPtrArray *gp;\n@@ -1059,9 +1066,80 @@ static ObjectProperty *create_link_property(ObjectClass *oc, const char *name,\n OBJ_PROP_LINK_STRONG);\n }\n \n+/*\n+ * The logic in these get_link() and set_link() functions is similar\n+ * to that used for single-element link properties in the\n+ * object_get_link_property() and object_set_link_property() functions.\n+ * The difference is largely in how we get the expected type of the\n+ * link: for us it is in the Property struct, and for a single link\n+ * property it is part of the property name on the object.\n+ */\n+static void get_link(Object *obj, Visitor *v, const char *name, void *opaque,\n+ Error **errp)\n+{\n+ const Property *prop = opaque;\n+ Object **targetp = object_field_prop_ptr(obj, prop);\n+ g_autofree char *path = NULL;\n+\n+ if (*targetp) {\n+ path = object_get_canonical_path(*targetp);\n+ visit_type_str(v, name, &path, errp);\n+ } else {\n+ path = g_strdup(\"\");\n+ visit_type_str(v, name, &path, errp);\n+ }\n+}\n+\n+static void set_link(Object *obj, Visitor *v, const char *name, void *opaque,\n+ Error **errp)\n+{\n+ const Property *prop = opaque;\n+ Object **targetp = object_field_prop_ptr(obj, prop);\n+ g_autofree char *path = NULL;\n+ Object *new_target, *old_target = *targetp;\n+\n+ ERRP_GUARD();\n+\n+ /* Get the path to the object we want to set the link to */\n+ if (!visit_type_str(v, name, &path, errp)) {\n+ return;\n+ }\n+\n+ /* Now get the pointer to the actual object */\n+ if (*path) {\n+ new_target = object_resolve_and_typecheck(path, prop->name,\n+ prop->link_type, errp);\n+ if (!new_target) {\n+ return;\n+ }\n+ } else {\n+ new_target = NULL;\n+ }\n+\n+ /*\n+ * Our link properties are always OBJ_PROP_LINK_STRONG and\n+ * have the allow_set_link_before_realize check.\n+ */\n+ qdev_prop_allow_set_link_before_realize(obj, prop->name, new_target, errp);\n+ if (*errp) {\n+ return;\n+ }\n+\n+ *targetp = new_target;\n+ object_ref(new_target);\n+ object_unref(old_target);\n+}\n+\n const PropertyInfo qdev_prop_link = {\n .type = \"link\",\n .create = create_link_property,\n+ /*\n+ * Since we have a create method, the get and set are used\n+ * only in get_prop_array() and set_prop_array() for the case\n+ * where we have an array of link properties.\n+ */\n+ .get = get_link,\n+ .set = set_link,\n };\n \n void qdev_property_add_static(DeviceState *dev, const Property *prop)\ndiff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h\nindex d8745d4c65..58527e62d5 100644\n--- a/include/hw/core/qdev-properties.h\n+++ b/include/hw/core/qdev-properties.h\n@@ -168,6 +168,32 @@ extern const PropertyInfo qdev_prop_link;\n DEFINE_PROP(_name, _state, _field, qdev_prop_link, _ptr_type, \\\n .link_type = _type)\n \n+/**\n+ * DEFINE_PROP_LINK_ARRAY:\n+ * @_name: name of the array\n+ * @_state: name of the device state structure type\n+ * @_field: uint32_t field in @_state to hold the array length\n+ * @_arrayfield: field in @_state (of type '@_arraytype *') which\n+ * will point to the array\n+ * @_linktype: QOM type name of the link type\n+ * @_arraytype: C type of the array elements\n+ *\n+ * Define device properties for a variable-length array _name of links\n+ * (i.e. this is the array version of DEFINE_PROP_LINK).\n+ *\n+ * The array is represented as a list of QStrings in the visitor interface,\n+ * where each string is the QOM path of the object to be linked.\n+ */\n+#define DEFINE_PROP_LINK_ARRAY(_name, _state, _field, _arrayfield, \\\n+ _linktype, _arraytype) \\\n+ DEFINE_PROP(_name, _state, _field, qdev_prop_array, uint32_t, \\\n+ .set_default = true, \\\n+ .defval.u = 0, \\\n+ .arrayinfo = &qdev_prop_link, \\\n+ .arrayfieldsize = sizeof(_arraytype), \\\n+ .arrayoffset = offsetof(_state, _arrayfield), \\\n+ .link_type = _linktype)\n+\n #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \\\n DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)\n #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \\\n@@ -219,6 +245,21 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);\n /* Takes ownership of @values */\n void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values);\n \n+/**\n+ * qlist_append_link: Add a QOM object to a QList of link properties\n+ * @qlist: list to append to\n+ * @obj: object to append\n+ *\n+ * This is a helper function for constructing a QList to pass to\n+ * qdev_prop_set_array() when the qdev property array is an array of\n+ * link properties (i.e. one defined with DEFINE_PROP_LINK_ARRAY).\n+ *\n+ * The object is encoded into the list as a QString which is the\n+ * canonical path of the object; this is the same encoding that\n+ * object_set_link_property() and object_get_link_property() use.\n+ */\n+void qlist_append_link(QList *qlist, Object *obj);\n+\n void *object_field_prop_ptr(Object *obj, const Property *prop);\n \n void qdev_prop_register_global(GlobalProperty *prop);\n", "prefixes": [ "v2", "02/65" ] }