[libvirt PATCH v5 26/32] qemu: try to connect to nbdkit early to detect errors
Peter Krempa
pkrempa at redhat.com
Thu Feb 16 16:30:25 UTC 2023
On Tue, Feb 14, 2023 at 11:08:13 -0600, Jonathon Jongsma wrote:
> When using nbdkit to serve a network disk source, the nbdkit process
> will start and wait for an nbd connection before actually attempting to
> connect to the (remote) disk location. Because of this, nbdkit will not
> report an error until after qemu is launched and tries to read from the
> disk. This results in a fairly user-unfriendly error saying that qemu
> was unable to start because "Requested export not available".
>
> Ideally we'd like to be able to tell the user *why* the export is not
> available, but this sort of information is only available to nbdkit, not
> qemu. It could be because the url was incorrect, or because of an
> authentication failure, or one of many other possibilities.
>
> To make this friendlier for users and easier to detect
> misconfigurations, try to connect to nbdkit immediately after starting
> nbdkit and before we try to start qemu. This requires adding a
> dependency on libnbd. If an error occurs when connecting to nbdkit, read
> back from the nbdkit error log and provide that information in the error
> report from qemuNbdkitProcessStart().
>
> User-visible change demonstrated below:
> Previous error:
>
> $ virsh start nbdkit-test
> 2023-01-18 19:47:45.778+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
> error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
> qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
> "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
> "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
> available
> error: Failed to start domain 'nbdkit-test'
> error: internal error: process exited while connecting to monitor: 2023-01-18T19:47:45.704658Z
> qemu-system-x86_64: -blockdev {"driver":"nbd","server":{"type":"unix",
> "path":"/var/lib/libvirt/qemu/domain-1-nbdkit-test/nbdkit-libvirt-1-storage.socket"},
> "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}: Requested export not
> available
>
> After this change:
>
> $ virsh start nbdkit-test
> 2023-01-18 19:44:36.242+0000: 30895: error : virNetClientProgramDispatchError:172 : internal
> error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso': nbdkit: curl[1]:
> error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
> HTTP response code said error: The requested URL returned error: 404
> error: Failed to start domain 'nbdkit-test'
> error: internal error: Failed to connect to nbdkit for 'http://localhost:8888/nonexistent.iso]:
> error: problem doing HEAD request to fetch size of URL [http://localhost:8888/nonexistent.iso]:
> HTTP response code said error: The requested URL returned error: 404
>
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
> meson.build | 7 +++++++
> meson_options.txt | 1 +
> src/qemu/meson.build | 1 +
> src/qemu/qemu_nbdkit.c | 24 ++++++++++++++++++++++++
> 4 files changed, 33 insertions(+)
Reviewed-by: Peter Krempa <pkrempa at redhat.com>
More information about the libvir-list
mailing list