mirror_qemu/include/hw
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
..
acpi hw/acpi: Implement the SRAT GI affinity structure 2024-03-12 17:56:55 -04:00
adc hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE() 2023-01-12 17:15:09 +00:00
arm hw/arm: Add the USART to the stm32l4x5 SoC 2024-04-25 10:21:59 +01:00
audio virtio-snd: rewrite invalid tx/rx message handling 2024-04-09 02:31:16 -04:00
block aspeed/smc: Only wire flash devices at reset 2024-03-19 11:58:15 +01:00
char hw/char/stm32l4x5_usart: Enable serial read and write 2024-04-25 10:21:59 +01:00
core Accelerator patches 2024-05-06 10:19:10 -07:00
cpu
cris hw/net/etraxfs-eth: use qemu_configure_nic_device() 2024-02-02 16:23:47 +00:00
cxl hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean 2024-04-25 12:48:12 +02:00
display hw/display : Add device DM163 2024-04-30 16:02:43 +01:00
dma hw/dma: Pass parent object to i8257_dma_init() 2024-02-15 16:58:46 +01:00
firmware smbios: get rid of global smbios_ep_type 2024-03-18 08:42:45 -04:00
fsi hw/fsi: Aspeed APB2OPB & On-chip peripheral bus 2024-02-01 08:33:18 +01:00
gpio misc/pca955*: Move models under hw/gpio 2024-03-25 15:05:38 +01:00
hyperv vmbus: Print a warning when enabled without the recommended set of features 2024-03-08 14:18:56 +01:00
i2c hw/i2c: Implement Broadcom Serial Controller (BSC) 2024-03-05 13:22:55 +00:00
i386 hw/i386: split x86.c in multiple parts 2024-05-10 15:45:15 +02:00
ide ide, vl: turn -win2k-hack into a property on IDE devices 2024-02-28 00:23:39 +01:00
input hw/input/pckbd: Open-code i8042_setup_a20_line() wrapper 2024-02-22 12:47:35 +01:00
intc hw/intc/loongarch_ipi: Rename as loongson_ipi 2024-05-09 00:07:21 +02:00
ipack
ipmi
isa hw/isa/vt82c686: Bring back via_isa_set_irq() 2023-11-28 14:26:37 +01:00
loongarch hw/intc/loongarch_ipi: Rename as loongson_ipi 2024-05-09 00:07:21 +02:00
m68k m68k: Clean up includes 2024-01-30 21:20:20 +03:00
mem include: Clean up includes 2024-01-30 21:20:20 +03:00
mips hw/mips: Inline 'bios.h' definitions 2024-01-05 16:20:15 +01:00
misc misc/pca955*: Move models under hw/gpio 2024-03-25 15:05:38 +01:00
net hw/net/npcm_gmac.h: correct typos 2024-02-21 08:16:43 +03:00
nubus hw/nubus: add nubus-virtio-mmio device 2024-02-27 09:36:39 +01:00
nvram fw_cfg: remove useless declarations from typedefs.h 2024-05-03 15:47:48 +02:00
openrisc
pci pci: remove some types from typedefs.h 2024-05-03 15:47:48 +02:00
pci-bridge hw/cxl: Add a switch mailbox CCI function 2023-11-07 03:39:11 -05:00
pci-host hw/loongarch: fdt adds pch_msi Controller 2024-04-29 10:25:56 +08:00
ppc ppc/pef: switch to use confidential_guest_kvm_init/reset() 2024-04-23 17:35:25 +02:00
remote include/hw/pci: Split pci_device.h off pci.h 2023-01-08 01:54:22 -05:00
riscv hw/riscv/virt.h: correct typos 2024-02-21 08:16:43 +03:00
rtc hw/i386: move rtc-reset-reinjection command out of hw/rtc 2024-05-10 15:45:15 +02:00
rx hw/rx/rx62n: Only call qdev_get_gpio_in() when necessary 2024-02-15 16:58:46 +01:00
s390x s390: move css_migration_enabled from machine to css.c 2024-05-10 15:45:15 +02:00
scsi esp.c: keep track of the DRQ state during DMA 2024-02-13 19:37:28 +00:00
sd hw/sd: Introduce a "sd-card" SPI variant model 2023-09-01 11:40:04 +02:00
sensor
sh4
southbridge hw/isa/piix: Allow for optional PIT creation in PIIX3 2023-10-22 05:18:17 -04:00
sparc hw/sparc/grlib: split out the headers for each peripherals 2024-02-15 16:58:46 +01:00
ssi hw/ssi: Implement BCM2835 SPI Controller 2024-02-02 13:51:59 +00:00
timer hw/timer: Move HPET_INTCAP definition to "hpet.h" 2024-02-20 20:34:21 +03:00
tricore hw/tricore/testboard: Use qdev_new() instead of QOM basic API 2024-02-22 12:47:40 +01:00
usb include: Include headers where needed 2023-01-08 01:54:22 -05:00
vfio ui/console: Use qemu_dmabuf_new() and free() helpers instead 2024-05-14 17:14:12 +04:00
virtio ui/console: Use qemu_dmabuf_new() and free() helpers instead 2024-05-14 17:14:12 +04:00
watchdog hw/watchdog/sbsa_gwdt: Make watchdog timer frequency a QOM property 2024-04-30 15:14:15 +01:00
xen xen: register legacy backends via xen_backend_init 2024-05-10 15:45:15 +02:00
xtensa
boards.h hw/core/machine: Introduce the module as a CPU topology level 2024-04-25 12:48:12 +02:00
clock.h hw/clock: Let clock_set_mul_div() return a boolean value 2024-03-26 14:24:06 +01:00
elf_ops.h.inc hw/elf_ops: Rename elf_ops.h -> elf_ops.h.inc 2024-04-25 12:48:12 +02:00
fw-path-provider.h
hotplug.h pci: fix 'hotplugglable' property behavior 2023-03-07 12:38:59 -05:00
hw.h
irq.h
loader-fit.h
loader.h hw/loader: Clean up global variable shadowing in rom_add_file() 2023-11-07 13:08:48 +01:00
nmi.h
or-irq.h hw: Replace qemu_or_irq typedef by OrIRQState 2023-02-27 13:27:05 +00:00
pcmcia.h replace TABs with spaces 2023-03-20 12:43:50 +01:00
platform-bus.h
ptimer.h
qdev-clock.h
qdev-core.h qdev-core: remove DeviceListener from typedefs.h 2024-05-03 15:47:48 +02:00
qdev-dma.h
qdev-properties-system.h migration/multifd: Add new migration option zero-page-detection. 2024-03-11 16:57:05 -04:00
qdev-properties.h qdev-properties: alias all object class properties 2023-12-21 22:49:28 +01:00
register.h
registerfields.h
resettable.h reset: Add RESET_TYPE_SNAPSHOT_LOAD 2024-04-25 10:21:59 +01:00
stream.h
sysbus.h hw/sysbus: Remove now unused sysbus_address_space() 2024-02-26 18:40:21 +01:00
usb.h hw/usb: remove usb_bus_find 2024-02-27 09:37:21 +01:00
vmstate-if.h