[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/23] ui: Get the fd associated with udmabuf driver
From: |
Gerd Hoffmann |
Subject: |
[PULL 10/23] ui: Get the fd associated with udmabuf driver |
Date: |
Thu, 27 May 2021 16:23:27 +0200 |
From: Vivek Kasireddy <vivek.kasireddy@intel.com>
Try to open the udmabuf dev node for the first time or return the
fd if the device was previously opened.
Based-on-patch-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Message-Id: <20210526231429.1045476-2-vivek.kasireddy@intel.com>
[ kraxel: fixup fcntl.h include ]
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/ui/console.h | 3 +++
ui/udmabuf.c | 40 ++++++++++++++++++++++++++++++++++++++++
ui/meson.build | 1 +
3 files changed, 44 insertions(+)
create mode 100644 ui/udmabuf.c
diff --git a/include/ui/console.h b/include/ui/console.h
index ca3c7af6a6c8..b30b63976a5a 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -471,4 +471,7 @@ bool vnc_display_reload_certs(const char *id, Error
**errp);
/* input.c */
int index_from_key(const char *key, size_t key_length);
+/* udmabuf.c */
+int udmabuf_fd(void);
+
#endif
diff --git a/ui/udmabuf.c b/ui/udmabuf.c
new file mode 100644
index 000000000000..23abe1e7eb91
--- /dev/null
+++ b/ui/udmabuf.c
@@ -0,0 +1,40 @@
+/*
+ * udmabuf helper functions.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "ui/console.h"
+
+#ifdef CONFIG_LINUX
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+int udmabuf_fd(void)
+{
+ static bool first = true;
+ static int udmabuf;
+
+ if (!first) {
+ return udmabuf;
+ }
+ first = false;
+
+ udmabuf = open("/dev/udmabuf", O_RDWR);
+ if (udmabuf < 0) {
+ warn_report("open /dev/udmabuf: %s", strerror(errno));
+ }
+ return udmabuf;
+}
+
+#else
+
+int udmabuf_fd(void)
+{
+ return -1;
+}
+
+#endif
diff --git a/ui/meson.build b/ui/meson.build
index b5aed14886cf..a3a187d633ab 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -12,6 +12,7 @@ softmmu_ss.add(files(
'kbd-state.c',
'keymaps.c',
'qemu-pixman.c',
+ 'udmabuf.c',
))
softmmu_ss.add([spice_headers, files('spice-module.c')])
softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.c'))
--
2.31.1
- [PULL 00/23] Vga 20210527 patches, Gerd Hoffmann, 2021/05/27
- [PULL 01/23] vhost-user-gpu: fix memory disclosure in virgl_cmd_get_capset_info (CVE-2021-3545), Gerd Hoffmann, 2021/05/27
- [PULL 02/23] vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' (CVE-2021-3544), Gerd Hoffmann, 2021/05/27
- [PULL 03/23] vhost-user-gpu: fix memory leak in vg_resource_attach_backing (CVE-2021-3544), Gerd Hoffmann, 2021/05/27
- [PULL 04/23] vhost-user-gpu: fix memory leak while calling 'vg_resource_unref' (CVE-2021-3544), Gerd Hoffmann, 2021/05/27
- [PULL 06/23] vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' (CVE-2021-3544), Gerd Hoffmann, 2021/05/27
- [PULL 05/23] vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' (CVE-2021-3544), Gerd Hoffmann, 2021/05/27
- [PULL 08/23] vhost-user-gpu: abstract vg_cleanup_mapping_iov, Gerd Hoffmann, 2021/05/27
- [PULL 07/23] vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' (CVE-2021-3546), Gerd Hoffmann, 2021/05/27
- [PULL 11/23] headers: Add udmabuf.h, Gerd Hoffmann, 2021/05/27
- [PULL 10/23] ui: Get the fd associated with udmabuf driver,
Gerd Hoffmann <=
- [PULL 12/23] virtio-gpu: Add udmabuf helpers, Gerd Hoffmann, 2021/05/27
- [PULL 09/23] hw/display/qxl: Set pci rom address aligned with page size, Gerd Hoffmann, 2021/05/27
- [PULL 13/23] stubs: Add stubs for udmabuf helpers, Gerd Hoffmann, 2021/05/27
- [PULL 14/23] virtio-gpu: Add virtio_gpu_find_check_resource, Gerd Hoffmann, 2021/05/27
- [PULL 16/23] virtio-gpu: Refactor virtio_gpu_create_mapping_iov, Gerd Hoffmann, 2021/05/27
- [PULL 15/23] virtio-gpu: Refactor virtio_gpu_set_scanout, Gerd Hoffmann, 2021/05/27
- [PULL 17/23] virtio-gpu: Add initial definitions for blob resources, Gerd Hoffmann, 2021/05/27
- [PULL 18/23] virtio-gpu: Add virtio_gpu_resource_create_blob, Gerd Hoffmann, 2021/05/27
- [PULL 19/23] ui/pixman: Add qemu_pixman_to_drm_format(), Gerd Hoffmann, 2021/05/27
- [PULL 21/23] virtio-gpu: Factor out update scanout, Gerd Hoffmann, 2021/05/27