提交 8b104947 编写于 作者: J John Ferlan

util: Add exitstatus parameter to virCommandRunRegex

Rather than have virCommandRun just spit out the error, allow callers
to decide to pass the exitstatus so the caller can make intelligent
decisions based on the error.
上级 f6ececa6
......@@ -267,7 +267,7 @@ virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state)
if (virCommandRunRegex(cmd, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc,
state, NULL) < 0)
state, NULL, NULL) < 0)
goto cleanup;
ret = 0;
......
......@@ -398,7 +398,8 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
vars,
virStorageBackendLogicalMakeVol,
&cbdata,
"lvs") < 0)
"lvs",
NULL) < 0)
goto cleanup;
ret = 0;
......@@ -511,10 +512,10 @@ virStorageBackendLogicalGetPoolSources(virStoragePoolSourceListPtr sourceList)
cmd = virCommandNewArgList(PVS,
"--noheadings",
"-o", "pv_name,vg_name",
NULL);
NULL, NULL);
if (virCommandRunRegex(cmd, 1, regexes, vars,
virStorageBackendLogicalFindPoolSourcesFunc,
sourceList, "pvs") < 0)
sourceList, "pvs", NULL) < 0)
goto cleanup;
ret = 0;
......@@ -799,7 +800,8 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
vars,
virStorageBackendLogicalRefreshPoolFunc,
pool,
"vgs") < 0)
"vgs",
NULL) < 0)
goto cleanup;
ret = 0;
......
......@@ -2900,6 +2900,7 @@ virCommandSetDryRun(virBufferPtr buf,
* needs to return 0 on success
* @data: additional data that will be passed to the callback function
* @prefix: prefix that will be skipped at the beginning of each line
* @exitstatus: allows the caller to handle command run exit failures
*
* Run an external program.
*
......@@ -2917,7 +2918,8 @@ virCommandRunRegex(virCommandPtr cmd,
int *nvars,
virCommandRunRegexFunc func,
void *data,
const char *prefix)
const char *prefix,
int *exitstatus)
{
int err;
regex_t *reg;
......@@ -2959,7 +2961,7 @@ virCommandRunRegex(virCommandPtr cmd,
goto cleanup;
virCommandSetOutputBuffer(cmd, &outbuf);
if (virCommandRun(cmd, NULL) < 0)
if (virCommandRun(cmd, exitstatus) < 0)
goto cleanup;
if (!outbuf) {
......@@ -3114,7 +3116,8 @@ virCommandRunRegex(virCommandPtr cmd ATTRIBUTE_UNUSED,
int *nvars ATTRIBUTE_UNUSED,
virCommandRunRegexFunc func ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED,
const char *prefix ATTRIBUTE_UNUSED)
const char *prefix ATTRIBUTE_UNUSED,
int *exitstatus ATTRIBUTE_UNUSED)
{
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s not implemented on Win32"), __FUNCTION__);
......
......@@ -205,7 +205,8 @@ int virCommandRunRegex(virCommandPtr cmd,
int *nvars,
virCommandRunRegexFunc func,
void *data,
const char *cmd_to_ignore);
const char *cmd_to_ignore,
int *exitstatus);
int virCommandRunNul(virCommandPtr cmd,
size_t n_columns,
......
......@@ -87,7 +87,7 @@ virISCSIGetSession(const char *devpath,
regexes,
vars,
virISCSIExtractSession,
&cbdata, NULL) < 0)
&cbdata, NULL, NULL) < 0)
goto cleanup;
if (cbdata.session == NULL && !probe) {
......@@ -437,7 +437,7 @@ virISCSIScanTargets(const char *portal,
regexes,
vars,
virISCSIGetTargets,
&list, NULL) < 0)
&list, NULL, NULL) < 0)
goto cleanup;
for (i = 0; i < list.ntargets; i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册