From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MnJ83-0007dp-EZ for qemu-devel@nongnu.org; Mon, 14 Sep 2009 17:30:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MnJ7y-0007Wm-Md for qemu-devel@nongnu.org; Mon, 14 Sep 2009 17:30:30 -0400 Received: from [199.232.76.173] (port=49253 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnJ7y-0007WG-EJ for qemu-devel@nongnu.org; Mon, 14 Sep 2009 17:30:26 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:51533) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MnJ7x-0003i5-CB for qemu-devel@nongnu.org; Mon, 14 Sep 2009 17:30:26 -0400 Received: by fxm7 with SMTP id 7so2395767fxm.34 for ; Mon, 14 Sep 2009 14:30:23 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4AAEB5ED.8040809@gnu.org> Date: Mon, 14 Sep 2009 23:30:21 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4AAEAC27.3070300@gnu.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 0/4] Fix VMState design flaws List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On 09/14/2009 10:50 PM, Juan Quintela wrote: > Paolo Bonzini wrote: >>> * Add version_id field to post_load(). Now we can assign default values >>> in post_load for old versions of the state (ps2_kbd as example). >> >> While this is a good idea, why don't we first reset the devices upon >> load, which would also set the default values?... > > It is safe to do that unconditionally? > If so, I am all for it. We can: > - add reset field to vmstate > - add default values to some fields, if it makse sense (haven't yet > looked at reset code). The PS2 reset is this: static void ps2_common_reset(PS2State *s) { PS2Queue *q; s->write_cmd = -1; q = &s->queue; q->rptr = 0; q->wptr = 0; q->count = 0; s->update_irq(s->update_arg, 0); // calls kbd_update_kbd_irq } static void ps2_kbd_reset(void *opaque) { PS2KbdState *s = (PS2KbdState *) opaque; ps2_common_reset(&s->common); s->scan_enabled = 0; s->translate = 0; s->scancode_set = 0; } All of these are later reset by load. The update_irq may seem unsafe, but maybe deasserting an IRQ is better than leaving it in whatever state it was left by the previous VM... Paolo