Received: from eggs.gnu.org ([2001:4830:134:3::10]:39081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJpFc-0001qR-G4 for qemu-devel@nongnu.org; Thu, 14 Jan 2016 16:16:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aJpFZ-0006mS-90 for qemu-devel@nongnu.org; Thu, 14 Jan 2016 16:16:12 -0500 Received: from e06smtp05.uk.ibm.com ([195.75.94.101]:39410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aJpFY-0006mJ-Vn for qemu-devel@nongnu.org; Thu, 14 Jan 2016 16:16:09 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 14 Jan 2016 21:16:06 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2D5F31B08061 for ; Thu, 14 Jan 2016 21:16:06 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0ELG3Pr917840 for ; Thu, 14 Jan 2016 21:16:03 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0ELG3px006686 for ; Thu, 14 Jan 2016 14:16:03 -0700 From: Sascha Silbe In-Reply-To: <1452083019-15141-2-git-send-email-dgilbert@redhat.com> References: <1452083019-15141-1-git-send-email-dgilbert@redhat.com> <1452083019-15141-2-git-send-email-dgilbert@redhat.com> Date: Thu, 14 Jan 2016 22:16:07 +0100 Message-ID: <871t9jhnfs.fsf@oc4731375738.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] migration/virtio: Remove simple .get/.put use List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" , qemu-devel@nongnu.org Cc: amit.shah@redhat.com, Cornelia Huck , quintela@redhat.com, mst@redhat.com Dear David, "Dr. David Alan Gilbert (git)" writes: > The 'virtqueue_state' and 'ringsize' can be saved using VMSTATE > macros rather than hand coded .get/.put [...] > @@ -1161,44 +1143,20 @@ static const VMStateDescription vmstate_virtio_vi= rtqueues =3D { > .minimum_version_id =3D 1, > .needed =3D &virtio_virtqueue_needed, > .fields =3D (VMStateField[]) { > - { > - .name =3D "virtqueues", > - .version_id =3D 0, > - .field_exists =3D NULL, > - .size =3D 0, > - .info =3D &vmstate_info_virtqueue, > - .flags =3D VMS_SINGLE, > - .offset =3D 0, > - }, > + VMSTATE_STRUCT_VARRAY_KNOWN(vq, struct VirtIODevice, VIRTIO_QUEU= E_MAX, > + 0, vmstate_virtqueue, VirtQueue), > VMSTATE_END_OF_LIST() > } > }; This completely breaks migration (including virsh save / restore) on s390x. It appears to work on x86_64 with a trivial test case, but that's probably pure luck and I'd expect a more extensive test case to show guest state corruption on migration. After staring at the code for several hours (this whole VMSTATE_* stuff is severely underdocumented), I think I've finally understood what's going on. Given the VMS_STRUCT|VMS_ARRAY field flags set by VMSTATE_STRUCT_VARRAY_KNOWN, vmstate_save_state() expects an array of fixed size embedded in the struct. However, VirtIODevice.vq is a pointer to an allocated array. Adding the VMS_POINTER flag looks like it could do the trick and indeed allows my trivial test case to complete on s390x again. (No further testing was done). I won't be sending a fix for this for now as I don't understand what the naming conventions for VMSTATE_* are (both VMSTATE_ARRAY* and VMSTATE_VARRAY* can use VMS_VARRAY, something with and sometimes without VMS_POINTER). Should VMSTATE_STRUCT_VARRAY_KNOWN be fixed to include VMS_POINTER or do you need to introduce another macro VMSTATE_STRUCT_VARRAY_POINTER_KNOWN? PS: Won't your patch break migration between different qemu versions? I don't see any compat code and you're changing at least some field names (e.g. "virtqueues" vs. "vq"). Sascha --=20 Softwareentwicklung Sascha Silbe, Niederhofenstra=C3=9Fe 5/1, 71229 Leonberg https://se-silbe.de/ USt-IdNr. DE281696641