[libvirt PATCH v5 15/32] qemu: log error output from nbdkit

Peter Krempa pkrempa at redhat.com
Thu Feb 16 15:01:31 UTC 2023


On Tue, Feb 14, 2023 at 11:08:02 -0600, Jonathon Jongsma wrote:
> log stderr and stdout from nbdkit into its own log so that
> nbdkit-related issues can be debugged more easily.
> 
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
>  src/qemu/qemu_nbdkit.c | 30 +++++++++++++++++++++++++-----
>  1 file changed, 25 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_nbdkit.c b/src/qemu/qemu_nbdkit.c
> index 5abccf1536..f2ff9552a3 100644
> --- a/src/qemu/qemu_nbdkit.c
> +++ b/src/qemu/qemu_nbdkit.c

[...]

> @@ -902,9 +915,16 @@ qemuNbdkitProcessStart(qemuNbdkitProcess *proc,
>      return 0;
>  
>   error:
> -    if (errbuf)
> -        virReportError(VIR_ERR_OPERATION_FAILED,
> -                       _("nbdkit failed to start and reported: %s"), errbuf);
> +    if (qemuLogContextReadFiltered(logContext, &errmsg, 1024) < 0)
> +        VIR_WARN("Unable to read from nbdkit log");
> +
> +    if ((uri = qemuBlockStorageSourceGetURI(proc->source)))
> +        uristring = virURIFormat(uri);
> +
> +    virReportError(VIR_ERR_INTERNAL_ERROR,

VIR_ERR_INTERNAL_ERROR is not appropriate for message which in most
cases involves user missconfig e.g:

  error: internal error: Failed to connect to nbdkit for 'http://storage.example.com:10809/ppc64dev': nbdkit: curl[1]: error: problem doing HEAD request to fetch size of URL [http://storage.example.com:10809/ppc64dev]: Couldn't resolve host name: Could not resolve host: storage.example.com

IMO 'VIR_ERR_OPERATION_FAILED' will be better. It says "operation
failed"


> +                   _("Failed to connect to nbdkit for '%s': %s"),
> +                   NULLSTR(uristring), NULLSTR(errmsg));
> +

Reviewed-by: Peter Krempa <pkrempa at redhat.com>


More information about the libvir-list mailing list