From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37459 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQKuc-00038r-5f for qemu-devel@nongnu.org; Wed, 08 Dec 2010 09:22:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PQKua-0003QJ-Qw for qemu-devel@nongnu.org; Wed, 08 Dec 2010 09:22:30 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:55965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PQKua-0003Pk-JL for qemu-devel@nongnu.org; Wed, 08 Dec 2010 09:22:28 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB8EBuft025723 for ; Wed, 8 Dec 2010 07:11:56 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id oB8EMLTU203142 for ; Wed, 8 Dec 2010 07:22:21 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB8EMIPl009356 for ; Wed, 8 Dec 2010 07:22:19 -0700 Message-ID: <4CFF9497.3090001@linux.vnet.ibm.com> Date: Wed, 08 Dec 2010 08:22:15 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 06/21] vl: add a tmp pointer so that a handler can delete the entry to which it belongs. References: <1290665220-26478-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <1290665220-26478-7-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> <20101208070358.GA3303@valinux.co.jp> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Yoshiaki Tamura Cc: Anthony Liguori , dlaor@redhat.com, ananth@in.ibm.com, kvm@vger.kernel.org, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, qemu-devel@nongnu.org, vatsa@linux.vnet.ibm.com, Isaku Yamahata , avi@redhat.com, psuriset@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com On 12/08/2010 02:11 AM, Yoshiaki Tamura wrote: > 2010/12/8 Isaku Yamahata: > >> QLIST_FOREACH_SAFE? >> > Thanks! So, it should be, > > QLIST_FOREACH_SAFE(e,&vm_change_state_head, entries, ne) { > e->cb(e->opaque, running, reason); > } > > I'll put it in the next spin. > This is still brittle though because it only allows the current handler to delete itself. A better approach is to borrow the technique we use with file descriptors (using a deleted flag) as that is robust against deletion of any elements in a handler. Regards, Anthony Liguori > Yoshi > > >> On Thu, Nov 25, 2010 at 03:06:45PM +0900, Yoshiaki Tamura wrote: >> >>> By copying the next entry to a tmp pointer, >>> qemu_del_vm_change_state_handler() can be called in the handler. >>> >>> Signed-off-by: Yoshiaki Tamura >>> --- >>> vl.c | 5 +++-- >>> 1 files changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/vl.c b/vl.c >>> index 805e11f..6b6aec0 100644 >>> --- a/vl.c >>> +++ b/vl.c >>> @@ -1073,11 +1073,12 @@ void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) >>> >>> void vm_state_notify(int running, int reason) >>> { >>> - VMChangeStateEntry *e; >>> + VMChangeStateEntry *e, *ne; >>> >>> trace_vm_state_notify(running, reason); >>> >>> - for (e = vm_change_state_head.lh_first; e; e = e->entries.le_next) { >>> + for (e = vm_change_state_head.lh_first; e; e = ne) { >>> + ne = e->entries.le_next; >>> e->cb(e->opaque, running, reason); >>> } >>> } >>> -- >>> 1.7.1.2 >>> >>> >>> >> -- >> yamahata >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >>