In terms of turning what Vadim wrote into code ...
First of all you will need to obtain the Windows kernel version by reading the following Registry key - "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion". Let's say it 6.3, which means that it is Win8.1 or WS2012R2,
We already access this field in the registry and present it through inspection, so: http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_major_version In virt-v2v this is present in the Types.inspect.i_major_version and Types.inspect.i_minor_version fields.
parsing "BuildLabEx" string from the same hive will give you information about the platform bitness.
Currently we can determine the bitness of a Windows VM by examining some of the binaries found in %systemroot%. We present this through inspection: http://libguestfs.org/guestfs.3.html#guestfs_inspect_get_arch (either "i386" or "x86-64") and this is present in virt-v2v in the Types.inspect.i_arch field. I looked at BuildLabEx, which is a field we've not looked at before.
From Windows 7:
"BuildLabEx"="7601.18247.amd64fre.win7sp1_gdr.130828-1532" Apparently the first four numbers are the build number, next five are the revision number, and after that is either ".amd64" or ".x86" (for x86-64 or i386 respectively).
Next you need to go through inf files, and find "DriverVer" string, like this one . taken from from vioscsi.inf
DriverVer=08/01/2015,62.72.104.10800
This string contains build time and version stamps. The version stamp looks as follow "62.72.104.10800" where 62 means a target Windows kernel version multiplied by 10. In this case it is 6.2 which means Win8 or WS2012 72 - the target host platform version multiplied bu 10 (was RHEL7.2) 104 just a magic number, but it can be changed, don't make any assumption based on this number. 10800 our internal build number (build 108) multiplied by 100 If you found an inf file with the matching minor OS (6 in our case) version and matching or less but close minor version number (2 vs 3) then you are in the right directory.
This should be easy enough to parse out. 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