VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp@ 104158

Last change on this file since 104158 was 103820, checked in by vboxsync, 11 months ago

FE/Qt: bugref:10384: VM settings / System page: Hiding TPM option for ARM host / ARM VMs same way as Chipset option in r161581.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 48.7 KB
Line 
1/* $Id: UIMachineSettingsSystem.cpp 103820 2024-03-13 10:30:05Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMachineSettingsSystem class implementation.
4 */
5
6/*
7 * Copyright (C) 2008-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QVBoxLayout>
30
31/* GUI includes: */
32#include "QITabWidget.h"
33#include "UIAccelerationFeaturesEditor.h"
34#include "UIBaseMemoryEditor.h"
35#include "UIBootOrderEditor.h"
36#include "UIChipsetEditor.h"
37#include "UIErrorString.h"
38#include "UIExecutionCapEditor.h"
39#include "UIGlobalSession.h"
40#include "UIMachineSettingsSystem.h"
41#include "UIMotherboardFeaturesEditor.h"
42#include "UIParavirtProviderEditor.h"
43#include "UIPointingHIDEditor.h"
44#include "UIProcessorFeaturesEditor.h"
45#include "UITpmEditor.h"
46#include "UITranslator.h"
47#include "UIVirtualCPUEditor.h"
48
49/* COM includes: */
50#include "CFirmwareSettings.h"
51#include "CPlatform.h"
52#include "CPlatformX86.h"
53#include "CNvramStore.h"
54#include "CTrustedPlatformModule.h"
55#include "CUefiVariableStore.h"
56
57
58/** Machine settings: System page data structure. */
59struct UIDataSettingsMachineSystem
60{
61 /** Constructs data. */
62 UIDataSettingsMachineSystem()
63 /* Support flags: */
64 : m_fSupportedPAE(false)
65 , m_fSupportedNestedHwVirtEx(false)
66 , m_fSupportedHwVirtEx(false)
67 , m_fSupportedNestedPaging(false)
68 /* Motherboard data: */
69 , m_iMemorySize(-1)
70 , m_bootItems(UIBootItemDataList())
71 , m_chipsetType(KChipsetType_Null)
72 , m_tpmType(KTpmType_None)
73 , m_pointingHIDType(KPointingHIDType_None)
74 , m_fEnabledIoApic(false)
75 , m_fEnabledEFI(false)
76 , m_fEnabledUTC(false)
77 , m_fAvailableSecureBoot(false)
78 , m_fEnabledSecureBoot(false)
79 , m_fResetSecureBoot(false)
80 /* CPU data: */
81 , m_cCPUCount(-1)
82 , m_iCPUExecCap(-1)
83 , m_fEnabledPAE(false)
84 , m_fEnabledNestedHwVirtEx(false)
85 /* Acceleration data: */
86 , m_paravirtProvider(KParavirtProvider_None)
87 , m_fEnabledNestedPaging(false)
88 {}
89
90 /** Returns whether the @a other passed data is equal to this one. */
91 bool equal(const UIDataSettingsMachineSystem &other) const
92 {
93 return true
94 /* Support flags: */
95 && (m_fSupportedPAE == other.m_fSupportedPAE)
96 && (m_fSupportedNestedHwVirtEx == other.m_fSupportedNestedHwVirtEx)
97 && (m_fSupportedHwVirtEx == other.m_fSupportedHwVirtEx)
98 && (m_fSupportedNestedPaging == other.m_fSupportedNestedPaging)
99 /* Motherboard data: */
100 && (m_iMemorySize == other.m_iMemorySize)
101 && (m_bootItems == other.m_bootItems)
102 && (m_chipsetType == other.m_chipsetType)
103 && (m_tpmType == other.m_tpmType)
104 && (m_pointingHIDType == other.m_pointingHIDType)
105 && (m_fEnabledIoApic == other.m_fEnabledIoApic)
106 && (m_fEnabledEFI == other.m_fEnabledEFI)
107 && (m_fEnabledUTC == other.m_fEnabledUTC)
108 && (m_fAvailableSecureBoot == other.m_fAvailableSecureBoot)
109 && (m_fEnabledSecureBoot == other.m_fEnabledSecureBoot)
110 && (m_fResetSecureBoot == other.m_fResetSecureBoot)
111 /* CPU data: */
112 && (m_cCPUCount == other.m_cCPUCount)
113 && (m_iCPUExecCap == other.m_iCPUExecCap)
114 && (m_fEnabledPAE == other.m_fEnabledPAE)
115 && (m_fEnabledNestedHwVirtEx == other.m_fEnabledNestedHwVirtEx)
116 /* Acceleration data: */
117 && (m_paravirtProvider == other.m_paravirtProvider)
118 && (m_fEnabledNestedPaging == other.m_fEnabledNestedPaging)
119 ;
120 }
121
122 /** Returns whether the @a other passed data is equal to this one. */
123 bool operator==(const UIDataSettingsMachineSystem &other) const { return equal(other); }
124 /** Returns whether the @a other passed data is different from this one. */
125 bool operator!=(const UIDataSettingsMachineSystem &other) const { return !equal(other); }
126
127 /** Holds whether the PAE is supported. */
128 bool m_fSupportedPAE;
129 /** Holds whether the Nested HW Virt Ex is supported. */
130 bool m_fSupportedNestedHwVirtEx;
131 /** Holds whether the HW Virt Ex is supported. */
132 bool m_fSupportedHwVirtEx;
133 /** Holds whether the Nested Paging is supported. */
134 bool m_fSupportedNestedPaging;
135
136 /** Holds the RAM size. */
137 int m_iMemorySize;
138 /** Holds the boot items. */
139 UIBootItemDataList m_bootItems;
140 /** Holds the chipset type. */
141 KChipsetType m_chipsetType;
142 /** Holds the TPM type. */
143 KTpmType m_tpmType;
144 /** Holds the pointing HID type. */
145 KPointingHIDType m_pointingHIDType;
146 /** Holds whether the IO APIC is enabled. */
147 bool m_fEnabledIoApic;
148 /** Holds whether the EFI is enabled. */
149 bool m_fEnabledEFI;
150 /** Holds whether the UTC is enabled. */
151 bool m_fEnabledUTC;
152 /** Holds whether the secure boot is available. */
153 bool m_fAvailableSecureBoot;
154 /** Holds whether the secure boot is enabled. */
155 bool m_fEnabledSecureBoot;
156 /** Holds whether the secure boot is reseted. */
157 bool m_fResetSecureBoot;
158
159 /** Holds the CPU count. */
160 int m_cCPUCount;
161 /** Holds the CPU execution cap. */
162 int m_iCPUExecCap;
163 /** Holds whether the PAE is enabled. */
164 bool m_fEnabledPAE;
165 /** Holds whether the Nested HW Virt Ex is enabled. */
166 bool m_fEnabledNestedHwVirtEx;
167
168 /** Holds the paravirtualization provider. */
169 KParavirtProvider m_paravirtProvider;
170 /** Holds whether the Nested Paging is enabled. */
171 bool m_fEnabledNestedPaging;
172};
173
174
175UIMachineSettingsSystem::UIMachineSettingsSystem()
176 : m_fIsUSBEnabled(false)
177 , m_pCache(0)
178 , m_pTabWidget(0)
179 , m_pTabMotherboard(0)
180 , m_pEditorBaseMemory(0)
181 , m_pEditorBootOrder(0)
182 , m_pEditorChipset(0)
183 , m_pEditorTpm(0)
184 , m_pEditorPointingHID(0)
185 , m_pEditorMotherboardFeatures(0)
186 , m_pTabProcessor(0)
187 , m_pEditorVCPU(0)
188 , m_pEditorExecCap(0)
189 , m_pEditorProcessorFeatures(0)
190 , m_pTabAcceleration(0)
191 , m_pEditorParavirtProvider(0)
192 , m_pEditorAccelerationFeatures(0)
193{
194 prepare();
195}
196
197UIMachineSettingsSystem::~UIMachineSettingsSystem()
198{
199 cleanup();
200}
201
202bool UIMachineSettingsSystem::isHWVirtExSupported() const
203{
204 AssertPtrReturn(m_pCache, false);
205 return m_pCache->base().m_fSupportedHwVirtEx;
206}
207
208bool UIMachineSettingsSystem::isNestedPagingSupported() const
209{
210 AssertPtrReturn(m_pCache, false);
211 return m_pCache->base().m_fSupportedNestedPaging;
212}
213
214bool UIMachineSettingsSystem::isNestedPagingEnabled() const
215{
216 return m_pEditorAccelerationFeatures
217 ? m_pEditorAccelerationFeatures->isEnabledNestedPaging()
218 : m_pCache->base().m_fEnabledNestedPaging;
219}
220
221bool UIMachineSettingsSystem::isNestedHWVirtExSupported() const
222{
223 AssertPtrReturn(m_pCache, false);
224 return m_pCache->base().m_fSupportedNestedHwVirtEx;
225}
226
227bool UIMachineSettingsSystem::isNestedHWVirtExEnabled() const
228{
229 return m_pEditorProcessorFeatures->isEnabledNestedVirtualization();
230}
231
232bool UIMachineSettingsSystem::isHIDEnabled() const
233{
234 return m_pEditorPointingHID->value() != KPointingHIDType_PS2Mouse;
235}
236
237KChipsetType UIMachineSettingsSystem::chipsetType() const
238{
239 return m_pEditorChipset
240 ? m_pEditorChipset->value()
241 : m_pCache->base().m_chipsetType;
242}
243
244void UIMachineSettingsSystem::setUSBEnabled(bool fEnabled)
245{
246 /* Make sure USB status has changed: */
247 if (m_fIsUSBEnabled == fEnabled)
248 return;
249
250 /* Update USB status value: */
251 m_fIsUSBEnabled = fEnabled;
252
253 /* Revalidate: */
254 revalidate();
255}
256
257bool UIMachineSettingsSystem::changed() const
258{
259 return m_pCache ? m_pCache->wasChanged() : false;
260}
261
262void UIMachineSettingsSystem::loadToCacheFrom(QVariant &data)
263{
264 /* Sanity check: */
265 if (!m_pCache)
266 return;
267
268 /* Fetch data to machine: */
269 UISettingsPageMachine::fetchData(data);
270
271 /* Clear cache initially: */
272 m_pCache->clear();
273
274 /* Prepare old data: */
275 UIDataSettingsMachineSystem oldSystemData;
276
277 CPlatform comPlatform = m_machine.GetPlatform();
278 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings();
279 CNvramStore comStoreLvl1 = m_machine.GetNonVolatileStore();
280 CUefiVariableStore comStoreLvl2 = comStoreLvl1.GetUefiVariableStore();
281
282 /* Gather support flags: */
283 oldSystemData.m_fSupportedPAE = gpGlobalSession->host().GetProcessorFeature(KProcessorFeature_PAE);
284 oldSystemData.m_fSupportedNestedHwVirtEx = gpGlobalSession->host().GetProcessorFeature(KProcessorFeature_NestedHWVirt);
285 oldSystemData.m_fSupportedHwVirtEx = gpGlobalSession->host().GetProcessorFeature(KProcessorFeature_HWVirtEx);
286 oldSystemData.m_fSupportedNestedPaging = gpGlobalSession->host().GetProcessorFeature(KProcessorFeature_NestedPaging);
287
288 /* Gather old 'Motherboard' data: */
289 oldSystemData.m_iMemorySize = m_machine.GetMemorySize();
290 oldSystemData.m_bootItems = loadBootItems(m_machine);
291 oldSystemData.m_chipsetType = comPlatform.GetChipsetType();
292 oldSystemData.m_tpmType = m_machine.GetTrustedPlatformModule().GetType();
293 oldSystemData.m_pointingHIDType = m_machine.GetPointingHIDType();
294 oldSystemData.m_fEnabledIoApic = comFirmwareSettings.GetIOAPICEnabled();
295 oldSystemData.m_fEnabledEFI = comFirmwareSettings.GetFirmwareType() >= KFirmwareType_EFI && comFirmwareSettings.GetFirmwareType() <= KFirmwareType_EFIDUAL;
296 oldSystemData.m_fEnabledUTC = comPlatform.GetRTCUseUTC();
297 oldSystemData.m_fAvailableSecureBoot = comStoreLvl2.isNotNull();
298 oldSystemData.m_fEnabledSecureBoot = oldSystemData.m_fAvailableSecureBoot
299 ? comStoreLvl2.GetSecureBootEnabled()
300 : false;
301 oldSystemData.m_fResetSecureBoot = false;
302
303 /* Gather old 'Processor' data: */
304 oldSystemData.m_cCPUCount = oldSystemData.m_fSupportedHwVirtEx ? m_machine.GetCPUCount() : 1;
305 oldSystemData.m_iCPUExecCap = m_machine.GetCPUExecutionCap();
306 switch (comPlatform.GetArchitecture())
307 {
308 case KPlatformArchitecture_x86:
309 {
310 CPlatformX86 comPlatformX86 = comPlatform.GetX86();
311 oldSystemData.m_fEnabledPAE = comPlatformX86.GetCPUProperty(KCPUPropertyTypeX86_PAE);
312 oldSystemData.m_fEnabledNestedHwVirtEx = comPlatformX86.GetCPUProperty(KCPUPropertyTypeX86_HWVirt);
313 oldSystemData.m_fEnabledNestedPaging = comPlatformX86.GetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging);
314 break;
315 }
316#ifdef VBOX_WITH_VIRT_ARMV8
317 case KPlatformArchitecture_ARM:
318 {
319 /** @todo BUGBUG ARM stuff goes here. */
320 break;
321 }
322#endif
323 default:
324 break;
325 }
326
327 /* Gather old 'Acceleration' data: */
328 oldSystemData.m_paravirtProvider = m_machine.GetParavirtProvider();
329
330 /* Cache old data: */
331 m_pCache->cacheInitialData(oldSystemData);
332
333 /* Upload machine to data: */
334 UISettingsPageMachine::uploadData(data);
335}
336
337void UIMachineSettingsSystem::getFromCache()
338{
339 /* Sanity check: */
340 if (!m_pCache)
341 return;
342
343 /* Get old data from cache: */
344 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
345
346 /* Load old 'Motherboard' data from cache: */
347 if (m_pEditorBaseMemory)
348 m_pEditorBaseMemory->setValue(oldSystemData.m_iMemorySize);
349 if (m_pEditorBootOrder)
350 m_pEditorBootOrder->setValue(oldSystemData.m_bootItems);
351 if (m_pEditorChipset)
352 m_pEditorChipset->setValue(oldSystemData.m_chipsetType);
353 if (m_pEditorTpm)
354 m_pEditorTpm->setValue(oldSystemData.m_tpmType);
355 if (m_pEditorPointingHID)
356 m_pEditorPointingHID->setValue(oldSystemData.m_pointingHIDType);
357 if (m_pEditorMotherboardFeatures)
358 {
359 m_pEditorMotherboardFeatures->setEnableIoApic(oldSystemData.m_fEnabledIoApic);
360 m_pEditorMotherboardFeatures->setEnableEfi(oldSystemData.m_fEnabledEFI);
361 m_pEditorMotherboardFeatures->setEnableUtcTime(oldSystemData.m_fEnabledUTC);
362 m_pEditorMotherboardFeatures->setEnableSecureBoot(oldSystemData.m_fEnabledSecureBoot);
363 }
364
365 /* Load old 'Processor' data from cache: */
366 if (m_pEditorVCPU)
367 m_pEditorVCPU->setValue(oldSystemData.m_cCPUCount);
368 if (m_pEditorExecCap)
369 m_pEditorExecCap->setValue(oldSystemData.m_iCPUExecCap);
370 if (m_pEditorProcessorFeatures)
371 {
372 m_pEditorProcessorFeatures->setEnablePae(oldSystemData.m_fEnabledPAE);
373 m_pEditorProcessorFeatures->setEnableNestedVirtualization(oldSystemData.m_fEnabledNestedHwVirtEx);
374 }
375
376 /* Load old 'Acceleration' data from cache: */
377 if (m_pEditorParavirtProvider)
378 m_pEditorParavirtProvider->setValue(oldSystemData.m_paravirtProvider);
379 if (m_pEditorAccelerationFeatures)
380 m_pEditorAccelerationFeatures->setEnableNestedPaging(oldSystemData.m_fEnabledNestedPaging);
381
382 /* Polish page finally: */
383 polishPage();
384
385 /* Revalidate: */
386 revalidate();
387}
388
389void UIMachineSettingsSystem::putToCache()
390{
391 /* Sanity check: */
392 if (!m_pCache)
393 return;
394
395 /* Prepare new data: */
396 UIDataSettingsMachineSystem newSystemData;
397
398 /* Gather support flags: */
399 newSystemData.m_fSupportedPAE = m_pCache->base().m_fSupportedPAE;
400 newSystemData.m_fSupportedNestedHwVirtEx = isNestedHWVirtExSupported();
401 newSystemData.m_fSupportedHwVirtEx = isHWVirtExSupported();
402 newSystemData.m_fSupportedNestedPaging = isNestedPagingSupported();
403
404 /* Gather 'Motherboard' data: */
405 if (m_pEditorBaseMemory)
406 newSystemData.m_iMemorySize = m_pEditorBaseMemory->value();
407 if (m_pEditorBootOrder)
408 newSystemData.m_bootItems = m_pEditorBootOrder->value();
409 newSystemData.m_chipsetType = chipsetType();
410 if (m_pEditorTpm)
411 newSystemData.m_tpmType = m_pEditorTpm->value();
412 if (m_pEditorPointingHID)
413 newSystemData.m_pointingHIDType = m_pEditorPointingHID->value();
414 if ( m_pEditorMotherboardFeatures
415 && m_pEditorVCPU)
416 newSystemData.m_fEnabledIoApic = m_pEditorMotherboardFeatures->isEnabledIoApic()
417 || m_pEditorVCPU->value() > 1
418 || chipsetType() == KChipsetType_ICH9;
419 if (m_pEditorMotherboardFeatures)
420 newSystemData.m_fEnabledEFI = m_pEditorMotherboardFeatures->isEnabledEfi();
421 if (m_pEditorMotherboardFeatures)
422 newSystemData.m_fEnabledUTC = m_pEditorMotherboardFeatures->isEnabledUtcTime();
423 if (m_pEditorMotherboardFeatures)
424 {
425 newSystemData.m_fAvailableSecureBoot = m_pCache->base().m_fAvailableSecureBoot;
426 newSystemData.m_fEnabledSecureBoot = m_pEditorMotherboardFeatures->isEnabledSecureBoot();
427 newSystemData.m_fResetSecureBoot = m_pEditorMotherboardFeatures->isResetSecureBoot();
428 }
429
430 /* Gather 'Processor' data: */
431 if (m_pEditorVCPU)
432 newSystemData.m_cCPUCount = m_pEditorVCPU->value();
433 if (m_pEditorExecCap)
434 newSystemData.m_iCPUExecCap = m_pEditorExecCap->value();
435 if (m_pEditorProcessorFeatures)
436 newSystemData.m_fEnabledPAE = m_pEditorProcessorFeatures->isEnabledPae();
437 newSystemData.m_fEnabledNestedHwVirtEx = isNestedHWVirtExEnabled();
438
439 /* Gather 'Acceleration' data: */
440 if (m_pEditorParavirtProvider)
441 newSystemData.m_paravirtProvider = m_pEditorParavirtProvider->value();
442 /* Enable Nested Paging automatically if it's supported and
443 * Nested HW Virt Ex is requested. */
444 newSystemData.m_fEnabledNestedPaging = isNestedPagingEnabled()
445 || ( isNestedPagingSupported()
446 && isNestedHWVirtExEnabled());
447
448 /* Cache new data: */
449 m_pCache->cacheCurrentData(newSystemData);
450}
451
452void UIMachineSettingsSystem::saveFromCacheTo(QVariant &data)
453{
454 /* Fetch data to machine: */
455 UISettingsPageMachine::fetchData(data);
456
457 /* Update data and failing state: */
458 setFailed(!saveData());
459
460 /* Upload machine to data: */
461 UISettingsPageMachine::uploadData(data);
462}
463
464bool UIMachineSettingsSystem::validate(QList<UIValidationMessage> &messages)
465{
466 /* Pass by default: */
467 bool fPass = true;
468
469 /* Motherboard tab: */
470 {
471 /* Prepare message: */
472 UIValidationMessage message;
473 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(0));
474
475 /* RAM amount test: */
476 const ulong uFullSize = gpGlobalSession->host().GetMemorySize();
477 if (m_pEditorBaseMemory->value() > (int)m_pEditorBaseMemory->maxRAMAlw())
478 {
479 message.second << tr(
480 "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
481 "Not enough memory is left for the host operating system. Please select a smaller amount.")
482 .arg((unsigned)qRound((double)m_pEditorBaseMemory->maxRAMAlw() / uFullSize * 100.0))
483 .arg(UITranslator::formatSize((uint64_t)uFullSize * _1M));
484 fPass = false;
485 }
486 else if (m_pEditorBaseMemory->value() > (int)m_pEditorBaseMemory->maxRAMOpt())
487 {
488 message.second << tr(
489 "More than <b>%1%</b> of the host computer's memory (<b>%2</b>) is assigned to the virtual machine. "
490 "There might not be enough memory left for the host operating system. Please consider selecting a smaller amount.")
491 .arg((unsigned)qRound((double)m_pEditorBaseMemory->maxRAMOpt() / uFullSize * 100.0))
492 .arg(UITranslator::formatSize((uint64_t)uFullSize * _1M));
493 }
494
495 /* Chipset type vs IO-APIC test: */
496 if ( chipsetType() == KChipsetType_ICH9
497 && !m_pEditorMotherboardFeatures->isEnabledIoApic())
498 {
499 message.second << tr(
500 "The I/O APIC feature is not currently enabled in the Motherboard section of the System page. "
501 "This is needed to support a chipset of type ICH9. "
502 "It will be enabled automatically if you confirm your changes.");
503 }
504
505 /* HID vs USB test: */
506 if (isHIDEnabled() && !m_fIsUSBEnabled)
507 {
508 message.second << tr(
509 "The USB controller emulation is not currently enabled on the USB page. "
510 "This is needed to support an emulated USB pointing device. "
511 "It will be enabled automatically if you confirm your changes.");
512 }
513
514 /* Serialize message: */
515 if (!message.second.isEmpty())
516 messages << message;
517 }
518
519 /* CPU tab: */
520 {
521 /* Prepare message: */
522 UIValidationMessage message;
523 message.first = UITranslator::removeAccelMark(m_pTabWidget->tabText(1));
524
525 /* VCPU amount test: */
526 const int cTotalCPUs = gpGlobalSession->host().GetProcessorOnlineCoreCount();
527 if (m_pEditorVCPU->value() > 2 * cTotalCPUs)
528 {
529 message.second << tr(
530 "For performance reasons, the number of virtual CPUs attached to the virtual machine may not be more than twice the number "
531 "of physical CPUs on the host (<b>%1</b>). Please reduce the number of virtual CPUs.")
532 .arg(cTotalCPUs);
533 fPass = false;
534 }
535 else if (m_pEditorVCPU->value() > cTotalCPUs)
536 {
537 message.second << tr(
538 "More virtual CPUs are assigned to the virtual machine than the number of physical CPUs on the host system (<b>%1</b>). "
539 "This is likely to degrade the performance of your virtual machine. Please consider reducing the number of virtual CPUs.")
540 .arg(cTotalCPUs);
541 }
542
543 /* VCPU vs IO-APIC test: */
544 if (m_pEditorVCPU->value() > 1 && !m_pEditorMotherboardFeatures->isEnabledIoApic())
545 {
546 message.second << tr(
547 "The I/O APIC feature is not currently enabled in the Motherboard section of the System page. "
548 "This is needed to support more than one virtual processor. "
549 "It will be enabled automatically if you confirm your changes.");
550 }
551
552 /* CPU execution cap test: */
553 if (m_pEditorExecCap->value() < m_pEditorExecCap->medExecCap())
554 {
555 message.second << tr("The processor execution cap is set to a low value. This may make the machine feel slow to respond.");
556 }
557
558 /* Warn user about possible performance degradation and suggest lowering # of CPUs assigned to the VM instead: */
559 if (m_pEditorExecCap->value() < 100)
560 {
561 if (m_pEditorVCPU->maxVCPUCount() > 1 && m_pEditorVCPU->value() > 1)
562 {
563 message.second << tr("Please consider lowering the number of CPUs assigned to the virtual machine rather "
564 "than setting the processor execution cap.");
565 }
566 else if (m_pEditorVCPU->maxVCPUCount() > 1)
567 {
568 message.second << tr("Lowering the processor execution cap may result in a decline in performance.");
569 }
570 }
571
572 /* Nested HW Virt Ex: */
573 if (isNestedHWVirtExEnabled())
574 {
575 /* Nested Paging test: */
576 if (isHWVirtExSupported() && isNestedPagingSupported() && !isNestedPagingEnabled())
577 {
578 message.second << tr(
579 "The nested paging is not currently enabled in the Acceleration section of the System page. "
580 "This is needed to support nested hardware virtualization. "
581 "It will be enabled automatically if you confirm your changes.");
582 }
583 }
584
585 /* Serialize message: */
586 if (!message.second.isEmpty())
587 messages << message;
588 }
589
590 /* Return result: */
591 return fPass;
592}
593
594void UIMachineSettingsSystem::setOrderAfter(QWidget *pWidget)
595{
596 /* Configure navigation for 'motherboard' tab: */
597 setTabOrder(pWidget, m_pTabWidget->focusProxy());
598 setTabOrder(m_pTabWidget->focusProxy(), m_pEditorBaseMemory);
599 setTabOrder(m_pEditorBaseMemory, m_pEditorBootOrder);
600 setTabOrder(m_pEditorBootOrder, m_pEditorChipset);
601 setTabOrder(m_pEditorChipset, m_pEditorTpm);
602 setTabOrder(m_pEditorTpm, m_pEditorPointingHID);
603 setTabOrder(m_pEditorPointingHID, m_pEditorMotherboardFeatures);
604 setTabOrder(m_pEditorMotherboardFeatures, m_pEditorVCPU);
605
606 /* Configure navigation for 'processor' tab: */
607 setTabOrder(m_pEditorVCPU, m_pEditorExecCap);
608 setTabOrder(m_pEditorExecCap, m_pEditorProcessorFeatures);
609 setTabOrder(m_pEditorProcessorFeatures, m_pEditorParavirtProvider);
610
611 /* Configure navigation for 'acceleration' tab: */
612 setTabOrder(m_pEditorParavirtProvider, m_pEditorAccelerationFeatures);
613}
614
615void UIMachineSettingsSystem::retranslateUi()
616{
617 m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabMotherboard), tr("&Motherboard"));
618 m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabProcessor), tr("&Processor"));
619 m_pTabWidget->setTabText(m_pTabWidget->indexOf(m_pTabAcceleration), tr("Acce&leration"));
620
621 updateMinimumLayoutHint();
622}
623
624void UIMachineSettingsSystem::handleFilterChange()
625{
626 /* Update some stuff: */
627 updateOptionSet();
628 updateMinimumLayoutHint();
629}
630
631void UIMachineSettingsSystem::polishPage()
632{
633 /* Get old data from cache: */
634 const UIDataSettingsMachineSystem &systemData = m_pCache->base();
635
636 /* Polish 'Motherboard' availability: */
637 m_pEditorBaseMemory->setEnabled(isMachineOffline());
638 m_pEditorBootOrder->setEnabled(isMachineOffline());
639 if (m_pEditorChipset)
640 m_pEditorChipset->setEnabled(isMachineOffline());
641 if (m_pEditorTpm)
642 m_pEditorTpm->setEnabled(isMachineOffline());
643 m_pEditorPointingHID->setEnabled(isMachineOffline());
644 m_pEditorMotherboardFeatures->setEnabled(isMachineOffline());
645
646 /* Polish 'Processor' availability: */
647 m_pEditorVCPU->setEnabled(isMachineOffline() && systemData.m_fSupportedHwVirtEx);
648 m_pEditorExecCap->setEnabled(isMachineInValidMode());
649 m_pEditorProcessorFeatures->setEnablePaeAvailable(isMachineOffline() && systemData.m_fSupportedPAE);
650 m_pEditorProcessorFeatures->setEnableNestedVirtualizationAvailable( isMachineOffline()
651 && ( systemData.m_fSupportedNestedHwVirtEx
652 || systemData.m_fEnabledNestedHwVirtEx));
653
654 /* Polish 'Acceleration' availability: */
655 m_pEditorParavirtProvider->setEnabled(isMachineOffline());
656 if (m_pEditorAccelerationFeatures)
657 {
658 m_pEditorAccelerationFeatures->setEnabled(isMachineOffline());
659 m_pEditorAccelerationFeatures->setEnableNestedPagingAvailable( (systemData.m_fSupportedNestedPaging && isMachineOffline())
660 || (systemData.m_fEnabledNestedPaging && isMachineOffline()));
661 }
662
663 /* Update option set: */
664 updateOptionSet();
665}
666
667void UIMachineSettingsSystem::prepare()
668{
669 /* Prepare cache: */
670 m_pCache = new UISettingsCacheMachineSystem;
671 AssertPtrReturnVoid(m_pCache);
672
673 /* Prepare everything: */
674 prepareWidgets();
675 prepareConnections();
676
677 /* Update option set: */
678 updateOptionSet();
679
680 /* Apply language settings: */
681 retranslateUi();
682}
683
684void UIMachineSettingsSystem::prepareWidgets()
685{
686 /* Prepare main layout: */
687 QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
688 if (pLayoutMain)
689 {
690 /* Prepare tab-widget: */
691 m_pTabWidget = new QITabWidget(this);
692 if (m_pTabWidget)
693 {
694 /* Prepare each tab separately: */
695 prepareTabMotherboard();
696 prepareTabProcessor();
697 prepareTabAcceleration();
698
699 pLayoutMain->addWidget(m_pTabWidget);
700 }
701 }
702}
703
704void UIMachineSettingsSystem::prepareTabMotherboard()
705{
706 /* Prepare 'Motherboard' tab: */
707 m_pTabMotherboard = new UIEditor(m_pTabWidget);
708 if (m_pTabMotherboard)
709 {
710 /* Prepare 'Motherboard' tab layout: */
711 QGridLayout *pLayoutMotherboard = new QGridLayout(m_pTabMotherboard);
712 if (pLayoutMotherboard)
713 {
714 pLayoutMotherboard->setColumnStretch(1, 1);
715 pLayoutMotherboard->setRowStretch(6, 1);
716#ifdef VBOX_WS_MAC
717 /* On Mac OS X we can do a bit of smoothness: */
718 int iLeft, iTop, iRight, iBottom;
719 pLayoutMotherboard->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
720 pLayoutMotherboard->setContentsMargins(iLeft / 2, iTop / 2, iRight / 2, iBottom / 2);
721#endif
722
723 /* Prepare base memory editor: */
724 m_pEditorBaseMemory = new UIBaseMemoryEditor(m_pTabMotherboard);
725 if (m_pEditorBaseMemory)
726 {
727 m_pTabMotherboard->addEditor(m_pEditorBaseMemory);
728 pLayoutMotherboard->addWidget(m_pEditorBaseMemory, 0, 0, 1, 2);
729 }
730
731 /* Prepare boot order editor: */
732 m_pEditorBootOrder = new UIBootOrderEditor(m_pTabMotherboard);
733 if (m_pEditorBootOrder)
734 {
735 m_pTabMotherboard->addEditor(m_pEditorBootOrder);
736 pLayoutMotherboard->addWidget(m_pEditorBootOrder, 1, 0);
737 }
738
739 /* Prepare chipset editor: */
740 m_pEditorChipset = new UIChipsetEditor(m_pTabMotherboard);
741 if (m_pEditorChipset)
742 {
743 m_pTabMotherboard->addEditor(m_pEditorChipset);
744 pLayoutMotherboard->addWidget(m_pEditorChipset, 2, 0);
745 }
746
747 /* Prepare TPM editor: */
748 m_pEditorTpm = new UITpmEditor(m_pTabMotherboard);
749 if (m_pEditorTpm)
750 {
751 m_pTabMotherboard->addEditor(m_pEditorTpm);
752 pLayoutMotherboard->addWidget(m_pEditorTpm, 3, 0);
753 }
754
755 /* Prepare pointing HID editor: */
756 m_pEditorPointingHID = new UIPointingHIDEditor(m_pTabMotherboard);
757 if (m_pEditorPointingHID)
758 {
759 m_pTabMotherboard->addEditor(m_pEditorPointingHID);
760 pLayoutMotherboard->addWidget(m_pEditorPointingHID, 4, 0);
761 }
762
763 /* Prepare motherboard features editor: */
764 m_pEditorMotherboardFeatures = new UIMotherboardFeaturesEditor(m_pTabMotherboard);
765 if (m_pEditorMotherboardFeatures)
766 {
767 m_pTabMotherboard->addEditor(m_pEditorMotherboardFeatures);
768 pLayoutMotherboard->addWidget(m_pEditorMotherboardFeatures, 5, 0);
769 }
770 }
771
772 addEditor(m_pTabMotherboard);
773 m_pTabWidget->addTab(m_pTabMotherboard, QString());
774 }
775}
776
777void UIMachineSettingsSystem::prepareTabProcessor()
778{
779 /* Prepare 'Processor' tab: */
780 m_pTabProcessor = new UIEditor(m_pTabWidget);
781 if (m_pTabProcessor)
782 {
783 /* Prepare 'Processor' tab layout: */
784 QGridLayout *pLayoutProcessor = new QGridLayout(m_pTabProcessor);
785 if (pLayoutProcessor)
786 {
787 pLayoutProcessor->setColumnStretch(1, 1);
788 pLayoutProcessor->setRowStretch(3, 1);
789#ifdef VBOX_WS_MAC
790 /* On Mac OS X we can do a bit of smoothness: */
791 int iLeft, iTop, iRight, iBottom;
792 pLayoutProcessor->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
793 pLayoutProcessor->setContentsMargins(iLeft / 2, iTop / 2, iRight / 2, iBottom / 2);
794#endif
795
796 /* Prepare VCPU editor : */
797 m_pEditorVCPU = new UIVirtualCPUEditor(m_pTabProcessor);
798 if (m_pEditorVCPU)
799 {
800 m_pTabProcessor->addEditor(m_pEditorVCPU);
801 pLayoutProcessor->addWidget(m_pEditorVCPU, 0, 0, 1, 2);
802 }
803
804 /* Prepare exec cap editor : */
805 m_pEditorExecCap = new UIExecutionCapEditor(m_pTabProcessor);
806 if (m_pEditorExecCap)
807 {
808 m_pTabProcessor->addEditor(m_pEditorExecCap);
809 pLayoutProcessor->addWidget(m_pEditorExecCap, 1, 0, 1, 2);
810 }
811
812 /* Prepare processor features editor: */
813 m_pEditorProcessorFeatures = new UIProcessorFeaturesEditor(m_pTabProcessor);
814 if (m_pEditorProcessorFeatures)
815 {
816 m_pTabProcessor->addEditor(m_pEditorProcessorFeatures);
817 pLayoutProcessor->addWidget(m_pEditorProcessorFeatures, 2, 0);
818 }
819 }
820
821 addEditor(m_pTabProcessor);
822 m_pTabWidget->addTab(m_pTabProcessor, QString());
823 }
824}
825
826void UIMachineSettingsSystem::prepareTabAcceleration()
827{
828 /* Prepare 'Acceleration' tab: */
829 m_pTabAcceleration = new UIEditor(m_pTabWidget);
830 if (m_pTabAcceleration)
831 {
832 /* Prepare 'Acceleration' tab layout: */
833 QGridLayout *pLayoutAcceleration = new QGridLayout(m_pTabAcceleration);
834 if (pLayoutAcceleration)
835 {
836 pLayoutAcceleration->setColumnStretch(2, 1);
837 pLayoutAcceleration->setRowStretch(3, 1);
838#ifdef VBOX_WS_MAC
839 /* On Mac OS X we can do a bit of smoothness: */
840 int iLeft, iTop, iRight, iBottom;
841 pLayoutAcceleration->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
842 pLayoutAcceleration->setContentsMargins(iLeft / 2, iTop / 2, iRight / 2, iBottom / 2);
843#endif
844
845 /* Prepare paravirtualization provider editor: */
846 m_pEditorParavirtProvider = new UIParavirtProviderEditor(m_pTabAcceleration);
847 if (m_pEditorParavirtProvider)
848 {
849 m_pTabAcceleration->addEditor(m_pEditorParavirtProvider);
850 pLayoutAcceleration->addWidget(m_pEditorParavirtProvider, 0, 0, 1, 2);
851 }
852
853 /* Prepare acceleration features editor: */
854#ifndef VBOX_WITH_VIRT_ARMV8
855 m_pEditorAccelerationFeatures = new UIAccelerationFeaturesEditor(m_pTabAcceleration);
856#endif
857 if (m_pEditorAccelerationFeatures)
858 {
859 m_pTabAcceleration->addEditor(m_pEditorAccelerationFeatures);
860 pLayoutAcceleration->addWidget(m_pEditorAccelerationFeatures, 1, 0);
861 }
862
863 addEditor(m_pTabAcceleration);
864 m_pTabWidget->addTab(m_pTabAcceleration, QString());
865 }
866 }
867}
868
869void UIMachineSettingsSystem::prepareConnections()
870{
871 /* Configure 'Motherboard' connections: */
872 if (m_pEditorChipset)
873 connect(m_pEditorChipset, &UIChipsetEditor::sigValueChanged,
874 this, &UIMachineSettingsSystem::revalidate);
875 if (m_pEditorTpm)
876 connect(m_pEditorTpm, &UITpmEditor::sigValueChanged,
877 this, &UIMachineSettingsSystem::revalidate);
878 connect(m_pEditorPointingHID, &UIPointingHIDEditor::sigValueChanged,
879 this, &UIMachineSettingsSystem::revalidate);
880 connect(m_pEditorBaseMemory, &UIBaseMemoryEditor::sigValidChanged,
881 this, &UIMachineSettingsSystem::revalidate);
882 connect(m_pEditorMotherboardFeatures, &UIMotherboardFeaturesEditor::sigChangedIoApic,
883 this, &UIMachineSettingsSystem::revalidate);
884
885 /* Configure 'Processor' connections: */
886 connect(m_pEditorVCPU, &UIVirtualCPUEditor::sigValueChanged,
887 this, &UIMachineSettingsSystem::revalidate);
888 connect(m_pEditorExecCap, &UIExecutionCapEditor::sigValueChanged,
889 this, &UIMachineSettingsSystem::revalidate);
890 connect(m_pEditorProcessorFeatures, &UIProcessorFeaturesEditor::sigChangedNestedVirtualization,
891 this, &UIMachineSettingsSystem::revalidate);
892
893 /* Configure 'Acceleration' connections: */
894 if (m_pEditorAccelerationFeatures)
895 connect(m_pEditorAccelerationFeatures, &UIAccelerationFeaturesEditor::sigChangedNestedPaging,
896 this, &UIMachineSettingsSystem::revalidate);
897}
898
899void UIMachineSettingsSystem::updateOptionSet()
900{
901 /* Load currently propagated arch type: */
902 const KPlatformArchitecture enmArch = optionalFlags().contains("arch")
903 ? optionalFlags().value("arch").value<KPlatformArchitecture>()
904 : KPlatformArchitecture_x86;
905
906 /* Some options visible only for x86 machines: */
907 const bool fx86 = enmArch == KPlatformArchitecture_x86;
908 if (m_pEditorChipset)
909 m_pEditorChipset->setVisible(fx86);
910 if (m_pEditorTpm)
911 m_pEditorTpm->setVisible(fx86);
912 m_pEditorProcessorFeatures->setVisible(fx86);
913}
914
915void UIMachineSettingsSystem::cleanup()
916{
917 /* Cleanup cache: */
918 delete m_pCache;
919 m_pCache = 0;
920}
921
922bool UIMachineSettingsSystem::saveData()
923{
924 /* Sanity check: */
925 if (!m_pCache)
926 return false;
927
928 /* Prepare result: */
929 bool fSuccess = true;
930 /* Save general settings from cache: */
931 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged())
932 {
933 /* Save 'Motherboard' data from cache: */
934 if (fSuccess)
935 fSuccess = saveMotherboardData();
936 /* Save 'Processor' data from cache: */
937 if (fSuccess)
938 fSuccess = saveProcessorData();
939 /* Save 'Acceleration' data from cache: */
940 if (fSuccess)
941 fSuccess = saveAccelerationData();
942 }
943 /* Return result: */
944 return fSuccess;
945}
946
947bool UIMachineSettingsSystem::saveMotherboardData()
948{
949 /* Sanity check: */
950 if (!m_pCache)
951 return false;
952
953 /* Prepare result: */
954 bool fSuccess = true;
955 /* Save 'Motherboard' settings from cache: */
956 if (fSuccess)
957 {
958 /* Get old data from cache: */
959 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
960 /* Get new data from cache: */
961 const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
962
963 /* Save memory size: */
964 if (fSuccess && isMachineOffline() && newSystemData.m_iMemorySize != oldSystemData.m_iMemorySize)
965 {
966 m_machine.SetMemorySize(newSystemData.m_iMemorySize);
967 fSuccess = m_machine.isOk();
968 }
969 /* Save boot items: */
970 if (fSuccess && isMachineOffline() && newSystemData.m_bootItems != oldSystemData.m_bootItems)
971 {
972 saveBootItems(newSystemData.m_bootItems, m_machine);
973 fSuccess = m_machine.isOk();
974 }
975 /* Save chipset type: */
976 if (fSuccess && isMachineOffline() && newSystemData.m_chipsetType != oldSystemData.m_chipsetType)
977 {
978 CPlatform comPlatform = m_machine.GetPlatform();
979 comPlatform.SetChipsetType(newSystemData.m_chipsetType);
980 fSuccess = comPlatform.isOk();
981 /// @todo convey error info ..
982 }
983 /* Save TPM type: */
984 if (fSuccess && isMachineOffline() && newSystemData.m_tpmType != oldSystemData.m_tpmType)
985 {
986 CTrustedPlatformModule comModule = m_machine.GetTrustedPlatformModule();
987 comModule.SetType(newSystemData.m_tpmType);
988 fSuccess = comModule.isOk();
989 /// @todo convey error info ..
990 }
991 /* Save pointing HID type: */
992 if (fSuccess && isMachineOffline() && newSystemData.m_pointingHIDType != oldSystemData.m_pointingHIDType)
993 {
994 m_machine.SetPointingHIDType(newSystemData.m_pointingHIDType);
995 fSuccess = m_machine.isOk();
996 }
997 /* Save whether IO APIC is enabled: */
998 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledIoApic != oldSystemData.m_fEnabledIoApic)
999 {
1000 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings();
1001 comFirmwareSettings.SetIOAPICEnabled(newSystemData.m_fEnabledIoApic);
1002 fSuccess = comFirmwareSettings.isOk();
1003 /// @todo convey error info ..
1004 }
1005 /* Save firware type (whether EFI is enabled): */
1006 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledEFI != oldSystemData.m_fEnabledEFI)
1007 {
1008 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings();
1009 comFirmwareSettings.SetFirmwareType(newSystemData.m_fEnabledEFI ? KFirmwareType_EFI : KFirmwareType_BIOS);
1010 fSuccess = comFirmwareSettings.isOk();
1011 /// @todo convey error info ..
1012 }
1013 /* Save whether UTC is enabled: */
1014 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledUTC != oldSystemData.m_fEnabledUTC)
1015 {
1016 CPlatform comPlatform = m_machine.GetPlatform();
1017 comPlatform.SetRTCUseUTC(newSystemData.m_fEnabledUTC);
1018 fSuccess = comPlatform.isOk();
1019 /// @todo convey error info ..
1020 }
1021 /* Save whether secure boot is enabled: */
1022 if ( fSuccess && isMachineOffline()
1023 && ( newSystemData.m_fEnabledSecureBoot != oldSystemData.m_fEnabledSecureBoot
1024 || newSystemData.m_fResetSecureBoot != oldSystemData.m_fResetSecureBoot))
1025 {
1026 CNvramStore comStoreLvl1 = m_machine.GetNonVolatileStore();
1027 CUefiVariableStore comStoreLvl2 = comStoreLvl1.GetUefiVariableStore();
1028
1029 /* Enabling secure boot? */
1030 if ( newSystemData.m_fEnabledSecureBoot
1031 && newSystemData.m_fEnabledEFI)
1032 {
1033 /* Secure boot was NOT available
1034 * or requested to be reseted: */
1035 if ( !newSystemData.m_fAvailableSecureBoot
1036 || newSystemData.m_fResetSecureBoot)
1037 {
1038 /* Init if required: */
1039 if (!newSystemData.m_fAvailableSecureBoot)
1040 comStoreLvl1.InitUefiVariableStore(0);
1041 /* Enroll everything: */
1042 comStoreLvl2 = comStoreLvl1.GetUefiVariableStore();
1043 comStoreLvl2.EnrollOraclePlatformKey();
1044 comStoreLvl2.EnrollDefaultMsSignatures();
1045 }
1046 comStoreLvl2.SetSecureBootEnabled(true);
1047 fSuccess = comStoreLvl2.isOk();
1048 /// @todo convey error info ..
1049 }
1050 /* Disabling secure boot? */
1051 else if (!newSystemData.m_fEnabledSecureBoot)
1052 {
1053 comStoreLvl2.SetSecureBootEnabled(false);
1054 fSuccess = comStoreLvl2.isOk();
1055 /// @todo convey error info ..
1056 }
1057 }
1058
1059 /* Show error message if necessary: */
1060 if (!fSuccess)
1061 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
1062 }
1063 /* Return result: */
1064 return fSuccess;
1065}
1066
1067bool UIMachineSettingsSystem::saveProcessorData()
1068{
1069 /* Sanity check: */
1070 if (!m_pCache)
1071 return false;
1072
1073 /* Prepare result: */
1074 bool fSuccess = true;
1075 /* Save 'Processor' settings from cache: */
1076 if (fSuccess)
1077 {
1078 /* Get old data from cache: */
1079 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
1080 /* Get new data from cache: */
1081 const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
1082
1083 /* Save CPU count: */
1084 if (fSuccess && isMachineOffline() && newSystemData.m_cCPUCount != oldSystemData.m_cCPUCount)
1085 {
1086 m_machine.SetCPUCount(newSystemData.m_cCPUCount);
1087 fSuccess = m_machine.isOk();
1088 }
1089 if (fSuccess)
1090 {
1091 const CPlatform comPlatform = m_machine.GetPlatform();
1092 switch (comPlatform.GetArchitecture())
1093 {
1094 case KPlatformArchitecture_x86:
1095 {
1096 CPlatformX86 comPlatformX86 = comPlatform.GetX86();
1097
1098 /* Save whether PAE is enabled: */
1099 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledPAE != oldSystemData.m_fEnabledPAE)
1100 {
1101 comPlatformX86.SetCPUProperty(KCPUPropertyTypeX86_PAE, newSystemData.m_fEnabledPAE);
1102 fSuccess = comPlatformX86.isOk();
1103 /// @todo convey error info ..
1104 }
1105 /* Save whether Nested HW Virt Ex is enabled: */
1106 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledNestedHwVirtEx != oldSystemData.m_fEnabledNestedHwVirtEx)
1107 {
1108 comPlatformX86.SetCPUProperty(KCPUPropertyTypeX86_HWVirt, newSystemData.m_fEnabledNestedHwVirtEx);
1109 fSuccess = comPlatformX86.isOk();
1110 /// @todo convey error info ..
1111 }
1112
1113 break;
1114 }
1115
1116#ifdef VBOX_WITH_VIRT_ARMV8
1117 case KPlatformArchitecture_ARM:
1118 {
1119 /** @todo BUGBUG ARM stuff goes here. */
1120 break;
1121 }
1122#endif
1123
1124 default:
1125 break;
1126 }
1127 }
1128 /* Save CPU execution cap: */
1129 if (fSuccess && newSystemData.m_iCPUExecCap != oldSystemData.m_iCPUExecCap)
1130 {
1131 m_machine.SetCPUExecutionCap(newSystemData.m_iCPUExecCap);
1132 fSuccess = m_machine.isOk();
1133 }
1134
1135 /* Show error message if necessary: */
1136 if (!fSuccess)
1137 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
1138 }
1139 /* Return result: */
1140 return fSuccess;
1141}
1142
1143bool UIMachineSettingsSystem::saveAccelerationData()
1144{
1145 /* Sanity check: */
1146 if (!m_pCache)
1147 return false;
1148
1149 /* Prepare result: */
1150 bool fSuccess = true;
1151 /* Save 'Acceleration' settings from cache: */
1152 if (fSuccess)
1153 {
1154 /* Get old data from cache: */
1155 const UIDataSettingsMachineSystem &oldSystemData = m_pCache->base();
1156 /* Get new data from cache: */
1157 const UIDataSettingsMachineSystem &newSystemData = m_pCache->data();
1158
1159 /* Save paravirtualization provider: */
1160 if (fSuccess && isMachineOffline() && newSystemData.m_paravirtProvider != oldSystemData.m_paravirtProvider)
1161 {
1162 m_machine.SetParavirtProvider(newSystemData.m_paravirtProvider);
1163 fSuccess = m_machine.isOk();
1164 }
1165 if (fSuccess)
1166 {
1167 const CPlatform comPlatform = m_machine.GetPlatform();
1168 switch (comPlatform.GetArchitecture())
1169 {
1170 case KPlatformArchitecture_x86:
1171 {
1172 CPlatformX86 comPlatformX86 = comPlatform.GetX86();
1173
1174 /* Save whether the nested paging is enabled: */
1175 if (fSuccess && isMachineOffline() && newSystemData.m_fEnabledNestedPaging != oldSystemData.m_fEnabledNestedPaging)
1176 {
1177 comPlatformX86.SetHWVirtExProperty(KHWVirtExPropertyType_NestedPaging, newSystemData.m_fEnabledNestedPaging);
1178 fSuccess = comPlatformX86.isOk();
1179 /// @todo convey error info ..
1180 }
1181
1182 break;
1183 }
1184
1185#ifdef VBOX_WITH_VIRT_ARMV8
1186 case KPlatformArchitecture_ARM:
1187 {
1188 /** @todo BUGBUG ARM stuff goes here. */
1189 break;
1190 }
1191#endif
1192
1193 default:
1194 break;
1195 }
1196 }
1197
1198 /* Show error message if necessary: */
1199 if (!fSuccess)
1200 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine));
1201 }
1202 /* Return result: */
1203 return fSuccess;
1204}
1205
1206void UIMachineSettingsSystem::updateMinimumLayoutHint()
1207{
1208 /* These editors have own labels, but we want them to be properly layouted according to each other: */
1209 int iMinimumLayoutHint = 0;
1210 if (m_pEditorBaseMemory && !m_pEditorBaseMemory->isHidden())
1211 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorBaseMemory->minimumLabelHorizontalHint());
1212 if (m_pEditorBootOrder && !m_pEditorBootOrder->isHidden())
1213 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorBootOrder->minimumLabelHorizontalHint());
1214 if (m_pEditorChipset && !m_pEditorChipset->isHidden())
1215 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorChipset->minimumLabelHorizontalHint());
1216 if (m_pEditorTpm && !m_pEditorTpm->isHidden())
1217 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorTpm->minimumLabelHorizontalHint());
1218 if (m_pEditorPointingHID && !m_pEditorPointingHID->isHidden())
1219 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorPointingHID->minimumLabelHorizontalHint());
1220 if (m_pEditorMotherboardFeatures && !m_pEditorMotherboardFeatures->isHidden())
1221 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorMotherboardFeatures->minimumLabelHorizontalHint());
1222 if (m_pEditorBaseMemory)
1223 m_pEditorBaseMemory->setMinimumLayoutIndent(iMinimumLayoutHint);
1224 if (m_pEditorBootOrder)
1225 m_pEditorBootOrder->setMinimumLayoutIndent(iMinimumLayoutHint);
1226 if (m_pEditorChipset)
1227 m_pEditorChipset->setMinimumLayoutIndent(iMinimumLayoutHint);
1228 if (m_pEditorTpm)
1229 m_pEditorTpm->setMinimumLayoutIndent(iMinimumLayoutHint);
1230 if (m_pEditorPointingHID)
1231 m_pEditorPointingHID->setMinimumLayoutIndent(iMinimumLayoutHint);
1232 if (m_pEditorMotherboardFeatures)
1233 m_pEditorMotherboardFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
1234
1235 iMinimumLayoutHint = 0;
1236 if (m_pEditorVCPU && !m_pEditorVCPU->isHidden())
1237 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorVCPU->minimumLabelHorizontalHint());
1238 if (m_pEditorExecCap && !m_pEditorExecCap->isHidden())
1239 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorExecCap->minimumLabelHorizontalHint());
1240 if (m_pEditorProcessorFeatures && !m_pEditorProcessorFeatures->isHidden())
1241 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorProcessorFeatures->minimumLabelHorizontalHint());
1242 if (m_pEditorVCPU)
1243 m_pEditorVCPU->setMinimumLayoutIndent(iMinimumLayoutHint);
1244 if (m_pEditorExecCap)
1245 m_pEditorExecCap->setMinimumLayoutIndent(iMinimumLayoutHint);
1246 if (m_pEditorProcessorFeatures)
1247 m_pEditorProcessorFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
1248
1249 iMinimumLayoutHint = 0;
1250 if (m_pEditorParavirtProvider && !m_pEditorParavirtProvider->isHidden())
1251 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorParavirtProvider->minimumLabelHorizontalHint());
1252 if (m_pEditorAccelerationFeatures && !m_pEditorAccelerationFeatures->isHidden())
1253 iMinimumLayoutHint = qMax(iMinimumLayoutHint, m_pEditorAccelerationFeatures->minimumLabelHorizontalHint());
1254 if (m_pEditorParavirtProvider)
1255 m_pEditorParavirtProvider->setMinimumLayoutIndent(iMinimumLayoutHint);
1256 if (m_pEditorAccelerationFeatures)
1257 m_pEditorAccelerationFeatures->setMinimumLayoutIndent(iMinimumLayoutHint);
1258}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette