From patchwork Mon Feb 5 19:28:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 869466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tFXJ11ck"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zZySD0W56z9sBW for ; Tue, 6 Feb 2018 06:33:32 +1100 (AEDT) Received: from localhost ([::1]:54767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimWA-0007Nx-4T for incoming@patchwork.ozlabs.org; Mon, 05 Feb 2018 14:33:30 -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) 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) 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) 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 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé QOM API learning curve is quite hard, in particular when devices inherit from 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é 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, void *data) dc->user_creatable = true; } +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset) +{ + *parent_reset = dc->reset; + dc->reset = dev_reset; +} + +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize) +{ + *parent_realize = dc->realize; + dc->realize = dev_realize; +} + +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize = dc->unrealize; + dc->unrealize = dev_unrealize; +} + void device_reset(DeviceState *dev) { DeviceClass *klass = 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); +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); const char *qdev_fw_name(DeviceState *dev);