This patch changes things around so that virStorageBackendRunProgRegex() does
*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.
Changes since last time:
1) Fix up whitespace damage
Signed-off-by: Chris Lalancette [EMAIL PROTECTED]
diff -urp libvirt.orig/src/storage_backend.c libvirt.runprogregex/src/storage_backend.c
--- libvirt.orig/src/storage_backend.c 2008-06-06 13:09:57.0 +0200
+++ libvirt.runprogregex/src/storage_backend.c 2008-06-16 14:22:12.0 +0200
@@ -352,7 +352,8 @@ virStorageBackendRunProgRegex(virConnect
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;
@@ -487,12 +488,8 @@ virStorageBackendRunProgRegex(virConnect
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));
diff -urp libvirt.orig/src/storage_backend.h libvirt.runprogregex/src/storage_backend.h
--- libvirt.orig/src/storage_backend.h 2008-04-10 18:53:29.0 +0200
+++ libvirt.runprogregex/src/storage_backend.h 2008-06-16 14:22:46.0 +0200
@@ -133,7 +133,8 @@ int virStorageBackendRunProgRegex(virCon
const char **regex,
int *nvars,
virStorageBackendListVolRegexFunc func,
- void *data);
+ void *data,
+ int *exitstatus);
int virStorageBackendRunProgNul(virConnectPtr conn,
virStoragePoolObjPtr pool,
diff -urp libvirt.orig/src/storage_backend_iscsi.c libvirt.runprogregex/src/storage_backend_iscsi.c
--- libvirt.orig/src/storage_backend_iscsi.c 2008-06-06 13:09:57.0 +0200
+++ libvirt.runprogregex/src/storage_backend_iscsi.c 2008-06-16 14:24:40.0 +0200
@@ -124,13 +124,18 @@ virStorageBackendISCSISession(virConnect
};
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) {
@@ -373,7 +378,7 @@ virStorageBackendISCSIFindLUNs(virConnec
regexes,
vars,
virStorageBackendISCSIMakeLUN,
- (void *)session);
+ (void *)session, NULL);
}
diff -urp libvirt.orig/src/storage_backend_logical.c libvirt.runprogregex/src/storage_backend_logical.c
--- libvirt.orig/src/storage_backend_logical.c 2008-06-06 13:09:57.0 +0200
+++ libvirt.runprogregex/src/storage_backend_logical.c 2008-06-16 14:26:09.0 +0200
@@ -214,14 +214,30 @@ virStorageBackendLogicalFindLVs(virConne
pool-def-name, NULL
};
-return virStorageBackendRunProgRegex(conn,
- pool,
- prog,
- 1,
- regexes,
- vars,
- virStorageBackendLogicalMakeVol,
- vol);
+int exitstatus;
+
+if