From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXuza-0004WQ-Le for qemu-devel@nongnu.org; Tue, 17 Mar 2015 13:09:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXuzW-0007BM-GZ for qemu-devel@nongnu.org; Tue, 17 Mar 2015 13:09:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56396 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXuzW-0007As-AW for qemu-devel@nongnu.org; Tue, 17 Mar 2015 13:09:18 -0400 Message-ID: <55085FBD.5060003@suse.de> Date: Tue, 17 Mar 2015 18:09:17 +0100 From: =?windows-1252?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1426024655-17561-2-git-send-email-ehabkost@redhat.com> <1426610796-27439-1-git-send-email-afaerber@suse.de> <20150317170435.GN3513@thinpad.lan.raisama.net> In-Reply-To: <20150317170435.GN3513@thinpad.lan.raisama.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-next] pc: Ensure non-zero CPU ref count after attaching to ICC bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Paolo Bonzini , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Richard Henderson Am 17.03.2015 um 18:04 schrieb Eduardo Habkost: > On Tue, Mar 17, 2015 at 05:46:36PM +0100, Andreas F=E4rber wrote: > [...] >> @@ -1054,7 +1055,12 @@ void pc_hot_add_cpu(const int64_t id, Error **e= rrp) >> =20 >> icc_bridge =3D DEVICE(object_resolve_path_type("icc-bridge", >> TYPE_ICC_BRIDGE, NUL= L)); >> - pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp); >> + cpu =3D pc_new_cpu(current_cpu_model, apic_id, icc_bridge, &local= _err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> + return; >> + } >> + object_unref(OBJECT(cpu)); >=20 > Calling object_unref(NULL) is valid, so you can still keep it simple an= d > do this: >=20 > - pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp); > + cpu =3D pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp); > + object_unref(OBJECT(cpu)); Valid yes, but I have a follow-up doing: error_propagate(errp, local_err); return; } + object_property_set_bool(OBJECT(cpu), true, "realized", errp); object_unref(OBJECT(cpu)); } So it's handier to keep it last. Regards, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Felix Imend=F6rffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG N=FCrnberg)