[PATCH 1/2] remote: allow passing cmd arguments to REMOTE_DRIVER_TRANSPORT_EXT

Sergey Dyasli posted 2 patches 2 weeks, 3 days ago
[PATCH 1/2] remote: allow passing cmd arguments to REMOTE_DRIVER_TRANSPORT_EXT
Posted by Sergey Dyasli 2 weeks, 3 days ago
Allow passing up to 5 arguments to the ext program via the query
parameters. URI example:

    qemu+ext:///system?command=/bin/prog&ext_arg1=192.168.0.10&ext_arg2=8080

Signed-off-by: Sergey Dyasli <sergey.dyasli@nutanix.com>
---
 src/remote/remote_driver.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index ec71eaed8762..e5f425da74bf 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -805,6 +805,11 @@ static int
 doRemoteOpenExtractURIArgs(virConnectPtr conn,
                            char **name,
                            char **command,
+                           char **extArg1,
+                           char **extArg2,
+                           char **extArg3,
+                           char **extArg4,
+                           char **extArg5,
                            char **sockname,
                            char **authtype,
                            char **sshauth,
@@ -829,6 +834,11 @@ doRemoteOpenExtractURIArgs(virConnectPtr conn,
 
         EXTRACT_URI_ARG_STR("name", *name);
         EXTRACT_URI_ARG_STR("command", *command);
+        EXTRACT_URI_ARG_STR("ext_arg1", *extArg1);
+        EXTRACT_URI_ARG_STR("ext_arg2", *extArg2);
+        EXTRACT_URI_ARG_STR("ext_arg3", *extArg3);
+        EXTRACT_URI_ARG_STR("ext_arg4", *extArg4);
+        EXTRACT_URI_ARG_STR("ext_arg5", *extArg5);
         EXTRACT_URI_ARG_STR("socket", *sockname);
         EXTRACT_URI_ARG_STR("auth", *authtype);
         EXTRACT_URI_ARG_STR("sshauth", *sshauth);
@@ -895,6 +905,11 @@ doRemoteOpen(virConnectPtr conn,
     g_autofree char *tls_priority = NULL;
     g_autofree char *name = NULL;
     g_autofree char *command = NULL;
+    g_autofree char *extArg1 = NULL;
+    g_autofree char *extArg2 = NULL;
+    g_autofree char *extArg3 = NULL;
+    g_autofree char *extArg4 = NULL;
+    g_autofree char *extArg5 = NULL;
     g_autofree char *sockname = NULL;
     g_autofree char *netcat = NULL;
     g_autofree char *port = NULL;
@@ -945,6 +960,11 @@ doRemoteOpen(virConnectPtr conn,
         if (doRemoteOpenExtractURIArgs(conn,
                                        &name,
                                        &command,
+                                       &extArg1,
+                                       &extArg2,
+                                       &extArg3,
+                                       &extArg4,
+                                       &extArg5,
                                        &sockname,
                                        &authtype,
                                        &sshauth,
@@ -1195,7 +1215,8 @@ doRemoteOpen(virConnectPtr conn,
         break;
 
     case REMOTE_DRIVER_TRANSPORT_EXT: {
-        char const *cmd_argv[] = { command, NULL };
+        char const *cmd_argv[] = { command, extArg1, extArg2, extArg3,
+                                   extArg4, extArg5, NULL };
         if (!(priv->client = virNetClientNewExternal(cmd_argv)))
             goto error;
 
-- 
2.39.3
Re: [PATCH 1/2] remote: allow passing cmd arguments to REMOTE_DRIVER_TRANSPORT_EXT
Posted by Daniel P. Berrangé via Devel 2 weeks, 3 days ago
On Fri, Oct 10, 2025 at 08:58:17AM +0000, Sergey Dyasli wrote:
> Allow passing up to 5 arguments to the ext program via the query
> parameters. URI example:
> 
>     qemu+ext:///system?command=/bin/prog&ext_arg1=192.168.0.10&ext_arg2=8080

AFAIR,  URI query parameters can be repeated arbitrarily many
times, so we shouldn't need to have a different name for each
parameter, nor any limit.

> 
> Signed-off-by: Sergey Dyasli <sergey.dyasli@nutanix.com>
> ---
>  src/remote/remote_driver.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index ec71eaed8762..e5f425da74bf 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c
> @@ -805,6 +805,11 @@ static int
>  doRemoteOpenExtractURIArgs(virConnectPtr conn,
>                             char **name,
>                             char **command,
> +                           char **extArg1,
> +                           char **extArg2,
> +                           char **extArg3,
> +                           char **extArg4,
> +                           char **extArg5,
>                             char **sockname,
>                             char **authtype,
>                             char **sshauth,
> @@ -829,6 +834,11 @@ doRemoteOpenExtractURIArgs(virConnectPtr conn,
>  
>          EXTRACT_URI_ARG_STR("name", *name);
>          EXTRACT_URI_ARG_STR("command", *command);
> +        EXTRACT_URI_ARG_STR("ext_arg1", *extArg1);
> +        EXTRACT_URI_ARG_STR("ext_arg2", *extArg2);
> +        EXTRACT_URI_ARG_STR("ext_arg3", *extArg3);
> +        EXTRACT_URI_ARG_STR("ext_arg4", *extArg4);
> +        EXTRACT_URI_ARG_STR("ext_arg5", *extArg5);
>          EXTRACT_URI_ARG_STR("socket", *sockname);
>          EXTRACT_URI_ARG_STR("auth", *authtype);
>          EXTRACT_URI_ARG_STR("sshauth", *sshauth);
> @@ -895,6 +905,11 @@ doRemoteOpen(virConnectPtr conn,
>      g_autofree char *tls_priority = NULL;
>      g_autofree char *name = NULL;
>      g_autofree char *command = NULL;
> +    g_autofree char *extArg1 = NULL;
> +    g_autofree char *extArg2 = NULL;
> +    g_autofree char *extArg3 = NULL;
> +    g_autofree char *extArg4 = NULL;
> +    g_autofree char *extArg5 = NULL;
>      g_autofree char *sockname = NULL;
>      g_autofree char *netcat = NULL;
>      g_autofree char *port = NULL;
> @@ -945,6 +960,11 @@ doRemoteOpen(virConnectPtr conn,
>          if (doRemoteOpenExtractURIArgs(conn,
>                                         &name,
>                                         &command,
> +                                       &extArg1,
> +                                       &extArg2,
> +                                       &extArg3,
> +                                       &extArg4,
> +                                       &extArg5,
>                                         &sockname,
>                                         &authtype,
>                                         &sshauth,
> @@ -1195,7 +1215,8 @@ doRemoteOpen(virConnectPtr conn,
>          break;
>  
>      case REMOTE_DRIVER_TRANSPORT_EXT: {
> -        char const *cmd_argv[] = { command, NULL };
> +        char const *cmd_argv[] = { command, extArg1, extArg2, extArg3,
> +                                   extArg4, extArg5, NULL };
>          if (!(priv->client = virNetClientNewExternal(cmd_argv)))
>              goto error;
>  
> -- 
> 2.39.3
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] remote: allow passing cmd arguments to REMOTE_DRIVER_TRANSPORT_EXT
Posted by Sergey Dyasli 1 week, 6 days ago
On 10/10/2025 10:18, Daniel P. Berrangé wrote:
> On Fri, Oct 10, 2025 at 08:58:17AM +0000, Sergey Dyasli wrote:
>> Allow passing up to 5 arguments to the ext program via the query
>> parameters. URI example:
>>
>>      qemu+ext:///system?command=/bin/prog&ext_arg1=192.168.0.10&ext_arg2=8080
> 
> AFAIR,  URI query parameters can be repeated arbitrarily many
> times, so we shouldn't need to have a different name for each
> parameter, nor any limit.
That indeed seems to be the case, thanks for pointing out! I plan to 
send out v2 at some point with "ext_arg" parameter that you can repeat 
multiple times.

Sergey
Re: [PATCH 1/2] remote: allow passing cmd arguments to REMOTE_DRIVER_TRANSPORT_EXT
Posted by Daniel P. Berrangé via Devel 1 week, 6 days ago
On Tue, Oct 14, 2025 at 03:13:10PM +0100, Sergey Dyasli wrote:
> On 10/10/2025 10:18, Daniel P. Berrangé wrote:
> > On Fri, Oct 10, 2025 at 08:58:17AM +0000, Sergey Dyasli wrote:
> > > Allow passing up to 5 arguments to the ext program via the query
> > > parameters. URI example:
> > > 
> > >      qemu+ext:///system?command=/bin/prog&ext_arg1=192.168.0.10&ext_arg2=8080
> > 
> > AFAIR,  URI query parameters can be repeated arbitrarily many
> > times, so we shouldn't need to have a different name for each
> > parameter, nor any limit.
> That indeed seems to be the case, thanks for pointing out! I plan to send
> out v2 at some point with "ext_arg" parameter that you can repeat multiple
> times.

I'd suggest just 'argv' as the parameter name.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|