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

Frediano Ziglio fziglio at redhat.com
Thu Feb 22 11:05:12 UTC 2018


> 
> Set different plugins directory using --plugins-dir=
> ---
> 
>  Would be helpful, but not really critical
> 

Can you add in the message how you would like to use?
I would personally use for debugging/testing purposes.
You miss the signed off.

>  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;

we used const char * for another option

>      struct option long_options[] = {
> +        { "plugins-dir", 1, NULL, 0},

I think would be better to use some enum and some number not conflicting with
ASCII/UTF-8 (for instance from 256 or UCHAR_MAX+1 if you want max portability).
Not better to use required_argument instead of 1 ?

>          { "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:

here I would use 256.. or better a enumeration, see
https://lists.freedesktop.org/archives/spice-devel/2018-February/041937.html
for instance

>              /* Handle long options if needed */
> +            if (optarg) /* currently --plugins-dir is the only long option
> with arg */
> +                pluginsdir = optarg;
>              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();
>  

Frediano


More information about the Spice-devel mailing list