[Libosinfo] [osinfo-db/libosinfo PATCH 0/6] Add support to images

Richard W.M. Jones rjones at redhat.com
Thu Nov 1 11:23:36 UTC 2018


On Thu, Nov 01, 2018 at 11:12:45AM +0000, Daniel P. Berrangé wrote:
> On Thu, Nov 01, 2018 at 11:06:11AM +0000, Richard W.M. Jones wrote:
> > On Thu, Nov 01, 2018 at 10:09:03AM +0000, Daniel P. Berrangé wrote:
> > > ie essentially encode the file content probing rules that libguestfs
> > > has, as osinfo DB information, so that it becomes user extendable in
> > > the normal way we do for ISO/install tree. Admittedly the image probing
> > > rules are significantly more complicated than ISO/install tree probiing
> > > rules, but I think it is doable if we wanted to. It ultimately just
> > > comes down to a (very large) set of file content matches.
> > 
> > It's rather more complicated than that.  It's definitely not true to
> > say that libguestfs is just doing some regexps over files.
> 
> I've not looked at all the OS match rules libguestfs has, but for the
> Linux matches, it looks like just file existance/content matches
> 
> I'm looking at "check_filesystem" which has a bunch of logic like:
> 
>   (* Minix root? *)
>   else if Is.is_dir "/etc" &&
>           Is.is_dir "/bin" &&
>           Is.is_file "/service/vm" &&
>           Is.is_file "/etc/fstab" &&
>           Is.is_file "/etc/version" then (
>     debug_matching "Minix root";
>     role := `Root;
>     Inspect_fs_unix.check_minix_root data;
>   )
>   (* Linux root? *)
>   else if Is.is_dir "/etc" &&
>           (Is.is_dir "/bin" ||
>            is_symlink_to "/bin" "usr/bin") &&
>           (Is.is_file "/etc/fstab" ||
>            Is.is_file "/etc/hosts") then (
>     debug_matching "Linux root";
>     role := `Root;
>     Inspect_fs_unix.check_linux_root mountable data;
>   )
>   (* CoreOS root? *)
>   else if Is.is_dir "/etc" &&
>           Is.is_dir "/root" &&
>           Is.is_dir "/home" &&
>           Is.is_dir "/usr" &&
>           Is.is_file "/etc/coreos/update.conf" then (
>     debug_matching "CoreOS root";
>     role := `Root;
>     Inspect_fs_unix.check_coreos_root mountable data;
>   )
> 
> And then looking at check_linux_root just iterates over the
> filename content regex matches defined in linux_root_tests.

This is to ignore the ordering in which operations take place, the
integration of the data structures derived from various filesystems
into a single data structure, and numerous tweaks that we've applied
over the years because the source data is really dirty.  The code
above is fairly simple, but the code in this file is not at all:

https://github.com/libguestfs/libguestfs/blob/master/daemon/inspect_fs_unix.ml

I guess we want to identify Windows too, and that code looks deep into
the Windows Registry.

Anyway I originally wanted to use Facter when rewriting it in 1.38,
but IIRC Facter was at that time written in Ruby so couldn't go into
the appliance (plus it didn't have all the features required).  I
think it's now rewritten in something else (C++?) but parts of it
still seem to be in Ruby.

I think we should tell people to use Facter for the "running in guest"
case.  It does what they want and is likely to be better and simpler
than any mess of regular expressions we can come up with.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libosinfo mailing list