On Wed, Jul 20, 2022 at 01:36:25PM -0400, dzrudy(a)gmail.com wrote:
On Wed, 2022-07-20 at 12:45 +0100, Richard W.M. Jones wrote:
> How about this instead?
>
> It actually changes the behaviour slightly. Currently a
> /etc/hostname
> which contains the single character '\n' would return
> inspect_get_hostname = "" (which seems wrong). This is the default
> /etc/hostname for virt-builder images.
>
> I think this is because in the current code, read_small_file actually
> returns “Some [""; ""]”, so it takes the branch where it
matches
> “| Some (hostname :: _)” which returns empty string.
>
> Anyway, after this patch it returns "unknown" which is documented as
> "the hostname could not be determined", which I think is more correct
> behaviour. I tested it also on files with blank lines and comments
> and so on, and it seems to do what is necessary, although it could do
> with a proper regression test.
>
> Rich.
>
Works great for me and looks much more elegant that what I came up
with.
Thanks - this is upstream commit 4a517601c752955e35b472ea127cb4b7330a6136
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v