[Libguestfs] [PATCH 4/9] backend: Add a .plugin_name method.

Richard W.M. Jones rjones at redhat.com
Wed Jan 17 20:53:51 UTC 2018


This returns the plugin name, which for plugins is the same as the
ordinary .name method (but for filters will be different).
---
 src/connections.c | 4 ++--
 src/internal.h    | 1 +
 src/plugins.c     | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/connections.c b/src/connections.c
index 921a5b2..e1ac543 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -221,7 +221,7 @@ _handle_single_connection (int sockin, int sockout)
   if (backend->open (backend, conn, readonly) == -1)
     goto done;
 
-  threadlocal_set_name (backend->name (backend));
+  threadlocal_set_name (backend->plugin_name (backend));
 
   /* Handshake. */
   if (negotiate_handshake (conn) == -1)
@@ -253,7 +253,7 @@ _handle_single_connection (int sockin, int sockout)
         goto wait;
       }
       if (asprintf (&worker->name,
-                    "%s.%d", backend->name (backend), nworkers) < 0) {
+                    "%s.%d", backend->plugin_name (backend), nworkers) < 0) {
         perror ("asprintf");
         set_status (conn, -1);
         free (worker);
diff --git a/src/internal.h b/src/internal.h
index c4ee51b..dc26665 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -154,6 +154,7 @@ struct backend {
   void (*free) (struct backend *);
   int (*thread_model) (struct backend *);
   const char *(*name) (struct backend *);
+  const char *(*plugin_name) (struct backend *);
   void (*usage) (struct backend *);
   const char *(*version) (struct backend *);
   void (*dump_fields) (struct backend *);
diff --git a/src/plugins.c b/src/plugins.c
index 6a2ef66..f0fe864 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -465,6 +465,7 @@ static struct backend plugin_functions = {
   .free = plugin_free,
   .thread_model = plugin_thread_model,
   .name = plugin_name,
+  .plugin_name = plugin_name,
   .usage = plugin_usage,
   .version = plugin_version,
   .dump_fields = plugin_dump_fields,
-- 
2.15.1




More information about the Libguestfs mailing list