Programming Guide Guest SDK 3.5

Similar documents
VERSION 1.0. VMware Guest SDK. Programming Guide

vsphere Guest Programming Guide VMware vsphere Guest SDK 4.0

Configuration Maximums VMware Infrastructure 3: ESX Server 3.5 Update 2, ESX Server 3i version 3.5 Update 2, VirtualCenter 2.

VMware Infrastructure 3 Primer Update 2 and later for ESX Server 3.5, ESX Server 3i version 3.5, VirtualCenter 2.5

Notes on Using the Beta VMware Importer Tool on Your Mac VMware Importer 1 Beta 2

Basic System Administration ESX Server and Virtual Center 2.0.1

Lifecycle Manager User's Guide

Setup for Microsoft Cluster Service Update 1 Release for ESX Server 3.5, ESX Server 3i version 3.5, VirtualCenter 2.5

Resource Management Guide ESX Server and VirtualCenter 2.0.1

Guest Operating System Installation Guide. May 28, 2008

Guest Operating System Installation Guide. February 25, 2008

VMware View Upgrade Guide

Guest Operating System Installation Guide. March 14, 2008

Getting Started with ESX Server 3i Embedded ESX Server 3i version 3.5 Embedded and VirtualCenter 2.5

VMware vcenter Configuration Manager and VMware vcenter Application Discovery Manager Integration Guide

Using vmkusage to Isolate Performance Problems

Virtual Infrastructure Web Access Administrator s Guide Update 2 and later for ESX Server 3.5 and VirtualCenter 2.5

Virtual Infrastructure Web Access Administrator s Guide ESX Server 3.0 and VirtualCenter 2.0

Resource Management Guide. ESX Server 3 and VirtualCenter 2

Using vrealize Operations Tenant App for vcloud Director as a Tenant Admin

VMware VMFS Volume Management VMware Infrastructure 3

Getting Started with ESX Server 3i Installable Update 2 and later for ESX Server 3i version 3.5 Installable and VirtualCenter 2.5

VMware vcloud Air Key Concepts

vcloud Automation Center Reference Architecture vcloud Automation Center 5.2

vsphere PowerCLI Installation Guide VMware vsphere PowerCLI 4.1 Update 1 EN

vsphere Availability Guide

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

Large Page Performance ESX Server 3.5 and ESX Server 3i v3.5

Image Management for View Desktops using Mirage

Getting Started with ESXi Embedded

Thin Client Compatibility Guide For VMware Virtual Desktop Manager (VDM)

Using VMware Identity Manager Apps Portal

Port Adapter Installation and Configuration Guide

VMware vrealize Configuration Manager SQL Migration Helper Tool User's Guide vrealize Configuration Manager 5.8

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

Request Manager User's Guide

vcenter Operations Manager for Horizon View Administration

VMware vcenter AppSpeed User s Guide AppSpeed 1.0 EN

VMware Virtual Machine Importer User s Manual

VMware vrealize Operations Management Pack for vcloud Director 4.5 Guide

Virtual Machine Backup Guide Update 2 Release for ESX Server 3.5, ESX Server 3i version 3.5, VirtualCenter 2.5

Developing and Deploying vsphere Solutions, vservices, and ESX Agents. 17 APR 2018 vsphere Web Services SDK 6.7 vcenter Server 6.7 VMware ESXi 6.

vsphere Update Manager Installation and Administration Guide 17 APR 2018 VMware vsphere 6.7 vsphere Update Manager 6.7

Compatibility Matrixes for VMware vcenter Site Recovery Manager 4.0 and Later

Getting Started with VMware Fusion VMware Fusion for Mac OS X Version 1.0

vcenter CapacityIQ Installation Guide

Comparison of Storage Protocol Performance ESX Server 3.5

vcloud Director User's Guide

Developing and Deploying vsphere Solutions, vservices, and ESX Agents

vcenter CapacityIQ Installation Guide

vsphere Virtual Machine Administration

vcenter Update Manager PowerCLI Installation and Administration Guide vcenter Update Manager PowerCLI 4.1 EN

