mirror_qemu/include/hw/virtio
Dongwon Kim c0fcd6334f ui/console: Use qemu_dmabuf_new() and free() helpers instead
This commit introduces utility functions for the creation and deallocation
of QemuDmaBuf instances. Additionally, it updates all relevant sections
of the codebase to utilize these new utility functions.

v7: remove prefix, "dpy_gl_" from all helpers
    qemu_dmabuf_free() returns without doing anything if input is null
    (Daniel P. Berrangé <berrange@redhat.com>)
    call G_DEFINE_AUTOPTR_CLEANUP_FUNC for qemu_dmabuf_free()
    (Daniel P. Berrangé <berrange@redhat.com>)

v8: Introduction of helpers was removed as those were already added
    by the previous commit

v9: set dmabuf->allow_fences to 'true' when dmabuf is created in
    virtio_gpu_create_dmabuf()/virtio-gpu-udmabuf.c

    removed unnecessary spaces were accidently added in the patch,
    'ui/console: Use qemu_dmabuf_new() a...'

v11: Calling qemu_dmabuf_close was removed as closing dmabuf->fd will be
     done in qemu_dmabuf_free anyway.
     (Daniel P. Berrangé <berrange@redhat.com>)

v12: --- Calling qemu_dmabuf_close separately as qemu_dmabuf_free doesn't
         do it.

     --- 'dmabuf' is now allocated space so it should be freed at the end of
         dbus_scanout_texture

v13: --- Immediately free dmabuf after it is released to prevent possible
         leaking of the ptr
         (Marc-André Lureau <marcandre.lureau@redhat.com>)

     --- Use g_autoptr macro to define *dmabuf for auto clean up instead of
         calling qemu_dmabuf_free
         (Marc-André Lureau <marcandre.lureau@redhat.com>)

v14: --- (vhost-user-gpu) Change qemu_dmabuf_free back to g_clear_pointer
         as it was done because of some misunderstanding (v13).

     --- (vhost-user-gpu) g->dmabuf[m->scanout_id] needs to be set to NULL
         to prevent freed dmabuf to be accessed again in case if(fd==-1)break;
         happens (before new dmabuf is allocated). Otherwise, it would cause
         invalid memory access when the same function is executed. Also NULL
         check should be done before qemu_dmabuf_close (it asserts dmabuf!=NULL.).
         (Marc-André Lureau <marcandre.lureau@redhat.com>)

Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
Message-Id: <20240508175403.3399895-6-dongwon.kim@intel.com>
2024-05-14 17:14:12 +04:00
..
vdpa-dev.h vdpa: add vdpa-dev support 2022-12-21 06:35:28 -05:00
vhost-backend.h vhost: Add worker backend callouts 2023-12-25 11:34:55 -05:00
vhost-scsi-common.h vhost-user-scsi: support reconnect to backend 2023-10-22 05:18:17 -04:00
vhost-scsi.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
vhost-user-base.h virtio: split into vhost-user-base and vhost-user-device 2024-02-14 06:01:39 -05:00
vhost-user-blk.h vhost-user-blk: make 'config_wce' part of 'host_features' 2022-10-07 09:41:51 -04:00
vhost-user-fs.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
vhost-user-gpio.h hw/virtio: derive vhost-user-gpio from vhost-user-base 2024-02-14 06:01:44 -05:00
vhost-user-i2c.h hw/virtio: derive vhost-user-i2c from vhost-user-base 2024-02-14 06:01:49 -05:00
vhost-user-rng.h hw/virtio: derive vhost-user-rng from vhost-user-base 2024-02-14 06:01:42 -05:00
vhost-user-scmi.h hw/virtio: Add a protection against duplicate vu_scmi_stop calls 2023-08-03 16:06:49 -04:00
vhost-user-scsi.h vhost-user-scsi: support reconnect to backend 2023-10-22 05:18:17 -04:00
vhost-user-snd.h hw/virtio: add vhost-user-snd and vhost-user-snd-pci devices 2024-02-14 06:09:03 -05:00
vhost-user-vsock.h Clean up ill-advised or unusual header guards 2022-05-11 16:50:01 +02:00
vhost-user.h vhost-user: Interface for migration state transfer 2023-11-07 03:39:10 -05:00
vhost-vdpa.h vdpa: define SVQ transitioning state for mode switching 2024-03-12 17:56:55 -04:00
vhost-vsock-common.h qapi: Improve documentation of file descriptor socket addresses 2024-02-12 10:04:32 +01:00
vhost-vsock.h vhost-vsock: handle common features in vhost-vsock-common 2021-10-05 17:30:57 -04:00
vhost.h include/hw/virtio/vhost.h: spelling fix: sate 2023-11-15 12:06:05 +03:00
virtio-access.h Replace TARGET_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
virtio-acpi.h acpi: Clean up includes 2024-01-30 21:20:20 +03:00
virtio-balloon.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
virtio-blk-common.h virtio-blk: move config size params to virtio-blk-common 2022-10-07 09:41:51 -04:00
virtio-blk.h virtio-blk: declare VirtIOBlock::rq with a type 2024-02-07 14:44:19 +01:00
virtio-bus.h virtio-bus: introduce iommu_enabled() 2021-09-04 16:35:17 -04:00
virtio-crypto.h crypto: Introduce RSA algorithm 2022-06-16 12:54:58 -04:00
virtio-dmabuf.h hw/display: introduce virtio-dmabuf 2023-10-04 18:15:06 -04:00
virtio-gpu-bswap.h virtio-gpu: blob prep 2023-10-16 11:29:56 +04:00
virtio-gpu-pci.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
virtio-gpu-pixman.h virtio-gpu: add a pixman helper header 2019-05-29 06:29:07 +02:00
virtio-gpu.h ui/console: Use qemu_dmabuf_new() and free() helpers instead 2024-05-14 17:14:12 +04:00
virtio-input.h hw/virtio: derive vhost-user-input from vhost-user-base 2024-02-14 06:09:32 -05:00
virtio-iommu.h virtio-iommu: Add an option to define the input range width 2024-03-12 17:58:42 -04:00
virtio-md-pci.h virtio-md-pci: Support unplug requests for compatible devices 2023-07-12 09:27:30 +02:00
virtio-mem.h virtio-mem: Expose device memory dynamically via multiple memslots if enabled 2023-10-12 14:15:22 +02:00
virtio-mmio.h include: Include headers where needed 2023-01-08 01:54:22 -05:00
virtio-net.h virtio-net: Added property to load eBPF RSS with fds. 2024-03-12 19:31:46 +08:00
virtio-pci.h Revert "hw/virtio: Add support for VDPA network simulation devices" 2024-04-09 02:30:18 -04:00
virtio-pmem.h qapi: Restrict device memory commands to machine code 2020-09-29 15:41:36 +02:00
virtio-rng.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
virtio-scsi.h vhost-scsi: Add support for a worker thread per virtqueue 2023-12-25 11:34:55 -05:00
virtio-serial.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
virtio.h hw/virtio: Introduce virtio_bh_new_guarded() helper 2024-04-10 09:09:33 +02:00