A few days ago I was trying to migrate running virtual machines from one virtual switch to another one without any downtime. When I thought I was done I tried to remove the vacated virtual switch, but instead was greeted with the following error:
Error: A specified parameter was not correct.
Well after scratching my head for a while I discovered nasty bug in vSphere. If you rename a port group, the configuration files of VMs using this portgroup are not updated. If you create a new port group with the old name, vSphere client then shows the VMs in the new port group, however in reality they are still residing in the old one and using its connectivity.
To reproduce my steps that lead to the above image:
- I created ‘Test’ virtual machine port group on new vSwitch2 and placed there a running VM1
- I renamed the port group to ‘Test2′ – VM1 disappeared
- I created new virtual machine port group ‘Test‘ on vSwitch0. The VM1 immediately jumped into this new port group.
- I tried to delete vSwitch2 and got the error.
Running esxcfg-vswitch -l I received this output:
The supposedly empty port group ‘Test2‘ is using 1 port and the new ‘Test‘ port group shows 0 used ports even though vSphere client shows running VM1 in it.
So what is really happening? Actually this is not a bug of vSphere client as it relays on info provided by SDK of ESX server. Running commands
vmware-vim-cmd vmsvc/get.networks <vmid>
gives wrong info about the port group names. vSphere client incorrectly assumes that the VM was migrated to the other switch, but in fact it still resides on the old switch. The only way out of it is open VM settings and change the network connection to a different port group and back again. The network adapter info gets updated and now finally the VM is migrated to the new switch and the old one can be removed.
This was tested on ESX build 4.0.0,236512.