qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCHv2 4/5] virtio-balloon: remove layout assumptions


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCHv2 4/5] virtio-balloon: remove layout assumptions
Date: Thu, 18 Mar 2010 11:42:47 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

use container_of to remove assumption that vdev
is 1st member of structure.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 hw/virtio-balloon.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index f8ccc00..21687e3 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -43,7 +43,7 @@ typedef struct VirtIOBalloon
 
 static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
 {
-    return (VirtIOBalloon *)vdev;
+    return container_of(vdev, VirtIOBalloon, vdev);
 }
 
 static void balloon_page(void *addr, int deflate)
@@ -165,7 +165,7 @@ static void complete_stats_request(VirtIOBalloon *vb)
 
 static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
+    VirtIOBalloon *s = to_virtio_balloon(vdev);
     VirtQueueElement *elem = &s->stats_vq_elem;
     VirtIOBalloonStat stat;
     size_t offset = 0;
-- 
1.7.0.2.280.gc6f05





reply via email to

[Prev in Thread] Current Thread [Next in Thread]