vcloud Director User's Guide

vsphere Upgrade Guide

PostgreSQL Solution 1.1

Installing and Configuring VMware Identity Manager Connector (Windows) OCT 2018 VMware Identity Manager VMware Identity Manager 3.

VMware vsphere Update Manager PowerCLI Installation and Administration Guide Update Manager PowerCLI 6.0 EN

vcloud Director User's Guide

vsphere Replication for Disaster Recovery to Cloud

vsphere Client Hardware Health Monitoring VMware vsphere 4.1

VMware Lab Manager User s Guide VMware Lab Manager 2.5

QuickStart Guide vcenter Server Heartbeat 5.5 Update 1 EN

Performance of Virtual Desktops in a VMware Infrastructure 3 Environment VMware ESX 3.5 Update 2

vsphere Replication for Disaster Recovery to Cloud vsphere Replication 6.5

vsphere Networking Update 2 VMware vsphere 5.5 VMware ESXi 5.5 vcenter Server 5.5 EN

vsphere Web Client Extensions Programming Guide vsphere 5.1

VMware vcloud Air User's Guide

VMware vfabric Data Director Installation Guide

What s New in VMware vsphere 5.1 Platform

Migration. 22 AUG 2017 VMware Validated Design 4.1 VMware Validated Design for Software-Defined Data Center 4.1

Using the vrealize Orchestrator Operations Client. vrealize Orchestrator 7.5

vcloud Director User's Guide

vsphere Upgrade Update 1 Modified on 4 OCT 2017 VMware vsphere 6.5 VMware ESXi 6.5 vcenter Server 6.5

Multi-Tenancy in vrealize Orchestrator. vrealize Orchestrator 7.4

Deploying VMware Identity Manager in the DMZ. JULY 2018 VMware Identity Manager 3.2

Using the vcenter Orchestrator Plug-In for vcloud Director 5.5. vrealize Orchestrator 5.5

vcenter Chargeback User s Guide

Administering View Cloud Pod Architecture. VMware Horizon 7 7.0

Using the vcenter Orchestrator Plug-In for vcloud Director 1.0

vfabric Hyperic Monitoring and Management

VMware Infrastructure 3

VMware Horizon Migration Tool User Guide

VMware vfabric Data Director Installation Guide

VMware Workspace Portal End User Guide

ESX Server 3i Embedded Setup Guide ESX Server 3i version 3.5 Embedded and VirtualCenter 2.5

Administering Cloud Pod Architecture in Horizon 7. Modified on 26 JUL 2017 VMware Horizon 7 7.2

vrealize Log Insight Developer Resources

Evaluator Guide. Site Recovery Manager 1.0

vrealize Log Insight Developer Resources Update 1 Modified on 03 SEP 2017 vrealize Log Insight 4.0

VMware Skyline Collector Installation and Configuration Guide. VMware Skyline Collector 2.0

Installing and Administering VMware vsphere Update Manager. Update 2 VMware vsphere 5.5 vsphere Update Manager 5.5

VMware Mirage Getting Started Guide

Administering Cloud Pod Architecture in Horizon 7. VMware Horizon 7 7.1

vcloud Director User's Guide 04 OCT 2018 vcloud Director 9.5

vsphere Basic System Administration

NSX-T Upgrade Guide. VMware NSX-T 2.0

SAP Solutions on VMware vsphere : High Availability

Enforcing Patch Management

vsphere Replication for Disaster Recovery to Cloud vsphere Replication 8.1

vcloud Director Administrator's Guide

Transcription:

Guest SDK 3.5

Revision: 20071129 Item: SDK-ENG-Q407-126 You can find the most up-to-date technical documentation on our Web site at http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com 1998 2007 VMware, Inc. All rights reserved. Protected by one or more of U.S. Patent Nos. 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145, 7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815, 7,260,820, 7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030, 7,281,102, and 7,290,253; patents pending. VMware, the VMware boxes logo and design, Virtual SMP and VMotion are registered trademarks or trademarks of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies. VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com 2 VMware, Inc.

