From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFtua-0003yE-C6 for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:26:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFtuV-0003qy-4z for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:26:47 -0500 Received: from [199.232.76.173] (port=55224 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFtuU-0003qW-Tx for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:26:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45824) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFtuU-0005dG-HE for qemu-devel@nongnu.org; Wed, 02 Dec 2009 13:26:42 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2IQfhl029152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Dec 2009 13:26:41 -0500 Date: Wed, 2 Dec 2009 20:24:00 +0200 From: "Michael S. Tsirkin" Message-ID: <20091202182400.GB3956@redhat.com> References: <186e0bde7077cd3384c2e872c008b0c494e0cdf0.1259754427.git.quintela@redhat.com> <20091202134758.GD18193@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: Juan Quintela Cc: qemu-devel@nongnu.org On Wed, Dec 02, 2009 at 07:24:12PM +0100, Juan Quintela wrote: > "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. Maybe try explaining this in commit log. -- MST