Received: from eggs.gnu.org ([2001:4830:134:3::10]:49449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZDBd-0004Py-W8 for qemu-devel@nongnu.org; Mon, 15 Aug 2016 04:23:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZDBZ-0003XD-Mp for qemu-devel@nongnu.org; Mon, 15 Aug 2016 04:23:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZDBZ-0003W7-EZ for qemu-devel@nongnu.org; Mon, 15 Aug 2016 04:23:53 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7F8JNc8128147 for ; Mon, 15 Aug 2016 04:23:51 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 24sxum6860-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 15 Aug 2016 04:23:51 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Aug 2016 09:23:48 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id DE6432190061 for ; Mon, 15 Aug 2016 09:23:02 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7F8Nc6t63963228 for ; Mon, 15 Aug 2016 08:23:38 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u7F8NbQ4032251 for ; Mon, 15 Aug 2016 02:23:38 -0600 Date: Mon, 15 Aug 2016 10:23:35 +0200 From: Cornelia Huck In-Reply-To: <1471015978-1123-2-git-send-email-stefanha@redhat.com> References: <1471015978-1123-1-git-send-email-stefanha@redhat.com> <1471015978-1123-2-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20160815102335.1c3ab18b.cornelia.huck@de.ibm.com> Subject: Re: [Qemu-devel] [PATCH for-2.7 1/4] virtio: recalculate vq->inuse after migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, gaudenz@debian.org, "Michael S. Tsirkin" , Luiz Capitulino On Fri, 12 Aug 2016 16:32:55 +0100 Stefan Hajnoczi wrote: > The vq->inuse field is not migrated. Many devices don't hold > VirtQueueElements across migration so it doesn't matter that vq->inuse > starts at 0 on the destination QEMU. > > At least virtio-serial, virtio-blk, and virtio-balloon migrate while > holding VirtQueueElements. For these devices we need to recalculate > vq->inuse upon load so the value is correct. > > Signed-off-by: Stefan Hajnoczi > --- > hw/virtio/virtio.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 15ee3a7..4df8274 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -1648,6 +1648,20 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) > } > vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]); > vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]); > + > + /* Some devices migrate VirtQueueElements that have been popped Make this /* * Some... ? > + * from the avail ring but not yet returned to the used ring. > + */ > + vdev->vq[i].inuse = vdev->vq[i].last_avail_idx - > + vdev->vq[i].used_idx; > + if (vdev->vq[i].inuse > vdev->vq[i].vring.num) { > + error_report("VQ %d size 0x%x < last_avail_idx 0x%x - " > + "used_idx 0x%x" ...as you need to add the comma here anyway. > + i, vdev->vq[i].vring.num, > + vdev->vq[i].last_avail_idx, > + vdev->vq[i].used_idx); > + return -1; > + } > } > } > Reviewed-by: Cornelia Huck