diff mbox

[05/21] virtio: modify save/load handler to handle inuse varialble.

Message ID AANLkTim2CojXtyGVDNngzaYMCXfan3kkS=thDE9i-yT=@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yoshiaki Tamura Dec. 1, 2010, 8:03 a.m. UTC
None
diff mbox

Patch

diff --git a/hw/virtio.c b/hw/virtio.c
index c8a0fc6..875c7ca 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -664,12 +664,16 @@  void virtio_save(VirtIODevice *vdev, QEMUFile *f)
     qemu_put_be32(f, i);

     for (i = 0; i < VIRTIO_PCI_QUEUE_MAX; i++) {
+        uint16_t last_avail_idx;
+
         if (vdev->vq[i].vring.num == 0)
             break;

+        last_avail_idx = vdev->vq[i].last_avail_idx - vdev->vq[i].inuse;
+
         qemu_put_be32(f, vdev->vq[i].vring.num);
         qemu_put_be64(f, vdev->vq[i].pa);
-        qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
+        qemu_put_be16s(f, &last_avail_idx);
         if (vdev->binding->save_queue)
             vdev->binding->save_queue(vdev->binding_opaque, i, f);
     }