From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2L96-0005RO-Nh for qemu-devel@nongnu.org; Wed, 02 Jul 2014 10:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2L8z-0007mr-7I for qemu-devel@nongnu.org; Wed, 02 Jul 2014 10:04:24 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:55322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2L8z-0007ml-11 for qemu-devel@nongnu.org; Wed, 02 Jul 2014 10:04:17 -0400 Received: by mail-pa0-f52.google.com with SMTP id eu11so12602690pac.11 for ; Wed, 02 Jul 2014 07:04:15 -0700 (PDT) Received: from aik.ozlabs.ibm.com (60-242-102-4.tpgi.com.au. [60.242.102.4]) by mx.google.com with ESMTPSA id tf10sm37449168pbc.70.2014.07.02.07.04.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Jul 2014 07:04:14 -0700 (PDT) Message-ID: <53B4115B.10602@ozlabs.ru> Date: Thu, 03 Jul 2014 00:04:11 +1000 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <53AA6E0B.60103@ozlabs.ru> In-Reply-To: <53AA6E0B.60103@ozlabs.ru> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] vmstate: struct (VMS_STRUCT) migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" On 06/25/2014 04:36 PM, Alexey Kardashevskiy wrote: > Hi! > > VMStateDescription supports enclosed VMStateDescription's via .vmsd. This > is used in multiple places and VMStateDescription definitions look the same > way - name, version_id, minimum_version_id, etc. > > QEMU handles first level VMStateDescription and enclosed VMStateDescription > slightly different - for the latter it ignores the version_id from the > source and always uses the version_id on the destination side so version > fields are useless (code is below). > > Is that by design? Or a bug? I cannot see how we could fix it without > breaking backward compatibility but I am sure the community does know that :) > > If this is by design, it probably makes sense to remove unused > version_id/minimum_version_id fields completely for vmsd's which we know > are enclosed (or embedded?). > > What do I miss here? Thanks! Anyone? :) > > > > int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, > void *opaque, int version_id) > { > VMStateField *field = vmsd->fields; > int ret; > > if (version_id > vmsd->version_id) { > return -EINVAL; > } > if (version_id < vmsd->minimum_version_id) { > if (vmsd->load_state_old && > version_id >= vmsd->minimum_version_id_old) { > return vmsd->load_state_old(f, opaque, version_id); > } > return -EINVAL; > } > if (vmsd->pre_load) { > int ret = vmsd->pre_load(opaque); > if (ret) { > return ret; > } > } > while (field->name) { > if ((field->field_exists && > field->field_exists(opaque, version_id)) || > (!field->field_exists && > field->version_id <= version_id)) { > void *base_addr = vmstate_base_addr(opaque, field, true); > int i, n_elems = vmstate_n_elems(opaque, field); > int size = vmstate_size(opaque, field); > > for (i = 0; i < n_elems; i++) { > void *addr = base_addr + size * i; > > if (field->flags & VMS_ARRAY_OF_POINTER) { > addr = *(void **)addr; > } > if (field->flags & VMS_STRUCT) { > ret = vmstate_load_state(f, field->vmsd, addr, > field->vmsd->version_id); > > > -- Alexey