[libvirt] [PATCH 05/12] storage: On error unlink created file in virFileOpen{As|Forked}

Peter Krempa pkrempa at redhat.com
Tue Oct 13 12:27:36 UTC 2015


On Fri, Oct 09, 2015 at 09:34:04 -0400, John Ferlan wrote:
> After a successful creation of a file, if some other call results
> in returning a failure, let's unlink the file we created to prevent
> another round trip or confusion in the caller. In particular, this
> function can be called during a storage backend buildVol, so in order
> to ensure that caller doesn't need to distinguish between failed create
> or some other failure after create, just remove the volume we created.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/util/virfile.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index a81f04c..51198e2 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c

...

> @@ -2069,6 +2069,7 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
> @@ -2225,6 +2231,7 @@ virFileOpenAs(const char *path, int openflags, mode_t mode,

Both of the modified functions have comments explaining them, but this
patch doesn't modify them.

Code looks definitely cleaner though.

ACK if you explain the change in the function headers.

Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151013/c4c431ff/attachment-0001.sig>


More information about the libvir-list mailing list