mirror of https://github.com/apache/cloudstack.git
Merge pull request #828 from sureshanaparti/CLOUDSTACK-8854
CLOUDSTACK-8854: Apple Mac OS/X VM get created without USB controller in ESXi hypervisorsCLOUDSTACK-8854: Apple Mac OS/X VM get created without USB controller in ESXi hypervisors Problem Description: CloudStack doesnt add a USB controller to the Apple Mac OS X VMs created in ESXi hypervisors. But, vSphere Client, by default, adds a USB Controller to the Mac OS VMs. Mac OS X machines require USB Controller for USB mouse and keyboard access. Root Cause: The Guest OS details are specified in the Virtual Machine Configuration Spec for creating the VM (using the SDK API) in the EXSi hypervisor. No USB Controller is added to the Virtual Machine Configuration Spec. As the guest OS Identification details are specified in the VM Configuration Spec, It is assumed that the Create VM SDK API would create the defaults in the VM same as vSphere Client. But, as per the observation, USB Controller is not added to the Guest OS - Mac OS VM created through the SDK API. Resolution: When the Guest OS is Apple Mac OS, Add the USB Controller (EHCI+UHCI - Mac supported) to the Virtual Machine Configuration Spec before Creating or Starting the VM. For any existing Mac OS VMs, Stop and Start to add the USB Controller. For new VMs with Mac OS, USB Controller is added automatically. * pr/828: CLOUDSTACK-8854: Apple Mac OS/X VM get created without USB controller in ESXi hypervisors Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
3ef775dc4d
|
|
@ -80,6 +80,7 @@ import com.vmware.vim25.VirtualDevice;
|
|||
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpec;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
|
||||
import com.vmware.vim25.VirtualUSBController;
|
||||
import com.vmware.vim25.VirtualDisk;
|
||||
import com.vmware.vim25.VirtualDiskFlatVer2BackingInfo;
|
||||
import com.vmware.vim25.VirtualEthernetCard;
|
||||
|
|
@ -1872,6 +1873,29 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Setup USB devices
|
||||
//
|
||||
if (guestOsId.startsWith("darwin")) { //Mac OS
|
||||
VirtualDevice[] devices = vmMo.getMatchedDevices(new Class<?>[] {VirtualUSBController.class});
|
||||
if (devices.length == 0) {
|
||||
s_logger.debug("No USB Controller device on VM Start. Add USB Controller device for Mac OS VM " + vmInternalCSName);
|
||||
|
||||
//For Mac OS X systems, the EHCI+UHCI controller is enabled by default and is required for USB mouse and keyboard access.
|
||||
VirtualDevice usbControllerDevice = VmwareHelper.prepareUSBControllerDevice();
|
||||
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
||||
deviceConfigSpecArray[i].setDevice(usbControllerDevice);
|
||||
deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.ADD);
|
||||
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Prepare USB controller at new device " + _gson.toJson(deviceConfigSpecArray[i]));
|
||||
|
||||
i++;
|
||||
} else {
|
||||
s_logger.debug("USB Controller device exists on VM Start for Mac OS VM " + vmInternalCSName);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Setup NIC devices
|
||||
//
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ import com.vmware.vim25.VMwareDVSPvlanConfigSpec;
|
|||
import com.vmware.vim25.VMwareDVSPvlanMapEntry;
|
||||
import com.vmware.vim25.VirtualBusLogicController;
|
||||
import com.vmware.vim25.VirtualController;
|
||||
import com.vmware.vim25.VirtualDevice;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpec;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
|
||||
import com.vmware.vim25.VirtualIDEController;
|
||||
|
|
@ -1291,6 +1292,18 @@ public class HypervisorHostHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if (guestOsIdentifier.startsWith("darwin")) { //Mac OS
|
||||
s_logger.debug("Add USB Controller device for blank Mac OS VM " + vmName);
|
||||
|
||||
//For Mac OS X systems, the EHCI+UHCI controller is enabled by default and is required for USB mouse and keyboard access.
|
||||
VirtualDevice usbControllerDevice = VmwareHelper.prepareUSBControllerDevice();
|
||||
VirtualDeviceConfigSpec usbControllerSpec = new VirtualDeviceConfigSpec();
|
||||
usbControllerSpec.setDevice(usbControllerDevice);
|
||||
usbControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
|
||||
|
||||
vmConfig.getDeviceChange().add(usbControllerSpec);
|
||||
}
|
||||
|
||||
VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
|
||||
DatastoreMO dsMo = new DatastoreMO(host.getContext(), morDs);
|
||||
fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import com.vmware.vim25.VirtualCdromRemotePassthroughBackingInfo;
|
|||
import com.vmware.vim25.VirtualDevice;
|
||||
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
||||
import com.vmware.vim25.VirtualDeviceConnectInfo;
|
||||
import com.vmware.vim25.VirtualUSBController;
|
||||
import com.vmware.vim25.VirtualDisk;
|
||||
import com.vmware.vim25.VirtualDiskFlatVer1BackingInfo;
|
||||
import com.vmware.vim25.VirtualDiskFlatVer2BackingInfo;
|
||||
|
|
@ -651,6 +652,15 @@ public class VmwareHelper {
|
|||
vmConfig.setGuestId(guestOsIdentifier);
|
||||
}
|
||||
|
||||
public static VirtualDevice prepareUSBControllerDevice() {
|
||||
s_logger.debug("Preparing USB controller(EHCI+UHCI) device");
|
||||
VirtualUSBController usbController = new VirtualUSBController(); //EHCI+UHCI
|
||||
usbController.setEhciEnabled(true);
|
||||
usbController.setAutoConnectDevices(true);
|
||||
|
||||
return usbController;
|
||||
}
|
||||
|
||||
public static ManagedObjectReference getDiskDeviceDatastore(VirtualDisk diskDevice) throws Exception {
|
||||
VirtualDeviceBackingInfo backingInfo = diskDevice.getBacking();
|
||||
assert (backingInfo instanceof VirtualDiskFlatVer2BackingInfo);
|
||||
|
|
|
|||
Loading…
Reference in New Issue