From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IS0-0000Lv-QH for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:59:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1IRv-0003Tf-3u for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:59:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1IRu-0003TT-S0 for qemu-devel@nongnu.org; Sun, 29 Jun 2014 12:59:31 -0400 Date: Sun, 29 Jun 2014 19:59:50 +0300 From: "Michael S. Tsirkin" Message-ID: <1404060115-27410-31-git-send-email-mst@redhat.com> References: <1404060115-27410-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1404060115-27410-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 30/37] virtio-balloon: use virtio wrappers to access page frame numbers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Anthony Liguori , Rusty Russell , Alexander Graf , Anthony Liguori , Greg Kurz From: Rusty Russell Signed-off-by: Rusty Russell Reviewed-by: Anthony Liguori [ pass VirtIODevice * to memory accessors, Greg Kurz ] Signed-off-by: Greg Kurz Reviewed-by: Alexander Graf Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-balloon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index e0ed5ee..2c30b3d 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -31,6 +31,7 @@ #endif #include "hw/virtio/virtio-bus.h" +#include "hw/virtio/virtio-access.h" static void balloon_page(void *addr, int deflate) { @@ -206,8 +207,9 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) while (iov_to_buf(elem.out_sg, elem.out_num, offset, &pfn, 4) == 4) { ram_addr_t pa; ram_addr_t addr; + int p = virtio_ldl_p(vdev, &pfn); - pa = (ram_addr_t)ldl_p(&pfn) << VIRTIO_BALLOON_PFN_SHIFT; + pa = (ram_addr_t) p << VIRTIO_BALLOON_PFN_SHIFT; offset += 4; /* FIXME: remove get_system_memory(), but how? */ @@ -248,8 +250,8 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) while (iov_to_buf(elem->out_sg, elem->out_num, offset, &stat, sizeof(stat)) == sizeof(stat)) { - uint16_t tag = tswap16(stat.tag); - uint64_t val = tswap64(stat.val); + uint16_t tag = virtio_tswap16(vdev, stat.tag); + uint64_t val = virtio_tswap64(vdev, stat.val); offset += sizeof(stat); if (tag < VIRTIO_BALLOON_S_NR) -- MST