[Libguestfs] [PATCH nbdkit] plugins: Add scripting language version to --dump-plugin output.

Richard W.M. Jones rjones at redhat.com
Mon Oct 1 13:44:37 UTC 2018


On Lua:

  lua_version=5.3.4

On Perl:

  perl_version=5.28.0

On Python 2:

  python_version=2.7.15

On Python 3:

  python_version=3.7.0
  python_pep_384_abi_version=3

On Ruby 2.5.1p57:

  ruby_api_version=2.5.0

On Tcl:

  tcl_version=8.6
  tcl_patch_level=8.6.8
---
 plugins/lua/lua.c       | 11 +++++++++++
 plugins/perl/perl.c     |  4 ++++
 plugins/python/python.c |  8 ++++++++
 plugins/ruby/ruby.c     | 14 ++++++++++++++
 plugins/tcl/tcl.c       |  8 ++++++++
 5 files changed, 45 insertions(+)

diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c
index a73a4da..2bad44c 100644
--- a/plugins/lua/lua.c
+++ b/plugins/lua/lua.c
@@ -102,6 +102,17 @@ function_defined (const char *name)
 static void
 lua_plugin_dump_plugin (void)
 {
+#ifdef LUA_VERSION_MAJOR
+  printf ("lua_version=%s", LUA_VERSION_MAJOR);
+#ifdef LUA_VERSION_MINOR
+  printf (".%s", LUA_VERSION_MINOR);
+#ifdef LUA_VERSION_RELEASE
+  printf (".%s", LUA_VERSION_RELEASE);
+#endif
+#endif
+  printf ("\n");
+#endif
+
   if (script && function_defined ("dump_plugin")) {
     lua_getglobal (L, "dump_plugin");
     if (lua_pcall (L, 0, 0, 0) != 0) {
diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c
index 3fce279..4cee89d 100644
--- a/plugins/perl/perl.c
+++ b/plugins/perl/perl.c
@@ -169,6 +169,10 @@ perl_dump_plugin (void)
 {
   dSP;
 
+#ifdef PERL_VERSION_STRING
+  printf ("perl_version=%s\n", PERL_VERSION_STRING);
+#endif
+
   if (script && callback_defined ("dump_plugin")) {
     ENTER;
     SAVETMPS;
diff --git a/plugins/python/python.c b/plugins/python/python.c
index ef1a2cf..8b16d7e 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -259,6 +259,14 @@ py_dump_plugin (void)
   PyObject *fn;
   PyObject *r;
 
+#ifdef PY_VERSION
+  printf ("python_version=%s\n", PY_VERSION);
+#endif
+
+#ifdef PYTHON_ABI_VERSION
+  printf ("python_pep_384_abi_version=%d\n", PYTHON_ABI_VERSION);
+#endif
+
   if (script && callback_defined ("dump_plugin", &fn)) {
     PyErr_Clear ();
 
diff --git a/plugins/ruby/ruby.c b/plugins/ruby/ruby.c
index aa57f65..a3d7a42 100644
--- a/plugins/ruby/ruby.c
+++ b/plugins/ruby/ruby.c
@@ -41,6 +41,9 @@
 #include <nbdkit-plugin.h>
 
 #include <ruby.h>
+#ifdef HAVE_RUBY_VERSION_H
+#include <ruby/version.h>
+#endif
 
 static VALUE nbdkit_module = Qnil;
 static int last_error;
@@ -168,6 +171,17 @@ plugin_rb_unload (void)
 static void
 plugin_rb_dump_plugin (void)
 {
+#ifdef RUBY_API_VERSION_MAJOR
+  printf ("ruby_api_version=%d", RUBY_API_VERSION_MAJOR);
+#ifdef RUBY_API_VERSION_MINOR
+  printf (".%d", RUBY_API_VERSION_MINOR);
+#ifdef RUBY_API_VERSION_TEENY
+  printf (".%d", RUBY_API_VERSION_TEENY);
+#endif
+#endif
+  printf ("\n");
+#endif
+
   if (!script)
     return;
 
diff --git a/plugins/tcl/tcl.c b/plugins/tcl/tcl.c
index b814195..b30fefd 100644
--- a/plugins/tcl/tcl.c
+++ b/plugins/tcl/tcl.c
@@ -95,6 +95,14 @@ proc_defined (const char *name)
 static void
 tcl_dump_plugin (void)
 {
+#ifdef TCL_VERSION
+  printf ("tcl_version=%s\n", TCL_VERSION);
+#endif
+
+#ifdef TCL_PATCH_LEVEL
+  printf ("tcl_patch_level=%s\n", TCL_PATCH_LEVEL);
+#endif
+
   if (script && proc_defined ("dump_plugin")) {
     int r;
     Tcl_Obj *cmd;
-- 
2.19.0.rc0




More information about the Libguestfs mailing list