[spice-streaming-agent] Report initialization errors more precisely

Submitted by Christophe de Dinechin on Nov. 22, 2017, 3:43 p.m.

Details

Message ID 20171122154335.63637-1-christophe@dinechin.org
State New
Headers show
Series "Report initialization errors more precisely" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Christophe de Dinechin Nov. 22, 2017, 3:43 p.m.
From: Christophe de Dinechin <dinechin@redhat.com>

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 src/concrete-agent.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index 192054a..ddeac8e 100644
--- a/src/concrete-agent.cpp
+++ b/src/concrete-agent.cpp
@@ -89,11 +89,15 @@  void ConcreteAgent::LoadPlugin(const char *plugin_filename)
         PluginInitFunc* init_func =
             (PluginInitFunc *) dlsym(dl, "spice_streaming_agent_plugin_init");
         if (!init_func || !init_func(this)) {
+            syslog(LOG_ERR, "error loading plugin %s: %s",
+                   plugin_filename,
+                   init_func ? "module init failed" : "no module init function");
             dlclose(dl);
         }
     }
     catch (std::runtime_error &err) {
-        syslog(LOG_ERR, "%s", err.what());
+        syslog(LOG_ERR, "error loading plugin %s: %s",
+               plugin_filename, err.what());
         dlclose(dl);
     }
 }

Comments

> 
> From: Christophe de Dinechin <dinechin@redhat.com>
> 
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
> ---
>  src/concrete-agent.cpp | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
> index 192054a..ddeac8e 100644
> --- a/src/concrete-agent.cpp
> +++ b/src/concrete-agent.cpp
> @@ -89,11 +89,15 @@ void ConcreteAgent::LoadPlugin(const char
> *plugin_filename)
>          PluginInitFunc* init_func =
>              (PluginInitFunc *) dlsym(dl,
>              "spice_streaming_agent_plugin_init");
>          if (!init_func || !init_func(this)) {
> +            syslog(LOG_ERR, "error loading plugin %s: %s",
> +                   plugin_filename,
> +                   init_func ? "module init failed" : "no module init
> function");
>              dlclose(dl);

The init function can return true also if it decided it
cannot work. This can be a normal condition if the specific
plugin require some specific h/w. In this case you should not
have a log.

>          }
>      }
>      catch (std::runtime_error &err) {
> -        syslog(LOG_ERR, "%s", err.what());
> +        syslog(LOG_ERR, "error loading plugin %s: %s",
> +               plugin_filename, err.what());

yes, better and more consistent

>          dlclose(dl);
>      }
>  }

Frediano