mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-29 16:05:17 +00:00
virCommand: Introduce virCommandGetArgList
The helper returns a list of arguments of a virCommand. This will be useful in tests where we'll inspect certain already formatted arguments. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
3cc35bf88e
commit
003f063dd6
@ -1841,6 +1841,7 @@ virCommandDaemonize;
|
|||||||
virCommandDoAsyncIO;
|
virCommandDoAsyncIO;
|
||||||
virCommandExec;
|
virCommandExec;
|
||||||
virCommandFree;
|
virCommandFree;
|
||||||
|
virCommandGetArgList;
|
||||||
virCommandGetGID;
|
virCommandGetGID;
|
||||||
virCommandGetUID;
|
virCommandGetUID;
|
||||||
virCommandHandshakeNotify;
|
virCommandHandshakeNotify;
|
||||||
|
@ -2132,6 +2132,29 @@ virCommandToString(virCommandPtr cmd, bool linebreaks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virCommandGetArgList(virCommandPtr cmd,
|
||||||
|
char ***args,
|
||||||
|
size_t *nargs)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (cmd->has_error) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("invalid use of command API"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*args = g_new0(char *, cmd->nargs);
|
||||||
|
*nargs = cmd->nargs - 1;
|
||||||
|
|
||||||
|
for (i = 1; i < cmd->nargs; i++)
|
||||||
|
(*args)[i - 1] = g_strdup(cmd->args[i]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
/*
|
/*
|
||||||
* Manage input and output to the child process.
|
* Manage input and output to the child process.
|
||||||
|
@ -170,6 +170,7 @@ void virCommandWriteArgLog(virCommandPtr cmd,
|
|||||||
int logfd);
|
int logfd);
|
||||||
|
|
||||||
char *virCommandToString(virCommandPtr cmd, bool linebreaks) G_GNUC_WARN_UNUSED_RESULT;
|
char *virCommandToString(virCommandPtr cmd, bool linebreaks) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
int virCommandGetArgList(virCommandPtr cmd, char ***args, size_t *nargs);
|
||||||
|
|
||||||
int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) G_GNUC_WARN_UNUSED_RESULT;
|
int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user