On Mon, Sep 6, 2021 at 6:59 PM Richard W.M. Jones <rjo...@redhat.com> wrote:
> On Mon, Sep 06, 2021 at 06:45:08PM +0300, Konstantin Kostiuk wrote: > > Hi All, > > > > I reviewed glib, libguestfs, and libosinfo tools. All tools read the > registry > > to get information about Windows but read different registry values. All > > information is returned in a localized form. > > Related key: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion > > We can get 'pretty-name' from 'ProductName' value (all tools use it). > > About 'version' there is three variant: > > 1. Set 'version' equals to 'kernel-version'. libguestfs and libosinfo > have this > > behavior. > > 2. Read 'version' from 'ReleaseId' value. glib has this behavior. In the > case > > of Windows Server 2022, 'ReleaseId' equals 2009. > > 3. Read 'version' from 'DisplayVersion' value. In the case of Windows > Server > > 2022, 'DisplayVersion' equals 21H2. > > The important point is, however you get it, return the information as > a libosinfo short value ("win2k22" in this case). > To get this string libguestfs just use a set of conditions. Return "win2k22" if Windows type is 'server' and ProductName contains 2022. But as I know guest agent does not returns short name. > > > What do you think about this solution instead of using a conversion > matrix? > > What version we should use in this case? > > If you need to cover old and new versions of Windows then there's no > good way. You just need lots of conditionals and to constantly evolve > the code as new versions come out. > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > Fedora Windows cross-compiler. Compile Windows programs, test, and > build Windows installers. Over 100 libraries supported. > http://fedoraproject.org/wiki/MinGW > >