[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] char: rename CharBackend->CharFrontend



On 22/10/25 09:46, marcandre.lureau@xxxxxxxxxx wrote:
From: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

The actual backend is "Chardev", CharBackend is the frontend side of
it (whatever talks to the backend), let's rename it for readability.

Signed-off-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
  chardev/chardev-internal.h           |  12 +-
  include/chardev/char-fe.h            |  67 +++++----
  include/chardev/char.h               |   4 +-
...

diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
index 9752dd75f7..8ea10414ab 100644
--- a/chardev/chardev-internal.h
+++ b/chardev/chardev-internal.h
@@ -37,9 +37,9 @@
  struct MuxChardev {
      Chardev parent;
      /* Linked frontends */
-    CharBackend *backends[MAX_MUX];
-    /* Linked backend */
-    CharBackend chr;
+    CharFrontend *frontends[MAX_MUX];
+    /* frontend of the underlying muxed chardev */
+    CharFrontend chr;
      unsigned long mux_bitset;
      int focus;
      bool term_got_escape;
diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
index 8ef05b3dd0..7901856f95 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -8,12 +8,12 @@ typedef void IOEventHandler(void *opaque, QEMUChrEvent event);
  typedef int BackendChangeHandler(void *opaque);
/**
- * struct CharBackend - back end as seen by front end
+ * struct CharFrontend - Chardev as seen by front end
   * @fe_is_open: the front end is ready for IO
   *
   * The actual backend is Chardev
   */
-struct CharBackend {
+struct CharFrontend {
      Chardev *chr;
      IOEventHandler *chr_event;
      IOCanReadHandler *chr_can_read;
@@ -27,53 +27,52 @@ struct CharBackend {
  /**
   * qemu_chr_fe_init:
   *
- * Initializes a front end for the given CharBackend and
- * Chardev. Call qemu_chr_fe_deinit() to remove the association and
- * release the driver.
+ * Initializes the frontend @c for the given Chardev backend @s. Call
+ * qemu_chr_fe_deinit() to remove the association and release the backend.
   *
   * Returns: false on error.
   */
-bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error **errp);
+bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Error **errp);

IMO even clearer for this API would be to use:

  bool qemu_chr_fe_init(CharFrontend *fe, Chardev *be, Error **errp);

and update documentation accordingly.

/**
   * qemu_chr_fe_deinit:
- * @b: a CharBackend
+ * @c: a CharFrontend
   * @del: if true, delete the chardev backend
  *
- * Dissociate the CharBackend from the Chardev.
+ * Dissociate the CharFrontend from the Chardev.
   *
   * Safe to call without associated Chardev.
   */
-void qemu_chr_fe_deinit(CharBackend *b, bool del);
+void qemu_chr_fe_deinit(CharFrontend *c, bool del);
/**
   * qemu_chr_fe_get_driver:
   *
- * Returns: the driver associated with a CharBackend or NULL if no
+ * Returns: the driver associated with a CharFrontend or NULL if no
   * associated Chardev.
   * Note: avoid this function as the driver should never be accessed directly,
   *       especially by the frontends that support chardevice hotswap.
   *       Consider qemu_chr_fe_backend_connected() to check for driver 
existence
   */
-Chardev *qemu_chr_fe_get_driver(CharBackend *be);
+Chardev *qemu_chr_fe_get_driver(CharFrontend *c);
/**
   * qemu_chr_fe_backend_connected:
   *
- * Returns: true if there is a chardevice associated with @be.
+ * Returns: true if there is a backend associated with @c.
   */
-bool qemu_chr_fe_backend_connected(CharBackend *be);
+bool qemu_chr_fe_backend_connected(CharFrontend *c);

LGTM otherwise!



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.