提交 003f063d 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 3cc35bf8
......@@ -1841,6 +1841,7 @@ virCommandDaemonize;
virCommandDoAsyncIO;
virCommandExec;
virCommandFree;
virCommandGetArgList;
virCommandGetGID;
virCommandGetUID;
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
/*
* Manage input and output to the child process.
......
......@@ -170,6 +170,7 @@ void virCommandWriteArgLog(virCommandPtr cmd,
int logfd);
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册