[Spice-devel] [PATCH v2 spice-streaming-agent] Allow to set plugins directory via command line
Frediano Ziglio
fziglio at redhat.com
Thu Feb 22 13:30:57 UTC 2018
>
> 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
> + };
> 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:
> + if (optarg)
> + pluginsdir = optarg;
style (brackets).
However as you specified required_argument I would just remove
the if statement.
> + 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();
>
Otherwise,
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list