diff mbox series

[06/11] hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper

Message ID 20230523163600.83391-7-philmd@linaro.org
State Superseded
Headers show
Series hw/virtio: Build various target-agnostic objects just once | expand

Commit Message

Philippe Mathieu-Daudé May 23, 2023, 4:35 p.m. UTC
Avoid accessing RAMBlock internals, use the provided
qemu_ram_get_fd() getter to get the file descriptor.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/virtio/virtio-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Hildenbrand May 23, 2023, 5:28 p.m. UTC | #1
On 23.05.23 18:35, Philippe Mathieu-Daudé wrote:
> Avoid accessing RAMBlock internals, use the provided
> qemu_ram_get_fd() getter to get the file descriptor.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/virtio/virtio-mem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> index 538b695c29..74e63bd47a 100644
> --- a/hw/virtio/virtio-mem.c
> +++ b/hw/virtio/virtio-mem.c
> @@ -135,7 +135,7 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
>        * anonymous RAM. In any other case, reading unplugged *can* populate a
>        * fresh page, consuming actual memory.
>        */
> -    return !qemu_ram_is_shared(rb) && rb->fd < 0 &&
> +    return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 &&
>              qemu_ram_pagesize(rb) == qemu_real_host_page_size();
>   }
>   #endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */

Reviewed-by: David Hildenbrand <david@redhat.com>
Richard Henderson May 23, 2023, 11:24 p.m. UTC | #2
On 5/23/23 09:35, Philippe Mathieu-Daudé wrote:
> Avoid accessing RAMBlock internals, use the provided
> qemu_ram_get_fd() getter to get the file descriptor.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   hw/virtio/virtio-mem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index 538b695c29..74e63bd47a 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -135,7 +135,7 @@  static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
      * anonymous RAM. In any other case, reading unplugged *can* populate a
      * fresh page, consuming actual memory.
      */
-    return !qemu_ram_is_shared(rb) && rb->fd < 0 &&
+    return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 &&
            qemu_ram_pagesize(rb) == qemu_real_host_page_size();
 }
 #endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */