From patchwork Thu Oct 1 08:49:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 525049 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 C4090140D6F for ; Fri, 2 Oct 2015 00:34:09 +1000 (AEST) Received: from localhost ([::1]:50975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhevv-0005cB-Or for incoming@patchwork.ozlabs.org; Thu, 01 Oct 2015 10:34:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhZYy-0000Ja-P7 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 04:50:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhZYu-00062a-NK for qemu-devel@nongnu.org; Thu, 01 Oct 2015 04:50:04 -0400 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:58871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhZYu-0005zj-E3 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 04:50:00 -0400 Received: from /spool/local by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Oct 2015 09:49:58 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 1 Oct 2015 09:49:55 +0100 X-Helo: d06dlp02.portsmouth.uk.ibm.com X-MailFrom: jfrei@linux.vnet.ibm.com X-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 31BC62190068 for ; Thu, 1 Oct 2015 09:49:25 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t918ntAT38076608 for ; Thu, 1 Oct 2015 08:49:55 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t918nsAu001435 for ; Thu, 1 Oct 2015 02:49:55 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t918ns2n001391 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 1 Oct 2015 02:49:54 -0600 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id 9750A20F20D; Thu, 1 Oct 2015 10:49:54 +0200 (CEST) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Thu, 1 Oct 2015 10:49:45 +0200 Message-Id: <1443689387-34473-4-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 2.3.9 In-Reply-To: <1443689387-34473-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1443689387-34473-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15100108-0025-0000-0000-0000045CA2C7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.102 Cc: David Hildenbrand , Jens Freimann , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/5] s390x: set missing parent for hotplug and quiesce events 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 From: David Hildenbrand Existing code missed to set a parent for the quiesce and hotplug event. While this didn't matter in practise, new introspection APIs basically now do an object_unref(object_new(T)), which loops forever. When trying to remove the event facility bus, the code tries to unparent all childs on the bus, so they are properly deleted and therefore removed. As object_unparent() on these child devices doesn't work, as there is no parent, we loop forever. Let's fix this by adding the event facility as a parent. Also switch from object_initialize to object_new, so the only valid reference is in fact the parent property. This makes it more obvious when the device (state) is actually gone (and how the reference counting works). Signed-off-by: David Hildenbrand Signed-off-by: Jens Freimann --- hw/s390x/event-facility.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index ef2a051..907b485 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -27,8 +27,6 @@ typedef struct SCLPEventsBus { struct SCLPEventFacility { SysBusDevice parent_obj; SCLPEventsBus sbus; - SCLPEvent quiesce_event; - SCLPEvent cpu_hotplug_event; /* guest' receive mask */ unsigned int receive_mask; }; @@ -347,19 +345,21 @@ static void init_event_facility(Object *obj) { SCLPEventFacility *event_facility = EVENT_FACILITY(obj); DeviceState *sdev = DEVICE(obj); + Object *new; /* Spawn a new bus for SCLP events */ qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus), TYPE_SCLP_EVENTS_BUS, sdev, NULL); - object_initialize(&event_facility->quiesce_event, sizeof(SCLPEvent), - TYPE_SCLP_QUIESCE); - qdev_set_parent_bus(DEVICE(&event_facility->quiesce_event), - &event_facility->sbus.qbus); - object_initialize(&event_facility->cpu_hotplug_event, sizeof(SCLPEvent), - TYPE_SCLP_CPU_HOTPLUG); - qdev_set_parent_bus(DEVICE(&event_facility->cpu_hotplug_event), - &event_facility->sbus.qbus); + new = object_new(TYPE_SCLP_QUIESCE); + object_property_add_child(obj, TYPE_SCLP_QUIESCE, new, NULL); + object_unref(new); + qdev_set_parent_bus(DEVICE(new), &event_facility->sbus.qbus); + + new = object_new(TYPE_SCLP_CPU_HOTPLUG); + object_property_add_child(obj, TYPE_SCLP_CPU_HOTPLUG, new, NULL); + object_unref(new); + qdev_set_parent_bus(DEVICE(new), &event_facility->sbus.qbus); /* the facility will automatically realize the devices via the bus */ }