Virus Scan all Hosted Disk
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:
- Write an application including both the Virtual Disk API and the VIX API.
- Initialize the virtual disk library withVixDiskLib_Init().
- Connect VIX to the Workstation host withVixHost_Connect().
- CallVixHost_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 theVixDiscoveryProc()callback function shown as an example on theVixHost_FindItems()page in theVIX API Reference Guide.
- Instead of printing “Found virtual machine” in the callback function, call theDoVirusScan()function shown in Scan VMDK for Virus Signatures.
- Decontaminate any infected sectors that the virus scanner located.