6.5

Table Of Contents
The following examples illustrate connecting and disconnecting a virtual device. Device names are case
sensitive.
n
The connectdevice option connects the virtual IDE device CD/DVD Drive 2 to the specied virtual
machine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost
<esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx connectdevice "CD/DVD drive 2"
n
The disconnectdevice option disconnects the virtual device.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost
<esx_host> /vmfs/volumes/Storage2/testvm/testvm.vmx disconnectdevice "CD/DVD drive 2"
Working with the AnswerVM API
The AnswerVM API allows users to provide input to questions, thereby allowing blocked virtual machine
operations to complete.
The vmware-cmd --answer option allows you to access the input. You can use this option when you want to
congure a virtual machine based on a user's input, such as in the following example situations.
1 The user clones a virtual machine and provides the default virtual disk type.
2 When the user powers on the virtual machine, it prompts for the desired virtual disk type.
Forcibly Stop a Virtual Machine with ESXCLI
You can use ESXCLI to stop a virtual machine forcibly.
In some cases, virtual machines do not respond to the normal shutdown or stop commands. In these cases, it
might be necessary to forcibly shut down the virtual machines. Forcibly shuing down a virtual machine
might result in guest operating system data loss and is similar to pulling the power cable on a physical
machine.
You can forcibly stop virtual machines that are not responding to normal stop operation with the esxcli vm
process kill command. Specify one of the options listed in “Connection Options for vCLI Host
Management Commands,” on page 19 in place of <conn_options>.
Procedure
1 List all running virtual machines on the system to see the World ID of the virtual machine that you
want to stop.
esxcli <conn_options> vm process list
2 Stop the virtual machine by running the following command.
esxcli <conn_options> vm process kill --type <kill_type> --world-id <ID>
The command supports three --type options. Try the types sequentially - soft before hard, hard before
force. The following types are supported through the --type option.
Type Description
soft Gives the VMX process a chance to shut down cleanly, like kill or kill -
SIGTERM.
hard Stops the VMX process immediately, like kill -9 or kill -SIGKILL.
force
Stops the VMX process when other options do not work.
What to do next
If all three options do not work, reboot your ESXi host to resolve the issue.
vSphere Command-Line Interface Concepts and Examples
130 VMware, Inc.