Suppose you want to run the antivirus software presented in Scan VMDK for Virus Signatures for all virtual machines hosted on a VMware Workstation. Here is the high-level algorithm for an VIX-based application that would scan hosted disk on all virtual machines.
To virus scan hosted virtual disk:
Procedure
- Write an application including both the Virtual Disk API and the VIX API.
- Initialize the virtual disk library with VixDiskLib_Init().
- Connect VIX to the Workstation host with VixHost_Connect().
- Call VixHost_FindItems() with item-type (second argument) VIX_FIND_RUNNING_VMS.
This provides to a callback routine (fifth argument) the name of each virtual machine, one at a time. To derive the name of each virtual machine’s disk, append “.vmdk” to the virtual machine name.
- Write a callback function to open the virtual machine’s VMDK.
Your callback function must be similar to the VixDiscoveryProc() callback function shown as an example on the VixHost_FindItems() page in the VIX API Reference Guide.
- Instead of printing “Found virtual machine” in the callback function, call the DoVirusScan() function shown in Scan VMDK for Virus Signatures.
- Decontaminate any infected sectors that the virus scanner located.