Task 782: .VMX File Format

Task 782: .VMX File Format

1. List of Properties for the .VMX File Format

The .VMX file format is a plain text configuration file used by VMware virtual machines. It is not a binary format but consists of key-value pairs, typically in the form key = "value" or key = value (with or without quotes for strings). Comments are supported with lines starting with #, and empty lines are ignored. The format is intrinsic to the file system as a standard text file (UTF-8 or ASCII encoding), with no fixed structure beyond the key-value syntax. Properties represent virtual machine configuration settings, such as hardware specifications, device mappings, and runtime behaviors.

Based on official VMware documentation, knowledge base articles, and comprehensive parameter lists from reliable sources (e.g., Broadcom TechDocs, sanbarrow.com, and community-compiled collections of over 1,200 documented and undocumented parameters), the properties include a vast array of keys. Not all are required; many are optional or version-specific. For completeness, the following is a categorized list of key properties extracted from these sources. This represents the intrinsic properties of the format, as they define the VM's configuration. Due to the extensive number, I have categorized them and provided examples with brief descriptions where applicable. Common properties are highlighted first.

Common Properties (Frequently Used in Standard Configurations)

  • config.version: Specifies the configuration file format version (e.g., "8").
  • virtualHW.version: Indicates the virtual hardware version (e.g., "7" for compatibility).
  • displayName: The display name of the virtual machine.
  • memsize: Memory allocated to the VM in MB (must be a multiple of 4).
  • numvcpus: Number of virtual CPUs.
  • guestOS: Guest operating system type (e.g., "windows9-64").
  • scsi0.present: Enables the SCSI controller (TRUE/FALSE).
  • scsi0:0.present: Enables a specific SCSI disk (TRUE/FALSE).
  • scsi0:0.fileName: Path to the virtual disk file (e.g., ".vmdk").
  • ide0.present: Enables the IDE controller (TRUE/FALSE).
  • ide0:0.present: Enables a specific IDE device (TRUE/FALSE).
  • ide0:0.fileName: Path to the IDE device file.
  • ethernet0.present: Enables the first network adapter (TRUE/FALSE).
  • ethernet0.connectionType: Network type (e.g., "bridged").
  • ethernet0.addressType: MAC address generation method (e.g., "generated").
  • ethernet0.virtualDev: Network device type (e.g., "e1000").
  • floppy0.present: Enables floppy drive (TRUE/FALSE).
  • sound.present: Enables sound card (TRUE/FALSE).
  • usb.present: Enables USB controller (TRUE/FALSE).
  • uuid.bios: BIOS UUID (autogenerated).
  • uuid.location: Location UUID (autogenerated).
  • extendedConfigFile: Path to extended configuration (e.g., ".vmxf").
  • bios.bootDelay: Boot delay in milliseconds.
  • bios.bootOrder: Boot device order (e.g., "hdd,cdrom").
  • bios.bootRetry.enabled: Enables boot retry (TRUE/FALSE).
  • bios.forceSetupOnce: Forces BIOS setup on next boot (TRUE/FALSE).

Disk and Storage Properties

  • disk.EnableUUID: Enables disk UUID (TRUE/FALSE).
  • diskLib.dataCacheMaxSize: Maximum disk data cache size.
  • diskLib.sparse.maxChangesBeforeFlush: Maximum changes before flushing sparse disk.
  • scsi0:0.deviceType: Device type for SCSI (e.g., "scsi-hardDisk").
  • ide0:0.deviceType: Device type for IDE (e.g., "cdrom-image").

Network (Ethernet) Properties

  • ethernet0.generatedAddress: Autogenerated MAC address.
  • ethernet0.startConnected: Starts network connected (TRUE/FALSE).
  • ethernet0.wakeOnPcktRcv: Wake on packet receive (TRUE/FALSE).

Memory and Performance Properties

  • mainMem.useNamedFile: Uses named file for memory backing (TRUE/FALSE).
  • priority.grabbed: CPU priority when input grabbed (e.g., "normal").
  • priority.ungrabbed: CPU priority when input ungrabbed (e.g., "idle").

