Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MiHDk-0007Eg-9P for qemu-devel@nongnu.org; Mon, 31 Aug 2009 20:27:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MiHDf-0007Ab-RH for qemu-devel@nongnu.org; Mon, 31 Aug 2009 20:27:35 -0400 Received: from [199.232.76.173] (port=49979 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MiHDf-0007AY-JJ for qemu-devel@nongnu.org; Mon, 31 Aug 2009 20:27:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62374) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MiHDf-0007VT-3Q for qemu-devel@nongnu.org; Mon, 31 Aug 2009 20:27:31 -0400 From: Juan Quintela In-Reply-To: <20090831192755.4b011b4e@doriath> (Luiz Capitulino's message of "Mon, 31 Aug 2009 19:27:55 -0300") References: <20090831160020.3799813c@doriath> <20090831192755.4b011b4e@doriath> Date: Tue, 01 Sep 2009 02:25:01 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 3/3] savevm: Convert loadvm handlers list to LIST List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Luiz Capitulino wrote: > On Tue, 01 Sep 2009 00:08:43 +0200 > Juan Quintela wrote: > >> Luiz Capitulino wrote: >> > On Fri, 28 Aug 2009 22:31:57 +0200 >> > Juan Quintela wrote: >> > >> >> >> >> Signed-off-by: Juan Quintela >> >> --- >> >> savevm.c | 20 +++++++++++--------- >> >> 1 files changed, 11 insertions(+), 9 deletions(-) >> >> >> >> diff --git a/savevm.c b/savevm.c >> >> index baef277..9836c60 100644 >> >> --- a/savevm.c >> >> +++ b/savevm.c >> >> @@ -1260,10 +1260,10 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) >> >> } >> >> >> >> typedef struct LoadStateEntry { >> >> + LIST_ENTRY(LoadStateEntry) entry; >> >> SaveStateEntry *se; >> >> int section_id; >> >> int version_id; >> >> - struct LoadStateEntry *next; >> >> } LoadStateEntry; >> >> >> >> static int qemu_loadvm_state_v2(QEMUFile *f) >> >> @@ -1309,7 +1309,8 @@ static int qemu_loadvm_state_v2(QEMUFile *f) >> >> >> >> int qemu_loadvm_state(QEMUFile *f) >> >> { >> >> - LoadStateEntry *first_le = NULL; >> >> + LIST_HEAD(, LoadStateEntry) loadvm_handlers; >> > >> > You're missing the initialization here, spot this while >> > testing staging. >> >> I looked at aio.c and guess what :) No LIST_INIT() either. > > As we talked by irc, if you are referring to 'aio_handlers' it's > global, so it will be initialized to 0 by the kernel. My bad. In this case, I am just a lucky man, and in all my testing, I always got the list intialized correctly :) Patches fixing it sent already. Thanks a lot, Juan. >> My understanding is that it is not needed (but it is better to add it, >> just in case the implementation change). > > I'm getting a segfault when I try to loadvm, I can write a recipe > to reproduce if needed. > >> #define LIST_HEAD_INITIALIZER(head) \ >> { NULL } >> >> #define LIST_INIT(head) do { \ >> (head)->lh_first = NULL; \ >> } while (/*CONSTCOND*/0) >> >> >> This should be what it does without puting it. Perhaps we should >> "correct" also the other users? > > Yes, IMHO. Not because it's a fix, but it's good practice to use the API > w/o making assumptions on its internals.