Contents About This Book 5 VMware Guest SDK 7 Overview of the VMware Guest API 7 VMware Guest API is a Read-Only API 7 Supported Guest Operating Systems 7 Types of Statistics That Can Be Monitored using the Guest API 7 Installing the Runtime Components 8 Disabling the VMware Guest API 8 Programming to the VMware Guest API 8 Gathering Information from the VMware Guest API 8 Understanding the VMware Guest API Data Types 9 Making Calls to the VMware Guest API 9 Open, Close, and Update Functions 9 Accessor Functions 9 Understanding VMware Guest API Error Codes 11 Index 13 VMware, Inc. 3

4 VMware, Inc.

About This Book This book, the, provides information about developing applications using the VMware Guest Application Programming Interface (API). VMware provides several different software development kit (SDK) products, each of which targets different developer communities and target platforms. This guide is intended for developers who want to monitor several different types of statistics about the virtual machine on which a Windows or Linux guest operating system is running. The supported platforms include VMware ESX Server 3.0.x,VMware ESX Server 3.5, and VMware ESX Server 3i version 3.5. Revision History This book is revised with each release of the Guest SDK or when necessary. A revised version can contain minor or major changes. Table 1 summarizes the significant changes in each version of this guide. Table 1. Revision History Revision Description 20050718 Initial release of the VMware Guest SDK providing support for VMware ESX Server 3.0. 20071129 No new information, but revised to note support for VMware ESX Server 3.5 and VMware ESX Server 3i version 3.5. To view the most current version of this guide, go to http://www.vmware.com/support/pubs/sdk_pubs.html. Intended Audience This book is intended for anyone developing applications to run inside guest operating systems under VMware ESX Server who wants to retrieve information about the virtual machine and host hardware in which the application runs. Document Feedback VMware welcomes your suggestions for improving our documentation. If you have comments, send your feedback to: docfeedback@vmware.com Technical Support and Education Resources The following sections describe the technical support resources available to you. You can access the most current versions of other VMware manuals by going to: http://www.vmware.com/support/pubs VMware, Inc. 5

Online Support You can submit questions or post comments to the Developer Community: SDKs and APIs forum, which is monitored by VMware technical support and product teams. You can access the forum at: http://communities.vmware.com/community/developer Support Offerings Find out how VMware support offerings can help meet your business needs. Go to http://www.vmware.com/support/services. VMware Education Services VMware courses offer extensive hands-on labs, case study examples, and course materials designed to be used as on-the-job reference tools. For more information about VMware Education Services, go to http://mylearn1.vmware.com/mgrreg/index.cfm. 6 VMware, Inc.

VMware Guest SDK This guide provides information about how to include VMware Guest API function calls from a program running in a VMware ESX Server virtual machine. It covers the following topics: Overview of the VMware Guest API Programming to the VMware Guest API Understanding VMware Guest API Error Codes Overview of the VMware Guest API The VMware Guest API provides entry points (or, hooks ) that management agents and other software running in the guest operating system in a VMware ESX Server 3 virtual machine can use to collect data about the state and performance of the virtual machine. VMware Guest API is a Read-Only API As a complement to the VMware Infrastructure SDK, the VMware Guest API provides fast access to resource management information, without the need for authentication. The Guest API provides read-only access, which means you can read data using the API, but you cannot send any control commands. To issue control commands, use the VMware Infrastructure SDK. For details, see the VMware Infrastructure SDK and the VMware Infrastructure API Reference, available from the VMware Web site. Supported Guest Operating Systems The VMware Guest API is supported in any Windows or Linux guest operating system supported by VMware ESX Server 3.0.x, VMware ESX Server 3.5, or VMware ESX Server 3i version 3.5. See the Guest Operating System Installation Guide for a list of supported guest operating system versions. Types of Statistics That Can Be Monitored using the Guest API Using the VMware Guest API, you can monitor various statistics about the virtual machine, including: The amount of memory reserved for the virtual machine The amount of memory actually being used by the virtual machine The upper limit of memory available to the virtual machine The number of memory shares assigned to the virtual machine The maximum speed to which the virtual machine s CPU is limited The minimum reserved rate at which the virtual machine is allowed to execute; note that an idling virtual machine may consume CPU cycles at a much lower rate VMware, Inc. 7

