[libvirt] [RFC 1/5]: Return exitstatus from virStorageBackendRunProgRegex

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. Signed-off-by: Chris Lalancette <clalance@redhat.com>

On Thu, Jun 12, 2008 at 04:09:00PM +0200, Chris Lalancette wrote:
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.
Oh joy :-(
Index: src/storage_backend.c =================================================================== RCS file: /data/cvs/libvirt/src/storage_backend.c,v retrieving revision 1.14 diff -u -r1.14 storage_backend.c --- a/src/storage_backend.c 6 Jun 2008 11:09:57 -0000 1.14 +++ b/src/storage_backend.c 12 Jun 2008 13:19:39 -0000 @@ -352,7 +352,8 @@ const char **regex, int *nvars, virStorageBackendListVolRegexFunc func, - void *data) + void *data, + int *outexit)
Whitespace damage
{ int child = 0, fd = -1, exitstatus, err, failed = 1; FILE *list = NULL; @@ -487,12 +488,8 @@ 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);
More here. Can you check your $HOME/.emacs file has the magic detailed in the HACKING file to preserve whitespace. There's a few more places with problems, but I won't list every single one here. Aside from that, the patch looks reasonable. Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Chris Lalancette
-
Daniel P. Berrange