On 7/9/23 09:43, Albert Esteve wrote:
This API manages objects (in this iteration,
dmabuf fds) that can be shared along different
virtio devices, associated to a UUID.

The API allows the different devices to add,
remove and/or retrieve the objects by simply
invoking the public functions that reside in the
virtio-dmabuf file.

For vhost backends, the API stores the pointer
to the backend holding the object.

Suggested-by: Gerd Hoffmann <kra...@redhat.com>
Signed-off-by: Albert Esteve <aest...@redhat.com>
---
  MAINTAINERS                       |   7 ++
  hw/display/meson.build            |   1 +
  hw/display/virtio-dmabuf.c        | 136 +++++++++++++++++++++++++++++
  include/hw/virtio/virtio-dmabuf.h | 103 ++++++++++++++++++++++
  tests/unit/meson.build            |   1 +
  tests/unit/test-virtio-dmabuf.c   | 137 ++++++++++++++++++++++++++++++
  6 files changed, 385 insertions(+)
  create mode 100644 hw/display/virtio-dmabuf.c
  create mode 100644 include/hw/virtio/virtio-dmabuf.h
  create mode 100644 tests/unit/test-virtio-dmabuf.c


diff --git a/include/hw/virtio/virtio-dmabuf.h 
b/include/hw/virtio/virtio-dmabuf.h
new file mode 100644
index 0000000000..202eec5868
--- /dev/null
+++ b/include/hw/virtio/virtio-dmabuf.h
@@ -0,0 +1,103 @@
+/*
+ * Virtio Shared dma-buf
+ *
+ * Copyright Red Hat, Inc. 2023
+ *
+ * Authors:
+ *     Albert Esteve <aest...@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef VIRTIO_DMABUF_H
+#define VIRTIO_DMABUF_H
+
+#include "qemu/osdep.h"

See https://www.qemu.org/docs/master/devel/style.html#include-directives

  Do not include “qemu/osdep.h” from header files since the .c
  file will have already included it.

+#include <glib.h>

This one is also included via "qemu/osdep.h" -> "glib-compat.h"

+#include "qemu/uuid.h"
+#include "vhost.h"
+
+typedef enum SharedObjectType {
+    TYPE_INVALID = 0,
+    TYPE_DMABUF,
+    TYPE_VHOST_DEV,
+} SharedObjectType;
+
+typedef struct VirtioSharedObject {
+    SharedObjectType type;
+    gpointer value;
+} VirtioSharedObject;

Since this need a repost, better use "hw/display: Introduce virtio-dmabuf" as patch subject (and "util/uuid" prefix for the previous patch).

Otherwise LGTM, so with these changes:

Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>


Reply via email to