Hello everyone!!!
I'm looking for a way to find the guest operating system type using vix api. I saw that was possible using VI but didn't experiment it yet... If I don't find a "clean" way to get it done, I think I'm going to pass it through a vm property:
vmware-guestd --cmd "info-set guestinfo.guestos linux"
for instance, running such a little script within my virtual machine as a daemon, but I don't really like that...
Could somebody help me?
The easiest way to get access to properties of a virtual machine is the Vix_GetProperties() method. It takes a VM handle and a list of properties that you are looking for. I have always gone straight to the vix.h file to get my list of available properties such as you are trying to do here. This is a list straight from the vix.h file with all available properties for a VM. The bad news is that guest OS is not one of them. You may be able to get the VIX_PROPERTY_VM_SUPPORTED_FEATURES property and program some switch/case block to parse through it and guess the OS, but I do not really know what that property returns.
/* VIX_HANDLETYPE_VM properties */
VIX_PROPERTY_VM_NUM_VCPUS = 101,
VIX_PROPERTY_VM_VMX_PATHNAME = 103,
VIX_PROPERTY_VM_VMTEAM_PATHNAME = 105,
VIX_PROPERTY_VM_MEMORY_SIZE = 106,
VIX_PROPERTY_VM_READ_ONLY = 107,
VIX_PROPERTY_VM_IN_VMTEAM = 128,
VIX_PROPERTY_VM_POWER_STATE = 129,
VIX_PROPERTY_VM_TOOLS_STATE = 152,
VIX_PROPERTY_VM_IS_RUNNING = 196,
VIX_PROPERTY_VM_SUPPORTED_FEATURES = 197,
VIX_PROPERTY_VM_IS_RECORDING = 236,
VIX_PROPERTY_VM_IS_REPLAYING = 237,
You can read any variable from the VM's config file (the .vmx file) using the VixVM_ReadVariable function. One of them is "guestOS".
However, I'm not sure if the result returned is 100% reliable, the value it contains is the one set when creating the VM. So you can create a new VM and set is OS to "Windows XP Home Edition" but then install a XP Professional.
Here's an example code:
char *readValue = NULL;
jobHandle = char *readValue = NULL;
jobHandle = VixVM_ReadVariable(vmHandle,
VIX_VM_CONFIG_RUNTIME_ONLY,
"guestOS",
0, // options
NULL, // callbackProc
NULL); // clientData);
err = VixJob_Wait(jobHandle,
VIX_PROPERTY_JOB_RESULT_VM_VARIABLE_STRING,
&readValue,
VIX_PROPERTY_NONE);
Vix_ReleaseHandle(vmHandle)
if (VIX_OK != err) {
// Handle the error...
}
And here there's a list of possible values:
Windows 3.1 = win31
Windows 95 = win95
Windows 98 = win98
Windows Me = winme
Windows NT = winnt
Windows 2000 Professional = win2000pro
Windows 2000 Server = win2000serv
Windows 2000 Advanced Server = win2000advserv
Windows XP Home Edition = winxphome
Windows XP Professional = winxppro
Windows XP Professional x64 Edition = winxppro-64
Windows Vista = winvista
Windows Vista x64 Edition = winvista-64
Windows Server 2003 Web Edition = winnetweb
Windows Server 2003 Standard Edition = winnetstandard
Windows Server 2003 Enterprise Edition = winnetenterprise
Windows Server 2003 Small Business = winnetbusiness
Windows Server 2003 Standard x64 Edition = winnetstandard-64
Windows Server 2003 Enterprise x64 Edition = winnetenterprise-64
Windows Server 2008 = longhorn
Windows Server 2008 x64 Edition = longhorn-64
Red Hat Linux = redhat
Red Hat Enterprise Linux 2 = rhel2
Red Hat Enterprise Linux 3 = rhel3
Red Hat Enterprise Linux 3 64-bit = rhel3-64
Red Hat Enterprise Linux 4 = rhel4
Red Hat Enterprise Linux 4 64-bit = rhel4-64
Red Hat Enterprise Linux 5 = rhel5
Red Hat Enterprise Linux 5 64-bit = rhel5-64
Asianux 3 = asianux3
Asianux 3 64-bit = asianux3-64
SUSE Linux = suse
SUSE Linux 64-bit = suse-64
SUSE Linux Enterprise Server = sles
SUSE Linux Enterprise Server 64-bit = sles-64
SUSE Linux Enterprise Server 10 = sles10
SUSE Linux Enterprise Server 10 64-bit = sles10-64
Novell Linux Desktop 9 = nld9
Sun Java Desktop System = sjds
Mandrake Linux = mandrake
Mandriva Linux = mandriva
Mandriva Linux 64-bit = mandriva-64
Turbolinux = turbolinux
Turbolinux 64-bit = turbolinux-64
Ubuntu = ubuntu
Ubuntu 64-bit = ubuntu-64
Other Linux 2.2.x kernel = otherlinux
Other Linux 2.4.x kernel = other24xlinux
Other Linux 2.4.x kernel 64-bit = other24xlinux-64
Other Linux 2.6.x kernel = other26xlinux
Other Linux 2.6.x kernel 64-bit = other26xlinux-64
Other Linux 64-bit = otherlinux-64
NetWare 5 = netware5
NetWare 6 = netware6
Solaris 8 (experimental) = solaris8
Solaris 9 (experimental) = solaris9
Solaris 10 = solaris10
Solaris 10 64-bit = solaris10-64
MS-DOS = dos
FreeBSD = freebsd
FreeBSD 64-bit = freebsd-64
Other = other
Other 64-bit = other-64