1 Star 0 Fork 71

lIshaohui/libvirt

forked from src-openEuler/libvirt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
virCommand-Introduce-virCommandGetArgList.patch 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
imxcc 提交于 2022-02-22 00:16 . update patch with openeuler !54
From 548ea1fcfcfbfc40fab04301e780d28ebe4320a4 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 13 May 2020 17:55:21 +0200
Subject: [PATCH 13/18] 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>
---
src/libvirt_private.syms | 1 +
src/util/vircommand.c | 23 +++++++++++++++++++++++
src/util/vircommand.h | 1 +
3 files changed, 25 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 726e7a21f9..861a4892be 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1829,6 +1829,7 @@ virCommandDaemonize;
virCommandDoAsyncIO;
virCommandExec;
virCommandFree;
+virCommandGetArgList;
virCommandGetGID;
virCommandGetUID;
virCommandHandshakeNotify;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index b84fb40948..86e4c5cd39 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -2167,6 +2167,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.
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index 4e6cb0ac0d..854bfe6576 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -171,6 +171,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;
--
2.23.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/li-shaohui/libvirt.git
git@gitee.com:li-shaohui/libvirt.git
li-shaohui
libvirt
libvirt
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385