From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrre3-0006vj-Qp for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zrrdz-0002f1-SG for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zrrdz-0002ew-NJ for qemu-devel@nongnu.org; Thu, 29 Oct 2015 14:09:47 -0400 From: Stefan Hajnoczi Date: Thu, 29 Oct 2015 18:09:21 +0000 Message-Id: <1446142165-24416-9-git-send-email-stefanha@redhat.com> In-Reply-To: <1446142165-24416-1-git-send-email-stefanha@redhat.com> References: <1446142165-24416-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 08/12] virtio: sync the dataplane vring state to the virtqueue before virtio_save List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , "Michael S. Tsirkin" , Pavel Butsykin , Stefan Hajnoczi , Paolo Bonzini , "Denis V. Lunev" From: Pavel Butsykin When creating snapshot with the dataplane enabled, the snapshot file gets not the actual state of virtqueue, because the current state is stored in VirtIOBlockDataPlane. Therefore, before saving snapshot need to sync the dataplane vring state to the virtqueue. The dataplane will resume its work at the next notify virtqueue. When snapshot loads with loadvm we get a message: VQ 0 size 0x80 Guest index 0x15f5 inconsistent with Host index 0x0: delta 0x15f5 error while loading state for instance 0x0 of device '0000:00:08.0/virtio-blk' Error -1 while loading VM state to reproduce the error I used the following hmp commands: savevm snap1 loadvm snap1 qemu parameters: --enable-kvm -smp 4 -m 1024 -drive file=/var/lib/libvirt/images/centos6.4.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x8,drive=drive-virtio-disk0,id=virtio-disk0 -set device.virtio-disk0.x-data-plane=on Signed-off-by: Pavel Butsykin Signed-off-by: Denis V. Lunev Message-id: 1445859777-2982-1-git-send-email-den@openvz.org CC: Stefan Hajnoczi CC: "Michael S. Tsirkin" CC: Kevin Wolf CC: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 5 +++++ hw/scsi/virtio-scsi.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 45a24e4..093e475 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -798,6 +798,11 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status) static void virtio_blk_save(QEMUFile *f, void *opaque) { VirtIODevice *vdev = VIRTIO_DEVICE(opaque); + VirtIOBlock *s = VIRTIO_BLK(vdev); + + if (s->dataplane) { + virtio_blk_data_plane_stop(s->dataplane); + } virtio_save(vdev, f); } diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 46553e1..7655401 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -653,6 +653,11 @@ static void virtio_scsi_reset(VirtIODevice *vdev) static void virtio_scsi_save(QEMUFile *f, void *opaque) { VirtIODevice *vdev = VIRTIO_DEVICE(opaque); + VirtIOSCSI *s = VIRTIO_SCSI(vdev); + + if (s->dataplane_started) { + virtio_scsi_dataplane_stop(s); + } virtio_save(vdev, f); } -- 2.4.3