From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFtso-0001fO-O3 for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:24:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFtsk-0001ZN-QQ for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:24:58 -0500 Received: from [199.232.76.173] (port=37045 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFtsk-0001Z9-Iq for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:24:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32646) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFtsk-0005T7-0B for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:24:54 -0500 From: Juan Quintela In-Reply-To: <20091202134758.GD18193@redhat.com> (Michael S. Tsirkin's message of "Wed, 2 Dec 2009 15:47:58 +0200") References: <186e0bde7077cd3384c2e872c008b0c494e0cdf0.1259754427.git.quintela@redhat.com> <20091202134758.GD18193@redhat.com> Date: Wed, 02 Dec 2009 19:24:12 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Re: [PATCH 19/41] virtio: use the right types for VirtQueue elements List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org "Michael S. Tsirkin" wrote: > On Wed, Dec 02, 2009 at 01:04:17PM +0100, Juan Quintela wrote: >> >> Signed-off-by: Juan Quintela >> --- >> hw/virtio.c | 8 ++++---- >> 1 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/hw/virtio.c b/hw/virtio.c >> index fd617ff..2b36cad 100644 >> --- a/hw/virtio.c >> +++ b/hw/virtio.c >> @@ -646,8 +646,8 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) >> qemu_put_sbe32s(f, &vdev->num_pci_queues); >> >> for (i = 0; i < vdev->num_pci_queues; i++) { >> - qemu_put_be32(f, vdev->vq[i].vring.num); >> - qemu_put_be64(f, vdev->vq[i].pa); >> + qemu_put_be32s(f, &vdev->vq[i].vring.num); >> + qemu_put_be64s(f, &vdev->vq[i].pa); >> qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); >> if (vdev->type == VIRTIO_PCI && >> virtio_pci_msix_present(vdev->binding_opaque)) { >> @@ -703,8 +703,8 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f) >> qemu_get_sbe32s(f, &vdev->num_pci_queues); >> >> for (i = 0; i < vdev->num_pci_queues; i++) { >> - vdev->vq[i].vring.num = qemu_get_be32(f); >> - vdev->vq[i].pa = qemu_get_be64(f); >> + qemu_get_be32s(f, &vdev->vq[i].vring.num); >> + qemu_get_be64s(f, &vdev->vq[i].pa); >> qemu_get_be16s(f, &vdev->vq[i].last_avail_idx); >> >> if (vdev->type == VIRTIO_PCI && > > Why are these the right types? > I see: > static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) > { > qemu_put_be64(f, *pv); > } > > so passing a pointer to qemu_get_be64s seems exactly equivalent to > qemu_put_be64 on value. > > What am I missing? While I was porting this to vmstate, it was difficult. vmstate always use the pointer functions (the other ones shouldn't have been defined at all, but that is another war). It just made the change to vmstate obvious. I had to redo it several times until it worked :( Later, Juan.