The number of CPU shares assigned to the virtual machine The elapsed time since the virtual machine was last powered on or reset CPU time scheduled on the ESX Server system for a particular virtual machine s CPU; combined with other available measurements, this allows you to estimate how fast the virtual machine s CPU is running compared to the host CPU Whether the API is able to provide accurate information (certain events, such as migrating a virtual machine with VMotion, temporarily make it impossible to provide accurate information) This information can be used by applications running in virtual machines to retrieve scheduling and resource utilization information about their environment. Using this information, the virtual machine can react to changes in the virtual environment immediately at the application layer. Installing the Runtime Components To use the VMware Guest API, you must install its runtime components in the guest operating system. These are installed when you install the VMware Tools. You can also download them from http://www.vmware.com/support/developer/guest-sdk/. The VMware Guest API runtime components are enabled by default. You can disable them by modifying an option in the virtual machine s configuration file, as detailed in Gathering Information from the VMware Guest API. Disabling the VMware Guest API To disable the runtime components of the VMware Guest API, edit the configuration file for the virtual machine and add the following line or, if it already exists, update it to the following: isolation.tools.guestlibgetinfo.disable = "TRUE" The default value for this setting is "FALSE". The default setting enables the runtime components. Reinstalling VMware Tools does not affect this setting. Therefore, if you disable the VMware Guest API and then reinstall the tools, the VMware Guest API continues to be unavailable until you change the guestlibgetinfo.disable configuration setting to "FALSE". Programming to the VMware Guest API This section provides information about how to query the API for the information it makes available, about the data types and functions available in the Guest API. In includes these topics: Gathering Information from the VMware Guest API Understanding the VMware Guest API Data Types Making Calls to the VMware Guest API Gathering Information from the VMware Guest API The runtime components of the VMware Guest API comprise dynamically loaded binary modules for 32-bit and 64-bit guests. In a Windows guest operating system, the library file is vmguestlib.dll. The import library file is vmguestlib.lib. In a Linux guest operating system, the library file is libvmguestlib.so. Use your program s standard methods to load the library to make the functions of the VMware Guest API available to your program. The vmguestlib.dll library file is a non-unicode DLL. In Microsoft Visual Studio, build the test program vmguestlibtest.c as non-unicode so that the program can access the DLL at runtime. 8 VMware, Inc.

VMware Guest SDK Understanding the VMware Guest API Data Types The VMware Guest API uses the data types listed in Table 1to facilitate access to virtual machine data. Table 1. Data Types Data Type VMGuestLibHandle VMGuestLibSessionID VMGuestLibError Description Reference to virtual machine data. Unique identifier for each session that changes after a virtual machine is migrated using VMotion, suspended and resumed, or reverted to a snapshot. Any of the events listed (migration with VMotion, suspend and resume, revert to snapshot) is likely to render invalid any information previously retrieved through this API. The session ID provides applications with a mechanism to detect those events and react accordingly for example, by refreshing and resetting any state that relies on the validity of previously retrieved information. Code returned after each function call that indicates success or failure. See Understanding VMware Guest API Error Codes on page 11. Making Calls to the VMware Guest API The functions available in VMware Guest API are described in tables below. Open, Close, and Update Functions Table 2 lists functions for obtaining new handles, releasing existing handles, and updating information: Table 2. Open, Close, and Update Functions Function VMGuestLib_OpenHandle VMGuestLib_CloseHandle VMGuestLib_UpdateInfo Description Gets a handle for use with other VMware Guest API functions. Releases a handle previously acquired with VMGuestLib_OpenHandle. Updates information about the virtual machine stored at the VMGuestLibHandle. Accessor Functions Table 3 lists functions that can retrieve information about a virtual machine. Each accessor function returns information about the attribute in question and an error code that indicates success or failure: When a call completes successfully, the error returned is VMGUESTLIB_ERROR_SUCCESS. Unsuccessful calls return error codes with appropriate description as part of the error code name. For details, see Understanding VMware Guest API Error Codes on page 11. Call VMGuestLib_UpdateInfo once to refresh all statistics before calling an accessor functions or a series of accessor functions. Table 3. Accessor Functions Function VMGuestLib_GetSessionId VMGuestLib_GetCpuReservationMHz VMGuestLib_GetCpuLimitMHz Description Retrieves the ID for the current session after calling VMGuestLib_UpdateInfo(). The session ID is opaque and cannot be compared in any meaningful way with the session IDs from any other virtual machines. If VMGuestLib_UpdateInfo() has never been called, the return value is VMGUESTLIB_ERROR_NO_INFO. Retrieves the minimum processing power in MHz reserved for the virtual machine. Assigning a cpureservationmhz ensures that even as other virtual machines on a single host consume shared processing power, there is still a certain minimum amount reserved for this virtual machine. Retrieves the upper limit of processing power in MHz available to the virtual machine. Assigning a cpulimitmhz ensures that this virtual machine never consumes more than a certain amount of the available processor power. By limiting the amount of processing power consumed, a portion of this shared resource is available to other virtual machines. VMware, Inc. 9

