From nobody Sun Feb 8 22:53:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517859297190953.4379483214947; Mon, 5 Feb 2018 11:34:57 -0800 (PST) Received: from localhost ([::1]:54777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimXU-0000LZ-0I for importer@patchew.org; Mon, 05 Feb 2018 14:34:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimRz-0004Ar-Mt for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimRy-0004rN-Cx for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:11 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:38687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimRy-0004qe-5N for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:10 -0500 Received: by mail-wm0-x244.google.com with SMTP id 141so27956862wme.3 for ; Mon, 05 Feb 2018 11:29:10 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jvPQQYXG7bl2k1dTyE0wfJnklOUeK/4RRnu7NC/O/ZM=; b=tFXJ11cklJsGVwq0+MnrO4Bu0N7ffqrRslPNF1ZPp87lxeS7MRNurPgVBO2D/Vi6nK N/0JwLSd4LVc8Pv33ScHvbLDFKH+9v5c6oGMas7jmEIAYINSfnXoc9RntfuA6YTTI3Xg QFjDn/C3t604WlxOo0Ir4gwqGCxAAstwuhl0HtMeFdnoPIimw3EPYBrQ02V7mpfISQRa dWtfTVIyIaEhHzMGYOrM2mzn5ySeR9GHTZnV0ETizGa5KjFt09+rN055/ziIgQLrLSU1 FyD8rTyzbPAyWfPi00s1bv13c+4kpKsOY5wzSHMkHL/W5qGeKoF2e+/291uEPhtE83m/ t4zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jvPQQYXG7bl2k1dTyE0wfJnklOUeK/4RRnu7NC/O/ZM=; b=QSWaTrQADrkAO8XLM4Mx6zRFnxud6ra823wsT6ah4bq78JhC6LoL0TT9lThCSpCr4d jmg6ipcnYMRUiQ7SiNO+EkH1G305uZBrtz5MZ4R4dOzJEfOEdoML6YV9r7H2kpFYre3T Nfl2Jke/Pvu1QwfmuvYWeo/V5/bgtRbiz4p4QHnl1f6RKn0ZoxsjUC5XrvrFNeey5oeN IRqp0hpB1NboAKEtza1sqeGBEvk1GFHHBvrMBMqhn57HjXo36A3T0vlG0m+3XZLPjpDh fCXicunHQKDQOngQaifAi7ep++cUXleaTQvQp6OZMJIzLJNYGTaaHjy4LhX/2oX5YWr7 0duA== X-Gm-Message-State: APf1xPCLMyv2dbxOZctqxKGO4zG/cYQlSRK7uKlMY8Es0uXQRxyKAMqZ jxfBS5LEA/L273Nqu7DD3BAGyaR2 X-Google-Smtp-Source: AH8x226fy9Vkd9UK1JwNisIuebPKA7Z3mVTD1BzZE3p8AD2KXTe7Wx55w2ZJ7/3qxpPl65EcpIEZNw== X-Received: by 10.28.182.5 with SMTP id g5mr318825wmf.44.1517858948822; Mon, 05 Feb 2018 11:29:08 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:17 +0100 Message-Id: <1517858941-5538-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 03/47] qdev: add helpers to be more explicit when using abstract QOM parent functions 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Philippe Mathieu-Daud=C3=A9 QOM API learning curve is quite hard, in particular when devices inherit fr= om abstract parent. To be more explicit about when a device class change the parent hooks, add = few helpers hoping a device class_init() will be easier to understand. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20180114020412.26160-3-f4bug@amsat.org> Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini --- hw/core/qdev.c | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2456035..11f8a27 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1075,6 +1075,30 @@ static void device_class_init(ObjectClass *class, vo= id *data) dc->user_creatable =3D true; } =20 +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset) +{ + *parent_reset =3D dc->reset; + dc->reset =3D dev_reset; +} + +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize) +{ + *parent_realize =3D dc->realize; + dc->realize =3D dev_realize; +} + +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize =3D dc->unrealize; + dc->unrealize =3D dev_unrealize; +} + void device_reset(DeviceState *dev) { DeviceClass *klass =3D DEVICE_GET_CLASS(dev); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 85fa26d..18c0251 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -382,6 +382,16 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); =20 +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset); +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize); +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize); + const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); =20 const char *qdev_fw_name(DeviceState *dev); --=20 1.8.3.1