From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5fFN-0002ET-85 for qemu-devel@nongnu.org; Wed, 25 May 2016 16:17:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5fFH-0001Cx-5L for qemu-devel@nongnu.org; Wed, 25 May 2016 16:17:40 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:45878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5fFG-0001CY-SI for qemu-devel@nongnu.org; Wed, 25 May 2016 16:17:35 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 May 2016 14:17:32 -0600 References: <1464112509-21806-1-git-send-email-duanj@linux.vnet.ibm.com> <1464112509-21806-5-git-send-email-duanj@linux.vnet.ibm.com> <5745D4E7.2000003@linux.vnet.ibm.com> <1171824705.17235966.1464198715349.JavaMail.zimbra@redhat.com> <5745EF5D.8050705@linux.vnet.ibm.com> <275886818.17251052.1464204154028.JavaMail.zimbra@redhat.com> From: Jianjun Duan Message-ID: <57460856.4070505@linux.vnet.ibm.com> Date: Wed, 25 May 2016 13:17:26 -0700 MIME-Version: 1.0 In-Reply-To: <275886818.17251052.1464204154028.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [QEMU RFC PATCH v2 4/6] Migration: migrate QTAILQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, quintela@redhat.com, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, amit shah , david@gibson.dropbear.id.au On 05/25/2016 12:22 PM, Paolo Bonzini wrote: >> 1 QTAILQ should only be accessed using the interfaces defined in >> queue.h. Its structs should not be directly used. So I created >> interfaces in queue.h to query about its layout. If the implementation >> is changed, these interfaces should be changed accordingly. Code using >> these interfaces should not break. > > You don't need to query the layout, as long as the knowledge > remains hidden in QTAILQ_RAW_* macros. And because QTAILQ_*_OFFSET > returns constant values, you can just put the knowledge of the offsets > directly in QTAILQ_RAW_FOREACH and QTAILQ_RAW_INSERT_TAIL. > >> 2 Based on point 1, vmstate_load_state/vmstate_put_state in vmstate.c >> doesn't exactly know the structs of QTAILAQ head and entry. So pointer >> arithmetic is needed to put/get a QTAILQ. To do it, we need those 6 >> parameters to be passed in. So it is not redundant if we only want to >> only use the interfaces. > > No, you only need two. The other four are internal to qemu/queue.h. > Just like QTAILQ users do not know about tqh_* and tqe_*, they need not > know about their offsets, only the fields that contain them. > In vmstate_load/put_state usually we use a VMSD to describe the type for dump/load purpose. The metadata for the QTAILQ is for the same purpose. Of course we can encode the information in a VMSD or VMStateField if we don't have to change much. The user may only care the position of head and entry. But to implement QTAILQ_RAW_***, we need more offset information than that. If we don't query the offsets using something like offset() and store it in a metadata, we have to make the assumption that all the pointer types have the same size. Since in vmstate_load/put_state we don't have any type information about the QTAILQ instance, we cannot use offset() in QTAILQ_RAW_*** macros. May have to stick the constants there for first/last/next/prev in QTAILQ_RAW_***. Not sure if it will work for all arches. >> 3 At this moment, vmstate_load_state/vmstate_put_state couldn't handle a >> queue, or a list, or another recursive structure. To make it >> extensible, I think a metadata is needed. The idea is for any >> structure which needs special handling, customized metadata/put/get >> should provide enough flexibility to hack around. > > I think your solution is a bit overengineered. If the metadata can > fit in the VMStateField, you can use VMStateField. > > Thanks, > > Paolo > Thanks, Jianjun