Table 3. (Continued)Accessor Functions (Continued) VMGuestLib_GetCpuShares VMGuestLib_GetCpuUsedMs VMGuestLib_GetHostProcessorSpeed VMGuestLib_GetMemReservationMB VMGuestLib_GetMemLimitMB VMGuestLib_GetMemShares VMGuestLib_GetMemMappedMB VMGuestLib_GetMemActiveMB VMGuestLib_GetMemOverheadMB VMGuestLib_GetMemBalloonedMB VMGuestLib_GetMemSwappedMB VMGuestLib_GetMemSharedMB VMGuestLib_GetMemSharedSavedMB VMGuestLib_GetMemUsedMB VMGuestLib_GetElapsedMs VMGuestLib_GetResourcePoolPath Retrieves the number of CPU shares allocated to the virtual machine. Retrieves the number of milliseconds during which the virtual machine has used the CPU. This value is the total amount of physical processor time used by the virtual machine including the time used by the guest operating system and the time used by virtualization code for tasks for this virtual machine. This value, in conjunction with elapsedms, can be used to estimate effective virtual machine CPU speed. This value is a subset of elapsedms. Retrieves the speed of the ESX Server system s physical CPU in MHz. Retrieves the minimum amount of memory that is reserved for the virtual machine. Assigning a cpureservationmb ensures that even as other virtual machines on a single host consume memory, there is still a certain minimum amount reserved for this virtual machine. Retrieves the upper limit of memory that is available to the virtual machine. Assigning a cpulimitmhz ensures that this virtual machine never consumes more than a certain amount of the available processor power. By limiting the amount of processing power consumed, a portion of this shared resource is available to other virtual machines. Retrieves the number of memory shares allocated to the virtual machine. Retrieves the amount of memory that is currently allocated to the virtual machine. Memory that is ballooned, swapped, or has never been accessed is excluded. Retrieves the size of the memory the virtual machine is actively using its estimated working set size. Retrieves the amount of overhead memory associated with this virtual machine that is currently consumed on the host system. Overhead memory is additional memory that is reserved for data structures required by the virtualization layer. Retrieves the amount of memory that has been reclaimed from this virtual machine by the VMware memory balloon driver (also referred to as the vmmemctl driver.) Retrieves the amount of memory that has been reclaimed from this virtual machine by transparently swapping guest memory to disk. Retrieves the amount of physical memory associated with this virtual machine that is copy-on-write (COW) shared on the host. Retrieves the estimated amount of physical memory on the host saved from copy-on-write (COW) shared guest physical memory. Retrieves the estimated amount of physical host memory currently consumed for this virtual machine's physical memory. This is the same as (mapped memory) - (sharedsaved memory). Retrieves the number of milliseconds that have passed in the virtual machine since it last started running on the server where it is currently running. The count of elapsed time begins again any time the virtual machine is powered on, resumed, or migrated using VMotion. This value counts milliseconds, regardless of whether the virtual machine is using processing power during that time. This value, in conjunction with cpuusedms, can be used to estimate effective virtual machine CPU speed. cpuusedms is a subset of this value. Retrieves the path name of the resource pool to which the virtual machine belongs on the ESX Server system where it is running. For more information about ESX Server resource management, see the VMware ESX Server Failover and Resource Management Guide, available on the VMware Web site. 10 VMware, Inc.

