[Spice-devel] [PATCH v2 spice-streaming-agent] Allow to set plugins directory via command line

Christophe de Dinechin cdupontd at redhat.com
Thu Feb 22 14:14:32 UTC 2018



> On 22 Feb 2018, at 14:15, Snir Sheriber <ssheribe at redhat.com> wrote:
> 
> Could be useful mainly for testing purposes, it allows to load
> plugins that aren't installed in the default plugins folder.
> To set different plugins directory use --plugins-dir=
> 
> Signed-off-by: Snir Sheriber <ssheribe at redhat.com>
> ---
> src/spice-streaming-agent.cpp | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 267b76e..9c04576 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -283,6 +283,7 @@ static void usage(const char *progname)
>     printf("\t-p portname  -- virtio-serial port to use\n");
>     printf("\t-l file -- log frames to file\n");
>     printf("\t--log-binary -- log binary frames (following -l)\n");
> +    printf("\t--plugins-dir=path -- change plugins directory\n");
>     printf("\t-d -- enable debug logs\n");
>     printf("\t-c variable=value -- change settings\n");
>     printf("\t\tframerate = 1-100 (check 10,20,30,40,50,60)\n");
> @@ -445,10 +446,15 @@ done:
> int main(int argc, char* argv[])
> {
>     const char *streamport = "/dev/virtio-ports/com.redhat.stream.0";
> -    char opt;
> +    int opt;
>     const char *log_filename = NULL;
>     int logmask = LOG_UPTO(LOG_WARNING);
> +    const char *pluginsdir = PLUGINSDIR;
> +    enum {
> +        OPT_PLUGINS_DIR = UCHAR_MAX+1
> +    };

I thought Frediano already had a patch that did that (for the log-binary option). Watch out for conflicts.

In order to help the resolution of such conflict, what about avoiding to have = on option names, i.e.

enum {
	OPT_FIRST = UCHAR_MAX,
	OPT_PLUGINS_DIR
}

(That way, if we merge with something that has OPT_LOG_BINARY, they don’t both have “OPT_X = same value”)


>     struct option long_options[] = {
> +        { "plugins-dir", required_argument, NULL, OPT_PLUGINS_DIR},
>         { "log-binary", no_argument, &log_binary, 1},
>         { "help", no_argument, NULL, 'h'},
>         { 0, 0, 0, 0}
> @@ -464,6 +470,10 @@ int main(int argc, char* argv[])
>         case 0:
>             /* Handle long options if needed */
>             break;
> +        case OPT_PLUGINS_DIR:

much better, thanks.

> +            if (optarg)
> +                pluginsdir = optarg;

else …

1) option error, we want a plugin directory argument
2) in that error, show the default plugin-dir, might be useful to extract a compile-time constant from a binary easily.



> +            break;
>         case 'p':
>             streamport = optarg;
>             break;
> @@ -493,7 +503,7 @@ int main(int argc, char* argv[])
>     // register built-in plugins
>     MjpegPlugin::Register(&agent);
> 
> -    agent.LoadPlugins(PLUGINSDIR);
> +    agent.LoadPlugins(pluginsdir);
> 
>     register_interrupts();
> 
> -- 
> 2.14.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



More information about the Spice-devel mailing list