[Ovirt-devel] [RFC][PATCH v2] edit-livecd : fail on error in arbitrary code
abhishek misra
fishy at linux.vnet.ibm.com
Fri Nov 13 08:36:03 UTC 2009
Hello All,
Below are David's comments on my last patch
David Huff wrote:
> I took a look at this today, I am not sure that a requirement for 'CODE'
> to touch a "fail" file is the best way to address this.
>
> I assume your script is mounting proc inside the ext filesystem, ie to
> use yum or something. And using trap and a similar mnt function, like
> what is in edit-livecd, is not cleaning up all the mounts in this case?
>
> A fix may be to use /proc/mounts instead of df when adding the Exits in
> the mnt function.
>
> Also can you clarify the statement, "note that it may not always be
> possible to return some error code on failure in 'CODE'" I am not really
> sure what you mean here.
>
> Does this make sense?
>
> -D
>
David, you were right about proc , I've now taken care of that in my 'CODE'
Here is another patch that tries to achieve the same without using
'touch fail'
1. removed compound statement ( list )
I found that its usage does not prevent trap to come into action if
$CODE fails (which is desired )
but allows commands after (list) to continue executing ( which is
not desired )
2 added addExit "cd -"
when $CODE fails and control returns to edit-livecd script, it is
still in $WDIR/ex
this causes failure when trap attempts umount
3 added EXIT=${EXIT/cd - ;/}
we no longer need it if $CODE goes well
4 added cd -
we need it as we removed (list)
5 removed set +/- e
Signed-off-by: Abhishek Misra <fishy at linux.vnet.ibm.com
---
--- a/edit-livecd 2009-11-10 17:23:21.000000000 +0530
+++ b/edit-livecd 2009-11-13 14:03:50.000000000 +0530
@@ -161,12 +161,11 @@ mnt "-t ext2 $WDIR/sq-w/LiveOS/ext3fs.im
echo ">>> Updating CD content"
if [ -n "$CODE" ]; then
- (
cd $WDIR/ex
- set +e
+ addExit "cd -"
eval "$CODE"
- set -e
- )
+ EXIT=${EXIT/cd - ;/}
+ cd -
else
echo "***"
echo "*** Pausing to allow manual changes. Press any key to continue."
More information about the ovirt-devel
mailing list