VMware Guest SDK Understanding VMware Guest API Error Codes Each VMware Guest API function returns an error code. In most cases, the error code returned is VMGUESTLIB_ERROR_SUCCESS, meaning the API function completed successfully. If the function is unable to complete its task, the error returned provides information that is useful in diagnosing the problem. Table 4 lists all error codes that can be returned by the VMware Guest API. Table 4. Error Codes Error Code VMGUESTLIB_ERROR_SUCCESS VMGUESTLIB_ERROR_OTHER VMGUESTLIB_ERROR_NOT_RUNNING_IN_VM VMGUESTLIB_ERROR_NOT_ENABLED VMGUESTLIB_ERROR_NOT_AVAILABLE VMGUESTLIB_ERROR_NO_INFO VMGUESTLIB_ERROR_MEMORY VMGUESTLIB_ERROR_BUFFER_TOO_SMALL VMGUESTLIB_ERROR_INVALID_HANDLE VMGUESTLIB_ERROR_INVALID_ARG Description The function has completed successfully. This is the standard code that is returned after a function finishes. An error has occurred. No additional information about the type of error is available. The program making this call is not running in a VMware virtual machine. The VMware Guest API is not enabled on this host, so these functions can not be used. For more information about how the to enable the library, see Gathering Information from the VMware Guest API on page 8. The information you have requested is not available on this host. VMGuestLib_UpdateInfo has not yet been called, so there is no information available to read from the data structure. Therefore, when an accessor function is called, there is no data to return. There is not enough memory available to complete the call. The buffer is too small to accommodate the call. For example, when VMGuestLib_GetResourcePoolPath is called, if the path buffer is too small to accommodate the resource pool path, this error is returned. To resolve this error, allocate a larger buffer. The handle you used is invalid. Ensure you have the correct handle and it has not been closed. You may need to create a new handle using VMGuestLib_OpenHandle(). One or more of the arguments passed to the function were invalid. VMware, Inc. 11

12 VMware, Inc.

Index Numerics 32-bit guest support 8 64-bit guest support 8 A accessor functions 9 D Data Types 9 disabling the VMware Guest API 8 VMGuestLib_GetSessionId 9 VMGuestLib_OpenHandle 9 VMGuestLib_UpdateInfo 9 VMGuestLibError 9 VMGuestLibHandle 9 VMGuestLibSessionID 9 VMware Tools, required for VMware Guest API 8 W Windows 7 E enabling VMware Guest API runtime components 8 L libvmguestlib.so 8 M mutator functions 9 R refreshing all statistics 9 T technical support resources 5 V vmguestlib.lib 8 VMGuestLib_CloseHandle 9 VMGuestLib_GetCpuLimitMHz 9 VMGuestLib_GetCpuReservationMHz 9 VMGuestLib_GetCpuShares 10 VMGuestLib_GetCpuUsedMs 10 VMGuestLib_GetElapsedMs 10 VMGuestLib_GetHostProcessorSpeed 10 VMGuestLib_GetMemActiveMB 10 VMGuestLib_GetMemBalloonedMB 10 VMGuestLib_GetMemLimitMB 10 VMGuestLib_GetMemMappedMB 10 VMGuestLib_GetMemOverheadMB 10 VMGuestLib_GetMemReservationMB 10 VMGuestLib_GetMemSharedMB 10 VMGuestLib_GetMemSharedSavedMB 10 VMGuestLib_GetMemShares 10 VMGuestLib_GetMemSwappedMB 10 VMGuestLib_GetMemUsedMB 10 VMGuestLib_GetResourcePoolPath 10 VMware, Inc. 13

14 VMware, Inc.