Isolation and Security Properties

  • isolation.tools.copy.disable: Disables copy operations (TRUE/FALSE).
  • isolation.tools.dnd.disable: Disables drag-and-drop (TRUE/FALSE).
  • isolation.tools.paste.disable: Disables paste operations (TRUE/FALSE).

Checkpoint and Snapshot Properties

  • checkpoint.vmState: Path to VM state file.
  • checkpoint.compressLevel: Compression level for checkpoints.

Graphics and Display Properties (SVGA/MKS)

  • svga.maxWidth: Maximum display width.
  • svga.maxHeight: Maximum display height.
  • svga.vramSize: VRAM size in bytes.
  • mks.enable3d: Enables 3D acceleration (TRUE/FALSE).

Other Advanced/Undocumented Properties (Partial List from Extensive Collections)

  • cpuid.coresPerSocket: Cores per socket in CPUID.
  • floppy0.fileName: Path to floppy image.
  • sound.fileName: Sound device file.
  • usb:0.present: Specific USB device presence.
  • vmotion.checkpointFBSize: Framebuffer size for vMotion.
  • workingDir: Working directory for the VM.
  • RemoteDisplay.vnc.enabled: Enables VNC (TRUE/FALSE).
  • RemoteDisplay.vnc.port: VNC port number.
  • For a more exhaustive list exceeding 1,200 parameters (including undocumented ones like aiomgr.numThreads, cbtmotion.maxIters, and ethernet0.filter0.name), refer to specialized resources such as VMware KB articles or community archives, as the format allows arbitrary keys for extensibility.

These properties are "intrinsic" in that they define the VM's interaction with the host file system (e.g., file paths for disks, memory backing files) and are parsed directly from the text file.

3. Ghost Blog Embedded HTML JavaScript for Drag-and-Drop .VMX File Dump

The following is a self-contained HTML page with embedded JavaScript that can be embedded in a Ghost blog post (or any HTML-enabled platform). It allows users to drag and drop a .VMX file, parses the key-value pairs (ignoring comments and empty lines), and dumps the properties to the screen.

VMX File Parser
Drag and drop a .VMX file here

4. Python Class for .VMX File Handling

import os

class VMXHandler:
    def __init__(self, filepath):
        self.filepath = filepath
        self.properties = {}

    def read(self):
        if not os.path.exists(self.filepath):
            raise FileNotFoundError(f"File {self.filepath} not found.")
        with open(self.filepath, 'r', encoding='utf-8') as f:
            for line in f:
                line = line.strip()
                if not line or line.startswith('#'):
                    continue
                try:
                    key, value = line.split('=', 1)
                    key = key.strip()
                    value = value.strip().strip('"\'')
                    self.properties[key] = value
                except ValueError:
                    pass  # Ignore malformed lines

    def print_properties(self):
        for key, value in self.properties.items():
            print(f"{key}: {value}")

    def write(self, new_properties=None):
        if new_properties:
            self.properties.update(new_properties)
        with open(self.filepath, 'w', encoding='utf-8') as f:
            for key, value in self.properties.items():
                f.write(f'{key} = "{value}"\n')

# Example usage:
# handler = VMXHandler('example.vmx')
# handler.read()
# handler.print_properties()
# handler.write({'new_key': 'new_value'})

5. Java Class for .VMX File Handling

