6.0

Table Of Contents
VMware, Inc. 111
Chapter 8 Managing Virtual Machines
ThecommandoptionsconnectanddisconnectadefinedISOorFLPfileoraphysicaldeviceonthehost.After
youconnectadevice,itscontentcanbeaccessedfromtheGuestOS.Fornetworkadapters,theoptionsconnect
thevirtualNICtoitsdefinedportgroupordisconnecttheNIC.
Thisisequivalenttoselectingordeselecting
theConnectedcheckboxinthevSphereWebClient.
Youcanconnectordisconnectdevicesifthefollowingconditionsaremet:
Thevirtualmachinehasaguestoperatingsystemthatsupportshotplugfunctionality.SeetheOperating
SystemInstallationdocumentation.
Thevirtualmachineisusinghardwareversion7orlater.
Thevirtualmachineispoweredon
Thefollowingexamplesillustrateconnectinganddisconnectingavirtualdevice.Devicenamesarecase
sensitive.
TheconnectdeviceoptionconnectsthevirtualIDEdeviceCD/DVDDrive2tothespecifiedvirtual
machine.
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx connectdevice "CD/DVD drive 2"
Thedisconnectdeviceoptiondisconnectsthevirtualdevice.
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
TheAnswerVMAPIallowsuserstoprovideinputtoquestions,therebyallowingblockedvirtualmachine
operationstocomplete.Thevmware-cmd --answeroptionallowsyoutoaccesstheinput.Youmightusethis
optionwhenyouwanttoconfigureavirtualmachinebasedonausers’sinput.Forexample:
1Theuserclonesa
virtualmachineandprovidesthedefaultvirtualdisktype.
2Whentheuserpowersonthevirtualmachine,itpromptsforthedesiredvirtualdisktype.
Forcibly Stopping Virtual Machines with EXCLI
Insomecases,virtualmachinesdonotrespondtothenormalshutdownorstopcommands.Inthesecases,it
mightbenecessarytoforciblyshutdownthevirtualmachines.Forciblyshuttingdownavirtualmachine
mightresultinguestoperatingsystemdatalossandissimilartopullingthepowercable
onaphysical
machine.
Youcanforciblystopvirtualmachinesthatarenotrespondingtonormalstopoperationwiththeesxcli vm
process killcommand.Specifyoneoftheoptionslistedin“ConnectionOptionsforvCLIHost
ManagementCommandsonpage 18inplaceof<conn_options>.
To forcibly stop a virtual machine
1Listallrunningvirtualmachinesonthe
systemtoseetheWorldIDofthevirtualmachinethatyouwant
tostop.
esxcli <conn_options> vm process list
2Stopthevirtualmachinebyrunningthefollowingcommand.
esxcli <conn_options> vm process kill --type <kill_type> --world-id <ID>
Thecommandsupportsthree--typeoptions.Trythetypessequentially(softbeforehard,hardbefore
force).Thefollowingtypesaresupportedthroughthe--typeoption:
soft.GivestheVMXprocessachancetoshutdowncleanly(likekillorkill -SIGTERM)
NOTEThetermsCD/DVD drive,Floppy drive.andNetwork adapter arecasesensitive.