From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8Awh-0006zy-Jn for qemu-devel@nongnu.org; Wed, 01 Jun 2016 14:32:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8Awf-0005Mi-H6 for qemu-devel@nongnu.org; Wed, 01 Jun 2016 14:32:46 -0400 Sender: Paolo Bonzini References: <1464717764-9040-1-git-send-email-duanj@linux.vnet.ibm.com> <1464717764-9040-5-git-send-email-duanj@linux.vnet.ibm.com> <142124939.18585117.1464724475643.JavaMail.zimbra@redhat.com> <574E07CD.1030908@linux.vnet.ibm.com> <67193839-a00a-9a2e-e60a-b85dd1c6dfb5@redhat.com> <574F15F8.8000400@linux.vnet.ibm.com> From: Paolo Bonzini Message-ID: <6b62efec-9c26-d84c-9999-83a8843dc3a9@redhat.com> Date: Wed, 1 Jun 2016 20:32:18 +0200 MIME-Version: 1.0 In-Reply-To: <574F15F8.8000400@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [QEMU RFC PATCH v3 4/6] Migration: migrate QTAILQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jianjun Duan Cc: veroniabahaa@gmail.com, peter maydell , mdroth@linux.vnet.ibm.com, mst@redhat.com, quintela@redhat.com, mark cave-ayland , qemu-devel@nongnu.org, mreitz@redhat.com, blauwirbel@gmail.com, amit shah , qemu-ppc@nongnu.org, kraxel@redhat.com, dmitry@daynix.com, kwolf@redhat.com, rth@twiddle.net, leon alrae , aurelien@aurel32.net, david@gibson.dropbear.id.au On 01/06/2016 19:06, Jianjun Duan wrote: > On 06/01/2016 08:29 AM, Paolo Bonzini wrote: >> On 31/05/2016 23:53, Jianjun Duan wrote: >>> On 05/31/2016 12:54 PM, Paolo Bonzini wrote: >>>>> +/* put for QTAILQ */ >>>>> +static void put_qtailq(QEMUFile *f, void *pv, size_t unused_size, >>>>> + VMStateField *field, QJSON *vmdesc) >>>>> +{ >>>>> + bool link = true; >>>>> + const VMStateDescription *vmsd = field->vmsd; >>>>> + size_t entry = field->start; >>>>> + void *elm; >>>>> + >>>>> + if (vmdesc) { >>>>> + json_prop_str(vmdesc, "vmsd_name", vmsd->name); >>>>> + json_prop_int(vmdesc, "version", vmsd->version_id); >>>>> + json_start_array(vmdesc, "fields"); >>>> >>>> You need to store the fields exactly once here, even if there are >>>> 0 or >1 elements. >>>> >>> Do you mean the json entries? I think it is already doing that. >> >> In the case of 0 entries we don't go through the loop, so the JSON >> entries are definitely missing in that case. I'm not sure if QJSON >> handles duplicates in the case of 2+ entries. > > The vmsd here is the vmsd for the queue elements. Not for the queue. > Maybe the stuff written here should be information about the qtailq > instead, but we don't have a vmsd for the queue as a whole. You're right, you could use vmsd_can_compress but it's not necessary to do so. Your code is fine. Paolo