Common Tasks :Getting a Handle to a Virtual Machine

Getting a Handle to a Virtual Machine

Most virtual machine operations require a handle to identify the virtual machine. The VixVM_Open() function converts a path name to a handle, which you can use in subsequent function calls. VixVM_Open() is an asynchronous function, so the function call must be completed with a callback function or a call to VixJob_Wait().

To get a handle to a virtual machine

  1. Supply a handle to the host on which the virtual machine is located. See Connecting to a Host.
  2. On VMware Server only, ensure that the virtual machine is registered on the host. See Registering and Unregistering Virtual Machines.
  3. Use the host handle and the virtual machine's path name in the host's file system to open the virtual machine withVixVM_Open().
  4. Retrieve the virtual machine handle from the job object.
    Example 3-6.
    C code below. Click here for PerlClick here for COM.
VixHandle jobHandle = VIX_INVALID_HANDLE;
VixHandle vmHandle = VIX_INVALID_HANDLE;
char vmxFilePath[] = "c:\\Virtual Machines\\vm1\\win2000.vmx";
VixError err;
 
// Open virtual machine and get a handle.
jobHandle = VixVM_Open(hostHandle,
                       vmxFilePath,
                       NULL, // callbackProc
                       NULL); // clientData
err = VixJob_Wait(jobHandle,
                  VIX_PROPERTY_JOB_RESULT_HANDLE,
                  &vmHandle,
                  VIX_PROPERTY_NONE);
if (VIX_OK != err) {
   // Handle the error...
   goto abort;
}
 
Vix_ReleaseHandle(jobHandle);
jobHandle = VIX_INVALID_HANDLE;
// ...Use vmHandle in subsequent code...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值