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.
(cherry picked from commit
8b1049473317c09d34b3ce9671d0f9e91dd4f1c0)
if (virCommandRunRegex(cmd, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc,
- state, NULL) < 0)
+ state, NULL, NULL) < 0)
goto cleanup;
ret = 0;
vars,
virStorageBackendLogicalMakeVol,
&cbdata,
- "lvs") < 0)
+ "lvs",
+ NULL) < 0)
goto cleanup;
ret = 0;
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;
vars,
virStorageBackendLogicalRefreshPoolFunc,
pool,
- "vgs") < 0)
+ "vgs",
+ NULL) < 0)
goto cleanup;
ret = 0;
* 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.
*
int *nvars,
virCommandRunRegexFunc func,
void *data,
- const char *prefix)
+ const char *prefix,
+ int *exitstatus)
{
int err;
regex_t *reg;
goto cleanup;
virCommandSetOutputBuffer(cmd, &outbuf);
- if (virCommandRun(cmd, NULL) < 0)
+ if (virCommandRun(cmd, exitstatus) < 0)
goto cleanup;
if (!outbuf) {
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__);
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,
regexes,
vars,
virISCSIExtractSession,
- &cbdata, NULL) < 0)
+ &cbdata, NULL, NULL) < 0)
goto cleanup;
if (cbdata.session == NULL && !probe) {
regexes,
vars,
virISCSIGetTargets,
- &list, NULL) < 0)
+ &list, NULL, NULL) < 0)
goto cleanup;
for (i = 0; i < list.ntargets; i++) {