virtio.c (3cdf847329a9911780372e6d8239839446d09d9f) virtio.c (874adf45dbfbae2810423527d777ba37bc5ca974)
1/*
2 * Virtio Support
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

--- 1843 unchanged lines hidden (view full) ---

1852 for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
1853 if (vdev->vq[i].vring.num == 0)
1854 break;
1855
1856 qemu_put_be32(f, vdev->vq[i].vring.num);
1857 if (k->has_variable_vring_alignment) {
1858 qemu_put_be32(f, vdev->vq[i].vring.align);
1859 }
1/*
2 * Virtio Support
3 *
4 * Copyright IBM, Corp. 2007
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *

--- 1843 unchanged lines hidden (view full) ---

1852 for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
1853 if (vdev->vq[i].vring.num == 0)
1854 break;
1855
1856 qemu_put_be32(f, vdev->vq[i].vring.num);
1857 if (k->has_variable_vring_alignment) {
1858 qemu_put_be32(f, vdev->vq[i].vring.align);
1859 }
1860 /* XXX virtio-1 devices */
1860 /*
1861 * Save desc now, the rest of the ring addresses are saved in
1862 * subsections for VIRTIO-1 devices.
1863 */
1861 qemu_put_be64(f, vdev->vq[i].vring.desc);
1862 qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
1863 if (k->save_queue) {
1864 k->save_queue(qbus->parent, i, f);
1865 }
1866 }
1867
1868 if (vdc->save != NULL) {

--- 124 unchanged lines hidden (view full) ---

1993 if (k->has_variable_vring_alignment) {
1994 vdev->vq[i].vring.align = qemu_get_be32(f);
1995 }
1996 vdev->vq[i].vring.desc = qemu_get_be64(f);
1997 qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
1998 vdev->vq[i].signalled_used_valid = false;
1999 vdev->vq[i].notification = true;
2000
1864 qemu_put_be64(f, vdev->vq[i].vring.desc);
1865 qemu_put_be16s(f, &vdev->vq[i].last_avail_idx);
1866 if (k->save_queue) {
1867 k->save_queue(qbus->parent, i, f);
1868 }
1869 }
1870
1871 if (vdc->save != NULL) {

--- 124 unchanged lines hidden (view full) ---

1996 if (k->has_variable_vring_alignment) {
1997 vdev->vq[i].vring.align = qemu_get_be32(f);
1998 }
1999 vdev->vq[i].vring.desc = qemu_get_be64(f);
2000 qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
2001 vdev->vq[i].signalled_used_valid = false;
2002 vdev->vq[i].notification = true;
2003
2001 if (vdev->vq[i].vring.desc) {
2002 /* XXX virtio-1 devices */
2003 virtio_queue_update_rings(vdev, i);
2004 } else if (vdev->vq[i].last_avail_idx) {
2004 if (!vdev->vq[i].vring.desc && vdev->vq[i].last_avail_idx) {
2005 error_report("VQ %d address 0x0 "
2006 "inconsistent with Host index 0x%x",
2007 i, vdev->vq[i].last_avail_idx);
2005 error_report("VQ %d address 0x0 "
2006 "inconsistent with Host index 0x%x",
2007 i, vdev->vq[i].last_avail_idx);
2008 return -1;
2008 return -1;
2009 }
2010 if (k->load_queue) {
2011 ret = k->load_queue(qbus->parent, i, f);
2012 if (ret)
2013 return ret;
2014 }
2015 }
2016

--- 44 unchanged lines hidden (view full) ---

2061 return -1;
2062 }
2063 }
2064
2065 rcu_read_lock();
2066 for (i = 0; i < num; i++) {
2067 if (vdev->vq[i].vring.desc) {
2068 uint16_t nheads;
2009 }
2010 if (k->load_queue) {
2011 ret = k->load_queue(qbus->parent, i, f);
2012 if (ret)
2013 return ret;
2014 }
2015 }
2016

--- 44 unchanged lines hidden (view full) ---

2061 return -1;
2062 }
2063 }
2064
2065 rcu_read_lock();
2066 for (i = 0; i < num; i++) {
2067 if (vdev->vq[i].vring.desc) {
2068 uint16_t nheads;
2069
2070 /*
2071 * VIRTIO-1 devices migrate desc, used, and avail ring addresses so
2072 * only the region cache needs to be set up. Legacy devices need
2073 * to calculate used and avail ring addresses based on the desc
2074 * address.
2075 */
2076 if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
2077 virtio_init_region_cache(vdev, i);
2078 } else {
2079 virtio_queue_update_rings(vdev, i);
2080 }
2081
2069 nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
2070 /* Check it isn't doing strange things with descriptor numbers. */
2071 if (nheads > vdev->vq[i].vring.num) {
2072 error_report("VQ %d size 0x%x Guest index 0x%x "
2073 "inconsistent with Host index 0x%x: delta 0x%x",
2074 i, vdev->vq[i].vring.num,
2075 vring_avail_idx(&vdev->vq[i]),
2076 vdev->vq[i].last_avail_idx, nheads);

--- 523 unchanged lines hidden ---
2082 nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
2083 /* Check it isn't doing strange things with descriptor numbers. */
2084 if (nheads > vdev->vq[i].vring.num) {
2085 error_report("VQ %d size 0x%x Guest index 0x%x "
2086 "inconsistent with Host index 0x%x: delta 0x%x",
2087 i, vdev->vq[i].vring.num,
2088 vring_avail_idx(&vdev->vq[i]),
2089 vdev->vq[i].last_avail_idx, nheads);

--- 523 unchanged lines hidden ---