From patchwork Thu Jul 9 16:51:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 493496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 1E1BC1402B5 for ; Fri, 10 Jul 2015 02:52:38 +1000 (AEST) Received: from localhost ([::1]:40927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDF3s-0002i5-3B for incoming@patchwork.ozlabs.org; Thu, 09 Jul 2015 12:52:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDF3Q-0001qc-EE for qemu-devel@nongnu.org; Thu, 09 Jul 2015 12:52:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDF3J-0003p9-Rv for qemu-devel@nongnu.org; Thu, 09 Jul 2015 12:52:08 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:49122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDF3J-0003os-Hw for qemu-devel@nongnu.org; Thu, 09 Jul 2015 12:52:01 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 9 Jul 2015 17:51:59 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 9 Jul 2015 17:51:37 +0100 X-Helo: d06dlp03.portsmouth.uk.ibm.com X-MailFrom: cornelia.huck@de.ibm.com X-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 72FC71B08061 for ; Thu, 9 Jul 2015 17:52:48 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t69GpasS31522914 for ; Thu, 9 Jul 2015 16:51:36 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t69GpZNE013874 for ; Thu, 9 Jul 2015 10:51:36 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t69GpYEb013844; Thu, 9 Jul 2015 10:51:35 -0600 From: Cornelia Huck To: qemu-devel@nongnu.org Date: Thu, 9 Jul 2015 18:51:31 +0200 Message-Id: <1436460692-5142-2-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 2.3.8 In-Reply-To: <1436460692-5142-1-git-send-email-cornelia.huck@de.ibm.com> References: <1436460692-5142-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15070916-0013-0000-0000-000004A31169 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.109 Cc: peter.crosthwaite@xilinx.com, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck , gesaint@linux.vnet.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH for-2.4 1/2] core: reset handler for bus-less devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Devices that don't live on a bus aren't caught by the normal device reset logic. Let's register a reset handler for those devices during device realization that calls the reset handler for the associated device class. Suggested-by: Peter Crosthwaite Signed-off-by: Cornelia Huck Reviewed-by: Peter Crosthwaite Tested-by: Christian Borntraeger --- hw/core/qdev.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index b2f404a..5c7c27b 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1018,6 +1018,13 @@ static bool device_get_realized(Object *obj, Error **errp) return dev->realized; } +static void do_device_reset(void *opaque) +{ + DeviceState *dev = opaque; + + device_reset(dev); +} + static void device_set_realized(Object *obj, bool value, Error **errp) { DeviceState *dev = DEVICE(obj); @@ -1061,6 +1068,11 @@ static void device_set_realized(Object *obj, bool value, Error **errp) goto post_realize_fail; } + if (!dev->parent_bus) { + /* Make sure that reset is called for bus-less devices. */ + qemu_register_reset(do_device_reset, dev); + } + if (qdev_get_vmsd(dev)) { vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, dev->instance_id_alias, @@ -1094,6 +1106,9 @@ static void device_set_realized(Object *obj, bool value, Error **errp) } dev->pending_deleted_event = true; DEVICE_LISTENER_CALL(unrealize, Reverse, dev); + if (!dev->parent_bus) { + qemu_unregister_reset(do_device_reset, dev); + } } if (local_err != NULL) {