*not* virStorageReportError() if the fork()/exec() process it spawned returned a
!= 0 exit code. Rather, it returns the exitcode in this case, and it is up to
the higher level to determine whether this is a fatal error or not. The use
case for this change is in the iSCSI stuff; older versions of iscsiadm tools
would return a failure when getting the session number, despite the command
succeeding.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
- void *data)
+ void *data,
+ int *outexit)
{
int child = 0, fd = -1, exitstatus, err, failed = 1;
FILE *list = NULL;
return -1;
} else {
if (WIFEXITED(exitstatus)) {
- if (WEXITSTATUS(exitstatus) != 0) {
- virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("non-zero exit status from command %d"),
- WEXITSTATUS(exitstatus));
- return -1;
- }
+ if (outexit != NULL)
+ *outexit = WEXITSTATUS(exitstatus);
} else {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("command did not exit cleanly"));
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
- void *data);
+ void *data,
+ int *exitstatus);
int virStorageBackendRunProgNul(virConnectPtr conn,
virStoragePoolObjPtr pool,
};
char *session = NULL;
+ /* Note that we ignore the exitstatus. Older versions of iscsiadm tools
+ * returned an exit status of > 0, even if they succeeded. We will just
+ * rely on whether session got filled in properly.
+ */
if (virStorageBackendRunProgRegex(conn, pool,
prog,
1,
regexes,
vars,
virStorageBackendISCSIExtractSession,
- &session) < 0)
+ &session,
+ NULL) < 0)
return NULL;
if (session == NULL) {
regexes,
vars,
virStorageBackendISCSIMakeLUN,
- (void *)session);
+ (void *)session, NULL);
}
pool->def->name, NULL
};
- return virStorageBackendRunProgRegex(conn,
- pool,
- prog,
- 1,
- regexes,
- vars,
- virStorageBackendLogicalMakeVol,
- vol);
+ int exitstatus;
+
+ if (virStorageBackendRunProgRegex(conn,
+ pool,
+ prog,
+ 1,
+ regexes,
+ vars,
+ virStorageBackendLogicalMakeVol,
+ vol,
+ &exitstatus) < 0) {
+ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("lvs command failed"));
+ return -1;
+ }
+
+ if (exitstatus != 0) {
+ virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("lvs command failed with exitstatus %d"),
+ exitstatus);
+ return -1;
+ }
+
+ return 0;
}
static int
"--nosuffix", "--options", "vg_size,vg_free",
pool->def->name, NULL
};
+ int exitstatus;
/* Get list of all logical volumes */
if (virStorageBackendLogicalFindLVs(conn, pool, NULL) < 0) {
regexes,
vars,
virStorageBackendLogicalRefreshPoolFunc,
- NULL) < 0) {
+ NULL,
+ &exitstatus) < 0) {
+ virStoragePoolObjClearVols(pool);
+ return -1;
+ }
+
+ if (exitstatus != 0) {
virStoragePoolObjClearVols(pool);
return -1;
}