Common Tasks :Virtual Machine Guest Operations

Virtual Machine Guest Operations

This section discusses several operations that provide access to the guest operating system.

VMware Tools

All functions that execute in a guest operating system require VMware Tools to be installed and running. See Installing VMware Tools in a Virtual Machine for information on installing VMware Tools.

Authentication

All functions that modify a file system in the guest operating system or that execute code in a guest operating system require the client to authenticate as a user account known to the guest. The following list shows the functions that require client authentication.

  •  VixVM_CopyFileFromHostToGuest()
  •  VixVM_CopyFileFromGuestToHost()
  •  VixVM_CreateDirectoryInGuest()
  •  VixVM_CreateTempFileInGuest()
  •  VixVM_DeleteDirectoryInGuest()
  •  VixVM_DeleteFileInGuest()
  •  VixVM_DirectoryExistsInGuest()
  •  VixVM_FileExistsInGuest()
  •  VixVM_KillProcessInGuest()
  •  VixVM_ListDirectoryInGuest()
  •  VixVM_ListProcessesInGuest()
  •  VixVM_OpenUrlInGuest()
  •  VixVM_RenameFileInGuest()
  •  VixVM_RunProgramInGuest()
  •  VixVM_RunScriptInGuest()

A client uses VixVM_LoginInGuest() to authenticate with the guest operating system. Once authenticated, the client may continue to perform guest operations until one of the following takes place:

  • The client calls VixVM_LogoutFromGuest().
  • The client terminates, which ends the session.
  • The client attempts to authenticate a second time, and the second attempt fails.
  • The virtual machine shuts down.

If a virtual machine is suspended while a client is authenticated with the guest operating system, the client may resume guest operations after resuming virtual machine execution. However, this is true only as long as the client continues running while the virtual machine is suspended.

To authenticate with the guest operating system:

  1. Connect to the host on which the virtual machine is located. See Connecting to a Host.
  2. Get a handle to the virtual machine. See Getting a Handle to a Virtual Machine.
  3. Power on the virtual machine and wait for VMware Tools to become active. See Starting or Resuming a Virtual Machine.
  4. Use the virtual machine handle, the user name, and the user password, to call VixVM_LoginInGuest().
    Example 3-10.
    C code below. Click here for PerlClick here for COM.
VixError err = VIX_OK;
VixHandle jobHandle = VIX_INVALID_HANDLE;
 
// Authenticate with guest operating system.
jobHandle = VixVM_LoginInGuest(vmHandle,
                               "Administrator", // userName
                               "secret", // password
                               0, // options
                               NULL, // callbackProc
                               NULL); // clientData
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if (VIX_OK != err) {
   // Handle the error...
   goto abort;
}
 
Vix_ReleaseHandle(jobHandle);
jobHandle = VIX_INVALID_HANDLE;

The Console User

You may sometimes choose to provide a predefined string in place of an actual user name when callingVixVM_LoginInGuest(). The Vix header file provides the define VIX_CONSOLE_USER_NAME as a substitute for an actual user name. You need to use this substitute for authentication with a Windows guest operating system if you plan to launch a graphical user interface in the guest.

Before calling VixVM_LoginInGuest() with VIX_CONSOLE_USER_NAME, you need to be sure that a user is currently logged in to the guest operating system. The user must log in through a graphical console connection to the virtual machine.

VixVM_LoginInGuest() establishes credentials for API operations but does not do an actual login to the guest.

Using VIX_CONSOLE_USER_NAME is similar to making a second console connection to a virtual machine. When a user has logged in through one console connection, a second connection to the same virtual machine shares the display with the first connection and takes advantage of the first user's login account.

VIX_CONSOLE_USER_NAME is needed prior to calling these functions:

  •  VixVM_OpenUrlInGuest()
  •  VixVM_RunProgramInGuest()

The password for VIX_CONSOLE_USER_NAME is always NULL.

  1. Example 3-11.
    C code below.  Click here for PerlClick here for COM.
VixError err = VIX_OK;
VixHandle jobHandle = VIX_INVALID_HANDLE;
 
// Authenticate with guest operating system.
jobHandle = VixVM_LoginInGuest(vmHandle,
                               CONSOLE_USER_NAME, // Use console ID
                               NULL, // no password needed
                               0, // options
                               NULL, // callbackProc
                               NULL); // clientData
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if (VIX_OK != err) {
// Handle the error...
goto abort;
}
Vix_ReleaseHandle(jobHandle);
jobHandle = VIX_INVALID_HANDLE;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值