From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 4/5] qom: delay DeviceState's reclaim to main-loop Date: Wed, 25 Jul 2012 09:37:19 +0200 Message-ID: <500FA22F.3010509@redhat.com> References: <1343187070-27371-1-git-send-email-qemulist@gmail.com> <1343187070-27371-5-git-send-email-qemulist@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Liu Ping Fan , qemu-devel@nongnu.org, kvm@vger.kernel.org, Anthony Liguori , Avi Kivity , Jan Kiszka , Marcelo Tosatti To: Stefan Hajnoczi Return-path: Received: from mail-wi0-f178.google.com ([209.85.212.178]:65189 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831Ab2GYHhY (ORCPT ); Wed, 25 Jul 2012 03:37:24 -0400 Received: by wibhr14 with SMTP id hr14so441481wib.1 for ; Wed, 25 Jul 2012 00:37:22 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 25/07/2012 09:03, Stefan Hajnoczi ha scritto: > From: Liu Ping Fan > > iohandler/bh/timer may use DeviceState when its refcnt=0, It's not clear how to me. The only reference to devices from an iohandler/bh/timer can be in the opaque. Now, if you have a iohandler/bh/timer whose opaque is a DeviceState, you should bump the refcount before setting it up, and unref after tearing it down. See for example how hw/scsi-disk.c bumps the refcount of a request before starting asynchronous I/O and calls unref at the end of the asynchronous I/O callback. Paolo