VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp@ 96141

Last change on this file since 96141 was 96141, checked in by vboxsync, 3 years ago

Recording/Main:

  • Renamed RecordingVideoScalingMethod -> RecordingVideoScalingMode (to match the other enums).
  • Renamed RecordingVideoRateControlMode -> RecordingRateControlMode, as this also can apply to audio codecs.
  • Added ABR (average bitrate) mode to RecordingRateControlMode.

IRecordingScreenSettings:

  • Added audioRateControlMode.
  • Added videoScalingMode.

ISystemProperties:

  • Renamed supportedRecordingVSMethods to supportedRecordingVSModes (to match RecordingVideoScalingMode).
  • Added supportedRecordingARCModes.

Renamed com::settings::RecordingScreenSettings.Audio.enmAudioCodec -> .enmCodec (Doppelmoppel).

More documentation.

​bugref:10275

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 72.1 KB
Line 
1/* $Id: SystemPropertiesImpl.cpp 96141 2022-08-11 15:37:19Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#define LOG_GROUP LOG_GROUP_MAIN_SYSTEMPROPERTIES
19#include "SystemPropertiesImpl.h"
20#include "VirtualBoxImpl.h"
21#include "MachineImpl.h"
22#ifdef VBOX_WITH_EXTPACK
23# include "ExtPackManagerImpl.h"
24#endif
25#include "CPUProfileImpl.h"
26#include "AutoCaller.h"
27#include "Global.h"
28#include "LoggingNew.h"
29#include "AutostartDb.h"
30#include "VirtualBoxTranslator.h"
31
32// generated header
33#include "SchemaDefs.h"
34
35#include <iprt/dir.h>
36#include <iprt/ldr.h>
37#include <iprt/locale.h>
38#include <iprt/path.h>
39#include <iprt/string.h>
40#include <iprt/uri.h>
41#include <iprt/cpp/utils.h>
42
43#include <iprt/errcore.h>
44#include <VBox/param.h>
45#include <VBox/settings.h>
46#include <VBox/vd.h>
47#include <VBox/vmm/cpum.h>
48
49// defines
50/////////////////////////////////////////////////////////////////////////////
51
52// constructor / destructor
53/////////////////////////////////////////////////////////////////////////////
54
55SystemProperties::SystemProperties()
56 : mParent(NULL)
57 , m(new settings::SystemProperties)
58 , m_fLoadedX86CPUProfiles(false)
59{
60}
61
62SystemProperties::~SystemProperties()
63{
64 delete m;
65}
66
67
68HRESULT SystemProperties::FinalConstruct()
69{
70 return BaseFinalConstruct();
71}
72
73void SystemProperties::FinalRelease()
74{
75 uninit();
76 BaseFinalRelease();
77}
78
79// public methods only for internal purposes
80/////////////////////////////////////////////////////////////////////////////
81
82/**
83 * Initializes the system information object.
84 *
85 * @returns COM result indicator
86 */
87HRESULT SystemProperties::init(VirtualBox *aParent)
88{
89 LogFlowThisFunc(("aParent=%p\n", aParent));
90
91 ComAssertRet(aParent, E_FAIL);
92
93 /* Enclose the state transition NotReady->InInit->Ready */
94 AutoInitSpan autoInitSpan(this);
95 AssertReturn(autoInitSpan.isOk(), E_FAIL);
96
97 unconst(mParent) = aParent;
98
99 i_setDefaultMachineFolder(Utf8Str::Empty);
100 i_setLoggingLevel(Utf8Str::Empty);
101 i_setDefaultHardDiskFormat(Utf8Str::Empty);
102
103 i_setVRDEAuthLibrary(Utf8Str::Empty);
104 i_setDefaultVRDEExtPack(Utf8Str::Empty);
105 i_setDefaultCryptoExtPack(Utf8Str::Empty);
106
107 m->uLogHistoryCount = 3;
108
109
110 /* On Windows, OS X and Solaris, HW virtualization use isn't exclusive
111 * by default so that VT-x or AMD-V can be shared with other
112 * hypervisors without requiring user intervention.
113 * NB: See also SystemProperties constructor in settings.h
114 */
115#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
116 m->fExclusiveHwVirt = false;
117#else
118 m->fExclusiveHwVirt = true;
119#endif
120
121 HRESULT rc = S_OK;
122
123 /* Fetch info of all available hd backends. */
124
125 /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
126 /// any number of backends
127
128 VDBACKENDINFO aVDInfo[100];
129 unsigned cEntries;
130 int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
131 AssertRC(vrc);
132 if (RT_SUCCESS(vrc))
133 {
134 for (unsigned i = 0; i < cEntries; ++ i)
135 {
136 ComObjPtr<MediumFormat> hdf;
137 rc = hdf.createObject();
138 if (FAILED(rc)) break;
139
140 rc = hdf->init(&aVDInfo[i]);
141 if (FAILED(rc)) break;
142
143 m_llMediumFormats.push_back(hdf);
144 }
145 }
146
147 /* Confirm a successful initialization */
148 if (SUCCEEDED(rc))
149 autoInitSpan.setSucceeded();
150
151 return rc;
152}
153
154/**
155 * Uninitializes the instance and sets the ready flag to FALSE.
156 * Called either from FinalRelease() or by the parent when it gets destroyed.
157 */
158void SystemProperties::uninit()
159{
160 LogFlowThisFunc(("\n"));
161
162 /* Enclose the state transition Ready->InUninit->NotReady */
163 AutoUninitSpan autoUninitSpan(this);
164 if (autoUninitSpan.uninitDone())
165 return;
166
167 unconst(mParent) = NULL;
168}
169
170// wrapped ISystemProperties properties
171/////////////////////////////////////////////////////////////////////////////
172
173HRESULT SystemProperties::getMinGuestRAM(ULONG *minRAM)
174
175{
176 /* no need to lock, this is const */
177 AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
178 *minRAM = MM_RAM_MIN_IN_MB;
179
180 return S_OK;
181}
182
183HRESULT SystemProperties::getMaxGuestRAM(ULONG *maxRAM)
184{
185 /* no need to lock, this is const */
186 AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
187 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
188 ULONG maxRAMArch = maxRAMSys;
189 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
190
191 return S_OK;
192}
193
194HRESULT SystemProperties::getMinGuestVRAM(ULONG *minVRAM)
195{
196 /* no need to lock, this is const */
197 *minVRAM = SchemaDefs::MinGuestVRAM;
198
199 return S_OK;
200}
201
202HRESULT SystemProperties::getMaxGuestVRAM(ULONG *maxVRAM)
203{
204 /* no need to lock, this is const */
205 *maxVRAM = SchemaDefs::MaxGuestVRAM;
206
207 return S_OK;
208}
209
210HRESULT SystemProperties::getMinGuestCPUCount(ULONG *minCPUCount)
211{
212 /* no need to lock, this is const */
213 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
214
215 return S_OK;
216}
217
218HRESULT SystemProperties::getMaxGuestCPUCount(ULONG *maxCPUCount)
219{
220 /* no need to lock, this is const */
221 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
222
223 return S_OK;
224}
225
226HRESULT SystemProperties::getMaxGuestMonitors(ULONG *maxMonitors)
227{
228
229 /* no need to lock, this is const */
230 *maxMonitors = SchemaDefs::MaxGuestMonitors;
231
232 return S_OK;
233}
234
235
236HRESULT SystemProperties::getInfoVDSize(LONG64 *infoVDSize)
237{
238 /*
239 * The BIOS supports currently 32 bit LBA numbers (implementing the full
240 * 48 bit range is in theory trivial, but the crappy compiler makes things
241 * more difficult). This translates to almost 2 TiBytes (to be on the safe
242 * side, the reported limit is 1 MiByte less than that, as the total number
243 * of sectors should fit in 32 bits, too), which should be enough for the
244 * moment. Since the MBR partition tables support only 32bit sector numbers
245 * and thus the BIOS can only boot from disks smaller than 2T this is a
246 * rather hard limit.
247 *
248 * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
249 * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
250 * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
251 * of magnitude, but not with 11..13 orders of magnitude.
252 */
253 /* no need to lock, this is const */
254 *infoVDSize = 2 * _1T - _1M;
255
256 return S_OK;
257}
258
259
260HRESULT SystemProperties::getSerialPortCount(ULONG *count)
261{
262 /* no need to lock, this is const */
263 *count = SchemaDefs::SerialPortCount;
264
265 return S_OK;
266}
267
268
269HRESULT SystemProperties::getParallelPortCount(ULONG *count)
270{
271 /* no need to lock, this is const */
272 *count = SchemaDefs::ParallelPortCount;
273
274 return S_OK;
275}
276
277
278HRESULT SystemProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
279{
280 /* no need to lock, this is const */
281 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
282
283 return S_OK;
284}
285
286
287HRESULT SystemProperties::getRawModeSupported(BOOL *aRawModeSupported)
288{
289 *aRawModeSupported = FALSE;
290 return S_OK;
291}
292
293
294HRESULT SystemProperties::getExclusiveHwVirt(BOOL *aExclusiveHwVirt)
295{
296 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
297
298 *aExclusiveHwVirt = m->fExclusiveHwVirt;
299
300 return S_OK;
301}
302
303HRESULT SystemProperties::setExclusiveHwVirt(BOOL aExclusiveHwVirt)
304{
305 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
306 m->fExclusiveHwVirt = !!aExclusiveHwVirt;
307 alock.release();
308
309 // VirtualBox::i_saveSettings() needs vbox write lock
310 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
311 HRESULT rc = mParent->i_saveSettings();
312
313 return rc;
314}
315
316HRESULT SystemProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
317{
318 /* no need for locking, no state */
319 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
320 if (uResult == 0)
321 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
322 *aMaxNetworkAdapters = uResult;
323 return S_OK;
324}
325
326HRESULT SystemProperties::getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
327{
328 /* no need for locking, no state */
329 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
330 if (uResult == 0)
331 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
332
333 switch (aType)
334 {
335 case NetworkAttachmentType_NAT:
336 case NetworkAttachmentType_Internal:
337 case NetworkAttachmentType_NATNetwork:
338 /* chipset default is OK */
339 break;
340 case NetworkAttachmentType_Bridged:
341 /* Maybe use current host interface count here? */
342 break;
343 case NetworkAttachmentType_HostOnly:
344 uResult = RT_MIN(uResult, 8);
345 break;
346 default:
347 AssertMsgFailed(("Unhandled attachment type %d\n", aType));
348 }
349
350 *count = uResult;
351
352 return S_OK;
353}
354
355
356HRESULT SystemProperties::getMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
357 ULONG *aMaxDevicesPerPort)
358{
359 /* no need to lock, this is const */
360 switch (aBus)
361 {
362 case StorageBus_SATA:
363 case StorageBus_SCSI:
364 case StorageBus_SAS:
365 case StorageBus_USB:
366 case StorageBus_PCIe:
367 case StorageBus_VirtioSCSI:
368 {
369 /* SATA and both SCSI controllers only support one device per port. */
370 *aMaxDevicesPerPort = 1;
371 break;
372 }
373 case StorageBus_IDE:
374 case StorageBus_Floppy:
375 {
376 /* The IDE and Floppy controllers support 2 devices. One as master
377 * and one as slave (or floppy drive 0 and 1). */
378 *aMaxDevicesPerPort = 2;
379 break;
380 }
381 default:
382 AssertMsgFailed(("Invalid bus type %d\n", aBus));
383 }
384
385 return S_OK;
386}
387
388HRESULT SystemProperties::getMinPortCountForStorageBus(StorageBus_T aBus,
389 ULONG *aMinPortCount)
390{
391 /* no need to lock, this is const */
392 switch (aBus)
393 {
394 case StorageBus_SATA:
395 case StorageBus_SAS:
396 case StorageBus_PCIe:
397 case StorageBus_VirtioSCSI:
398 {
399 *aMinPortCount = 1;
400 break;
401 }
402 case StorageBus_SCSI:
403 {
404 *aMinPortCount = 16;
405 break;
406 }
407 case StorageBus_IDE:
408 {
409 *aMinPortCount = 2;
410 break;
411 }
412 case StorageBus_Floppy:
413 {
414 *aMinPortCount = 1;
415 break;
416 }
417 case StorageBus_USB:
418 {
419 *aMinPortCount = 8;
420 break;
421 }
422 default:
423 AssertMsgFailed(("Invalid bus type %d\n", aBus));
424 }
425
426 return S_OK;
427}
428
429HRESULT SystemProperties::getMaxPortCountForStorageBus(StorageBus_T aBus,
430 ULONG *aMaxPortCount)
431{
432 /* no need to lock, this is const */
433 switch (aBus)
434 {
435 case StorageBus_SATA:
436 {
437 *aMaxPortCount = 30;
438 break;
439 }
440 case StorageBus_SCSI:
441 {
442 *aMaxPortCount = 16;
443 break;
444 }
445 case StorageBus_IDE:
446 {
447 *aMaxPortCount = 2;
448 break;
449 }
450 case StorageBus_Floppy:
451 {
452 *aMaxPortCount = 1;
453 break;
454 }
455 case StorageBus_SAS:
456 case StorageBus_PCIe:
457 {
458 *aMaxPortCount = 255;
459 break;
460 }
461 case StorageBus_USB:
462 {
463 *aMaxPortCount = 8;
464 break;
465 }
466 case StorageBus_VirtioSCSI:
467 {
468 *aMaxPortCount = 256;
469 break;
470 }
471 default:
472 AssertMsgFailed(("Invalid bus type %d\n", aBus));
473 }
474
475 return S_OK;
476}
477
478HRESULT SystemProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
479 StorageBus_T aBus,
480 ULONG *aMaxInstances)
481{
482 ULONG cCtrs = 0;
483
484 /* no need to lock, this is const */
485 switch (aBus)
486 {
487 case StorageBus_SATA:
488 case StorageBus_SCSI:
489 case StorageBus_SAS:
490 case StorageBus_PCIe:
491 case StorageBus_VirtioSCSI:
492 cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
493 break;
494 case StorageBus_USB:
495 case StorageBus_IDE:
496 case StorageBus_Floppy:
497 {
498 cCtrs = 1;
499 break;
500 }
501 default:
502 AssertMsgFailed(("Invalid bus type %d\n", aBus));
503 }
504
505 *aMaxInstances = cCtrs;
506
507 return S_OK;
508}
509
510HRESULT SystemProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
511 std::vector<DeviceType_T> &aDeviceTypes)
512{
513 aDeviceTypes.resize(0);
514
515 /* no need to lock, this is const */
516 switch (aBus)
517 {
518 case StorageBus_IDE:
519 case StorageBus_SATA:
520 case StorageBus_SCSI:
521 case StorageBus_SAS:
522 case StorageBus_USB:
523 case StorageBus_VirtioSCSI:
524 {
525 aDeviceTypes.resize(2);
526 aDeviceTypes[0] = DeviceType_DVD;
527 aDeviceTypes[1] = DeviceType_HardDisk;
528 break;
529 }
530 case StorageBus_Floppy:
531 {
532 aDeviceTypes.resize(1);
533 aDeviceTypes[0] = DeviceType_Floppy;
534 break;
535 }
536 case StorageBus_PCIe:
537 {
538 aDeviceTypes.resize(1);
539 aDeviceTypes[0] = DeviceType_HardDisk;
540 break;
541 }
542 default:
543 AssertMsgFailed(("Invalid bus type %d\n", aBus));
544 }
545
546 return S_OK;
547}
548
549HRESULT SystemProperties::getStorageBusForStorageControllerType(StorageControllerType_T aStorageControllerType,
550 StorageBus_T *aStorageBus)
551{
552 /* no need to lock, this is const */
553 switch (aStorageControllerType)
554 {
555 case StorageControllerType_LsiLogic:
556 case StorageControllerType_BusLogic:
557 *aStorageBus = StorageBus_SCSI;
558 break;
559 case StorageControllerType_IntelAhci:
560 *aStorageBus = StorageBus_SATA;
561 break;
562 case StorageControllerType_PIIX3:
563 case StorageControllerType_PIIX4:
564 case StorageControllerType_ICH6:
565 *aStorageBus = StorageBus_IDE;
566 break;
567 case StorageControllerType_I82078:
568 *aStorageBus = StorageBus_Floppy;
569 break;
570 case StorageControllerType_LsiLogicSas:
571 *aStorageBus = StorageBus_SAS;
572 break;
573 case StorageControllerType_USB:
574 *aStorageBus = StorageBus_USB;
575 break;
576 case StorageControllerType_NVMe:
577 *aStorageBus = StorageBus_PCIe;
578 break;
579 case StorageControllerType_VirtioSCSI:
580 *aStorageBus = StorageBus_VirtioSCSI;
581 break;
582 default:
583 return setError(E_FAIL, tr("Invalid storage controller type %d\n"), aStorageBus);
584 }
585
586 return S_OK;
587}
588
589HRESULT SystemProperties::getStorageControllerTypesForStorageBus(StorageBus_T aStorageBus,
590 std::vector<StorageControllerType_T> &aStorageControllerTypes)
591{
592 aStorageControllerTypes.resize(0);
593
594 /* no need to lock, this is const */
595 switch (aStorageBus)
596 {
597 case StorageBus_IDE:
598 aStorageControllerTypes.resize(3);
599 aStorageControllerTypes[0] = StorageControllerType_PIIX4;
600 aStorageControllerTypes[1] = StorageControllerType_PIIX3;
601 aStorageControllerTypes[2] = StorageControllerType_ICH6;
602 break;
603 case StorageBus_SATA:
604 aStorageControllerTypes.resize(1);
605 aStorageControllerTypes[0] = StorageControllerType_IntelAhci;
606 break;
607 case StorageBus_SCSI:
608 aStorageControllerTypes.resize(2);
609 aStorageControllerTypes[0] = StorageControllerType_LsiLogic;
610 aStorageControllerTypes[1] = StorageControllerType_BusLogic;
611 break;
612 case StorageBus_Floppy:
613 aStorageControllerTypes.resize(1);
614 aStorageControllerTypes[0] = StorageControllerType_I82078;
615 break;
616 case StorageBus_SAS:
617 aStorageControllerTypes.resize(1);
618 aStorageControllerTypes[0] = StorageControllerType_LsiLogicSas;
619 break;
620 case StorageBus_USB:
621 aStorageControllerTypes.resize(1);
622 aStorageControllerTypes[0] = StorageControllerType_USB;
623 break;
624 case StorageBus_PCIe:
625 aStorageControllerTypes.resize(1);
626 aStorageControllerTypes[0] = StorageControllerType_NVMe;
627 break;
628 case StorageBus_VirtioSCSI:
629 aStorageControllerTypes.resize(1);
630 aStorageControllerTypes[0] = StorageControllerType_VirtioSCSI;
631 break;
632 default:
633 return setError(E_FAIL, tr("Invalid storage bus %d\n"), aStorageBus);
634 }
635
636 return S_OK;
637}
638
639HRESULT SystemProperties::getDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType,
640 BOOL *aEnabled)
641{
642 /* no need to lock, this is const */
643 switch (aControllerType)
644 {
645 case StorageControllerType_LsiLogic:
646 case StorageControllerType_BusLogic:
647 case StorageControllerType_IntelAhci:
648 case StorageControllerType_LsiLogicSas:
649 case StorageControllerType_USB:
650 case StorageControllerType_NVMe:
651 case StorageControllerType_VirtioSCSI:
652 *aEnabled = false;
653 break;
654 case StorageControllerType_PIIX3:
655 case StorageControllerType_PIIX4:
656 case StorageControllerType_ICH6:
657 case StorageControllerType_I82078:
658 *aEnabled = true;
659 break;
660 default:
661 AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
662 }
663 return S_OK;
664}
665
666HRESULT SystemProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
667 BOOL *aHotplugCapable)
668{
669 switch (aControllerType)
670 {
671 case StorageControllerType_IntelAhci:
672 case StorageControllerType_USB:
673 *aHotplugCapable = true;
674 break;
675 case StorageControllerType_LsiLogic:
676 case StorageControllerType_LsiLogicSas:
677 case StorageControllerType_BusLogic:
678 case StorageControllerType_NVMe:
679 case StorageControllerType_VirtioSCSI:
680 case StorageControllerType_PIIX3:
681 case StorageControllerType_PIIX4:
682 case StorageControllerType_ICH6:
683 case StorageControllerType_I82078:
684 *aHotplugCapable = false;
685 break;
686 default:
687 AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
688 }
689
690 return S_OK;
691}
692
693HRESULT SystemProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
694 USBControllerType_T aType,
695 ULONG *aMaxInstances)
696{
697 NOREF(aChipset);
698 ULONG cCtrs = 0;
699
700 /* no need to lock, this is const */
701 switch (aType)
702 {
703 case USBControllerType_OHCI:
704 case USBControllerType_EHCI:
705 case USBControllerType_XHCI:
706 {
707 cCtrs = 1;
708 break;
709 }
710 default:
711 AssertMsgFailed(("Invalid bus type %d\n", aType));
712 }
713
714 *aMaxInstances = cCtrs;
715
716 return S_OK;
717}
718
719HRESULT SystemProperties::getCPUProfiles(CPUArchitecture_T aArchitecture, const com::Utf8Str &aNamePattern,
720 std::vector<ComPtr<ICPUProfile> > &aProfiles)
721{
722 /*
723 * Validate and adjust the architecture.
724 */
725 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
726 CPUArchitecture_T enmSecondaryArch = aArchitecture;
727 bool fLoaded;
728 switch (aArchitecture)
729 {
730 case CPUArchitecture_Any:
731 aArchitecture = CPUArchitecture_AMD64;
732 RT_FALL_THROUGH();
733 case CPUArchitecture_AMD64:
734 enmSecondaryArch = CPUArchitecture_x86;
735 RT_FALL_THROUGH();
736 case CPUArchitecture_x86:
737 fLoaded = m_fLoadedX86CPUProfiles;
738 break;
739 default:
740 return setError(E_INVALIDARG, tr("Invalid or unsupported architecture value: %d"), aArchitecture);
741 }
742
743 /*
744 * Do we need to load the profiles?
745 */
746 HRESULT hrc;
747 if (fLoaded)
748 hrc = S_OK;
749 else
750 {
751 alock.release();
752 AutoWriteLock alockWrite(this COMMA_LOCKVAL_SRC_POS);
753
754 /*
755 * Translate the architecture to a VMM module handle.
756 */
757 const char *pszVMM;
758 switch (aArchitecture)
759 {
760 case CPUArchitecture_AMD64:
761 case CPUArchitecture_x86:
762 pszVMM = "VBoxVMM";
763 fLoaded = m_fLoadedX86CPUProfiles;
764 break;
765 default:
766 AssertFailedReturn(E_INVALIDARG);
767 }
768 if (fLoaded)
769 hrc = S_OK;
770 else
771 {
772 char szPath[RTPATH_MAX];
773 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
774 if (RT_SUCCESS(vrc))
775 vrc = RTPathAppend(szPath, sizeof(szPath), pszVMM);
776 if (RT_SUCCESS(vrc))
777 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
778 if (RT_SUCCESS(vrc))
779 {
780 RTLDRMOD hMod = NIL_RTLDRMOD;
781 vrc = RTLdrLoad(szPath, &hMod);
782 if (RT_SUCCESS(vrc))
783 {
784 /*
785 * Resolve the CPUMDb APIs we need.
786 */
787 PFNCPUMDBGETENTRIES pfnGetEntries
788 = (PFNCPUMDBGETENTRIES)RTLdrGetFunction(hMod, "CPUMR3DbGetEntries");
789 PFNCPUMDBGETENTRYBYINDEX pfnGetEntryByIndex
790 = (PFNCPUMDBGETENTRYBYINDEX)RTLdrGetFunction(hMod, "CPUMR3DbGetEntryByIndex");
791 if (pfnGetEntries && pfnGetEntryByIndex)
792 {
793 size_t const cExistingProfiles = m_llCPUProfiles.size();
794
795 /*
796 * Instantate the profiles.
797 */
798 hrc = S_OK;
799 uint32_t const cEntries = pfnGetEntries();
800 for (uint32_t i = 0; i < cEntries; i++)
801 {
802 PCCPUMDBENTRY pDbEntry = pfnGetEntryByIndex(i);
803 AssertBreakStmt(pDbEntry, hrc = setError(E_UNEXPECTED, "CPUMR3DbGetEntryByIndex failed for %i", i));
804
805 ComObjPtr<CPUProfile> ptrProfile;
806 hrc = ptrProfile.createObject();
807 if (SUCCEEDED(hrc))
808 {
809 hrc = ptrProfile->initFromDbEntry(pDbEntry);
810 if (SUCCEEDED(hrc))
811 {
812 try
813 {
814 m_llCPUProfiles.push_back(ptrProfile);
815 continue;
816 }
817 catch (std::bad_alloc &)
818 {
819 hrc = E_OUTOFMEMORY;
820 }
821 }
822 }
823 break;
824 }
825
826 /*
827 * On success update the flag and retake the read lock.
828 * If we fail, drop the profiles we added to the list.
829 */
830 if (SUCCEEDED(hrc))
831 {
832 switch (aArchitecture)
833 {
834 case CPUArchitecture_AMD64:
835 case CPUArchitecture_x86:
836 m_fLoadedX86CPUProfiles = true;
837 break;
838 default:
839 AssertFailedStmt(hrc = E_INVALIDARG);
840 }
841
842 alockWrite.release();
843 alock.acquire();
844 }
845 else
846 m_llCPUProfiles.resize(cExistingProfiles);
847 }
848 else
849 hrc = setErrorVrc(VERR_SYMBOL_NOT_FOUND,
850 tr("'%s' is missing symbols: CPUMR3DbGetEntries, CPUMR3DbGetEntryByIndex"), szPath);
851 RTLdrClose(hMod);
852 }
853 else
854 hrc = setErrorVrc(vrc, tr("Failed to construct load '%s': %Rrc"), szPath, vrc);
855 }
856 else
857 hrc = setErrorVrc(vrc, tr("Failed to construct path to the VMM DLL/Dylib/SharedObject: %Rrc"), vrc);
858 }
859 }
860 if (SUCCEEDED(hrc))
861 {
862 /*
863 * Return the matching profiles.
864 */
865 /* Count matches: */
866 size_t cMatches = 0;
867 for (CPUProfileList_T::const_iterator it = m_llCPUProfiles.begin(); it != m_llCPUProfiles.end(); ++it)
868 if ((*it)->i_match(aArchitecture, enmSecondaryArch, aNamePattern))
869 cMatches++;
870
871 /* Resize the output array. */
872 try
873 {
874 aProfiles.resize(cMatches);
875 }
876 catch (std::bad_alloc &)
877 {
878 aProfiles.resize(0);
879 hrc = E_OUTOFMEMORY;
880 }
881
882 /* Get the return objects: */
883 if (SUCCEEDED(hrc) && cMatches > 0)
884 {
885 size_t iMatch = 0;
886 for (CPUProfileList_T::const_iterator it = m_llCPUProfiles.begin(); it != m_llCPUProfiles.end(); ++it)
887 if ((*it)->i_match(aArchitecture, enmSecondaryArch, aNamePattern))
888 {
889 AssertBreakStmt(iMatch < cMatches, hrc = E_UNEXPECTED);
890 hrc = (*it).queryInterfaceTo(aProfiles[iMatch].asOutParam());
891 if (SUCCEEDED(hrc))
892 iMatch++;
893 else
894 break;
895 }
896 AssertStmt(iMatch == cMatches || FAILED(hrc), hrc = E_UNEXPECTED);
897 }
898 }
899 return hrc;
900}
901
902
903HRESULT SystemProperties::getDefaultMachineFolder(com::Utf8Str &aDefaultMachineFolder)
904{
905 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
906 aDefaultMachineFolder = m->strDefaultMachineFolder;
907 return S_OK;
908}
909
910HRESULT SystemProperties::setDefaultMachineFolder(const com::Utf8Str &aDefaultMachineFolder)
911{
912 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
913 HRESULT rc = i_setDefaultMachineFolder(aDefaultMachineFolder);
914 alock.release();
915 if (SUCCEEDED(rc))
916 {
917 // VirtualBox::i_saveSettings() needs vbox write lock
918 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
919 rc = mParent->i_saveSettings();
920 }
921
922 return rc;
923}
924
925HRESULT SystemProperties::getLoggingLevel(com::Utf8Str &aLoggingLevel)
926{
927 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
928
929 aLoggingLevel = m->strLoggingLevel;
930
931 if (aLoggingLevel.isEmpty())
932 aLoggingLevel = VBOXSVC_LOG_DEFAULT;
933
934 return S_OK;
935}
936
937
938HRESULT SystemProperties::setLoggingLevel(const com::Utf8Str &aLoggingLevel)
939{
940 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
941 HRESULT rc = i_setLoggingLevel(aLoggingLevel);
942 alock.release();
943
944 if (SUCCEEDED(rc))
945 {
946 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
947 rc = mParent->i_saveSettings();
948 }
949 else
950 LogRel(("Cannot set passed logging level=%s, or the default one - Error=%Rhrc \n", aLoggingLevel.c_str(), rc));
951
952 return rc;
953}
954
955HRESULT SystemProperties::getMediumFormats(std::vector<ComPtr<IMediumFormat> > &aMediumFormats)
956{
957 MediumFormatList mediumFormats(m_llMediumFormats);
958 aMediumFormats.resize(mediumFormats.size());
959 size_t i = 0;
960 for (MediumFormatList::const_iterator it = mediumFormats.begin(); it != mediumFormats.end(); ++it, ++i)
961 (*it).queryInterfaceTo(aMediumFormats[i].asOutParam());
962 return S_OK;
963}
964
965HRESULT SystemProperties::getDefaultHardDiskFormat(com::Utf8Str &aDefaultHardDiskFormat)
966{
967 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
968 aDefaultHardDiskFormat = m->strDefaultHardDiskFormat;
969 return S_OK;
970}
971
972
973HRESULT SystemProperties::setDefaultHardDiskFormat(const com::Utf8Str &aDefaultHardDiskFormat)
974{
975 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
976 HRESULT rc = i_setDefaultHardDiskFormat(aDefaultHardDiskFormat);
977 alock.release();
978 if (SUCCEEDED(rc))
979 {
980 // VirtualBox::i_saveSettings() needs vbox write lock
981 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
982 rc = mParent->i_saveSettings();
983 }
984
985 return rc;
986}
987
988HRESULT SystemProperties::getFreeDiskSpaceWarning(LONG64 *aFreeSpace)
989{
990 NOREF(aFreeSpace);
991 ReturnComNotImplemented();
992}
993
994HRESULT SystemProperties::setFreeDiskSpaceWarning(LONG64 /* aFreeSpace */)
995{
996 ReturnComNotImplemented();
997}
998
999HRESULT SystemProperties::getFreeDiskSpacePercentWarning(ULONG *aFreeSpacePercent)
1000{
1001 NOREF(aFreeSpacePercent);
1002 ReturnComNotImplemented();
1003}
1004
1005HRESULT SystemProperties::setFreeDiskSpacePercentWarning(ULONG /* aFreeSpacePercent */)
1006{
1007 ReturnComNotImplemented();
1008}
1009
1010HRESULT SystemProperties::getFreeDiskSpaceError(LONG64 *aFreeSpace)
1011{
1012 NOREF(aFreeSpace);
1013 ReturnComNotImplemented();
1014}
1015
1016HRESULT SystemProperties::setFreeDiskSpaceError(LONG64 /* aFreeSpace */)
1017{
1018 ReturnComNotImplemented();
1019}
1020
1021HRESULT SystemProperties::getFreeDiskSpacePercentError(ULONG *aFreeSpacePercent)
1022{
1023 NOREF(aFreeSpacePercent);
1024 ReturnComNotImplemented();
1025}
1026
1027HRESULT SystemProperties::setFreeDiskSpacePercentError(ULONG /* aFreeSpacePercent */)
1028{
1029 ReturnComNotImplemented();
1030}
1031
1032HRESULT SystemProperties::getVRDEAuthLibrary(com::Utf8Str &aVRDEAuthLibrary)
1033{
1034 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1035
1036 aVRDEAuthLibrary = m->strVRDEAuthLibrary;
1037
1038 return S_OK;
1039}
1040
1041HRESULT SystemProperties::setVRDEAuthLibrary(const com::Utf8Str &aVRDEAuthLibrary)
1042{
1043 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1044 HRESULT rc = i_setVRDEAuthLibrary(aVRDEAuthLibrary);
1045 alock.release();
1046 if (SUCCEEDED(rc))
1047 {
1048 // VirtualBox::i_saveSettings() needs vbox write lock
1049 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1050 rc = mParent->i_saveSettings();
1051 }
1052
1053 return rc;
1054}
1055
1056HRESULT SystemProperties::getWebServiceAuthLibrary(com::Utf8Str &aWebServiceAuthLibrary)
1057{
1058 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1059
1060 aWebServiceAuthLibrary = m->strWebServiceAuthLibrary;
1061
1062 return S_OK;
1063}
1064
1065HRESULT SystemProperties::setWebServiceAuthLibrary(const com::Utf8Str &aWebServiceAuthLibrary)
1066{
1067 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1068 HRESULT rc = i_setWebServiceAuthLibrary(aWebServiceAuthLibrary);
1069 alock.release();
1070
1071 if (SUCCEEDED(rc))
1072 {
1073 // VirtualBox::i_saveSettings() needs vbox write lock
1074 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1075 rc = mParent->i_saveSettings();
1076 }
1077
1078 return rc;
1079}
1080
1081HRESULT SystemProperties::getDefaultVRDEExtPack(com::Utf8Str &aExtPack)
1082{
1083 HRESULT hrc = S_OK;
1084 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1085 Utf8Str strExtPack(m->strDefaultVRDEExtPack);
1086 if (strExtPack.isNotEmpty())
1087 {
1088 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
1089 hrc = S_OK;
1090 else
1091#ifdef VBOX_WITH_EXTPACK
1092 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&strExtPack);
1093#else
1094 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
1095#endif
1096 }
1097 else
1098 {
1099#ifdef VBOX_WITH_EXTPACK
1100 hrc = mParent->i_getExtPackManager()->i_getDefaultVrdeExtPack(&strExtPack);
1101#endif
1102 if (strExtPack.isEmpty())
1103 {
1104 /*
1105 * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
1106 * This is hardcoded uglyness, sorry.
1107 */
1108 char szPath[RTPATH_MAX];
1109 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
1110 if (RT_SUCCESS(vrc))
1111 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
1112 if (RT_SUCCESS(vrc))
1113 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
1114 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
1115 {
1116 /* Illegal extpack name, so no conflict. */
1117 strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
1118 }
1119 }
1120 }
1121
1122 if (SUCCEEDED(hrc))
1123 aExtPack = strExtPack;
1124
1125 return S_OK;
1126}
1127
1128
1129HRESULT SystemProperties::setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
1130{
1131 HRESULT hrc = S_OK;
1132 if (aExtPack.isNotEmpty())
1133 {
1134 if (aExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
1135 hrc = S_OK;
1136 else
1137#ifdef VBOX_WITH_EXTPACK
1138 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&aExtPack);
1139#else
1140 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), aExtPack.c_str());
1141#endif
1142 }
1143 if (SUCCEEDED(hrc))
1144 {
1145 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1146 hrc = i_setDefaultVRDEExtPack(aExtPack);
1147 if (SUCCEEDED(hrc))
1148 {
1149 /* VirtualBox::i_saveSettings() needs the VirtualBox write lock. */
1150 alock.release();
1151 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1152 hrc = mParent->i_saveSettings();
1153 }
1154 }
1155
1156 return hrc;
1157}
1158
1159
1160HRESULT SystemProperties::getDefaultCryptoExtPack(com::Utf8Str &aExtPack)
1161{
1162 HRESULT hrc = S_OK;
1163 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1164 Utf8Str strExtPack(m->strDefaultCryptoExtPack);
1165 if (strExtPack.isNotEmpty())
1166 {
1167 if (strExtPack.equals(VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME))
1168 hrc = S_OK;
1169 else
1170#ifdef VBOX_WITH_EXTPACK
1171 hrc = mParent->i_getExtPackManager()->i_checkCryptoExtPack(&strExtPack);
1172#else
1173 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
1174#endif
1175 }
1176 else
1177 {
1178#ifdef VBOX_WITH_EXTPACK
1179 hrc = mParent->i_getExtPackManager()->i_getDefaultCryptoExtPack(&strExtPack);
1180#endif
1181 if (strExtPack.isEmpty())
1182 {
1183 /*
1184 * Klugde - check if VBoxPuelCrypto.dll/.so/.dylib is installed.
1185 * This is hardcoded uglyness, sorry.
1186 */
1187 char szPath[RTPATH_MAX];
1188 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
1189 if (RT_SUCCESS(vrc))
1190 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxPuelCrypto");
1191 if (RT_SUCCESS(vrc))
1192 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
1193 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
1194 {
1195 /* Illegal extpack name, so no conflict. */
1196 strExtPack = VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME;
1197 }
1198 }
1199 }
1200
1201 if (SUCCEEDED(hrc))
1202 aExtPack = strExtPack;
1203
1204 return S_OK;
1205}
1206
1207
1208HRESULT SystemProperties::setDefaultCryptoExtPack(const com::Utf8Str &aExtPack)
1209{
1210 HRESULT hrc = S_OK;
1211 if (aExtPack.isNotEmpty())
1212 {
1213 if (aExtPack.equals(VBOXPUELCRYPTO_KLUDGE_EXTPACK_NAME))
1214 hrc = S_OK;
1215 else
1216#ifdef VBOX_WITH_EXTPACK
1217 hrc = mParent->i_getExtPackManager()->i_checkCryptoExtPack(&aExtPack);
1218#else
1219 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), aExtPack.c_str());
1220#endif
1221 }
1222 if (SUCCEEDED(hrc))
1223 {
1224 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1225 hrc = i_setDefaultCryptoExtPack(aExtPack);
1226 if (SUCCEEDED(hrc))
1227 {
1228 /* VirtualBox::i_saveSettings() needs the VirtualBox write lock. */
1229 alock.release();
1230 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1231 hrc = mParent->i_saveSettings();
1232 }
1233 }
1234
1235 return hrc;
1236}
1237
1238
1239HRESULT SystemProperties::getLogHistoryCount(ULONG *count)
1240{
1241 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1242
1243 *count = m->uLogHistoryCount;
1244
1245 return S_OK;
1246}
1247
1248
1249HRESULT SystemProperties::setLogHistoryCount(ULONG count)
1250{
1251 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1252 m->uLogHistoryCount = count;
1253 alock.release();
1254
1255 // VirtualBox::i_saveSettings() needs vbox write lock
1256 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1257 HRESULT rc = mParent->i_saveSettings();
1258
1259 return rc;
1260}
1261
1262HRESULT SystemProperties::getDefaultAudioDriver(AudioDriverType_T *aAudioDriver)
1263{
1264 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1265
1266 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
1267
1268 return S_OK;
1269}
1270
1271HRESULT SystemProperties::getAutostartDatabasePath(com::Utf8Str &aAutostartDbPath)
1272{
1273 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1274
1275 aAutostartDbPath = m->strAutostartDatabasePath;
1276
1277 return S_OK;
1278}
1279
1280HRESULT SystemProperties::setAutostartDatabasePath(const com::Utf8Str &aAutostartDbPath)
1281{
1282 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1283 HRESULT rc = i_setAutostartDatabasePath(aAutostartDbPath);
1284 alock.release();
1285
1286 if (SUCCEEDED(rc))
1287 {
1288 // VirtualBox::i_saveSettings() needs vbox write lock
1289 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1290 rc = mParent->i_saveSettings();
1291 }
1292
1293 return rc;
1294}
1295
1296HRESULT SystemProperties::getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
1297{
1298 return i_getDefaultAdditionsISO(aDefaultAdditionsISO);
1299}
1300
1301HRESULT SystemProperties::setDefaultAdditionsISO(const com::Utf8Str &aDefaultAdditionsISO)
1302{
1303 RT_NOREF(aDefaultAdditionsISO);
1304 /** @todo not yet implemented, settings handling is missing */
1305 ReturnComNotImplemented();
1306#if 0 /* not implemented */
1307 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1308 HRESULT rc = i_setDefaultAdditionsISO(aDefaultAdditionsISO);
1309 alock.release();
1310
1311 if (SUCCEEDED(rc))
1312 {
1313 // VirtualBox::i_saveSettings() needs vbox write lock
1314 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1315 rc = mParent->i_saveSettings();
1316 }
1317
1318 return rc;
1319#endif
1320}
1321
1322HRESULT SystemProperties::getDefaultFrontend(com::Utf8Str &aDefaultFrontend)
1323{
1324 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1325 aDefaultFrontend = m->strDefaultFrontend;
1326 return S_OK;
1327}
1328
1329HRESULT SystemProperties::setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
1330{
1331 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1332 if (m->strDefaultFrontend == aDefaultFrontend)
1333 return S_OK;
1334 HRESULT rc = i_setDefaultFrontend(aDefaultFrontend);
1335 alock.release();
1336
1337 if (SUCCEEDED(rc))
1338 {
1339 // VirtualBox::i_saveSettings() needs vbox write lock
1340 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
1341 rc = mParent->i_saveSettings();
1342 }
1343
1344 return rc;
1345}
1346
1347HRESULT SystemProperties::getScreenShotFormats(std::vector<BitmapFormat_T> &aBitmapFormats)
1348{
1349 aBitmapFormats.push_back(BitmapFormat_BGR0);
1350 aBitmapFormats.push_back(BitmapFormat_BGRA);
1351 aBitmapFormats.push_back(BitmapFormat_RGBA);
1352 aBitmapFormats.push_back(BitmapFormat_PNG);
1353 return S_OK;
1354}
1355
1356HRESULT SystemProperties::getProxyMode(ProxyMode_T *pProxyMode)
1357{
1358 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1359 ProxyMode_T enmMode = *pProxyMode = (ProxyMode_T)m->uProxyMode;
1360 AssertMsgReturn(enmMode == ProxyMode_System || enmMode == ProxyMode_NoProxy || enmMode == ProxyMode_Manual,
1361 ("enmMode=%d\n", enmMode), E_UNEXPECTED);
1362 return S_OK;
1363}
1364
1365HRESULT SystemProperties::setProxyMode(ProxyMode_T aProxyMode)
1366{
1367 /* Validate input. */
1368 switch (aProxyMode)
1369 {
1370 case ProxyMode_System:
1371 case ProxyMode_NoProxy:
1372 case ProxyMode_Manual:
1373 break;
1374 default:
1375 return setError(E_INVALIDARG, tr("Invalid ProxyMode value: %d"), (int)aProxyMode);
1376 }
1377
1378 /* Set and write out settings. */
1379 {
1380 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1381 m->uProxyMode = aProxyMode;
1382 }
1383 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1384 return mParent->i_saveSettings();
1385}
1386
1387HRESULT SystemProperties::getProxyURL(com::Utf8Str &aProxyURL)
1388{
1389 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1390 aProxyURL = m->strProxyUrl;
1391 return S_OK;
1392}
1393
1394HRESULT SystemProperties::setProxyURL(const com::Utf8Str &aProxyURL)
1395{
1396 /*
1397 * Validate input.
1398 */
1399 Utf8Str const *pStrProxyUrl = &aProxyURL;
1400 Utf8Str strTmp;
1401 if (pStrProxyUrl->isNotEmpty())
1402 {
1403 /* RTUriParse requires a scheme, so append 'http://' if none seems present: */
1404 if (pStrProxyUrl->find("://") == RTCString::npos)
1405 {
1406 strTmp.printf("http://%s", aProxyURL.c_str());
1407 pStrProxyUrl = &strTmp;
1408 }
1409
1410 /* Use RTUriParse to check the format. There must be a hostname, but nothing
1411 can follow it and the port. */
1412 RTURIPARSED Parsed;
1413 int vrc = RTUriParse(pStrProxyUrl->c_str(), &Parsed);
1414 if (RT_FAILURE(vrc))
1415 return setErrorBoth(E_INVALIDARG, vrc, tr("Failed to parse proxy URL: %Rrc"), vrc);
1416 if ( Parsed.cchAuthorityHost == 0
1417 && !RTUriIsSchemeMatch(pStrProxyUrl->c_str(), "direct"))
1418 return setError(E_INVALIDARG, tr("Proxy URL must include a hostname"));
1419 if (Parsed.cchPath > 0)
1420 return setError(E_INVALIDARG, tr("Proxy URL must not include a path component (%.*s)"),
1421 Parsed.cchPath, pStrProxyUrl->c_str() + Parsed.offPath);
1422 if (Parsed.cchQuery > 0)
1423 return setError(E_INVALIDARG, tr("Proxy URL must not include a query component (?%.*s)"),
1424 Parsed.cchQuery, pStrProxyUrl->c_str() + Parsed.offQuery);
1425 if (Parsed.cchFragment > 0)
1426 return setError(E_INVALIDARG, tr("Proxy URL must not include a fragment component (#%.*s)"),
1427 Parsed.cchFragment, pStrProxyUrl->c_str() + Parsed.offFragment);
1428 }
1429
1430 /*
1431 * Set and write out settings.
1432 */
1433 {
1434 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1435 m->strProxyUrl = *pStrProxyUrl;
1436 }
1437 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1438 return mParent->i_saveSettings();
1439}
1440
1441HRESULT SystemProperties::getSupportedParavirtProviders(std::vector<ParavirtProvider_T> &aSupportedParavirtProviders)
1442{
1443 static const ParavirtProvider_T aParavirtProviders[] =
1444 {
1445 ParavirtProvider_None,
1446 ParavirtProvider_Default,
1447 ParavirtProvider_Legacy,
1448 ParavirtProvider_Minimal,
1449 ParavirtProvider_HyperV,
1450 ParavirtProvider_KVM,
1451 };
1452 aSupportedParavirtProviders.assign(aParavirtProviders,
1453 aParavirtProviders + RT_ELEMENTS(aParavirtProviders));
1454 return S_OK;
1455}
1456
1457HRESULT SystemProperties::getSupportedClipboardModes(std::vector<ClipboardMode_T> &aSupportedClipboardModes)
1458{
1459 static const ClipboardMode_T aClipboardModes[] =
1460 {
1461 ClipboardMode_Disabled,
1462 ClipboardMode_HostToGuest,
1463 ClipboardMode_GuestToHost,
1464 ClipboardMode_Bidirectional,
1465 };
1466 aSupportedClipboardModes.assign(aClipboardModes,
1467 aClipboardModes + RT_ELEMENTS(aClipboardModes));
1468 return S_OK;
1469}
1470
1471HRESULT SystemProperties::getSupportedDnDModes(std::vector<DnDMode_T> &aSupportedDnDModes)
1472{
1473 static const DnDMode_T aDnDModes[] =
1474 {
1475 DnDMode_Disabled,
1476 DnDMode_HostToGuest,
1477 DnDMode_GuestToHost,
1478 DnDMode_Bidirectional,
1479 };
1480 aSupportedDnDModes.assign(aDnDModes,
1481 aDnDModes + RT_ELEMENTS(aDnDModes));
1482 return S_OK;
1483}
1484
1485HRESULT SystemProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
1486{
1487 static const FirmwareType_T aFirmwareTypes[] =
1488 {
1489 FirmwareType_BIOS,
1490 FirmwareType_EFI,
1491 FirmwareType_EFI32,
1492 FirmwareType_EFI64,
1493 FirmwareType_EFIDUAL,
1494 };
1495 aSupportedFirmwareTypes.assign(aFirmwareTypes,
1496 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
1497 return S_OK;
1498}
1499
1500HRESULT SystemProperties::getSupportedPointingHIDTypes(std::vector<PointingHIDType_T> &aSupportedPointingHIDTypes)
1501{
1502 static const PointingHIDType_T aPointingHIDTypes[] =
1503 {
1504 PointingHIDType_PS2Mouse,
1505#ifdef DEBUG
1506 PointingHIDType_USBMouse,
1507#endif
1508 PointingHIDType_USBTablet,
1509#ifdef DEBUG
1510 PointingHIDType_ComboMouse,
1511#endif
1512 PointingHIDType_USBMultiTouch,
1513 PointingHIDType_USBMultiTouchScreenPlusPad,
1514 };
1515 aSupportedPointingHIDTypes.assign(aPointingHIDTypes,
1516 aPointingHIDTypes + RT_ELEMENTS(aPointingHIDTypes));
1517 return S_OK;
1518}
1519
1520HRESULT SystemProperties::getSupportedKeyboardHIDTypes(std::vector<KeyboardHIDType_T> &aSupportedKeyboardHIDTypes)
1521{
1522 static const KeyboardHIDType_T aKeyboardHIDTypes[] =
1523 {
1524 KeyboardHIDType_PS2Keyboard,
1525 KeyboardHIDType_USBKeyboard,
1526#ifdef DEBUG
1527 KeyboardHIDType_ComboKeyboard,
1528#endif
1529 };
1530 aSupportedKeyboardHIDTypes.assign(aKeyboardHIDTypes,
1531 aKeyboardHIDTypes + RT_ELEMENTS(aKeyboardHIDTypes));
1532 return S_OK;
1533}
1534
1535HRESULT SystemProperties::getSupportedVFSTypes(std::vector<VFSType_T> &aSupportedVFSTypes)
1536{
1537 static const VFSType_T aVFSTypes[] =
1538 {
1539 VFSType_File,
1540 VFSType_Cloud,
1541 VFSType_S3,
1542#ifdef DEBUG
1543 VFSType_WebDav,
1544#endif
1545 };
1546 aSupportedVFSTypes.assign(aVFSTypes,
1547 aVFSTypes + RT_ELEMENTS(aVFSTypes));
1548 return S_OK;
1549}
1550
1551HRESULT SystemProperties::getSupportedImportOptions(std::vector<ImportOptions_T> &aSupportedImportOptions)
1552{
1553 static const ImportOptions_T aImportOptions[] =
1554 {
1555 ImportOptions_KeepAllMACs,
1556 ImportOptions_KeepNATMACs,
1557 ImportOptions_ImportToVDI,
1558 };
1559 aSupportedImportOptions.assign(aImportOptions,
1560 aImportOptions + RT_ELEMENTS(aImportOptions));
1561 return S_OK;
1562}
1563
1564HRESULT SystemProperties::getSupportedExportOptions(std::vector<ExportOptions_T> &aSupportedExportOptions)
1565{
1566 static const ExportOptions_T aExportOptions[] =
1567 {
1568 ExportOptions_CreateManifest,
1569 ExportOptions_ExportDVDImages,
1570 ExportOptions_StripAllMACs,
1571 ExportOptions_StripAllNonNATMACs,
1572 };
1573 aSupportedExportOptions.assign(aExportOptions,
1574 aExportOptions + RT_ELEMENTS(aExportOptions));
1575 return S_OK;
1576}
1577
1578HRESULT SystemProperties::getSupportedRecordingFeatures(std::vector<RecordingFeature_T> &aSupportedRecordingFeatures)
1579{
1580#ifdef VBOX_WITH_RECORDING
1581 static const RecordingFeature_T aRecordingFeatures[] =
1582 {
1583# ifdef VBOX_WITH_AUDIO_RECORDING
1584 RecordingFeature_Audio,
1585# endif
1586 RecordingFeature_Video,
1587 };
1588 aSupportedRecordingFeatures.assign(aRecordingFeatures,
1589 aRecordingFeatures + RT_ELEMENTS(aRecordingFeatures));
1590#else /* !VBOX_WITH_RECORDING */
1591 aSupportedRecordingFeatures.clear();
1592#endif /* VBOX_WITH_RECORDING */
1593 return S_OK;
1594}
1595
1596HRESULT SystemProperties::getSupportedRecordingAudioCodecs(std::vector<RecordingAudioCodec_T> &aSupportedRecordingAudioCodecs)
1597{
1598 static const RecordingAudioCodec_T aRecordingAudioCodecs[] =
1599 {
1600#ifdef DEBUG
1601 RecordingAudioCodec_WavPCM,
1602#endif
1603#ifdef VBOX_WITH_LIBOPUS
1604 RecordingAudioCodec_Opus,
1605#endif
1606#ifdef VBOX_WITH_LIBVORBIS
1607 RecordingAudioCodec_OggVorbis,
1608#endif
1609 };
1610 aSupportedRecordingAudioCodecs.assign(aRecordingAudioCodecs,
1611 aRecordingAudioCodecs + RT_ELEMENTS(aRecordingAudioCodecs));
1612 return S_OK;
1613}
1614
1615HRESULT SystemProperties::getSupportedRecordingVideoCodecs(std::vector<RecordingVideoCodec_T> &aSupportedRecordingVideoCodecs)
1616{
1617 static const RecordingVideoCodec_T aRecordingVideoCodecs[] =
1618 {
1619 RecordingVideoCodec_VP8,
1620#ifdef DEBUG
1621 RecordingVideoCodec_VP9,
1622 RecordingVideoCodec_AV1,
1623#endif
1624 };
1625 aSupportedRecordingVideoCodecs.assign(aRecordingVideoCodecs,
1626 aRecordingVideoCodecs + RT_ELEMENTS(aRecordingVideoCodecs));
1627 return S_OK;
1628}
1629
1630HRESULT SystemProperties::getSupportedRecordingVSModes(std::vector<RecordingVideoScalingMode_T> &aSupportedRecordingVideoScalingModes)
1631{
1632 static const RecordingVideoScalingMode_T aRecordingVideoScalingModes[] =
1633 {
1634 RecordingVideoScalingMode_None,
1635#ifdef DEBUG
1636 RecordingVideoScalingMode_NearestNeighbor,
1637 RecordingVideoScalingMode_Bilinear,
1638 RecordingVideoScalingMode_Bicubic,
1639#endif
1640 };
1641 aSupportedRecordingVideoScalingModes.assign(aRecordingVideoScalingModes,
1642 aRecordingVideoScalingModes + RT_ELEMENTS(aRecordingVideoScalingModes));
1643 return S_OK;
1644}
1645
1646HRESULT SystemProperties::getSupportedRecordingARCModes(std::vector<RecordingRateControlMode_T> &aSupportedRecordingAudioRateControlModes)
1647{
1648 static const RecordingRateControlMode_T aRecordingAudioRateControlModes[] =
1649 {
1650#ifdef DEBUG
1651 RecordingRateControlMode_ABR,
1652 RecordingRateControlMode_CBR,
1653#endif
1654 RecordingRateControlMode_VBR
1655 };
1656 aSupportedRecordingAudioRateControlModes.assign(aRecordingAudioRateControlModes,
1657 aRecordingAudioRateControlModes + RT_ELEMENTS(aRecordingAudioRateControlModes));
1658 return S_OK;
1659}
1660
1661HRESULT SystemProperties::getSupportedRecordingVRCModes(std::vector<RecordingRateControlMode_T> &aSupportedRecordingVideoRateControlModes)
1662{
1663 static const RecordingRateControlMode_T aRecordingVideoRateControlModes[] =
1664 {
1665#ifdef DEBUG
1666 RecordingRateControlMode_ABR,
1667 RecordingRateControlMode_CBR,
1668#endif
1669 RecordingRateControlMode_VBR
1670 };
1671 aSupportedRecordingVideoRateControlModes.assign(aRecordingVideoRateControlModes,
1672 aRecordingVideoRateControlModes + RT_ELEMENTS(aRecordingVideoRateControlModes));
1673 return S_OK;
1674}
1675
1676HRESULT SystemProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
1677{
1678 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
1679 {
1680 GraphicsControllerType_VBoxVGA,
1681 GraphicsControllerType_VMSVGA,
1682 GraphicsControllerType_VBoxSVGA,
1683 GraphicsControllerType_Null,
1684 };
1685 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes,
1686 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
1687 return S_OK;
1688}
1689
1690HRESULT SystemProperties::getSupportedCloneOptions(std::vector<CloneOptions_T> &aSupportedCloneOptions)
1691{
1692 static const CloneOptions_T aCloneOptions[] =
1693 {
1694 CloneOptions_Link,
1695 CloneOptions_KeepAllMACs,
1696 CloneOptions_KeepNATMACs,
1697 CloneOptions_KeepDiskNames,
1698 CloneOptions_KeepHwUUIDs,
1699 };
1700 aSupportedCloneOptions.assign(aCloneOptions,
1701 aCloneOptions + RT_ELEMENTS(aCloneOptions));
1702 return S_OK;
1703}
1704
1705HRESULT SystemProperties::getSupportedAutostopTypes(std::vector<AutostopType_T> &aSupportedAutostopTypes)
1706{
1707 static const AutostopType_T aAutostopTypes[] =
1708 {
1709 AutostopType_Disabled,
1710 AutostopType_SaveState,
1711 AutostopType_PowerOff,
1712 AutostopType_AcpiShutdown,
1713 };
1714 aSupportedAutostopTypes.assign(aAutostopTypes,
1715 aAutostopTypes + RT_ELEMENTS(aAutostopTypes));
1716 return S_OK;
1717}
1718
1719HRESULT SystemProperties::getSupportedVMProcPriorities(std::vector<VMProcPriority_T> &aSupportedVMProcPriorities)
1720{
1721 static const VMProcPriority_T aVMProcPriorities[] =
1722 {
1723 VMProcPriority_Default,
1724 VMProcPriority_Flat,
1725 VMProcPriority_Low,
1726 VMProcPriority_Normal,
1727 VMProcPriority_High,
1728 };
1729 aSupportedVMProcPriorities.assign(aVMProcPriorities,
1730 aVMProcPriorities + RT_ELEMENTS(aVMProcPriorities));
1731 return S_OK;
1732}
1733
1734HRESULT SystemProperties::getSupportedNetworkAttachmentTypes(std::vector<NetworkAttachmentType_T> &aSupportedNetworkAttachmentTypes)
1735{
1736 static const NetworkAttachmentType_T aNetworkAttachmentTypes[] =
1737 {
1738 NetworkAttachmentType_NAT,
1739 NetworkAttachmentType_Bridged,
1740 NetworkAttachmentType_Internal,
1741 NetworkAttachmentType_HostOnly,
1742#ifdef VBOX_WITH_VMNET
1743 NetworkAttachmentType_HostOnlyNetwork,
1744#endif /* VBOX_WITH_VMNET */
1745 NetworkAttachmentType_Generic,
1746 NetworkAttachmentType_NATNetwork,
1747#ifdef VBOX_WITH_CLOUD_NET
1748 NetworkAttachmentType_Cloud,
1749#endif
1750 NetworkAttachmentType_Null,
1751 };
1752 aSupportedNetworkAttachmentTypes.assign(aNetworkAttachmentTypes,
1753 aNetworkAttachmentTypes + RT_ELEMENTS(aNetworkAttachmentTypes));
1754 return S_OK;
1755}
1756
1757HRESULT SystemProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
1758{
1759 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
1760 {
1761 NetworkAdapterType_Am79C970A,
1762 NetworkAdapterType_Am79C973,
1763 NetworkAdapterType_I82540EM,
1764 NetworkAdapterType_I82543GC,
1765 NetworkAdapterType_I82545EM,
1766 NetworkAdapterType_Virtio,
1767 };
1768 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes,
1769 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
1770 return S_OK;
1771}
1772
1773HRESULT SystemProperties::getSupportedPortModes(std::vector<PortMode_T> &aSupportedPortModes)
1774{
1775 static const PortMode_T aPortModes[] =
1776 {
1777 PortMode_Disconnected,
1778 PortMode_HostPipe,
1779 PortMode_HostDevice,
1780 PortMode_RawFile,
1781 PortMode_TCP,
1782 };
1783 aSupportedPortModes.assign(aPortModes,
1784 aPortModes + RT_ELEMENTS(aPortModes));
1785 return S_OK;
1786}
1787
1788HRESULT SystemProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
1789{
1790 static const UartType_T aUartTypes[] =
1791 {
1792 UartType_U16450,
1793 UartType_U16550A,
1794 UartType_U16750,
1795 };
1796 aSupportedUartTypes.assign(aUartTypes,
1797 aUartTypes + RT_ELEMENTS(aUartTypes));
1798 return S_OK;
1799}
1800
1801HRESULT SystemProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
1802{
1803 static const USBControllerType_T aUSBControllerTypesWithoutExtPack[] =
1804 {
1805 USBControllerType_OHCI,
1806 };
1807 static const USBControllerType_T aUSBControllerTypesWithExtPack[] =
1808 {
1809 USBControllerType_OHCI,
1810 USBControllerType_EHCI,
1811 USBControllerType_XHCI,
1812 };
1813 bool fExtPack = false;
1814# ifdef VBOX_WITH_EXTPACK
1815 static const char *s_pszUsbExtPackName = "Oracle VM VirtualBox Extension Pack";
1816 if (mParent->i_getExtPackManager()->i_isExtPackUsable(s_pszUsbExtPackName))
1817# endif
1818 {
1819 fExtPack = true;
1820 }
1821
1822 if (fExtPack)
1823 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithExtPack,
1824 aUSBControllerTypesWithExtPack + RT_ELEMENTS(aUSBControllerTypesWithExtPack));
1825 else
1826 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithoutExtPack,
1827 aUSBControllerTypesWithoutExtPack + RT_ELEMENTS(aUSBControllerTypesWithoutExtPack));
1828 return S_OK;
1829}
1830
1831HRESULT SystemProperties::getSupportedAudioDriverTypes(std::vector<AudioDriverType_T> &aSupportedAudioDriverTypes)
1832{
1833 static const AudioDriverType_T aAudioDriverTypes[] =
1834 {
1835 AudioDriverType_Default,
1836#ifdef RT_OS_WINDOWS
1837# if 0 /* deprecated for many years now */
1838 AudioDriverType_WinMM,
1839# endif
1840 AudioDriverType_WAS,
1841 AudioDriverType_DirectSound,
1842#endif
1843#ifdef RT_OS_DARWIN
1844 AudioDriverType_CoreAudio,
1845#endif
1846#ifdef RT_OS_OS2
1847 AudioDriverType_MMPM,
1848#endif
1849#ifdef RT_OS_SOLARIS
1850# if 0 /* deprecated for many years now */
1851 AudioDriverType_SolAudio,
1852# endif
1853#endif
1854#ifdef VBOX_WITH_AUDIO_ALSA
1855 AudioDriverType_ALSA,
1856#endif
1857#ifdef VBOX_WITH_AUDIO_OSS
1858 AudioDriverType_OSS,
1859#endif
1860#ifdef VBOX_WITH_AUDIO_PULSE
1861 AudioDriverType_Pulse,
1862#endif
1863 AudioDriverType_Null,
1864 };
1865 aSupportedAudioDriverTypes.assign(aAudioDriverTypes,
1866 aAudioDriverTypes + RT_ELEMENTS(aAudioDriverTypes));
1867 return S_OK;
1868}
1869
1870HRESULT SystemProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
1871{
1872 static const AudioControllerType_T aAudioControllerTypes[] =
1873 {
1874 AudioControllerType_AC97,
1875 AudioControllerType_SB16,
1876 AudioControllerType_HDA,
1877 };
1878 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
1879 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
1880 return S_OK;
1881}
1882
1883HRESULT SystemProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
1884{
1885 static const StorageBus_T aStorageBuses[] =
1886 {
1887 StorageBus_SATA,
1888 StorageBus_IDE,
1889 StorageBus_SCSI,
1890 StorageBus_Floppy,
1891 StorageBus_SAS,
1892 StorageBus_USB,
1893 StorageBus_PCIe,
1894 StorageBus_VirtioSCSI,
1895 };
1896 aSupportedStorageBuses.assign(aStorageBuses,
1897 aStorageBuses + RT_ELEMENTS(aStorageBuses));
1898 return S_OK;
1899}
1900
1901HRESULT SystemProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
1902{
1903 static const StorageControllerType_T aStorageControllerTypes[] =
1904 {
1905 StorageControllerType_IntelAhci,
1906 StorageControllerType_PIIX4,
1907 StorageControllerType_PIIX3,
1908 StorageControllerType_ICH6,
1909 StorageControllerType_LsiLogic,
1910 StorageControllerType_BusLogic,
1911 StorageControllerType_I82078,
1912 StorageControllerType_LsiLogicSas,
1913 StorageControllerType_USB,
1914 StorageControllerType_NVMe,
1915 StorageControllerType_VirtioSCSI,
1916 };
1917 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
1918 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
1919 return S_OK;
1920}
1921
1922HRESULT SystemProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
1923{
1924 static const ChipsetType_T aChipsetTypes[] =
1925 {
1926 ChipsetType_PIIX3,
1927 ChipsetType_ICH9,
1928 };
1929 aSupportedChipsetTypes.assign(aChipsetTypes,
1930 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
1931 return S_OK;
1932}
1933
1934HRESULT SystemProperties::getSupportedIommuTypes(std::vector<IommuType_T> &aSupportedIommuTypes)
1935{
1936 static const IommuType_T aIommuTypes[] =
1937 {
1938 IommuType_None,
1939 IommuType_Automatic,
1940 IommuType_AMD,
1941 /** @todo Add Intel when it's supported. */
1942 };
1943 aSupportedIommuTypes.assign(aIommuTypes,
1944 aIommuTypes + RT_ELEMENTS(aIommuTypes));
1945 return S_OK;
1946}
1947
1948
1949// public methods only for internal purposes
1950/////////////////////////////////////////////////////////////////////////////
1951
1952HRESULT SystemProperties::i_loadSettings(const settings::SystemProperties &data)
1953{
1954 AutoCaller autoCaller(this);
1955 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1956
1957 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1958 HRESULT rc = S_OK;
1959 rc = i_setDefaultMachineFolder(data.strDefaultMachineFolder);
1960 if (FAILED(rc)) return rc;
1961
1962 rc = i_setLoggingLevel(data.strLoggingLevel);
1963 if (FAILED(rc)) return rc;
1964
1965 rc = i_setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
1966 if (FAILED(rc)) return rc;
1967
1968 rc = i_setVRDEAuthLibrary(data.strVRDEAuthLibrary);
1969 if (FAILED(rc)) return rc;
1970
1971 rc = i_setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
1972 if (FAILED(rc)) return rc;
1973
1974 rc = i_setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
1975 if (FAILED(rc)) return rc;
1976
1977 rc = i_setDefaultCryptoExtPack(data.strDefaultCryptoExtPack);
1978 if (FAILED(rc)) return rc;
1979
1980 m->uLogHistoryCount = data.uLogHistoryCount;
1981 m->fExclusiveHwVirt = data.fExclusiveHwVirt;
1982 m->uProxyMode = data.uProxyMode;
1983 m->strProxyUrl = data.strProxyUrl;
1984
1985 m->strLanguageId = data.strLanguageId;
1986
1987 rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath);
1988 if (FAILED(rc)) return rc;
1989
1990 {
1991 /* must ignore errors signalled here, because the guest additions
1992 * file may not exist, and in this case keep the empty string */
1993 ErrorInfoKeeper eik;
1994 (void)i_setDefaultAdditionsISO(data.strDefaultAdditionsISO);
1995 }
1996
1997 rc = i_setDefaultFrontend(data.strDefaultFrontend);
1998 if (FAILED(rc)) return rc;
1999
2000 return S_OK;
2001}
2002
2003HRESULT SystemProperties::i_saveSettings(settings::SystemProperties &data)
2004{
2005 AutoCaller autoCaller(this);
2006 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2007
2008 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2009
2010 data = *m;
2011
2012 return S_OK;
2013}
2014
2015/**
2016 * Returns a medium format object corresponding to the given format
2017 * identifier or null if no such format.
2018 *
2019 * @param aFormat Format identifier.
2020 *
2021 * @return ComObjPtr<MediumFormat>
2022 */
2023ComObjPtr<MediumFormat> SystemProperties::i_mediumFormat(const Utf8Str &aFormat)
2024{
2025 ComObjPtr<MediumFormat> format;
2026
2027 AutoCaller autoCaller(this);
2028 AssertComRCReturn (autoCaller.rc(), format);
2029
2030 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2031
2032 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
2033 it != m_llMediumFormats.end();
2034 ++ it)
2035 {
2036 /* MediumFormat is all const, no need to lock */
2037
2038 if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
2039 {
2040 format = *it;
2041 break;
2042 }
2043 }
2044
2045 return format;
2046}
2047
2048/**
2049 * Returns a medium format object corresponding to the given file extension or
2050 * null if no such format.
2051 *
2052 * @param aExt File extension.
2053 *
2054 * @return ComObjPtr<MediumFormat>
2055 */
2056ComObjPtr<MediumFormat> SystemProperties::i_mediumFormatFromExtension(const Utf8Str &aExt)
2057{
2058 ComObjPtr<MediumFormat> format;
2059
2060 AutoCaller autoCaller(this);
2061 AssertComRCReturn (autoCaller.rc(), format);
2062
2063 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2064
2065 bool fFound = false;
2066 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
2067 it != m_llMediumFormats.end() && !fFound;
2068 ++it)
2069 {
2070 /* MediumFormat is all const, no need to lock */
2071 MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
2072 for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
2073 it1 != aFileList.end();
2074 ++it1)
2075 {
2076 if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
2077 {
2078 format = *it;
2079 fFound = true;
2080 break;
2081 }
2082 }
2083 }
2084
2085 return format;
2086}
2087
2088
2089/**
2090 * VD plugin load
2091 */
2092int SystemProperties::i_loadVDPlugin(const char *pszPluginLibrary)
2093{
2094 int vrc = VDPluginLoadFromFilename(pszPluginLibrary);
2095 LogFlowFunc(("pszPluginLibrary='%s' -> %Rrc\n", pszPluginLibrary, vrc));
2096 return vrc;
2097}
2098
2099/**
2100 * VD plugin unload
2101 */
2102int SystemProperties::i_unloadVDPlugin(const char *pszPluginLibrary)
2103{
2104 int vrc = VDPluginUnloadFromFilename(pszPluginLibrary);
2105 LogFlowFunc(("pszPluginLibrary='%s' -> %Rrc\n", pszPluginLibrary, vrc));
2106 return vrc;
2107}
2108
2109/**
2110 * Internally usable version of getDefaultAdditionsISO.
2111 */
2112HRESULT SystemProperties::i_getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
2113{
2114 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2115 if (m->strDefaultAdditionsISO.isNotEmpty())
2116 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
2117 else
2118 {
2119 /* no guest additions, check if it showed up in the mean time */
2120 alock.release();
2121 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
2122 if (m->strDefaultAdditionsISO.isEmpty())
2123 {
2124 ErrorInfoKeeper eik;
2125 (void)i_setDefaultAdditionsISO("");
2126 }
2127 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
2128 }
2129 return S_OK;
2130}
2131
2132// private methods
2133/////////////////////////////////////////////////////////////////////////////
2134
2135/**
2136 * Returns the user's home directory. Wrapper around RTPathUserHome().
2137 * @param strPath
2138 * @return
2139 */
2140HRESULT SystemProperties::i_getUserHomeDirectory(Utf8Str &strPath)
2141{
2142 char szHome[RTPATH_MAX];
2143 int vrc = RTPathUserHome(szHome, sizeof(szHome));
2144 if (RT_FAILURE(vrc))
2145 return setErrorBoth(E_FAIL, vrc,
2146 tr("Cannot determine user home directory (%Rrc)"),
2147 vrc);
2148 strPath = szHome;
2149 return S_OK;
2150}
2151
2152/**
2153 * Internal implementation to set the default machine folder. Gets called
2154 * from the public attribute setter as well as loadSettings(). With 4.0,
2155 * the "default default" machine folder has changed, and we now require
2156 * a full path always.
2157 * @param strPath
2158 * @return
2159 */
2160HRESULT SystemProperties::i_setDefaultMachineFolder(const Utf8Str &strPath)
2161{
2162 Utf8Str path(strPath); // make modifiable
2163 if ( path.isEmpty() // used by API calls to reset the default
2164 || path == "Machines" // this value (exactly like this, without path) is stored
2165 // in VirtualBox.xml if user upgrades from before 4.0 and
2166 // has not changed the default machine folder
2167 )
2168 {
2169 // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
2170 HRESULT rc = i_getUserHomeDirectory(path);
2171 if (FAILED(rc)) return rc;
2172 path += RTPATH_SLASH_STR "VirtualBox VMs";
2173 }
2174
2175 if (!RTPathStartsWithRoot(path.c_str()))
2176 return setError(E_INVALIDARG,
2177 tr("Given default machine folder '%s' is not fully qualified"),
2178 path.c_str());
2179
2180 m->strDefaultMachineFolder = path;
2181
2182 return S_OK;
2183}
2184
2185HRESULT SystemProperties::i_setLoggingLevel(const com::Utf8Str &aLoggingLevel)
2186{
2187 Utf8Str useLoggingLevel(aLoggingLevel);
2188 if (useLoggingLevel.isEmpty())
2189 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
2190 int rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str());
2191 // If failed and not the default logging level - try to use the default logging level.
2192 if (RT_FAILURE(rc))
2193 {
2194 // If failed write message to the release log.
2195 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
2196 // If attempted logging level not the default one then try the default one.
2197 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
2198 {
2199 rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), VBOXSVC_LOG_DEFAULT);
2200 // If failed report this to the release log.
2201 if (RT_FAILURE(rc))
2202 LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
2203 }
2204 // On any failure - set default level as the one to be stored.
2205 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
2206 }
2207 // Set to passed value or if default used/attempted (even if error condition) use empty string.
2208 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
2209 return RT_SUCCESS(rc) ? S_OK : E_FAIL;
2210}
2211
2212HRESULT SystemProperties::i_setDefaultHardDiskFormat(const com::Utf8Str &aFormat)
2213{
2214 if (!aFormat.isEmpty())
2215 m->strDefaultHardDiskFormat = aFormat;
2216 else
2217 m->strDefaultHardDiskFormat = "VDI";
2218
2219 return S_OK;
2220}
2221
2222HRESULT SystemProperties::i_setVRDEAuthLibrary(const com::Utf8Str &aPath)
2223{
2224 if (!aPath.isEmpty())
2225 m->strVRDEAuthLibrary = aPath;
2226 else
2227 m->strVRDEAuthLibrary = "VBoxAuth";
2228
2229 return S_OK;
2230}
2231
2232HRESULT SystemProperties::i_setWebServiceAuthLibrary(const com::Utf8Str &aPath)
2233{
2234 if (!aPath.isEmpty())
2235 m->strWebServiceAuthLibrary = aPath;
2236 else
2237 m->strWebServiceAuthLibrary = "VBoxAuth";
2238
2239 return S_OK;
2240}
2241
2242HRESULT SystemProperties::i_setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
2243{
2244 m->strDefaultVRDEExtPack = aExtPack;
2245
2246 return S_OK;
2247}
2248
2249HRESULT SystemProperties::i_setDefaultCryptoExtPack(const com::Utf8Str &aExtPack)
2250{
2251 m->strDefaultCryptoExtPack = aExtPack;
2252
2253 return S_OK;
2254}
2255
2256HRESULT SystemProperties::i_setAutostartDatabasePath(const com::Utf8Str &aPath)
2257{
2258 HRESULT rc = S_OK;
2259 AutostartDb *autostartDb = this->mParent->i_getAutostartDb();
2260
2261 if (!aPath.isEmpty())
2262 {
2263 /* Update path in the autostart database. */
2264 int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
2265 if (RT_SUCCESS(vrc))
2266 m->strAutostartDatabasePath = aPath;
2267 else
2268 rc = setErrorBoth(E_FAIL, vrc,
2269 tr("Cannot set the autostart database path (%Rrc)"),
2270 vrc);
2271 }
2272 else
2273 {
2274 int vrc = autostartDb->setAutostartDbPath(NULL);
2275 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
2276 m->strAutostartDatabasePath = "";
2277 else
2278 rc = setErrorBoth(E_FAIL, vrc,
2279 tr("Deleting the autostart database path failed (%Rrc)"),
2280 vrc);
2281 }
2282
2283 return rc;
2284}
2285
2286HRESULT SystemProperties::i_setDefaultAdditionsISO(const com::Utf8Str &aPath)
2287{
2288 com::Utf8Str path(aPath);
2289 if (path.isEmpty())
2290 {
2291 char strTemp[RTPATH_MAX];
2292 int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
2293 AssertRC(vrc);
2294 Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
2295
2296 vrc = RTPathExecDir(strTemp, sizeof(strTemp));
2297 AssertRC(vrc);
2298 Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
2299
2300 vrc = RTPathUserHome(strTemp, sizeof(strTemp));
2301 AssertRC(vrc);
2302 Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%s.iso", strTemp, VirtualBox::i_getVersionNormalized().c_str());
2303
2304 /* Check the standard image locations */
2305 if (RTFileExists(strSrc1.c_str()))
2306 path = strSrc1;
2307 else if (RTFileExists(strSrc2.c_str()))
2308 path = strSrc2;
2309 else if (RTFileExists(strSrc3.c_str()))
2310 path = strSrc3;
2311 else
2312 return setError(E_FAIL,
2313 tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
2314 }
2315
2316 if (!RTPathStartsWithRoot(path.c_str()))
2317 return setError(E_INVALIDARG,
2318 tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
2319 path.c_str());
2320
2321 if (!RTFileExists(path.c_str()))
2322 return setError(E_INVALIDARG,
2323 tr("Given default machine Guest Additions ISO file '%s' does not exist"),
2324 path.c_str());
2325
2326 m->strDefaultAdditionsISO = path;
2327
2328 return S_OK;
2329}
2330
2331HRESULT SystemProperties::i_setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
2332{
2333 m->strDefaultFrontend = aDefaultFrontend;
2334
2335 return S_OK;
2336}
2337
2338HRESULT SystemProperties::getLanguageId(com::Utf8Str &aLanguageId)
2339{
2340#ifdef VBOX_WITH_MAIN_NLS
2341 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2342 aLanguageId = m->strLanguageId;
2343 alock.release();
2344
2345 HRESULT hrc = S_OK;
2346 if (aLanguageId.isEmpty())
2347 {
2348 char szLocale[256];
2349 memset(szLocale, 0, sizeof(szLocale));
2350 int vrc = RTLocaleQueryNormalizedBaseLocaleName(szLocale, sizeof(szLocale));
2351 if (RT_SUCCESS(vrc))
2352 aLanguageId = szLocale;
2353 else
2354 hrc = Global::vboxStatusCodeToCOM(vrc);
2355 }
2356 return hrc;
2357#else
2358 aLanguageId = "C";
2359 return S_OK;
2360#endif
2361}
2362
2363HRESULT SystemProperties::setLanguageId(const com::Utf8Str &aLanguageId)
2364{
2365#ifdef VBOX_WITH_MAIN_NLS
2366 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::instance();
2367 if (!pTranslator)
2368 return E_FAIL;
2369
2370 HRESULT hrc = S_OK;
2371 int vrc = pTranslator->i_loadLanguage(aLanguageId.c_str());
2372 if (RT_SUCCESS(vrc))
2373 {
2374 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2375 m->strLanguageId = aLanguageId;
2376 alock.release();
2377
2378 // VirtualBox::i_saveSettings() needs vbox write lock
2379 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
2380 hrc = mParent->i_saveSettings();
2381 }
2382 else
2383 hrc = Global::vboxStatusCodeToCOM(vrc);
2384
2385 pTranslator->release();
2386
2387 if (SUCCEEDED(hrc))
2388 mParent->i_onLanguageChanged(aLanguageId);
2389
2390 return hrc;
2391#else
2392 NOREF(aLanguageId);
2393 return E_NOTIMPL;
2394#endif
2395}
2396
Note: See TracBrowser for help on using the repository browser.

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