On 5/21/26 18:23, Peter Krempa via Devel wrote:
> From: Peter Krempa <[email protected]>
> 
> Introduce virCommandArgListAccess which returns 'args' and 'nargs'
> 
> Upcoming patches will add code which censores/stabilizes FD numbers in
> test outputs. This will be done by rewriting the argument of the command
> before comparing it with test output. Add a test-only function to
> directly access 'args' and 'nargs' of a virCommand to do this
> modification.
> 
> This accessor will also be used instead of 'virCommandGetArgList' in
> 'testCompareXMLToArgvValidateSchema' to avoid needles copy of all
> arguments.
> 
> Signed-off-by: Peter Krempa <[email protected]>
> ---
>  src/libvirt_private.syms  |  1 +
>  src/util/vircommand.c     | 20 ++++++++++++++++++++
>  src/util/vircommandpriv.h |  4 ++++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 7232b7c663..d2fc35505b 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2208,6 +2208,7 @@ virCommandAddEnvPassCommon;
>  virCommandAddEnvString;
>  virCommandAddEnvXDG;
>  virCommandAllowCap;
> +virCommandArgListAccess;
>  virCommandClearCaps;
>  virCommandDaemonize;
>  virCommandDoAsyncIO;
> diff --git a/src/util/vircommand.c b/src/util/vircommand.c
> index 2d13cf629c..00d0b58ee1 100644
> --- a/src/util/vircommand.c
> +++ b/src/util/vircommand.c
> @@ -2172,6 +2172,26 @@ virCommandGetArgList(virCommand *cmd,
>  }
> 
> 
> +/**
> + * virCommandGetArgList:

s/virCommandGetArgList/virCommandArgListAccess/

> + * @cmd: command struct
> + * @args: filled with pointer to list of args of @cmd
> + * @nargs: filled with number of arguments
> + *
> + * For use only in tests.
> + *
> + * Allows access to the arguments, including modification.
> + */
> +void
> +virCommandArgListAccess(virCommand *cmd,
> +                        char ***args,
> +                        size_t *nargs)

Michal

Reply via email to