storage_backend: Fix error reporting with regex helper

Some clients overwrite the error from the regex helper, or do half-baked
error reporting with the exitstatus.
This commit is contained in:
Cole Robinson 2011-05-10 15:36:50 -04:00
parent be1965be66
commit 51622f21a2
5 changed files with 15 additions and 50 deletions

View File

@ -1401,8 +1401,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
void *data,
int *outexit)
void *data)
{
int fd = -1, err, ret = -1;
FILE *list = NULL;
@ -1500,7 +1499,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
}
}
ret = virCommandWait(cmd, outexit);
ret = virCommandWait(cmd, NULL);
cleanup:
if (groups) {
for (j = 0 ; j < totgroups ; j++)
@ -1623,10 +1622,10 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
const char **regex ATTRIBUTE_UNUSED,
int *nvars ATTRIBUTE_UNUSED,
virStorageBackendListVolRegexFunc func ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED,
int *outexit ATTRIBUTE_UNUSED)
void *data ATTRIBUTE_UNUSED)
{
virStorageReportError(VIR_ERR_INTERNAL_ERROR, _("%s not implemented on Win32"), __FUNCTION__);
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
_("%s not implemented on Win32"), __FUNCTION__);
return -1;
}

View File

@ -135,8 +135,7 @@ int virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
void *data,
int *exitstatus);
void *data);
int virStorageBackendRunProgNul(virStoragePoolObjPtr pool,
const char **prog,

View File

@ -233,7 +233,6 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
};
const char *prog[] = { SHOWMOUNT, "--no-headers", "--exports", NULL, NULL };
virStoragePoolSourcePtr source = NULL;
int exitstatus;
char *retval = NULL;
unsigned int i;
@ -246,8 +245,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
prog[3] = source->host.name;
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc,
&state, &exitstatus) < 0)
virStorageBackendFileSystemNetFindPoolSourcesFunc,
&state) < 0)
goto cleanup;
retval = virStoragePoolSourceListFormat(&state.list);

View File

@ -160,8 +160,7 @@ virStorageBackendISCSISession(virStoragePoolObjPtr pool,
regexes,
vars,
virStorageBackendISCSIExtractSession,
&session,
NULL) < 0)
&session) < 0)
return NULL;
if (session == NULL &&
@ -503,7 +502,6 @@ virStorageBackendISCSIScanTargets(const char *portal,
};
struct virStorageBackendISCSITargetList list;
int i;
int exitstatus;
memset(&list, 0, sizeof(list));
@ -513,17 +511,7 @@ virStorageBackendISCSIScanTargets(const char *portal,
regexes,
vars,
virStorageBackendISCSIGetTargets,
&list,
&exitstatus) < 0) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("iscsiadm command failed"));
return -1;
}
if (exitstatus != 0) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
_("iscsiadm sendtargets command failed with exitstatus %d"),
exitstatus);
&list) < 0) {
return -1;
}

View File

@ -205,25 +205,13 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
pool->def->source.name, NULL
};
int exitstatus;
if (virStorageBackendRunProgRegex(pool,
prog,
1,
regexes,
vars,
virStorageBackendLogicalMakeVol,
vol,
&exitstatus) < 0) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("lvs command failed"));
return -1;
}
if (exitstatus != 0) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
_("lvs command failed with exitstatus %d"),
exitstatus);
vol) < 0) {
return -1;
}
@ -321,7 +309,6 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
};
const char *const prog[] = { PVS, "--noheadings", "-o", "pv_name,vg_name", NULL };
const char *const scanprog[] = { VGSCAN, NULL };
int exitstatus;
char *retval = NULL;
virStoragePoolSourceList sourceList;
int i;
@ -331,7 +318,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
* that might be hanging around, so if this fails for some reason, the
* worst that happens is that scanning doesn't pick everything up
*/
if (virRun(scanprog, &exitstatus) < 0) {
if (virRun(scanprog, NULL) < 0) {
VIR_WARN("Failure when running vgscan to refresh physical volumes");
}
@ -339,8 +326,8 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
sourceList.type = VIR_STORAGE_POOL_LOGICAL;
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendLogicalFindPoolSourcesFunc,
&sourceList, &exitstatus) < 0)
virStorageBackendLogicalFindPoolSourcesFunc,
&sourceList) < 0)
return NULL;
retval = virStoragePoolSourceListFormat(&sourceList);
@ -489,7 +476,6 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
"--nosuffix", "--options", "vg_size,vg_free",
pool->def->source.name, NULL
};
int exitstatus;
virFileWaitForDevices();
@ -506,13 +492,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
regexes,
vars,
virStorageBackendLogicalRefreshPoolFunc,
NULL,
&exitstatus) < 0) {
virStoragePoolObjClearVols(pool);
return -1;
}
if (exitstatus != 0) {
NULL) < 0) {
virStoragePoolObjClearVols(pool);
return -1;
}