On 5/7/19 1:36 PM, Max Reitz wrote:
> qemu_nbd_pipe() currently unconditionally reads qemu-nbd's output.  That
> is not ideal because qemu-nbd may keep stderr open after the parent
> process has exited.
> 
> Currently, the only user of qemu_nbd_pipe() is 147, which discards the
> whole output if the parent process returned success and only evaluates
> it on error.  Therefore, we can replace qemu_nbd_pipe() by
> qemu_nbd_early_pipe() that does the same: Discard the output on success,
> and return it on error.
> 
> Signed-off-by: Max Reitz <[email protected]>
> ---
>  tests/qemu-iotests/147        | 4 ++--
>  tests/qemu-iotests/iotests.py | 9 ++++++---
>  2 files changed, 8 insertions(+), 5 deletions(-)
> 

> @@ -216,7 +216,10 @@ def qemu_nbd_pipe(*args):
>          sys.stderr.write('qemu-nbd received signal %i: %s\n' %
>                           (-exitcode,
>                            ' '.join(qemu_nbd_args + ['--fork'] + list(args))))
> -    return exitcode, subp.communicate()[0]
> +    if exitcode == 0:
> +        return exitcode, ''
> +    else:
> +        return exitcode, subp.communicate()[0]
>  

Reviewed-by: Eric Blake <[email protected]>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to