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

Christophe de Dinechin christophe.de.dinechin at gmail.com
Thu Feb 22 11:02:15 UTC 2018



> On 22 Feb 2018, at 11:55, Snir Sheriber <ssheribe at redhat.com> wrote:
> 
> Set different plugins directory using --plugins-dir=
> ---
> 
> Would be helpful, but not really critical
> 
> src/spice-streaming-agent.cpp | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 267b76e..bfdd19a 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");
> @@ -448,7 +449,9 @@ int main(int argc, char* argv[])
>     char opt;
>     const char *log_filename = NULL;
>     int logmask = LOG_UPTO(LOG_WARNING);
> +    std::string pluginsdir = PLUGINSDIR;
>     struct option long_options[] = {
> +        { "plugins-dir", 1, NULL, 0},
>         { "log-binary", no_argument, &log_binary, 1},
>         { "help", no_argument, NULL, 'h'},
>         { 0, 0, 0, 0}
> @@ -463,6 +466,8 @@ int main(int argc, char* argv[])
>         switch (opt) {
>         case 0:
>             /* Handle long options if needed */
> +            if (optarg) /* currently --plugins-dir is the only long option with arg */
> +                pluginsdir = optarg;

This is fragile, whoever adds the second option might get caught…
Why not actually test for a specific opt?

>             break;
>         case 'p':
>             streamport = optarg;
> @@ -493,7 +498,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