From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlGqd-0001gz-LX for qemu-devel@nongnu.org; Wed, 09 Sep 2009 02:40:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlGqX-0001fE-T6 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 02:40:06 -0400 Received: from [199.232.76.173] (port=43724 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlGqX-0001f9-JL for qemu-devel@nongnu.org; Wed, 09 Sep 2009 02:40:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19067) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlGqX-0007JB-59 for qemu-devel@nongnu.org; Wed, 09 Sep 2009 02:40:01 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n896dx7L000552 for ; Wed, 9 Sep 2009 02:39:59 -0400 Date: Wed, 9 Sep 2009 09:38:21 +0300 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] [PATCH 07/23] New VMstate save/load infrastructure Message-ID: <20090909063821.GA12469@redhat.com> References: <80e9d57f76c584f30112e7de00c545471a009bcf.1250788880.git.quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80e9d57f76c584f30112e7de00c545471a009bcf.1250788880.git.quintela@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org, kraxel@redhat.com On Thu, Aug 20, 2009 at 07:42:25PM +0200, Juan Quintela wrote: > This patch introduces VMState infrastructure, to convert the save/load > functions of devices to a table approach. This new approach has the > following advantages: > - it is type-safe > - you can't have load/save functions out of sync > - will allows us to have new interesting commands, like dump , that > shows all its internal state. > - Just now, the only added type is arrays, but we can add structures. > - Uses old load_state() function for loading old state. > > Signed-off-by: Juan Quintela > --- ... > +#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) { \ > + .name = (stringify(_field)), \ > + .version_id = (_version), \ > + .size = sizeof(_type), \ > + .info = &(_info), \ > + .flags = VMS_SINGLE, \ > + .offset = offsetof(_state, _field) \ > + + type_check(_type,typeof_field(_state, _field)) \ > +} As I said in a different thread, I think the versioning approach taken here is too limited. In particular, it does not easily support optional features such as msix. We can use other mechanisms for this, such as encoding options in the device name, but I think it's too limiting. What I think we should have instead of a version is an identifier for each field. This way it is easy to add or skip each field separately, depending on command line options, and we can also verify, at load time, that all required fields are present. This will also reduce the amount of duplicated code required each time we extend migration format. As a bonus, we'll be able to write a utility parsing the state and checking that it's sane. -- MST