Changeset 66443 in vbox
- Timestamp:
- Apr 5, 2017 2:54:58 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp
r66345 r66443 214 214 m_pCache->clear(); 215 215 216 /* Prepare system data: */ 217 UIDataSettingsMachineSystem systemData; 218 219 /* Load support flags: */ 220 systemData.m_fSupportedPAE = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_PAE); 221 systemData.m_fSupportedHwVirtEx = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_HWVirtEx); 222 223 /* Load motherboard data: */ 224 systemData.m_iMemorySize = m_machine.GetMemorySize(); 225 /* Load boot-items of current VM: */ 216 /* Prepare old system data: */ 217 UIDataSettingsMachineSystem oldSystemData; 218 219 /* Gather support flags: */ 220 oldSystemData.m_fSupportedPAE = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_PAE); 221 oldSystemData.m_fSupportedHwVirtEx = vboxGlobal().host().GetProcessorFeature(KProcessorFeature_HWVirtEx); 222 223 /* Gather old 'Motherboard' data: */ 224 oldSystemData.m_iMemorySize = m_machine.GetMemorySize(); 225 oldSystemData.m_chipsetType = m_machine.GetChipsetType(); 226 oldSystemData.m_pointingHIDType = m_machine.GetPointingHIDType(); 227 oldSystemData.m_fEnabledIoApic = m_machine.GetBIOSSettings().GetIOAPICEnabled(); 228 oldSystemData.m_fEnabledEFI = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL; 229 oldSystemData.m_fEnabledUTC = m_machine.GetRTCUseUTC(); 230 /* Gather boot-items of current VM: */ 226 231 QList<KDeviceType> usedBootItems; 227 232 for (int i = 1; i <= m_possibleBootItems.size(); ++i) … … 234 239 data.m_type = type; 235 240 data.m_fEnabled = true; 236 systemData.m_bootItems << data;237 } 238 } 239 /* Loadother unique boot-items: */241 oldSystemData.m_bootItems << data; 242 } 243 } 244 /* Gather other unique boot-items: */ 240 245 for (int i = 0; i < m_possibleBootItems.size(); ++i) 241 246 { … … 246 251 data.m_type = type; 247 252 data.m_fEnabled = false; 248 systemData.m_bootItems << data; 249 } 250 } 251 /* Load other motherboard data: */ 252 systemData.m_chipsetType = m_machine.GetChipsetType(); 253 systemData.m_pointingHIDType = m_machine.GetPointingHIDType(); 254 systemData.m_fEnabledIoApic = m_machine.GetBIOSSettings().GetIOAPICEnabled(); 255 systemData.m_fEnabledEFI = m_machine.GetFirmwareType() >= KFirmwareType_EFI && m_machine.GetFirmwareType() <= KFirmwareType_EFIDUAL; 256 systemData.m_fEnabledUTC = m_machine.GetRTCUseUTC(); 257 258 /* Load CPU data: */ 259 systemData.m_cCPUCount = systemData.m_fSupportedHwVirtEx ? m_machine.GetCPUCount() : 1; 260 systemData.m_iCPUExecCap = m_machine.GetCPUExecutionCap(); 261 systemData.m_fEnabledPAE = m_machine.GetCPUProperty(KCPUPropertyType_PAE); 262 263 /* Load acceleration data: */ 264 systemData.m_paravirtProvider = m_machine.GetParavirtProvider(); 265 systemData.m_fEnabledHwVirtEx = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled); 266 systemData.m_fEnabledNestedPaging = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging); 267 268 /* Cache system data: */ 269 m_pCache->cacheInitialData(systemData); 253 oldSystemData.m_bootItems << data; 254 } 255 } 256 257 /* Gather old 'Processor' data: */ 258 oldSystemData.m_cCPUCount = oldSystemData.m_fSupportedHwVirtEx ? m_machine.GetCPUCount() : 1; 259 oldSystemData.m_iCPUExecCap = m_machine.GetCPUExecutionCap(); 260 oldSystemData.m_fEnabledPAE = m_machine.GetCPUProperty(KCPUPropertyType_PAE); 261 262 /* Gather old 'Acceleration' data: */ 263 oldSystemData.m_paravirtProvider = m_machine.GetParavirtProvider(); 264 oldSystemData.m_fEnabledHwVirtEx = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_Enabled); 265 oldSystemData.m_fEnabledNestedPaging = m_machine.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging); 266 267 /* Cache old system data: */ 268 m_pCache->cacheInitialData(oldSystemData); 270 269 271 270 /* Upload machine to data: */ … … 275 274 void UIMachineSettingsSystem::getFromCache() 276 275 { 277 /* Get system data fromcache: */278 const UIDataSettingsMachineSystem & systemData = m_pCache->base();276 /* Get old system data from the cache: */ 277 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base(); 279 278 280 279 /* Repopulate 'pointing HID type' combo. 281 * We are doing that *now* because it has dynamical content282 * which depends on recashed value: */280 * We are doing that *now* because it has 281 * dynamical content which depends on cashed value: */ 283 282 repopulateComboPointingHIDType(); 284 283 285 /* Load motherboard data to page: */ 286 m_pSliderMemorySize->setValue(systemData.m_iMemorySize); 284 /* Load old 'Motherboard' data to the page: */ 285 m_pSliderMemorySize->setValue(oldSystemData.m_iMemorySize); 286 const int iChipsetTypePosition = m_pComboChipsetType->findData(oldSystemData.m_chipsetType); 287 m_pComboChipsetType->setCurrentIndex(iChipsetTypePosition == -1 ? 0 : iChipsetTypePosition); 288 const int iHIDTypePosition = m_pComboPointingHIDType->findData(oldSystemData.m_pointingHIDType); 289 m_pComboPointingHIDType->setCurrentIndex(iHIDTypePosition == -1 ? 0 : iHIDTypePosition); 290 m_pCheckBoxApic->setChecked(oldSystemData.m_fEnabledIoApic); 291 m_pCheckBoxEFI->setChecked(oldSystemData.m_fEnabledEFI); 292 m_pCheckBoxUseUTC->setChecked(oldSystemData.m_fEnabledUTC); 287 293 /* Remove any old data in the boot view: */ 288 QAbstractItemView * iv = qobject_cast <QAbstractItemView*>(mTwBootOrder);289 iv->model()->removeRows(0, iv->model()->rowCount());294 QAbstractItemView *pItemView = qobject_cast<QAbstractItemView*>(mTwBootOrder); 295 pItemView->model()->removeRows(0, pItemView->model()->rowCount()); 290 296 /* Apply internal variables data to QWidget(s): */ 291 for (int i = 0; i < systemData.m_bootItems.size(); ++i)292 { 293 UIBootItemData data = systemData.m_bootItems[i];297 for (int i = 0; i < oldSystemData.m_bootItems.size(); ++i) 298 { 299 const UIBootItemData data = oldSystemData.m_bootItems[i]; 294 300 QListWidgetItem *pItem = new UIBootTableItem(data.m_type); 295 301 pItem->setCheckState(data.m_fEnabled ? Qt::Checked : Qt::Unchecked); 296 302 mTwBootOrder->addItem(pItem); 297 303 } 298 /* Load other motherboard data to page: */ 299 int iChipsetTypePosition = m_pComboChipsetType->findData(systemData.m_chipsetType); 300 m_pComboChipsetType->setCurrentIndex(iChipsetTypePosition == -1 ? 0 : iChipsetTypePosition); 301 int iHIDTypePosition = m_pComboPointingHIDType->findData(systemData.m_pointingHIDType); 302 m_pComboPointingHIDType->setCurrentIndex(iHIDTypePosition == -1 ? 0 : iHIDTypePosition); 303 m_pCheckBoxApic->setChecked(systemData.m_fEnabledIoApic); 304 m_pCheckBoxEFI->setChecked(systemData.m_fEnabledEFI); 305 m_pCheckBoxUseUTC->setChecked(systemData.m_fEnabledUTC); 306 307 /* Load CPU data to page: */ 308 m_pSliderCPUCount->setValue(systemData.m_cCPUCount); 309 m_pSliderCPUExecCap->setValue(systemData.m_iCPUExecCap); 310 m_pCheckBoxPAE->setChecked(systemData.m_fEnabledPAE); 311 312 /* Load acceleration data to page: */ 313 int iParavirtProviderPosition = m_pComboParavirtProvider->findData(systemData.m_paravirtProvider); 304 305 /* Load old 'Processor' data to the page: */ 306 m_pSliderCPUCount->setValue(oldSystemData.m_cCPUCount); 307 m_pSliderCPUExecCap->setValue(oldSystemData.m_iCPUExecCap); 308 m_pCheckBoxPAE->setChecked(oldSystemData.m_fEnabledPAE); 309 310 /* Load old 'Acceleration' data to the page: */ 311 const int iParavirtProviderPosition = m_pComboParavirtProvider->findData(oldSystemData.m_paravirtProvider); 314 312 m_pComboParavirtProvider->setCurrentIndex(iParavirtProviderPosition == -1 ? 0 : iParavirtProviderPosition); 315 m_pCheckBoxVirtualization->setChecked( systemData.m_fEnabledHwVirtEx);316 m_pCheckBoxNestedPaging->setChecked( systemData.m_fEnabledNestedPaging);313 m_pCheckBoxVirtualization->setChecked(oldSystemData.m_fEnabledHwVirtEx); 314 m_pCheckBoxNestedPaging->setChecked(oldSystemData.m_fEnabledNestedPaging); 317 315 318 316 /* Polish page finally: */ … … 325 323 void UIMachineSettingsSystem::putToCache() 326 324 { 327 /* Prepare system data: */ 328 UIDataSettingsMachineSystem systemData = m_pCache->base(); 329 330 /* Gather motherboard data: */ 331 systemData.m_iMemorySize = m_pSliderMemorySize->value(); 325 /* Prepare new system data: */ 326 UIDataSettingsMachineSystem newSystemData; 327 328 /* Gather support flags: */ 329 newSystemData.m_fSupportedPAE = m_pCache->base().m_fSupportedPAE; 330 newSystemData.m_fSupportedHwVirtEx = m_pCache->base().m_fSupportedHwVirtEx; 331 332 /* Gather 'Motherboard' data: */ 333 newSystemData.m_iMemorySize = m_pSliderMemorySize->value(); 334 newSystemData.m_chipsetType = (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt(); 335 newSystemData.m_pointingHIDType = (KPointingHIDType)m_pComboPointingHIDType->itemData(m_pComboPointingHIDType->currentIndex()).toInt(); 336 newSystemData.m_fEnabledIoApic = m_pCheckBoxApic->isChecked() || m_pSliderCPUCount->value() > 1 || 337 (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9; 338 newSystemData.m_fEnabledEFI = m_pCheckBoxEFI->isChecked(); 339 newSystemData.m_fEnabledUTC = m_pCheckBoxUseUTC->isChecked(); 332 340 /* Gather boot-table data: */ 333 systemData.m_bootItems.clear();341 newSystemData.m_bootItems.clear(); 334 342 for (int i = 0; i < mTwBootOrder->count(); ++i) 335 343 { 336 344 QListWidgetItem *pItem = mTwBootOrder->item(i); 337 UIBootItemData data; 338 data.m_type = static_cast<UIBootTableItem*>(pItem)->type(); 339 data.m_fEnabled = pItem->checkState() == Qt::Checked; 340 systemData.m_bootItems << data; 341 } 342 /* Gather other motherboard data: */ 343 systemData.m_chipsetType = (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt(); 344 systemData.m_pointingHIDType = (KPointingHIDType)m_pComboPointingHIDType->itemData(m_pComboPointingHIDType->currentIndex()).toInt(); 345 systemData.m_fEnabledIoApic = m_pCheckBoxApic->isChecked() || m_pSliderCPUCount->value() > 1 || 346 (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9; 347 systemData.m_fEnabledEFI = m_pCheckBoxEFI->isChecked(); 348 systemData.m_fEnabledUTC = m_pCheckBoxUseUTC->isChecked(); 349 350 /* Gather CPU data: */ 351 systemData.m_cCPUCount = m_pSliderCPUCount->value(); 352 systemData.m_iCPUExecCap = m_pSliderCPUExecCap->value(); 353 systemData.m_fEnabledPAE = m_pCheckBoxPAE->isChecked(); 354 355 /* Gather acceleration data: */ 356 systemData.m_paravirtProvider = (KParavirtProvider)m_pComboParavirtProvider->itemData(m_pComboParavirtProvider->currentIndex()).toInt(); 357 systemData.m_fEnabledHwVirtEx = m_pCheckBoxVirtualization->checkState() == Qt::Checked || m_pSliderCPUCount->value() > 1; 358 systemData.m_fEnabledNestedPaging = m_pCheckBoxNestedPaging->isChecked(); 359 360 /* Cache system data: */ 361 m_pCache->cacheCurrentData(systemData); 345 UIBootItemData bootData; 346 bootData.m_type = static_cast<UIBootTableItem*>(pItem)->type(); 347 bootData.m_fEnabled = pItem->checkState() == Qt::Checked; 348 newSystemData.m_bootItems << bootData; 349 } 350 351 /* Gather 'Processor' data: */ 352 newSystemData.m_cCPUCount = m_pSliderCPUCount->value(); 353 newSystemData.m_iCPUExecCap = m_pSliderCPUExecCap->value(); 354 newSystemData.m_fEnabledPAE = m_pCheckBoxPAE->isChecked(); 355 356 /* Gather 'Acceleration' data: */ 357 newSystemData.m_paravirtProvider = (KParavirtProvider)m_pComboParavirtProvider->itemData(m_pComboParavirtProvider->currentIndex()).toInt(); 358 newSystemData.m_fEnabledHwVirtEx = m_pCheckBoxVirtualization->checkState() == Qt::Checked || m_pSliderCPUCount->value() > 1; 359 newSystemData.m_fEnabledNestedPaging = m_pCheckBoxNestedPaging->isChecked(); 360 361 /* Cache new system data: */ 362 m_pCache->cacheCurrentData(newSystemData); 362 363 } 363 364 … … 367 368 UISettingsPageMachine::fetchData(data); 368 369 369 /* Check if system data was changed: */ 370 if (m_pCache->wasChanged()) 371 { 372 /* Get system data from cache: */ 373 const UIDataSettingsMachineSystem &systemData = m_pCache->data(); 374 375 /* Store system data: */ 376 if (isMachineOffline()) 377 { 378 /* Motherboard tab: */ 379 m_machine.SetMemorySize(systemData.m_iMemorySize); 380 /* Save boot-items of current VM: */ 370 /* Make sure machine is in valid mode & system data was changed: */ 371 if (isMachineInValidMode() && m_pCache->wasChanged()) 372 { 373 /* Get old system data from the cache: */ 374 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base(); 375 /* Get new system data from the cache: */ 376 const UIDataSettingsMachineSystem &newSystemData = m_pCache->data(); 377 378 /* Store new 'Motherboard' data: */ 379 if (isMachineOffline() && newSystemData.m_iMemorySize != oldSystemData.m_iMemorySize) 380 m_machine.SetMemorySize(newSystemData.m_iMemorySize); 381 if (isMachineOffline() && newSystemData.m_chipsetType != oldSystemData.m_chipsetType) 382 m_machine.SetChipsetType(newSystemData.m_chipsetType); 383 if (isMachineOffline() && newSystemData.m_pointingHIDType != oldSystemData.m_pointingHIDType) 384 m_machine.SetPointingHIDType(newSystemData.m_pointingHIDType); 385 if (isMachineOffline() && newSystemData.m_fEnabledIoApic != oldSystemData.m_fEnabledIoApic) 386 m_machine.GetBIOSSettings().SetIOAPICEnabled(newSystemData.m_fEnabledIoApic); 387 if (isMachineOffline() && newSystemData.m_fEnabledEFI != oldSystemData.m_fEnabledEFI) 388 m_machine.SetFirmwareType(newSystemData.m_fEnabledEFI ? KFirmwareType_EFI : KFirmwareType_BIOS); 389 if (isMachineOffline() && newSystemData.m_fEnabledUTC != oldSystemData.m_fEnabledUTC) 390 m_machine.SetRTCUseUTC(newSystemData.m_fEnabledUTC); 391 if (isMachineOffline() && newSystemData.m_bootItems != oldSystemData.m_bootItems) 392 { 381 393 int iBootIndex = 0; 382 for (int i = 0; i < systemData.m_bootItems.size(); ++i)394 for (int i = 0; i < newSystemData.m_bootItems.size(); ++i) 383 395 { 384 if ( systemData.m_bootItems[i].m_fEnabled)385 m_machine.SetBootOrder(++iBootIndex, systemData.m_bootItems[i].m_type);396 if (newSystemData.m_bootItems.at(i).m_fEnabled) 397 m_machine.SetBootOrder(++iBootIndex, newSystemData.m_bootItems.at(i).m_type); 386 398 } 387 /* Save other unique boot-items: */ 388 for (int i = 0; i < systemData.m_bootItems.size(); ++i) 399 for (int i = 0; i < newSystemData.m_bootItems.size(); ++i) 389 400 { 390 if (! systemData.m_bootItems[i].m_fEnabled)401 if (!newSystemData.m_bootItems.at(i).m_fEnabled) 391 402 m_machine.SetBootOrder(++iBootIndex, KDeviceType_Null); 392 403 } 393 m_machine.SetChipsetType(systemData.m_chipsetType); 394 m_machine.SetPointingHIDType(systemData.m_pointingHIDType); 395 m_machine.GetBIOSSettings().SetIOAPICEnabled(systemData.m_fEnabledIoApic); 396 m_machine.SetFirmwareType(systemData.m_fEnabledEFI ? KFirmwareType_EFI : KFirmwareType_BIOS); 397 m_machine.SetRTCUseUTC(systemData.m_fEnabledUTC); 398 399 /* Processor tab: */ 400 m_machine.SetCPUCount(systemData.m_cCPUCount); 401 m_machine.SetCPUProperty(KCPUPropertyType_PAE, systemData.m_fEnabledPAE); 402 403 /* Acceleration tab: */ 404 m_machine.SetParavirtProvider(systemData.m_paravirtProvider); 405 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, systemData.m_fEnabledHwVirtEx); 406 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, systemData.m_fEnabledNestedPaging); 407 } 408 if (isMachineInValidMode()) 409 { 410 /* Processor tab: */ 411 m_machine.SetCPUExecutionCap(systemData.m_iCPUExecCap); 412 } 404 } 405 406 /* Store new 'Processor' data: */ 407 if (isMachineOffline() && newSystemData.m_cCPUCount != oldSystemData.m_cCPUCount) 408 m_machine.SetCPUCount(newSystemData.m_cCPUCount); 409 if (isMachineOffline() && newSystemData.m_fEnabledPAE != oldSystemData.m_fEnabledPAE) 410 m_machine.SetCPUProperty(KCPUPropertyType_PAE, newSystemData.m_fEnabledPAE); 411 if (newSystemData.m_iCPUExecCap != oldSystemData.m_iCPUExecCap) 412 m_machine.SetCPUExecutionCap(newSystemData.m_iCPUExecCap); 413 414 /* Store new 'Acceleration' data: */ 415 if (isMachineOffline() && newSystemData.m_paravirtProvider != oldSystemData.m_paravirtProvider) 416 m_machine.SetParavirtProvider(newSystemData.m_paravirtProvider); 417 if (isMachineOffline() && newSystemData.m_fEnabledHwVirtEx != oldSystemData.m_fEnabledHwVirtEx) 418 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_Enabled, newSystemData.m_fEnabledHwVirtEx); 419 if (isMachineOffline() && newSystemData.m_fEnabledNestedPaging != oldSystemData.m_fEnabledNestedPaging) 420 m_machine.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, newSystemData.m_fEnabledNestedPaging); 413 421 } 414 422 … … 586 594 void UIMachineSettingsSystem::polishPage() 587 595 { 588 /* Get system data from cache: */596 /* Get system data from the cache: */ 589 597 const UIDataSettingsMachineSystem &systemData = m_pCache->base(); 590 598
Note:
See TracChangeset
for help on using the changeset viewer.