From nobody Tue Feb 10 19:23:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515895735822733.8758039123163; Sat, 13 Jan 2018 18:08:55 -0800 (PST) Received: from localhost ([::1]:56254 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaXjD-0001SR-2v for importer@patchew.org; Sat, 13 Jan 2018 21:08:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eaXfE-00075p-LD for qemu-devel@nongnu.org; Sat, 13 Jan 2018 21:04:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eaXfD-0006sI-Mc for qemu-devel@nongnu.org; Sat, 13 Jan 2018 21:04:48 -0500 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:42880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eaXfD-0006s1-H0 for qemu-devel@nongnu.org; Sat, 13 Jan 2018 21:04:47 -0500 Received: by mail-qk0-x241.google.com with SMTP id q1so13190877qkb.9 for ; Sat, 13 Jan 2018 18:04:47 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id p8sm13333337qki.61.2018.01.13.18.04.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jan 2018 18:04:46 -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=VwpC2BSJkYWjs9/XAE2+QWljRXUqcphSj9hm+mNO7zw=; b=FqUrrIcPRnfnEQ0ihxj+Yicsk6NOwVl3XR3lqhH15TGp/zfBF+o1LZJ3oIDjVWIzQr RC+JGcYvsdS6X43frW99feOUgSueij1+SgdgfmxXhj1oTSOQnjKvIBa0/KuOzYh94t3B YENzPU6F/Cb+HX3h4qpWvKlTfll84E36pvoA6IdBi5aK6336TPz1qqMslboX9ekF5tN+ DA41bk9hY6ZIBZ8nBh3RVSBjCBtNA/iR/cQDwwgqR+YhbmA2aP5BDS7mk3BP3hL08SMU lfuJxSCHuJGKcQWENOXaPvjPAWpFfJ3KZIEeDgvTRM9ExS2BxiPe0PbrK0l0XQjWrt9t SCcg== 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=VwpC2BSJkYWjs9/XAE2+QWljRXUqcphSj9hm+mNO7zw=; b=sW5gp2CIKZY1lb6OKmeK0fFVZmakYQKcwJuczPlyScEfuhZu1b1493TZajrMkr9GJx SAJ9x1jCQL7vxOKXa5s9RlVYAUltBw7D19oKEfwPdo4B1oZUylth+y4eUf1TPhONUvGN x/+Xysa3cjZGthtvC/Q330BEIWA71gO7Vz/UsrJQUA6fkbwKZCcBmE96l2FxK+xxKG3v pnZczhi/RpLkPhuvCisWpbenBIwY5c9CHY106GlV6MW70/h0aW5r9d+39RFFMvMU59zr tJmkocqjXD0OHtrLcL1FBOxDp3DyhiDnvFHPJbVFzdz2cf1ua+XDQ8B628GY9UT5GTse AXNg== X-Gm-Message-State: AKwxyte50eKcL31oxTSRzYCbjQGIOp8RiZQRRx3fq8NBbP2SYxr9D+hL /Q995Vz3VJH+ZVn0vudGkBY= X-Google-Smtp-Source: ACJfBou6u8AaA1utCnHkmmvayvejJwRGrtT/+XfYeksG/xy0MCGpQHYeK2X4hsyojW1zVA9NKbzcKQ== X-Received: by 10.55.212.129 with SMTP id s1mr44984584qks.44.1515895487014; Sat, 13 Jan 2018 18:04:47 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Eduardo Habkost , Marcel Apfelbaum Date: Sat, 13 Jan 2018 23:04:11 -0300 Message-Id: <20180114020412.26160-3-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180114020412.26160-1-f4bug@amsat.org> References: <20180114020412.26160-1-f4bug@amsat.org> 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: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [RFC PATCH 2/3] 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: qemu-devel@nongnu.org, Michael Roth , Markus Armbruster , Paolo Bonzini , "Dr. David Alan Gilbert" , =?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 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 Reviewed-by: Laurent Vivier --- include/hw/qdev-core.h | 10 ++++++++++ hw/core/qdev.c | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 83db53b3f5..0fc53b33d0 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -381,6 +381,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); diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 11112951a5..a71cd264e2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1140,6 +1140,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); --=20 2.15.1