[libvirt] [PATCH] Fix reporting of i/o errors by iohelper process

Eric Blake eblake at redhat.com
Wed Jul 16 14:30:24 UTC 2014


On 07/16/2014 08:12 AM, Jason J. Herne wrote:
> From: "Jason J. Herne" <jjherne at us.ibm.com>
> 
> libvirt_iohelper is a helper process that is exec'ed and used to handle I/O
> during a Qemu managed save operation. Due to a missing call to
> virFileWrapperFdClose, all I/O error messages reported by iohelper are lost.
> 
> This patch adds a call to virFileWrapperFdClose to the cleanup phase of
> qemuDomainSaveMemory.
> 
> This patch also modifies virFileWrapperFdClose such that errors are only
> reported when the length of the err_msg buffer is > 0. Before now, the
> existence of the buffer would trigger error reporting in virFileWrapperFdClose.
> 
> Signed-off-by: Jason J. Herne <jjherne at us.ibm.com>
> ---
>  src/qemu/qemu_driver.c | 1 +
>  src/util/virfile.c     | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)

Nice! Thanks for persevering on this one.  Congrats on your first
libvirt patch.

> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index ecccf6c..8d78805 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3015,6 +3015,7 @@ qemuDomainSaveMemory(virQEMUDriverPtr driver,
>  
>   cleanup:
>      VIR_FORCE_CLOSE(fd);
> +    virFileWrapperFdClose(wrapperFd);
>      virFileWrapperFdFree(wrapperFd);
>      VIR_FREE(xml);
>  
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index 463064c..813b4f5 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -322,7 +322,7 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
>          return 0;
>  
>      ret = virCommandWait(wfd->cmd, NULL);
> -    if (wfd->err_msg)
> +    if (wfd->err_msg && strlen(wfd->err_msg))

Micro-optimization: more efficient when written:

if (wfd->err_msg && *wfd->err_msg)

since then you don't have to waste time of crawling the entire string.

ACK based on looking at the code, and I'll push with that modification
once I've also tested it (or reply again if something turns up).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140716/b6e28326/attachment-0001.sig>


More information about the libvir-list mailing list