From patchwork Tue Jun 19 01:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931296 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; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OmxFTu/w"; 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 418sb83qzRz9s1R for ; Tue, 19 Jun 2018 12:38:28 +1000 (AEST) Received: from localhost ([::1]:38687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6XK-0008RP-5N for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:38:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jf-00038U-Ht for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5je-0000sf-KV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:07 -0400 Received: from mail-ot0-x22f.google.com ([2607:f8b0:4003:c0f::22f]:35258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5je-0000sC-FC; Mon, 18 Jun 2018 21:47:06 -0400 Received: by mail-ot0-x22f.google.com with SMTP id q17-v6so20780716otg.2; Mon, 18 Jun 2018 18:47:06 -0700 (PDT) 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=2UMT+GFNZKTuXW3jx4E5cgr0GCvUy1Ici4Cy1mboVZM=; b=OmxFTu/wUUS7A7L3cby3QujyW3jWnkT2Gk4mwO8+OS3JoGKgoEqJqyAYY81cx5dpu3 k922klp0aJfjl0cekmOvn3M14yRzHMc+StXBfatpL7EpZUY/ey9D035yRX7rp1d6u0dg bEpzEpMeCxrddcWG6/f7vCi/nT4SkrA/48xT7Stms+u3u5tCBPEeEpJo1joi+nUurzLk YrdDmGdML0mPCj5euzkxdf6BsqCzut5uBMj0Bki4De8HTDnTL0HCdmz35dxVxZaWnXhx i3Yw+XXFLCY6cbZsb5BF1ufwLMXLp4R7Sri87MdXq2j6Pwno+QRD83pyO7zN2262BIBc 8p5Q== 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=2UMT+GFNZKTuXW3jx4E5cgr0GCvUy1Ici4Cy1mboVZM=; b=NVduCvc4PeX/tA/FksLLn4JqMoF0x6Fo0iSl6Aqk81HRUTsH4SOsOGwrJ/bSDW5mRg 5fjqiTi/L/8ODMJzl8R1DzKPB7Np4u96GEGcJw8VcPSvX2ADpBaqfVOINATZ5SeM+JI8 20ela6HM9FIifkvJXFbXE87uBTTCIpN9dVu7b3ZFct0Eng2O0RMCcQuZOTGordJQ+c+q UiPKUAnhWmYMaPPnxQtQfyRT4s3Zpj3S5SX5ntTGCNi1aX9eseGClwTISJIF2HHUxJ8i mxYQcM6Wzh2DTkhD9o4RYgXwG9Xn/9DqDXRh2ESDHdr8wKLy3CuKLs28xYXSdOEVfUH4 4yVQ== X-Gm-Message-State: APt69E03SVLYrqSR6RPp6EaZscf5NJSR9sFkys4U78xBSJjI5eFlJNQm j1pouVV92fpF2KbKahr55kxWbPtezVQ= X-Google-Smtp-Source: ADUXVKKUt2cMoM9JR02Bhxh4TGKyc+BIB9XmfSX72dBdgTwCnkLfQzZjVh+85BxqTZwEn46poh2LKg== X-Received: by 2002:a9d:4905:: with SMTP id e5-v6mr9713923otf.101.1529372825212; Mon, 18 Jun 2018 18:47:05 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id b26-v6sm7272963otl.41.2018.06.18.18.47.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:46 -0500 Message-Id: <20180619014319.28272-81-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::22f Subject: [Qemu-devel] [PATCH 080/113] 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: Paolo Bonzini , qemu-stable@nongnu.org, =?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 (cherry picked from commit 46795cf2e2f643ace9454822022ba8b1e9c0cf61) *prereq for 0c53057adb Signed-off-by: Michael Roth --- 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 11112951a5..a71cd264e2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1140,6 +1140,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 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); +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);