public static VirtualDeviceConfigSpec createCdrom(VirtualDevice ideController, int unitNumber) { VirtualCdrom cdrom = new VirtualCdrom(); cdrom.setControllerKey(ideController.getKey()); cdrom.setUnitNumber(unitNumber); VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo(); info.setAllowGuestControl(true); info.setConnected(true); info.setStartConnected(true); cdrom.setConnectable(info); VirtualCdromAtapiBackingInfo backing = new VirtualCdromAtapiBackingInfo(); backing.setDeviceName(String.format("cdrom-%d-%d", ideController.getKey(), unitNumber)); backing.setUseAutoDetect(false); cdrom.setBacking(backing); VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec(); spec.setDevice(cdrom); spec.setOperation(VirtualDeviceConfigSpecOperation.ADD); return spec; }