From patchwork Mon Jul 10 15:35:03 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: 701023 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5243169wrs; Mon, 10 Jul 2023 08:36:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXOp8W7TeZnMwq7gm3djjVhUgX7q7RccPCEkSQlnIUWH92n+MuM/nArNdS9fAVGSbNowAO X-Received: by 2002:a05:622a:507:b0:403:a9cb:dd58 with SMTP id l7-20020a05622a050700b00403a9cbdd58mr5703117qtx.51.1689003408726; Mon, 10 Jul 2023 08:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689003408; cv=none; d=google.com; s=arc-20160816; b=zgDoqRyQeQQvZ4KBmls7fiw70K+eMqRephp0utNLrr/d8RdmNv5ltTBwGS6Uj5vWfh /lkEgL5JIyhIZuRJypam5nauoAz3cqwiP7yRnrPsb6Dsx5Z9PgnWpjK40RHN9ZZQRbrX KatyyH0TiV3buwZ/p7zQs1IDsw7KhSZxn8/KameBhluZGQ2gVn/ECoX6rCLN+NpPIhz8 8m0XwgyAd/qAXWNtrW4qNJGy0u27BdxzfX2YsfaXrusTWpMDYIRpAgmysQD+E877b3MU kGMHf6Fi5PX0KUC3DZhDkb5k3a9fXZu6Uo2RagUM+Yg/65OzosOzFNWNTnBif5XrpADB aMuA== 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=2VTCVQrd6KCn5j7u4ggdRsXsalHDUZEasAWYhlhI0Zk=; fh=pHpVzH22N3up2JSv0jV3vGkBG2/OCgsTpbbdQUlofss=; b=I5ZeXLk9VaZhkIZxeyAixpp0vRbxYhCWYQX3Rh4jbvWw22IKa1S5gCB+Rt6gybyZjS 4ShmCXmvgMtUwZouc8waHTZtqD9FmrvUIZ4a6jgkxeIJre1DBQlBo4ZJyUV1K5My1h0t o2K4tQoCbgDBExXP0xQ5OW0G0yBsC4xKy6jRrPSHdxWGxJHdA+d90z7tXZxKx8XR50vn NzbAcaqjZ2IGDvOgW2dt3Dmy+YmeGUm9dykBO8am6xFuoTGk6hgRC1HwrSwFtsHygamk mF/sX0aFA+dH+xbJT1QkIfc3PUaXR91bYZMAa5jEjaZ0/gGEblq5mpz2rxlc80AEAwwF TRJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j+WDoZ1i; 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 s14-20020a05622a018e00b004039eb0c4fdsi10335qtw.597.2023.07.10.08.36.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 08:36:48 -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=j+WDoZ1i; 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 1qIsvJ-0005cN-1a; Mon, 10 Jul 2023 11:35:37 -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 1qIsvB-0005Yn-9s for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:29 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIsv8-0004hm-7X for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:29 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc5d5742bso51841975e9.2 for ; Mon, 10 Jul 2023 08:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689003324; x=1691595324; 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=2VTCVQrd6KCn5j7u4ggdRsXsalHDUZEasAWYhlhI0Zk=; b=j+WDoZ1iK16umdVplpNjyby+C0HXEitODI37kGwJGXP8HLOVKe7rt/a/fw7jXjba2v zs1wAHlxk/Q0gaA1/EiJk1gIej/DaDqErNIuRsyn+V1aYx2zPQYHF82wztebpRwOgDdR wDqaRu8ZbrT7AmcnqHRt5hh/t3t9ctn/KE0KuSYJ1MRNrZYGPsAaBSC6EWxhxA/ELSah ssLutXIIMBRxXlihjutw4bgwVOv+fE2at4V0BKhYv7N3unwblarbHdJ1Zs11Q/JzVm2K nGkk3S7WpCKhBVvOhtq0iL4/XKlTn9C4IYBO7y1oNaY9ibZp27R/VNPsJVXR0gDmkWip wm2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689003324; x=1691595324; 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=2VTCVQrd6KCn5j7u4ggdRsXsalHDUZEasAWYhlhI0Zk=; b=AQD3k3NJI4QZDDSXZWhBxuBdCOMOFg1uIOjfFmtT6iFhCMeCbi/ZqmKZ8I7ZoYu0uF zA0jGhy8ZF/aQ0B0C2CN9y+s6gl9MK74/Hsi09RB5W0Z2gA5bCJjih9+Iyurx1ouhaRk 8ZTvbLij1sq9H0iAmYNqzsHJD5RatWQuERiV2Oi3IjB95e8GXcqUsYWJ3VGXJjv7/U7D I5XCetaNfmxxmXNTu/ScdXIQG0TGLoH/p6XZ1nh27zsMbBt9EVJuxJ08To5NYEypXTn7 XNmIdoPVeS+DUhsoU+vPK7SpHXexSizg31mzIRmJ0vCseKtgyBSR8BcZOdMeDrRC8BmH O/Aw== X-Gm-Message-State: ABy/qLZOQFYa9ahz9KR5bvVLJgl+V798ywzjpl/rdKvHorpgX6Y5OLir lVvekAP0LwC6i+honSiuL6VBEw== X-Received: by 2002:a1c:7502:0:b0:3f8:fc96:6bfd with SMTP id o2-20020a1c7502000000b003f8fc966bfdmr11967928wmc.17.1689003324449; Mon, 10 Jul 2023 08:35:24 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f19-20020a7bcc13000000b003fa973e6612sm10709182wmh.44.2023.07.10.08.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 08:35:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 503791FFBC; Mon, 10 Jul 2023 16:35:22 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Jason Wang , Viresh Kumar , Raphael Norwitz , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Eric Blake , "Michael S. Tsirkin" , Mark Cave-Ayland , Kevin Wolf , Markus Armbruster , Gerd Hoffmann , Mathieu Poirier , Hanna Reitz , =?utf-8?q?Alex_Benn=C3=A9e?= , Erik Schilling , "Gonglei (Arei)" , Eduardo Habkost , Fam Zheng , virtio-fs@redhat.com, Stefan Hajnoczi Subject: [PATCH v3 01/20] include: attempt to document device_class_set_props Date: Mon, 10 Jul 2023 16:35:03 +0100 Message-Id: <20230710153522.3469097-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230710153522.3469097-1-alex.bennee@linaro.org> References: <20230710153522.3469097-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.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 I'm still not sure how I achieve by use case of the parent class defining the following properties: static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("id", VHostUserDevice, id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; But for the specialisation of the class I want the id to default to the actual device id, e.g.: static Property vu_rng_properties[] = { DEFINE_PROP_UINT16("id", VHostUserDevice, id, VIRTIO_ID_RNG), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; And so far the API for doing that isn't super clear. Signed-off-by: Alex Bennée --- include/hw/qdev-core.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 06cadfc492..196ebf6d91 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -926,6 +926,15 @@ BusState *sysbus_get_default(void); char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); +/** + * device_class_set_props(): add a set of properties to an device + * @dc: the parent DeviceClass all devices inherit + * @props: an array of properties, terminate by DEFINE_PROP_END_OF_LIST() + * + * This will add a set of properties to the object. It will fault if + * you attempt to add an existing property defined by a parent class. + * To modify an inherited property you need to use???? + */ void device_class_set_props(DeviceClass *dc, Property *props); /**