[libvirt] [PATCH 05/11] Add an API for iterating over disk paths

Daniel Veillard veillard at redhat.com
Thu Jul 15 16:43:50 UTC 2010


On Mon, Jul 12, 2010 at 02:30:42PM +0100, Daniel P. Berrange wrote:
> There is duplicated code which iterates over disk backing stores
> performing some action. Provide a convenient helper for doing
> this to eliminate duplication & risk of mistakes with disk format
> probing
> 
> * src/conf/domain_conf.c, src/conf/domain_conf.h,
>   src/libvirt_private.syms: Add virDomainDiskDefForeachPath()
[...]
> +        if ((fd = open(path, O_RDONLY)) < 0) {

> +        if (virStorageFileGetMetadataFromFD(path, fd, format, &meta) < 0) {
> +            close(fd);
> +            goto cleanup;
> +        }
> +        close(fd);

  stylistic
           ret = f(... fd, )
           close(fd);
           if (ret < 0)
               goto cleanup;

looks simpler to me, but it's a matter of taste :-)

ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list