qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 06/21] vl: add a tmp pointer so that a handler c


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 06/21] vl: add a tmp pointer so that a handler can delete the entry to which it belongs.
Date: Wed, 08 Dec 2010 08:22:15 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10

On 12/08/2010 02:11 AM, Yoshiaki Tamura wrote:
2010/12/8 Isaku Yamahata<address@hidden>:
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<address@hidden>
---
  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 address@hidden
More majordomo info at  http://vger.kernel.org/majordomo-info.html





reply via email to

[Prev in Thread] Current Thread [Next in Thread]