提交 51622f21 编写于 作者: C Cole Robinson

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.
上级 be1965be
...@@ -1401,8 +1401,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, ...@@ -1401,8 +1401,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
const char **regex, const char **regex,
int *nvars, int *nvars,
virStorageBackendListVolRegexFunc func, virStorageBackendListVolRegexFunc func,
void *data, void *data)
int *outexit)
{ {
int fd = -1, err, ret = -1; int fd = -1, err, ret = -1;
FILE *list = NULL; FILE *list = NULL;
...@@ -1500,7 +1499,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, ...@@ -1500,7 +1499,7 @@ virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
} }
} }
ret = virCommandWait(cmd, outexit); ret = virCommandWait(cmd, NULL);
cleanup: cleanup:
if (groups) { if (groups) {
for (j = 0 ; j < totgroups ; j++) for (j = 0 ; j < totgroups ; j++)
...@@ -1623,10 +1622,10 @@ virStorageBackendRunProgRegex(virConnectPtr conn, ...@@ -1623,10 +1622,10 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
const char **regex ATTRIBUTE_UNUSED, const char **regex ATTRIBUTE_UNUSED,
int *nvars ATTRIBUTE_UNUSED, int *nvars ATTRIBUTE_UNUSED,
virStorageBackendListVolRegexFunc func ATTRIBUTE_UNUSED, virStorageBackendListVolRegexFunc func ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED, void *data ATTRIBUTE_UNUSED)
int *outexit 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; return -1;
} }
......
...@@ -135,8 +135,7 @@ int virStorageBackendRunProgRegex(virStoragePoolObjPtr pool, ...@@ -135,8 +135,7 @@ int virStorageBackendRunProgRegex(virStoragePoolObjPtr pool,
const char **regex, const char **regex,
int *nvars, int *nvars,
virStorageBackendListVolRegexFunc func, virStorageBackendListVolRegexFunc func,
void *data, void *data);
int *exitstatus);
int virStorageBackendRunProgNul(virStoragePoolObjPtr pool, int virStorageBackendRunProgNul(virStoragePoolObjPtr pool,
const char **prog, const char **prog,
......
...@@ -233,7 +233,6 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE ...@@ -233,7 +233,6 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
}; };
const char *prog[] = { SHOWMOUNT, "--no-headers", "--exports", NULL, NULL }; const char *prog[] = { SHOWMOUNT, "--no-headers", "--exports", NULL, NULL };
virStoragePoolSourcePtr source = NULL; virStoragePoolSourcePtr source = NULL;
int exitstatus;
char *retval = NULL; char *retval = NULL;
unsigned int i; unsigned int i;
...@@ -246,8 +245,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE ...@@ -246,8 +245,8 @@ virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSE
prog[3] = source->host.name; prog[3] = source->host.name;
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars, if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendFileSystemNetFindPoolSourcesFunc, virStorageBackendFileSystemNetFindPoolSourcesFunc,
&state, &exitstatus) < 0) &state) < 0)
goto cleanup; goto cleanup;
retval = virStoragePoolSourceListFormat(&state.list); retval = virStoragePoolSourceListFormat(&state.list);
......
...@@ -160,8 +160,7 @@ virStorageBackendISCSISession(virStoragePoolObjPtr pool, ...@@ -160,8 +160,7 @@ virStorageBackendISCSISession(virStoragePoolObjPtr pool,
regexes, regexes,
vars, vars,
virStorageBackendISCSIExtractSession, virStorageBackendISCSIExtractSession,
&session, &session) < 0)
NULL) < 0)
return NULL; return NULL;
if (session == NULL && if (session == NULL &&
...@@ -503,7 +502,6 @@ virStorageBackendISCSIScanTargets(const char *portal, ...@@ -503,7 +502,6 @@ virStorageBackendISCSIScanTargets(const char *portal,
}; };
struct virStorageBackendISCSITargetList list; struct virStorageBackendISCSITargetList list;
int i; int i;
int exitstatus;
memset(&list, 0, sizeof(list)); memset(&list, 0, sizeof(list));
...@@ -513,17 +511,7 @@ virStorageBackendISCSIScanTargets(const char *portal, ...@@ -513,17 +511,7 @@ virStorageBackendISCSIScanTargets(const char *portal,
regexes, regexes,
vars, vars,
virStorageBackendISCSIGetTargets, virStorageBackendISCSIGetTargets,
&list, &list) < 0) {
&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);
return -1; return -1;
} }
......
...@@ -205,25 +205,13 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, ...@@ -205,25 +205,13 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
pool->def->source.name, NULL pool->def->source.name, NULL
}; };
int exitstatus;
if (virStorageBackendRunProgRegex(pool, if (virStorageBackendRunProgRegex(pool,
prog, prog,
1, 1,
regexes, regexes,
vars, vars,
virStorageBackendLogicalMakeVol, virStorageBackendLogicalMakeVol,
vol, vol) < 0) {
&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);
return -1; return -1;
} }
...@@ -321,7 +309,6 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -321,7 +309,6 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
}; };
const char *const prog[] = { PVS, "--noheadings", "-o", "pv_name,vg_name", NULL }; const char *const prog[] = { PVS, "--noheadings", "-o", "pv_name,vg_name", NULL };
const char *const scanprog[] = { VGSCAN, NULL }; const char *const scanprog[] = { VGSCAN, NULL };
int exitstatus;
char *retval = NULL; char *retval = NULL;
virStoragePoolSourceList sourceList; virStoragePoolSourceList sourceList;
int i; int i;
...@@ -331,7 +318,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -331,7 +318,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
* that might be hanging around, so if this fails for some reason, the * that might be hanging around, so if this fails for some reason, the
* worst that happens is that scanning doesn't pick everything up * 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"); VIR_WARN("Failure when running vgscan to refresh physical volumes");
} }
...@@ -339,8 +326,8 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -339,8 +326,8 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
sourceList.type = VIR_STORAGE_POOL_LOGICAL; sourceList.type = VIR_STORAGE_POOL_LOGICAL;
if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars, if (virStorageBackendRunProgRegex(NULL, prog, 1, regexes, vars,
virStorageBackendLogicalFindPoolSourcesFunc, virStorageBackendLogicalFindPoolSourcesFunc,
&sourceList, &exitstatus) < 0) &sourceList) < 0)
return NULL; return NULL;
retval = virStoragePoolSourceListFormat(&sourceList); retval = virStoragePoolSourceListFormat(&sourceList);
...@@ -489,7 +476,6 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -489,7 +476,6 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
"--nosuffix", "--options", "vg_size,vg_free", "--nosuffix", "--options", "vg_size,vg_free",
pool->def->source.name, NULL pool->def->source.name, NULL
}; };
int exitstatus;
virFileWaitForDevices(); virFileWaitForDevices();
...@@ -506,13 +492,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -506,13 +492,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
regexes, regexes,
vars, vars,
virStorageBackendLogicalRefreshPoolFunc, virStorageBackendLogicalRefreshPoolFunc,
NULL, NULL) < 0) {
&exitstatus) < 0) {
virStoragePoolObjClearVols(pool);
return -1;
}
if (exitstatus != 0) {
virStoragePoolObjClearVols(pool); virStoragePoolObjClearVols(pool);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册