import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class VMXHandler {
    private String filepath;
    private Map<String, String> properties = new HashMap<>();

    public VMXHandler(String filepath) {
        this.filepath = filepath;
    }

    public void read() throws IOException {
        File file = new File(filepath);
        if (!file.exists()) {
            throw new FileNotFoundException("File " + filepath + " not found.");
        }
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.isEmpty() || line.startsWith("#")) {
                    continue;
                }
                String[] parts = line.split("=", 2);
                if (parts.length == 2) {
                    String key = parts[0].trim();
                    String value = parts[1].trim().replaceAll("^[\"']|[\"']$", "");
                    properties.put(key, value);
                }
            }
        }
    }

    public void printProperties() {
        for (Map.Entry<String, String> entry : properties.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }

    public void write(Map<String, String> newProperties) throws IOException {
        if (newProperties != null) {
            properties.putAll(newProperties);
        }
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filepath))) {
            for (Map.Entry<String, String> entry : properties.entrySet()) {
                writer.write(entry.getKey() + " = \"" + entry.getValue() + "\"\n");
            }
        }
    }

    // Example usage:
    // public static void main(String[] args) throws IOException {
    //     VMXHandler handler = new VMXHandler("example.vmx");
    //     handler.read();
    //     handler.printProperties();
    //     Map<String, String> updates = new HashMap<>();
    //     updates.put("new_key", "new_value");
    //     handler.write(updates);
    // }
}

6. JavaScript Class for .VMX File Handling (Node.js)

const fs = require('fs');

class VMXHandler {
    constructor(filepath) {
        this.filepath = filepath;
        this.properties = {};
    }

    read() {
        if (!fs.existsSync(this.filepath)) {
            throw new Error(`File ${this.filepath} not found.`);
        }
        const content = fs.readFileSync(this.filepath, 'utf-8');
        const lines = content.split('\n');
        lines.forEach(line => {
            line = line.trim();
            if (!line || line.startsWith('#')) return;
            const parts = line.split('=');
            if (parts.length >= 2) {
                const key = parts[0].trim();
                const value = parts.slice(1).join('=').trim().replace(/^["']|["']$/g, '');
                this.properties[key] = value;
            }
        });
    }

    printProperties() {
        for (const [key, value] of Object.entries(this.properties)) {
            console.log(`${key}: ${value}`);
        }
    }

    write(newProperties = {}) {
        Object.assign(this.properties, newProperties);
        let output = '';
        for (const [key, value] of Object.entries(this.properties)) {
            output += `${key} = "${value}"\n`;
        }
        fs.writeFileSync(this.filepath, output, 'utf-8');
    }
}

// Example usage:
// const handler = new VMXHandler('example.vmx');
// handler.read();
// handler.printProperties();
// handler.write({ new_key: 'new_value' });

7. C++ Class for .VMX File Handling

#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <algorithm>

class VMXHandler {
private:
    std::string filepath;
    std::map<std::string, std::string> properties;

public:
    VMXHandler(const std::string& fp) : filepath(fp) {}

    void read() {
        std::ifstream file(filepath);
        if (!file.is_open()) {
            throw std::runtime_error("File " + filepath + " not found.");
        }
        std::string line;
        while (std::getline(file, line)) {
            line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end()); // Trim
            if (line.empty() || line[0] == '#') continue;
            size_t pos = line.find('=');
            if (pos != std::string::npos) {
                std::string key = line.substr(0, pos);
                std::string value = line.substr(pos + 1);
                // Strip quotes
                if (!value.empty() && (value[0] == '"' || value[0] == '\'')) value.erase(0, 1);
                if (!value.empty() && (value.back() == '"' || value.back() == '\'')) value.pop_back();
                properties[key] = value;
            }
        }
        file.close();
    }

    void printProperties() const {
        for (const auto& pair : properties) {
            std::cout << pair.first << ": " << pair.second << std::endl;
        }
    }

    void write(const std::map<std::string, std::string>& newProperties = {}) {
        for (const auto& pair : newProperties) {
            properties[pair.first] = pair.second;
        }
        std::ofstream file(filepath);
        if (!file.is_open()) {
            throw std::runtime_error("Unable to write to " + filepath);
        }
        for (const auto& pair : properties) {
            file << pair.first << " = \"" << pair.second << "\"\n";
        }
        file.close();
    }
};

// Example usage:
// int main() {
//     try {
//         VMXHandler handler("example.vmx");
//         handler.read();
//         handler.printProperties();
//         std::map<std::string, std::string> updates = {{"new_key", "new_value"}};
//         handler.write(updates);
//     } catch (const std::exception& e) {
//         std::cerr << e.what() << std::endl;
//     }
//     return 0;
// }