]> git.proxmox.com Git - qemu.git/commitdiff
vfio-pci: Fix BAR->VFIODevice translation in
authorJan Kiszka <jan.kiszka@siemens.com>
Mon, 8 Oct 2012 14:45:31 +0000 (08:45 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 8 Oct 2012 14:45:31 +0000 (08:45 -0600)
DO_UPCAST is supposed to translate from the first member of a struct to
that struct, not from arbitrary ones. And it (usually) breaks the build
when neglecting this rule. Use container_of to fix the build breakage
and likely also the runtime behavior.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
aw: runtime behavior is actually the same, but clearly misuse of DO_UPCAST
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio_pci.c

index 85b16bbd2346fd1737b9739e7fbd3a510449743e..639371e7a26ab9a7046b972515a022a45f5b06af 100644 (file)
@@ -721,7 +721,7 @@ static void vfio_bar_write(void *opaque, target_phys_addr_t addr,
      * which access will service the interrupt, so we're potentially
      * getting quite a few host interrupts per guest interrupt.
      */
-    vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
 }
 
 static uint64_t vfio_bar_read(void *opaque,
@@ -761,7 +761,7 @@ static uint64_t vfio_bar_read(void *opaque,
             __func__, bar->nr, addr, size, data);
 
     /* Same as write above */
-    vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
 
     return data;
 }