VirtualBox

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

Last change on this file since 82105 was 82105, checked in by vboxsync, 5 years ago

Main/SystemProperties: let virtio-scsi also handle DVD drives

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 55.5 KB
Line 
1/* $Id: SystemPropertiesImpl.cpp 82105 2019-11-22 18:06:08Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. 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 "AutoCaller.h"
26#include "Global.h"
27#include "LoggingNew.h"
28#include "AutostartDb.h"
29
30// generated header
31#include "SchemaDefs.h"
32
33#include <iprt/dir.h>
34#include <iprt/ldr.h>
35#include <iprt/path.h>
36#include <iprt/string.h>
37#include <iprt/uri.h>
38#include <iprt/cpp/utils.h>
39
40#include <iprt/errcore.h>
41#include <VBox/param.h>
42#include <VBox/settings.h>
43#include <VBox/vd.h>
44
45// defines
46/////////////////////////////////////////////////////////////////////////////
47
48// constructor / destructor
49/////////////////////////////////////////////////////////////////////////////
50
51SystemProperties::SystemProperties()
52 : mParent(NULL),
53 m(new settings::SystemProperties)
54{
55}
56
57SystemProperties::~SystemProperties()
58{
59 delete m;
60}
61
62
63HRESULT SystemProperties::FinalConstruct()
64{
65 return BaseFinalConstruct();
66}
67
68void SystemProperties::FinalRelease()
69{
70 uninit();
71 BaseFinalRelease();
72}
73
74// public methods only for internal purposes
75/////////////////////////////////////////////////////////////////////////////
76
77/**
78 * Initializes the system information object.
79 *
80 * @returns COM result indicator
81 */
82HRESULT SystemProperties::init(VirtualBox *aParent)
83{
84 LogFlowThisFunc(("aParent=%p\n", aParent));
85
86 ComAssertRet(aParent, E_FAIL);
87
88 /* Enclose the state transition NotReady->InInit->Ready */
89 AutoInitSpan autoInitSpan(this);
90 AssertReturn(autoInitSpan.isOk(), E_FAIL);
91
92 unconst(mParent) = aParent;
93
94 i_setDefaultMachineFolder(Utf8Str::Empty);
95 i_setLoggingLevel(Utf8Str::Empty);
96 i_setDefaultHardDiskFormat(Utf8Str::Empty);
97
98 i_setVRDEAuthLibrary(Utf8Str::Empty);
99 i_setDefaultVRDEExtPack(Utf8Str::Empty);
100
101 m->uLogHistoryCount = 3;
102
103
104 /* On Windows, OS X and Solaris, HW virtualization use isn't exclusive
105 * by default so that VT-x or AMD-V can be shared with other
106 * hypervisors without requiring user intervention.
107 * NB: See also SystemProperties constructor in settings.h
108 */
109#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
110 m->fExclusiveHwVirt = false;
111#else
112 m->fExclusiveHwVirt = true;
113#endif
114
115 HRESULT rc = S_OK;
116
117 /* Fetch info of all available hd backends. */
118
119 /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
120 /// any number of backends
121
122 VDBACKENDINFO aVDInfo[100];
123 unsigned cEntries;
124 int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
125 AssertRC(vrc);
126 if (RT_SUCCESS(vrc))
127 {
128 for (unsigned i = 0; i < cEntries; ++ i)
129 {
130 ComObjPtr<MediumFormat> hdf;
131 rc = hdf.createObject();
132 if (FAILED(rc)) break;
133
134 rc = hdf->init(&aVDInfo[i]);
135 if (FAILED(rc)) break;
136
137 m_llMediumFormats.push_back(hdf);
138 }
139 }
140
141 /* Confirm a successful initialization */
142 if (SUCCEEDED(rc))
143 autoInitSpan.setSucceeded();
144
145 return rc;
146}
147
148/**
149 * Uninitializes the instance and sets the ready flag to FALSE.
150 * Called either from FinalRelease() or by the parent when it gets destroyed.
151 */
152void SystemProperties::uninit()
153{
154 LogFlowThisFunc(("\n"));
155
156 /* Enclose the state transition Ready->InUninit->NotReady */
157 AutoUninitSpan autoUninitSpan(this);
158 if (autoUninitSpan.uninitDone())
159 return;
160
161 unconst(mParent) = NULL;
162}
163
164// wrapped ISystemProperties properties
165/////////////////////////////////////////////////////////////////////////////
166
167HRESULT SystemProperties::getMinGuestRAM(ULONG *minRAM)
168
169{
170 /* no need to lock, this is const */
171 AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
172 *minRAM = MM_RAM_MIN_IN_MB;
173
174 return S_OK;
175}
176
177HRESULT SystemProperties::getMaxGuestRAM(ULONG *maxRAM)
178{
179 /* no need to lock, this is const */
180 AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
181 ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
182 ULONG maxRAMArch = maxRAMSys;
183 *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
184
185 return S_OK;
186}
187
188HRESULT SystemProperties::getMinGuestVRAM(ULONG *minVRAM)
189{
190 /* no need to lock, this is const */
191 *minVRAM = SchemaDefs::MinGuestVRAM;
192
193 return S_OK;
194}
195
196HRESULT SystemProperties::getMaxGuestVRAM(ULONG *maxVRAM)
197{
198 /* no need to lock, this is const */
199 *maxVRAM = SchemaDefs::MaxGuestVRAM;
200
201 return S_OK;
202}
203
204HRESULT SystemProperties::getMinGuestCPUCount(ULONG *minCPUCount)
205{
206 /* no need to lock, this is const */
207 *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
208
209 return S_OK;
210}
211
212HRESULT SystemProperties::getMaxGuestCPUCount(ULONG *maxCPUCount)
213{
214 /* no need to lock, this is const */
215 *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
216
217 return S_OK;
218}
219
220HRESULT SystemProperties::getMaxGuestMonitors(ULONG *maxMonitors)
221{
222
223 /* no need to lock, this is const */
224 *maxMonitors = SchemaDefs::MaxGuestMonitors;
225
226 return S_OK;
227}
228
229
230HRESULT SystemProperties::getInfoVDSize(LONG64 *infoVDSize)
231{
232 /*
233 * The BIOS supports currently 32 bit LBA numbers (implementing the full
234 * 48 bit range is in theory trivial, but the crappy compiler makes things
235 * more difficult). This translates to almost 2 TiBytes (to be on the safe
236 * side, the reported limit is 1 MiByte less than that, as the total number
237 * of sectors should fit in 32 bits, too), which should be enough for the
238 * moment. Since the MBR partition tables support only 32bit sector numbers
239 * and thus the BIOS can only boot from disks smaller than 2T this is a
240 * rather hard limit.
241 *
242 * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
243 * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
244 * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
245 * of magnitude, but not with 11..13 orders of magnitude.
246 */
247 /* no need to lock, this is const */
248 *infoVDSize = 2 * _1T - _1M;
249
250 return S_OK;
251}
252
253
254HRESULT SystemProperties::getSerialPortCount(ULONG *count)
255{
256 /* no need to lock, this is const */
257 *count = SchemaDefs::SerialPortCount;
258
259 return S_OK;
260}
261
262
263HRESULT SystemProperties::getParallelPortCount(ULONG *count)
264{
265 /* no need to lock, this is const */
266 *count = SchemaDefs::ParallelPortCount;
267
268 return S_OK;
269}
270
271
272HRESULT SystemProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
273{
274 /* no need to lock, this is const */
275 *aMaxBootPosition = SchemaDefs::MaxBootPosition;
276
277 return S_OK;
278}
279
280
281HRESULT SystemProperties::getRawModeSupported(BOOL *aRawModeSupported)
282{
283 *aRawModeSupported = FALSE;
284 return S_OK;
285}
286
287
288HRESULT SystemProperties::getExclusiveHwVirt(BOOL *aExclusiveHwVirt)
289{
290 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
291
292 *aExclusiveHwVirt = m->fExclusiveHwVirt;
293
294 return S_OK;
295}
296
297HRESULT SystemProperties::setExclusiveHwVirt(BOOL aExclusiveHwVirt)
298{
299 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
300 m->fExclusiveHwVirt = !!aExclusiveHwVirt;
301 alock.release();
302
303 // VirtualBox::i_saveSettings() needs vbox write lock
304 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
305 HRESULT rc = mParent->i_saveSettings();
306
307 return rc;
308}
309
310HRESULT SystemProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
311{
312 /* no need for locking, no state */
313 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
314 if (uResult == 0)
315 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
316 *aMaxNetworkAdapters = uResult;
317 return S_OK;
318}
319
320HRESULT SystemProperties::getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
321{
322 /* no need for locking, no state */
323 uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
324 if (uResult == 0)
325 AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
326
327 switch (aType)
328 {
329 case NetworkAttachmentType_NAT:
330 case NetworkAttachmentType_Internal:
331 case NetworkAttachmentType_NATNetwork:
332 /* chipset default is OK */
333 break;
334 case NetworkAttachmentType_Bridged:
335 /* Maybe use current host interface count here? */
336 break;
337 case NetworkAttachmentType_HostOnly:
338 uResult = RT_MIN(uResult, 8);
339 break;
340 default:
341 AssertMsgFailed(("Unhandled attachment type %d\n", aType));
342 }
343
344 *count = uResult;
345
346 return S_OK;
347}
348
349
350HRESULT SystemProperties::getMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
351 ULONG *aMaxDevicesPerPort)
352{
353 /* no need to lock, this is const */
354 switch (aBus)
355 {
356 case StorageBus_SATA:
357 case StorageBus_SCSI:
358 case StorageBus_SAS:
359 case StorageBus_USB:
360 case StorageBus_PCIe:
361 case StorageBus_VirtioSCSI:
362 {
363 /* SATA and both SCSI controllers only support one device per port. */
364 *aMaxDevicesPerPort = 1;
365 break;
366 }
367 case StorageBus_IDE:
368 case StorageBus_Floppy:
369 {
370 /* The IDE and Floppy controllers support 2 devices. One as master
371 * and one as slave (or floppy drive 0 and 1). */
372 *aMaxDevicesPerPort = 2;
373 break;
374 }
375 default:
376 AssertMsgFailed(("Invalid bus type %d\n", aBus));
377 }
378
379 return S_OK;
380}
381
382HRESULT SystemProperties::getMinPortCountForStorageBus(StorageBus_T aBus,
383 ULONG *aMinPortCount)
384{
385 /* no need to lock, this is const */
386 switch (aBus)
387 {
388 case StorageBus_SATA:
389 case StorageBus_SAS:
390 case StorageBus_PCIe:
391 case StorageBus_VirtioSCSI:
392 {
393 *aMinPortCount = 1;
394 break;
395 }
396 case StorageBus_SCSI:
397 {
398 *aMinPortCount = 16;
399 break;
400 }
401 case StorageBus_IDE:
402 {
403 *aMinPortCount = 2;
404 break;
405 }
406 case StorageBus_Floppy:
407 {
408 *aMinPortCount = 1;
409 break;
410 }
411 case StorageBus_USB:
412 {
413 *aMinPortCount = 8;
414 break;
415 }
416 default:
417 AssertMsgFailed(("Invalid bus type %d\n", aBus));
418 }
419
420 return S_OK;
421}
422
423HRESULT SystemProperties::getMaxPortCountForStorageBus(StorageBus_T aBus,
424 ULONG *aMaxPortCount)
425{
426 /* no need to lock, this is const */
427 switch (aBus)
428 {
429 case StorageBus_SATA:
430 {
431 *aMaxPortCount = 30;
432 break;
433 }
434 case StorageBus_SCSI:
435 {
436 *aMaxPortCount = 16;
437 break;
438 }
439 case StorageBus_IDE:
440 {
441 *aMaxPortCount = 2;
442 break;
443 }
444 case StorageBus_Floppy:
445 {
446 *aMaxPortCount = 1;
447 break;
448 }
449 case StorageBus_SAS:
450 case StorageBus_PCIe:
451 {
452 *aMaxPortCount = 255;
453 break;
454 }
455 case StorageBus_USB:
456 {
457 *aMaxPortCount = 8;
458 break;
459 }
460 case StorageBus_VirtioSCSI:
461 {
462 *aMaxPortCount = 256;
463 break;
464 }
465 default:
466 AssertMsgFailed(("Invalid bus type %d\n", aBus));
467 }
468
469 return S_OK;
470}
471
472HRESULT SystemProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
473 StorageBus_T aBus,
474 ULONG *aMaxInstances)
475{
476 ULONG cCtrs = 0;
477
478 /* no need to lock, this is const */
479 switch (aBus)
480 {
481 case StorageBus_SATA:
482 case StorageBus_SCSI:
483 case StorageBus_SAS:
484 case StorageBus_PCIe:
485 case StorageBus_VirtioSCSI:
486 cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
487 break;
488 case StorageBus_USB:
489 case StorageBus_IDE:
490 case StorageBus_Floppy:
491 {
492 cCtrs = 1;
493 break;
494 }
495 default:
496 AssertMsgFailed(("Invalid bus type %d\n", aBus));
497 }
498
499 *aMaxInstances = cCtrs;
500
501 return S_OK;
502}
503
504HRESULT SystemProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
505 std::vector<DeviceType_T> &aDeviceTypes)
506{
507 aDeviceTypes.resize(0);
508
509 /* no need to lock, this is const */
510 switch (aBus)
511 {
512 case StorageBus_IDE:
513 case StorageBus_SATA:
514 case StorageBus_SCSI:
515 case StorageBus_SAS:
516 case StorageBus_USB:
517 case StorageBus_VirtioSCSI:
518 {
519 aDeviceTypes.resize(2);
520 aDeviceTypes[0] = DeviceType_DVD;
521 aDeviceTypes[1] = DeviceType_HardDisk;
522 break;
523 }
524 case StorageBus_Floppy:
525 {
526 aDeviceTypes.resize(1);
527 aDeviceTypes[0] = DeviceType_Floppy;
528 break;
529 }
530 case StorageBus_PCIe:
531 {
532 aDeviceTypes.resize(1);
533 aDeviceTypes[0] = DeviceType_HardDisk;
534 break;
535 }
536 default:
537 AssertMsgFailed(("Invalid bus type %d\n", aBus));
538 }
539
540 return S_OK;
541}
542
543HRESULT SystemProperties::getDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType,
544 BOOL *aEnabled)
545{
546 /* no need to lock, this is const */
547 switch (aControllerType)
548 {
549 case StorageControllerType_LsiLogic:
550 case StorageControllerType_BusLogic:
551 case StorageControllerType_IntelAhci:
552 case StorageControllerType_LsiLogicSas:
553 case StorageControllerType_USB:
554 case StorageControllerType_NVMe:
555 case StorageControllerType_VirtioSCSI:
556 *aEnabled = false;
557 break;
558 case StorageControllerType_PIIX3:
559 case StorageControllerType_PIIX4:
560 case StorageControllerType_ICH6:
561 case StorageControllerType_I82078:
562 *aEnabled = true;
563 break;
564 default:
565 AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
566 }
567 return S_OK;
568}
569
570HRESULT SystemProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
571 BOOL *aHotplugCapable)
572{
573 switch (aControllerType)
574 {
575 case StorageControllerType_IntelAhci:
576 case StorageControllerType_USB:
577 *aHotplugCapable = true;
578 break;
579 case StorageControllerType_LsiLogic:
580 case StorageControllerType_LsiLogicSas:
581 case StorageControllerType_BusLogic:
582 case StorageControllerType_NVMe:
583 case StorageControllerType_VirtioSCSI:
584 case StorageControllerType_PIIX3:
585 case StorageControllerType_PIIX4:
586 case StorageControllerType_ICH6:
587 case StorageControllerType_I82078:
588 *aHotplugCapable = false;
589 break;
590 default:
591 AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
592 }
593
594 return S_OK;
595}
596
597HRESULT SystemProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
598 USBControllerType_T aType,
599 ULONG *aMaxInstances)
600{
601 NOREF(aChipset);
602 ULONG cCtrs = 0;
603
604 /* no need to lock, this is const */
605 switch (aType)
606 {
607 case USBControllerType_OHCI:
608 case USBControllerType_EHCI:
609 case USBControllerType_XHCI:
610 {
611 cCtrs = 1;
612 break;
613 }
614 default:
615 AssertMsgFailed(("Invalid bus type %d\n", aType));
616 }
617
618 *aMaxInstances = cCtrs;
619
620 return S_OK;
621}
622
623HRESULT SystemProperties::getDefaultMachineFolder(com::Utf8Str &aDefaultMachineFolder)
624{
625 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
626 aDefaultMachineFolder = m->strDefaultMachineFolder;
627 return S_OK;
628}
629
630HRESULT SystemProperties::setDefaultMachineFolder(const com::Utf8Str &aDefaultMachineFolder)
631{
632 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
633 HRESULT rc = i_setDefaultMachineFolder(aDefaultMachineFolder);
634 alock.release();
635 if (SUCCEEDED(rc))
636 {
637 // VirtualBox::i_saveSettings() needs vbox write lock
638 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
639 rc = mParent->i_saveSettings();
640 }
641
642 return rc;
643}
644
645HRESULT SystemProperties::getLoggingLevel(com::Utf8Str &aLoggingLevel)
646{
647 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
648
649 aLoggingLevel = m->strLoggingLevel;
650
651 if (aLoggingLevel.isEmpty())
652 aLoggingLevel = VBOXSVC_LOG_DEFAULT;
653
654 return S_OK;
655}
656
657
658HRESULT SystemProperties::setLoggingLevel(const com::Utf8Str &aLoggingLevel)
659{
660 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
661 HRESULT rc = i_setLoggingLevel(aLoggingLevel);
662 alock.release();
663
664 if (SUCCEEDED(rc))
665 {
666 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
667 rc = mParent->i_saveSettings();
668 }
669 else
670 LogRel(("Cannot set passed logging level=%s, or the default one - Error=%Rhrc \n", aLoggingLevel.c_str(), rc));
671
672 return rc;
673}
674
675HRESULT SystemProperties::getMediumFormats(std::vector<ComPtr<IMediumFormat> > &aMediumFormats)
676{
677 MediumFormatList mediumFormats(m_llMediumFormats);
678 aMediumFormats.resize(mediumFormats.size());
679 size_t i = 0;
680 for (MediumFormatList::const_iterator it = mediumFormats.begin(); it != mediumFormats.end(); ++it, ++i)
681 (*it).queryInterfaceTo(aMediumFormats[i].asOutParam());
682 return S_OK;
683}
684
685HRESULT SystemProperties::getDefaultHardDiskFormat(com::Utf8Str &aDefaultHardDiskFormat)
686{
687 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
688 aDefaultHardDiskFormat = m->strDefaultHardDiskFormat;
689 return S_OK;
690}
691
692
693HRESULT SystemProperties::setDefaultHardDiskFormat(const com::Utf8Str &aDefaultHardDiskFormat)
694{
695 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
696 HRESULT rc = i_setDefaultHardDiskFormat(aDefaultHardDiskFormat);
697 alock.release();
698 if (SUCCEEDED(rc))
699 {
700 // VirtualBox::i_saveSettings() needs vbox write lock
701 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
702 rc = mParent->i_saveSettings();
703 }
704
705 return rc;
706}
707
708HRESULT SystemProperties::getFreeDiskSpaceWarning(LONG64 *aFreeSpace)
709{
710 NOREF(aFreeSpace);
711 ReturnComNotImplemented();
712}
713
714HRESULT SystemProperties::setFreeDiskSpaceWarning(LONG64 /* aFreeSpace */)
715{
716 ReturnComNotImplemented();
717}
718
719HRESULT SystemProperties::getFreeDiskSpacePercentWarning(ULONG *aFreeSpacePercent)
720{
721 NOREF(aFreeSpacePercent);
722 ReturnComNotImplemented();
723}
724
725HRESULT SystemProperties::setFreeDiskSpacePercentWarning(ULONG /* aFreeSpacePercent */)
726{
727 ReturnComNotImplemented();
728}
729
730HRESULT SystemProperties::getFreeDiskSpaceError(LONG64 *aFreeSpace)
731{
732 NOREF(aFreeSpace);
733 ReturnComNotImplemented();
734}
735
736HRESULT SystemProperties::setFreeDiskSpaceError(LONG64 /* aFreeSpace */)
737{
738 ReturnComNotImplemented();
739}
740
741HRESULT SystemProperties::getFreeDiskSpacePercentError(ULONG *aFreeSpacePercent)
742{
743 NOREF(aFreeSpacePercent);
744 ReturnComNotImplemented();
745}
746
747HRESULT SystemProperties::setFreeDiskSpacePercentError(ULONG /* aFreeSpacePercent */)
748{
749 ReturnComNotImplemented();
750}
751
752HRESULT SystemProperties::getVRDEAuthLibrary(com::Utf8Str &aVRDEAuthLibrary)
753{
754 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
755
756 aVRDEAuthLibrary = m->strVRDEAuthLibrary;
757
758 return S_OK;
759}
760
761HRESULT SystemProperties::setVRDEAuthLibrary(const com::Utf8Str &aVRDEAuthLibrary)
762{
763 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
764 HRESULT rc = i_setVRDEAuthLibrary(aVRDEAuthLibrary);
765 alock.release();
766 if (SUCCEEDED(rc))
767 {
768 // VirtualBox::i_saveSettings() needs vbox write lock
769 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
770 rc = mParent->i_saveSettings();
771 }
772
773 return rc;
774}
775
776HRESULT SystemProperties::getWebServiceAuthLibrary(com::Utf8Str &aWebServiceAuthLibrary)
777{
778 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
779
780 aWebServiceAuthLibrary = m->strWebServiceAuthLibrary;
781
782 return S_OK;
783}
784
785HRESULT SystemProperties::setWebServiceAuthLibrary(const com::Utf8Str &aWebServiceAuthLibrary)
786{
787 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
788 HRESULT rc = i_setWebServiceAuthLibrary(aWebServiceAuthLibrary);
789 alock.release();
790
791 if (SUCCEEDED(rc))
792 {
793 // VirtualBox::i_saveSettings() needs vbox write lock
794 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
795 rc = mParent->i_saveSettings();
796 }
797
798 return rc;
799}
800
801HRESULT SystemProperties::getDefaultVRDEExtPack(com::Utf8Str &aExtPack)
802{
803 HRESULT hrc = S_OK;
804 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
805 Utf8Str strExtPack(m->strDefaultVRDEExtPack);
806 if (strExtPack.isNotEmpty())
807 {
808 if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
809 hrc = S_OK;
810 else
811#ifdef VBOX_WITH_EXTPACK
812 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&strExtPack);
813#else
814 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
815#endif
816 }
817 else
818 {
819#ifdef VBOX_WITH_EXTPACK
820 hrc = mParent->i_getExtPackManager()->i_getDefaultVrdeExtPack(&strExtPack);
821#endif
822 if (strExtPack.isEmpty())
823 {
824 /*
825 * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
826 * This is hardcoded uglyness, sorry.
827 */
828 char szPath[RTPATH_MAX];
829 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
830 if (RT_SUCCESS(vrc))
831 vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
832 if (RT_SUCCESS(vrc))
833 vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
834 if (RT_SUCCESS(vrc) && RTFileExists(szPath))
835 {
836 /* Illegal extpack name, so no conflict. */
837 strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
838 }
839 }
840 }
841
842 if (SUCCEEDED(hrc))
843 aExtPack = strExtPack;
844
845 return S_OK;
846}
847
848
849HRESULT SystemProperties::setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
850{
851 HRESULT hrc = S_OK;
852 if (aExtPack.isNotEmpty())
853 {
854 if (aExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
855 hrc = S_OK;
856 else
857#ifdef VBOX_WITH_EXTPACK
858 hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&aExtPack);
859#else
860 hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), aExtPack.c_str());
861#endif
862 }
863 if (SUCCEEDED(hrc))
864 {
865 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
866 hrc = i_setDefaultVRDEExtPack(aExtPack);
867 if (SUCCEEDED(hrc))
868 {
869 /* VirtualBox::i_saveSettings() needs the VirtualBox write lock. */
870 alock.release();
871 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
872 hrc = mParent->i_saveSettings();
873 }
874 }
875
876 return hrc;
877}
878
879
880HRESULT SystemProperties::getLogHistoryCount(ULONG *count)
881{
882 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
883
884 *count = m->uLogHistoryCount;
885
886 return S_OK;
887}
888
889
890HRESULT SystemProperties::setLogHistoryCount(ULONG count)
891{
892 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
893 m->uLogHistoryCount = count;
894 alock.release();
895
896 // VirtualBox::i_saveSettings() needs vbox write lock
897 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
898 HRESULT rc = mParent->i_saveSettings();
899
900 return rc;
901}
902
903HRESULT SystemProperties::getDefaultAudioDriver(AudioDriverType_T *aAudioDriver)
904{
905 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
906
907 *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
908
909 return S_OK;
910}
911
912HRESULT SystemProperties::getAutostartDatabasePath(com::Utf8Str &aAutostartDbPath)
913{
914 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
915
916 aAutostartDbPath = m->strAutostartDatabasePath;
917
918 return S_OK;
919}
920
921HRESULT SystemProperties::setAutostartDatabasePath(const com::Utf8Str &aAutostartDbPath)
922{
923 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
924 HRESULT rc = i_setAutostartDatabasePath(aAutostartDbPath);
925 alock.release();
926
927 if (SUCCEEDED(rc))
928 {
929 // VirtualBox::i_saveSettings() needs vbox write lock
930 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
931 rc = mParent->i_saveSettings();
932 }
933
934 return rc;
935}
936
937HRESULT SystemProperties::getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
938{
939 return i_getDefaultAdditionsISO(aDefaultAdditionsISO);
940}
941
942HRESULT SystemProperties::setDefaultAdditionsISO(const com::Utf8Str &aDefaultAdditionsISO)
943{
944 RT_NOREF(aDefaultAdditionsISO);
945 /** @todo not yet implemented, settings handling is missing */
946 ReturnComNotImplemented();
947#if 0 /* not implemented */
948 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
949 HRESULT rc = i_setDefaultAdditionsISO(aDefaultAdditionsISO);
950 alock.release();
951
952 if (SUCCEEDED(rc))
953 {
954 // VirtualBox::i_saveSettings() needs vbox write lock
955 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
956 rc = mParent->i_saveSettings();
957 }
958
959 return rc;
960#endif
961}
962
963HRESULT SystemProperties::getDefaultFrontend(com::Utf8Str &aDefaultFrontend)
964{
965 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
966 aDefaultFrontend = m->strDefaultFrontend;
967 return S_OK;
968}
969
970HRESULT SystemProperties::setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
971{
972 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
973 if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
974 return S_OK;
975 HRESULT rc = i_setDefaultFrontend(aDefaultFrontend);
976 alock.release();
977
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::getScreenShotFormats(std::vector<BitmapFormat_T> &aBitmapFormats)
989{
990 aBitmapFormats.push_back(BitmapFormat_BGR0);
991 aBitmapFormats.push_back(BitmapFormat_BGRA);
992 aBitmapFormats.push_back(BitmapFormat_RGBA);
993 aBitmapFormats.push_back(BitmapFormat_PNG);
994 return S_OK;
995}
996
997HRESULT SystemProperties::getProxyMode(ProxyMode_T *pProxyMode)
998{
999 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1000 ProxyMode_T enmMode = *pProxyMode = (ProxyMode_T)m->uProxyMode;
1001 AssertMsgReturn(enmMode == ProxyMode_System || enmMode == ProxyMode_NoProxy || enmMode == ProxyMode_Manual,
1002 ("enmMode=%d\n", enmMode), E_UNEXPECTED);
1003 return S_OK;
1004}
1005
1006HRESULT SystemProperties::setProxyMode(ProxyMode_T aProxyMode)
1007{
1008 /* Validate input. */
1009 switch (aProxyMode)
1010 {
1011 case ProxyMode_System:
1012 case ProxyMode_NoProxy:
1013 case ProxyMode_Manual:
1014 break;
1015 default:
1016 return setError(E_INVALIDARG, tr("Invalid ProxyMode value: %d"), (int)aProxyMode);
1017 }
1018
1019 /* Set and write out settings. */
1020 {
1021 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1022 m->uProxyMode = aProxyMode;
1023 }
1024 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1025 return mParent->i_saveSettings();
1026}
1027
1028HRESULT SystemProperties::getProxyURL(com::Utf8Str &aProxyURL)
1029{
1030 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1031 aProxyURL = m->strProxyUrl;
1032 return S_OK;
1033}
1034
1035HRESULT SystemProperties::setProxyURL(const com::Utf8Str &aProxyURL)
1036{
1037 /*
1038 * Validate input.
1039 */
1040 Utf8Str const *pStrProxyUrl = &aProxyURL;
1041 Utf8Str strTmp;
1042 if (pStrProxyUrl->isNotEmpty())
1043 {
1044 /* RTUriParse requires a scheme, so append 'http://' if none seems present: */
1045 if (pStrProxyUrl->find("://") == RTCString::npos)
1046 {
1047 strTmp.printf("http://%s", aProxyURL.c_str());
1048 pStrProxyUrl = &strTmp;
1049 }
1050
1051 /* Use RTUriParse to check the format. There must be a hostname, but nothing
1052 can follow it and the port. */
1053 RTURIPARSED Parsed;
1054 int vrc = RTUriParse(pStrProxyUrl->c_str(), &Parsed);
1055 if (RT_FAILURE(vrc))
1056 return setErrorBoth(E_INVALIDARG, vrc, tr("Failed to parse proxy URL: %Rrc"), vrc);
1057 if ( Parsed.cchAuthorityHost == 0
1058 && !RTUriIsSchemeMatch(pStrProxyUrl->c_str(), "direct"))
1059 return setError(E_INVALIDARG, tr("Proxy URL must include a hostname"));
1060 if (Parsed.cchPath > 0)
1061 return setError(E_INVALIDARG, tr("Proxy URL must not include a path component (%.*s)"),
1062 Parsed.cchPath, pStrProxyUrl->c_str() + Parsed.offPath);
1063 if (Parsed.cchQuery > 0)
1064 return setError(E_INVALIDARG, tr("Proxy URL must not include a query component (?%.*s)"),
1065 Parsed.cchQuery, pStrProxyUrl->c_str() + Parsed.offQuery);
1066 if (Parsed.cchFragment > 0)
1067 return setError(E_INVALIDARG, tr("Proxy URL must not include a fragment component (#%.*s)"),
1068 Parsed.cchFragment, pStrProxyUrl->c_str() + Parsed.offFragment);
1069 }
1070
1071 /*
1072 * Set and write out settings.
1073 */
1074 {
1075 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1076 m->strProxyUrl = *pStrProxyUrl;
1077 }
1078 AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS); /* required for saving. */
1079 return mParent->i_saveSettings();
1080}
1081
1082HRESULT SystemProperties::getSupportedParavirtProviders(std::vector<ParavirtProvider_T> &aSupportedParavirtProviders)
1083{
1084 static const ParavirtProvider_T aParavirtProviders[] =
1085 {
1086 ParavirtProvider_None,
1087 ParavirtProvider_Default,
1088 ParavirtProvider_Legacy,
1089 ParavirtProvider_Minimal,
1090 ParavirtProvider_HyperV,
1091 ParavirtProvider_KVM,
1092 };
1093 aSupportedParavirtProviders.assign(aParavirtProviders,
1094 aParavirtProviders + RT_ELEMENTS(aParavirtProviders));
1095 return S_OK;
1096}
1097
1098HRESULT SystemProperties::getSupportedClipboardModes(std::vector<ClipboardMode_T> &aSupportedClipboardModes)
1099{
1100 static const ClipboardMode_T aClipboardModes[] =
1101 {
1102 ClipboardMode_Disabled,
1103 ClipboardMode_HostToGuest,
1104 ClipboardMode_GuestToHost,
1105 ClipboardMode_Bidirectional,
1106 };
1107 aSupportedClipboardModes.assign(aClipboardModes,
1108 aClipboardModes + RT_ELEMENTS(aClipboardModes));
1109 return S_OK;
1110}
1111
1112HRESULT SystemProperties::getSupportedDnDModes(std::vector<DnDMode_T> &aSupportedDnDModes)
1113{
1114 static const DnDMode_T aDnDModes[] =
1115 {
1116 DnDMode_Disabled,
1117 DnDMode_HostToGuest,
1118 DnDMode_GuestToHost,
1119 DnDMode_Bidirectional,
1120 };
1121 aSupportedDnDModes.assign(aDnDModes,
1122 aDnDModes + RT_ELEMENTS(aDnDModes));
1123 return S_OK;
1124}
1125
1126HRESULT SystemProperties::getSupportedFirmwareTypes(std::vector<FirmwareType_T> &aSupportedFirmwareTypes)
1127{
1128 static const FirmwareType_T aFirmwareTypes[] =
1129 {
1130 FirmwareType_BIOS,
1131 FirmwareType_EFI,
1132 FirmwareType_EFI32,
1133 FirmwareType_EFI64,
1134 FirmwareType_EFIDUAL,
1135 };
1136 aSupportedFirmwareTypes.assign(aFirmwareTypes,
1137 aFirmwareTypes + RT_ELEMENTS(aFirmwareTypes));
1138 return S_OK;
1139}
1140
1141HRESULT SystemProperties::getSupportedPointingHIDTypes(std::vector<PointingHIDType_T> &aSupportedPointingHIDTypes)
1142{
1143 static const PointingHIDType_T aPointingHIDTypes[] =
1144 {
1145 PointingHIDType_None,
1146 PointingHIDType_PS2Mouse,
1147#ifdef DEBUG
1148 PointingHIDType_USBMouse,
1149#endif
1150 PointingHIDType_USBTablet,
1151#ifdef DEBUG
1152 PointingHIDType_ComboMouse,
1153#endif
1154 PointingHIDType_USBMultiTouch,
1155 };
1156 aSupportedPointingHIDTypes.assign(aPointingHIDTypes,
1157 aPointingHIDTypes + RT_ELEMENTS(aPointingHIDTypes));
1158 return S_OK;
1159}
1160
1161HRESULT SystemProperties::getSupportedKeyboardHIDTypes(std::vector<KeyboardHIDType_T> &aSupportedKeyboardHIDTypes)
1162{
1163 static const KeyboardHIDType_T aKeyboardHIDTypes[] =
1164 {
1165 KeyboardHIDType_None,
1166 KeyboardHIDType_PS2Keyboard,
1167 KeyboardHIDType_USBKeyboard,
1168#ifdef DEBUG
1169 KeyboardHIDType_ComboKeyboard,
1170#endif
1171 };
1172 aSupportedKeyboardHIDTypes.assign(aKeyboardHIDTypes,
1173 aKeyboardHIDTypes + RT_ELEMENTS(aKeyboardHIDTypes));
1174 return S_OK;
1175}
1176
1177HRESULT SystemProperties::getSupportedVFSTypes(std::vector<VFSType_T> &aSupportedVFSTypes)
1178{
1179 static const VFSType_T aVFSTypes[] =
1180 {
1181 VFSType_File,
1182 VFSType_Cloud,
1183 VFSType_S3,
1184#ifdef DEBUG
1185 VFSType_WebDav,
1186#endif
1187 };
1188 aSupportedVFSTypes.assign(aVFSTypes,
1189 aVFSTypes + RT_ELEMENTS(aVFSTypes));
1190 return S_OK;
1191}
1192
1193HRESULT SystemProperties::getSupportedImportOptions(std::vector<ImportOptions_T> &aSupportedImportOptions)
1194{
1195 static const ImportOptions_T aImportOptions[] =
1196 {
1197 ImportOptions_KeepAllMACs,
1198 ImportOptions_KeepNATMACs,
1199 ImportOptions_ImportToVDI,
1200 };
1201 aSupportedImportOptions.assign(aImportOptions,
1202 aImportOptions + RT_ELEMENTS(aImportOptions));
1203 return S_OK;
1204}
1205
1206HRESULT SystemProperties::getSupportedExportOptions(std::vector<ExportOptions_T> &aSupportedExportOptions)
1207{
1208 static const ExportOptions_T aExportOptions[] =
1209 {
1210 ExportOptions_CreateManifest,
1211 ExportOptions_ExportDVDImages,
1212 ExportOptions_StripAllMACs,
1213 ExportOptions_StripAllNonNATMACs,
1214 };
1215 aSupportedExportOptions.assign(aExportOptions,
1216 aExportOptions + RT_ELEMENTS(aExportOptions));
1217 return S_OK;
1218}
1219
1220HRESULT SystemProperties::getSupportedRecordingAudioCodecs(std::vector<RecordingAudioCodec_T> &aSupportedRecordingAudioCodecs)
1221{
1222 static const RecordingAudioCodec_T aRecordingAudioCodecs[] =
1223 {
1224#ifdef DEBUG
1225 RecordingAudioCodec_WavPCM,
1226#endif
1227 RecordingAudioCodec_Opus,
1228 };
1229 aSupportedRecordingAudioCodecs.assign(aRecordingAudioCodecs,
1230 aRecordingAudioCodecs + RT_ELEMENTS(aRecordingAudioCodecs));
1231 return S_OK;
1232}
1233
1234HRESULT SystemProperties::getSupportedRecordingVideoCodecs(std::vector<RecordingVideoCodec_T> &aSupportedRecordingVideoCodecs)
1235{
1236 static const RecordingVideoCodec_T aRecordingVideoCodecs[] =
1237 {
1238 RecordingVideoCodec_VP8,
1239#ifdef DEBUG
1240 RecordingVideoCodec_VP9,
1241 RecordingVideoCodec_AV1,
1242#endif
1243 };
1244 aSupportedRecordingVideoCodecs.assign(aRecordingVideoCodecs,
1245 aRecordingVideoCodecs + RT_ELEMENTS(aRecordingVideoCodecs));
1246 return S_OK;
1247}
1248
1249HRESULT SystemProperties::getSupportedRecordingVSMethods(std::vector<RecordingVideoScalingMethod_T> &aSupportedRecordingVideoScalingMethods)
1250{
1251 static const RecordingVideoScalingMethod_T aRecordingVideoScalingMethods[] =
1252 {
1253 RecordingVideoScalingMethod_None,
1254#ifdef DEBUG
1255 RecordingVideoScalingMethod_NearestNeighbor,
1256 RecordingVideoScalingMethod_Bilinear,
1257 RecordingVideoScalingMethod_Bicubic,
1258#endif
1259 };
1260 aSupportedRecordingVideoScalingMethods.assign(aRecordingVideoScalingMethods,
1261 aRecordingVideoScalingMethods + RT_ELEMENTS(aRecordingVideoScalingMethods));
1262 return S_OK;
1263}
1264
1265HRESULT SystemProperties::getSupportedRecordingVRCModes(std::vector<RecordingVideoRateControlMode_T> &aSupportedRecordingVideoRateControlModes)
1266{
1267 static const RecordingVideoRateControlMode_T aRecordingVideoRateControlModes[] =
1268 {
1269 RecordingVideoRateControlMode_CBR,
1270#ifdef DEBUG
1271 RecordingVideoRateControlMode_VBR,
1272#endif
1273 };
1274 aSupportedRecordingVideoRateControlModes.assign(aRecordingVideoRateControlModes,
1275 aRecordingVideoRateControlModes + RT_ELEMENTS(aRecordingVideoRateControlModes));
1276 return S_OK;
1277}
1278
1279HRESULT SystemProperties::getSupportedGraphicsControllerTypes(std::vector<GraphicsControllerType_T> &aSupportedGraphicsControllerTypes)
1280{
1281 static const GraphicsControllerType_T aGraphicsControllerTypes[] =
1282 {
1283 GraphicsControllerType_VBoxVGA,
1284 GraphicsControllerType_VMSVGA,
1285 GraphicsControllerType_VBoxSVGA,
1286 };
1287 aSupportedGraphicsControllerTypes.assign(aGraphicsControllerTypes,
1288 aGraphicsControllerTypes + RT_ELEMENTS(aGraphicsControllerTypes));
1289 return S_OK;
1290}
1291
1292HRESULT SystemProperties::getSupportedCloneOptions(std::vector<CloneOptions_T> &aSupportedCloneOptions)
1293{
1294 static const CloneOptions_T aCloneOptions[] =
1295 {
1296 CloneOptions_Link,
1297 CloneOptions_KeepAllMACs,
1298 CloneOptions_KeepNATMACs,
1299 CloneOptions_KeepDiskNames,
1300 CloneOptions_KeepHwUUIDs,
1301 };
1302 aSupportedCloneOptions.assign(aCloneOptions,
1303 aCloneOptions + RT_ELEMENTS(aCloneOptions));
1304 return S_OK;
1305}
1306
1307HRESULT SystemProperties::getSupportedAutostopTypes(std::vector<AutostopType_T> &aSupportedAutostopTypes)
1308{
1309 static const AutostopType_T aAutostopTypes[] =
1310 {
1311 AutostopType_Disabled,
1312 AutostopType_SaveState,
1313 AutostopType_PowerOff,
1314 AutostopType_AcpiShutdown,
1315 };
1316 aSupportedAutostopTypes.assign(aAutostopTypes,
1317 aAutostopTypes + RT_ELEMENTS(aAutostopTypes));
1318 return S_OK;
1319}
1320
1321HRESULT SystemProperties::getSupportedVMProcPriorities(std::vector<VMProcPriority_T> &aSupportedVMProcPriorities)
1322{
1323 static const VMProcPriority_T aVMProcPriorities[] =
1324 {
1325 VMProcPriority_Default,
1326 VMProcPriority_Flat,
1327 VMProcPriority_Low,
1328 VMProcPriority_Normal,
1329 VMProcPriority_High,
1330 };
1331 aSupportedVMProcPriorities.assign(aVMProcPriorities,
1332 aVMProcPriorities + RT_ELEMENTS(aVMProcPriorities));
1333 return S_OK;
1334}
1335
1336HRESULT SystemProperties::getSupportedNetworkAttachmentTypes(std::vector<NetworkAttachmentType_T> &aSupportedNetworkAttachmentTypes)
1337{
1338 static const NetworkAttachmentType_T aNetworkAttachmentTypes[] =
1339 {
1340 NetworkAttachmentType_NAT,
1341 NetworkAttachmentType_Bridged,
1342 NetworkAttachmentType_Internal,
1343 NetworkAttachmentType_HostOnly,
1344 NetworkAttachmentType_Generic,
1345 NetworkAttachmentType_NATNetwork,
1346#ifdef DEBUG
1347 NetworkAttachmentType_Cloud,
1348#endif
1349 };
1350 aSupportedNetworkAttachmentTypes.assign(aNetworkAttachmentTypes,
1351 aNetworkAttachmentTypes + RT_ELEMENTS(aNetworkAttachmentTypes));
1352 return S_OK;
1353}
1354
1355HRESULT SystemProperties::getSupportedNetworkAdapterTypes(std::vector<NetworkAdapterType_T> &aSupportedNetworkAdapterTypes)
1356{
1357 static const NetworkAdapterType_T aNetworkAdapterTypes[] =
1358 {
1359 NetworkAdapterType_Am79C970A,
1360 NetworkAdapterType_Am79C973,
1361 NetworkAdapterType_I82540EM,
1362 NetworkAdapterType_I82543GC,
1363 NetworkAdapterType_I82545EM,
1364 NetworkAdapterType_Virtio,
1365 NetworkAdapterType_Am79C960,
1366 };
1367 aSupportedNetworkAdapterTypes.assign(aNetworkAdapterTypes,
1368 aNetworkAdapterTypes + RT_ELEMENTS(aNetworkAdapterTypes));
1369 return S_OK;
1370}
1371
1372HRESULT SystemProperties::getSupportedPortModes(std::vector<PortMode_T> &aSupportedPortModes)
1373{
1374 static const PortMode_T aPortModes[] =
1375 {
1376 PortMode_Disconnected,
1377 PortMode_HostPipe,
1378 PortMode_HostDevice,
1379 PortMode_RawFile,
1380 PortMode_TCP,
1381 };
1382 aSupportedPortModes.assign(aPortModes,
1383 aPortModes + RT_ELEMENTS(aPortModes));
1384 return S_OK;
1385}
1386
1387HRESULT SystemProperties::getSupportedUartTypes(std::vector<UartType_T> &aSupportedUartTypes)
1388{
1389 static const UartType_T aUartTypes[] =
1390 {
1391 UartType_U16450,
1392 UartType_U16550A,
1393 UartType_U16750,
1394 };
1395 aSupportedUartTypes.assign(aUartTypes,
1396 aUartTypes + RT_ELEMENTS(aUartTypes));
1397 return S_OK;
1398}
1399
1400HRESULT SystemProperties::getSupportedUSBControllerTypes(std::vector<USBControllerType_T> &aSupportedUSBControllerTypes)
1401{
1402 static const USBControllerType_T aUSBControllerTypesWithoutExtPack[] =
1403 {
1404 USBControllerType_OHCI,
1405 };
1406 static const USBControllerType_T aUSBControllerTypesWithExtPack[] =
1407 {
1408 USBControllerType_OHCI,
1409 USBControllerType_EHCI,
1410 USBControllerType_XHCI,
1411 };
1412 bool fExtPack = false;
1413# ifdef VBOX_WITH_EXTPACK
1414 static const char *s_pszUsbExtPackName = "Oracle VM VirtualBox Extension Pack";
1415 if (mParent->i_getExtPackManager()->i_isExtPackUsable(s_pszUsbExtPackName))
1416# endif
1417 {
1418 fExtPack = true;
1419 }
1420
1421 if (fExtPack)
1422 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithExtPack,
1423 aUSBControllerTypesWithExtPack + RT_ELEMENTS(aUSBControllerTypesWithExtPack));
1424 else
1425 aSupportedUSBControllerTypes.assign(aUSBControllerTypesWithoutExtPack,
1426 aUSBControllerTypesWithoutExtPack + RT_ELEMENTS(aUSBControllerTypesWithoutExtPack));
1427 return S_OK;
1428}
1429
1430HRESULT SystemProperties::getSupportedAudioDriverTypes(std::vector<AudioDriverType_T> &aSupportedAudioDriverTypes)
1431{
1432 static const AudioDriverType_T aAudioDriverTypes[] =
1433 {
1434#ifdef RT_OS_WINDOWS
1435# if 0 /* deprecated for many years now */
1436 AudioDriverType_WinMM,
1437# endif
1438 AudioDriverType_DirectSound,
1439#endif
1440#ifdef RT_OS_DARWIN
1441 AudioDriverType_CoreAudio,
1442#endif
1443#ifdef RT_OS_OS2
1444 AudioDriverType_MMPM,
1445#endif
1446#ifdef RT_OS_SOLARIS
1447# if 0 /* deprecated for many years now */
1448 AudioDriverType_SolAudio,
1449# endif
1450#endif
1451#ifdef VBOX_WITH_AUDIO_ALSA
1452 AudioDriverType_ALSA,
1453#endif
1454#ifdef VBOX_WITH_AUDIO_OSS
1455 AudioDriverType_OSS,
1456#endif
1457#ifdef VBOX_WITH_AUDIO_PULSE
1458 AudioDriverType_Pulse,
1459#endif
1460 };
1461 aSupportedAudioDriverTypes.assign(aAudioDriverTypes,
1462 aAudioDriverTypes + RT_ELEMENTS(aAudioDriverTypes));
1463 return S_OK;
1464}
1465
1466HRESULT SystemProperties::getSupportedAudioControllerTypes(std::vector<AudioControllerType_T> &aSupportedAudioControllerTypes)
1467{
1468 static const AudioControllerType_T aAudioControllerTypes[] =
1469 {
1470 AudioControllerType_AC97,
1471 AudioControllerType_SB16,
1472 AudioControllerType_HDA,
1473 };
1474 aSupportedAudioControllerTypes.assign(aAudioControllerTypes,
1475 aAudioControllerTypes + RT_ELEMENTS(aAudioControllerTypes));
1476 return S_OK;
1477}
1478
1479HRESULT SystemProperties::getSupportedStorageBuses(std::vector<StorageBus_T> &aSupportedStorageBuses)
1480{
1481 static const StorageBus_T aStorageBuses[] =
1482 {
1483 StorageBus_IDE,
1484 StorageBus_SATA,
1485 StorageBus_SCSI,
1486 StorageBus_Floppy,
1487 StorageBus_SAS,
1488 StorageBus_USB,
1489 StorageBus_PCIe,
1490#ifdef DEBUG
1491 StorageBus_VirtioSCSI,
1492#endif
1493 };
1494 aSupportedStorageBuses.assign(aStorageBuses,
1495 aStorageBuses + RT_ELEMENTS(aStorageBuses));
1496 return S_OK;
1497}
1498
1499HRESULT SystemProperties::getSupportedStorageControllerTypes(std::vector<StorageControllerType_T> &aSupportedStorageControllerTypes)
1500{
1501 static const StorageControllerType_T aStorageControllerTypes[] =
1502 {
1503 StorageControllerType_LsiLogic,
1504 StorageControllerType_BusLogic,
1505 StorageControllerType_IntelAhci,
1506 StorageControllerType_PIIX3,
1507 StorageControllerType_PIIX4,
1508 StorageControllerType_ICH6,
1509 StorageControllerType_I82078,
1510 StorageControllerType_LsiLogicSas,
1511 StorageControllerType_USB,
1512 StorageControllerType_NVMe,
1513#ifdef DEBUG
1514 StorageControllerType_VirtioSCSI,
1515#endif
1516 };
1517 aSupportedStorageControllerTypes.assign(aStorageControllerTypes,
1518 aStorageControllerTypes + RT_ELEMENTS(aStorageControllerTypes));
1519 return S_OK;
1520}
1521
1522HRESULT SystemProperties::getSupportedChipsetTypes(std::vector<ChipsetType_T> &aSupportedChipsetTypes)
1523{
1524 static const ChipsetType_T aChipsetTypes[] =
1525 {
1526 ChipsetType_PIIX3,
1527 ChipsetType_ICH9,
1528 };
1529 aSupportedChipsetTypes.assign(aChipsetTypes,
1530 aChipsetTypes + RT_ELEMENTS(aChipsetTypes));
1531 return S_OK;
1532}
1533
1534
1535// public methods only for internal purposes
1536/////////////////////////////////////////////////////////////////////////////
1537
1538HRESULT SystemProperties::i_loadSettings(const settings::SystemProperties &data)
1539{
1540 AutoCaller autoCaller(this);
1541 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1542
1543 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1544 HRESULT rc = S_OK;
1545 rc = i_setDefaultMachineFolder(data.strDefaultMachineFolder);
1546 if (FAILED(rc)) return rc;
1547
1548 rc = i_setLoggingLevel(data.strLoggingLevel);
1549 if (FAILED(rc)) return rc;
1550
1551 rc = i_setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
1552 if (FAILED(rc)) return rc;
1553
1554 rc = i_setVRDEAuthLibrary(data.strVRDEAuthLibrary);
1555 if (FAILED(rc)) return rc;
1556
1557 rc = i_setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
1558 if (FAILED(rc)) return rc;
1559
1560 rc = i_setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
1561 if (FAILED(rc)) return rc;
1562
1563 m->uLogHistoryCount = data.uLogHistoryCount;
1564 m->fExclusiveHwVirt = data.fExclusiveHwVirt;
1565 m->uProxyMode = data.uProxyMode;
1566 m->strProxyUrl = data.strProxyUrl;
1567
1568 rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath);
1569 if (FAILED(rc)) return rc;
1570
1571 {
1572 /* must ignore errors signalled here, because the guest additions
1573 * file may not exist, and in this case keep the empty string */
1574 ErrorInfoKeeper eik;
1575 (void)i_setDefaultAdditionsISO(data.strDefaultAdditionsISO);
1576 }
1577
1578 rc = i_setDefaultFrontend(data.strDefaultFrontend);
1579 if (FAILED(rc)) return rc;
1580
1581 return S_OK;
1582}
1583
1584HRESULT SystemProperties::i_saveSettings(settings::SystemProperties &data)
1585{
1586 AutoCaller autoCaller(this);
1587 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1588
1589 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1590
1591 data = *m;
1592
1593 return S_OK;
1594}
1595
1596/**
1597 * Returns a medium format object corresponding to the given format
1598 * identifier or null if no such format.
1599 *
1600 * @param aFormat Format identifier.
1601 *
1602 * @return ComObjPtr<MediumFormat>
1603 */
1604ComObjPtr<MediumFormat> SystemProperties::i_mediumFormat(const Utf8Str &aFormat)
1605{
1606 ComObjPtr<MediumFormat> format;
1607
1608 AutoCaller autoCaller(this);
1609 AssertComRCReturn (autoCaller.rc(), format);
1610
1611 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1612
1613 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1614 it != m_llMediumFormats.end();
1615 ++ it)
1616 {
1617 /* MediumFormat is all const, no need to lock */
1618
1619 if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
1620 {
1621 format = *it;
1622 break;
1623 }
1624 }
1625
1626 return format;
1627}
1628
1629/**
1630 * Returns a medium format object corresponding to the given file extension or
1631 * null if no such format.
1632 *
1633 * @param aExt File extension.
1634 *
1635 * @return ComObjPtr<MediumFormat>
1636 */
1637ComObjPtr<MediumFormat> SystemProperties::i_mediumFormatFromExtension(const Utf8Str &aExt)
1638{
1639 ComObjPtr<MediumFormat> format;
1640
1641 AutoCaller autoCaller(this);
1642 AssertComRCReturn (autoCaller.rc(), format);
1643
1644 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1645
1646 bool fFound = false;
1647 for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
1648 it != m_llMediumFormats.end() && !fFound;
1649 ++it)
1650 {
1651 /* MediumFormat is all const, no need to lock */
1652 MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
1653 for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
1654 it1 != aFileList.end();
1655 ++it1)
1656 {
1657 if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
1658 {
1659 format = *it;
1660 fFound = true;
1661 break;
1662 }
1663 }
1664 }
1665
1666 return format;
1667}
1668
1669
1670/**
1671 * VD plugin load
1672 */
1673int SystemProperties::i_loadVDPlugin(const char *pszPluginLibrary)
1674{
1675 return VDPluginLoadFromFilename(pszPluginLibrary);
1676}
1677
1678/**
1679 * VD plugin unload
1680 */
1681int SystemProperties::i_unloadVDPlugin(const char *pszPluginLibrary)
1682{
1683 return VDPluginUnloadFromFilename(pszPluginLibrary);
1684}
1685
1686/**
1687 * Internally usable version of getDefaultAdditionsISO.
1688 */
1689HRESULT SystemProperties::i_getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
1690{
1691 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
1692 if (m->strDefaultAdditionsISO.isNotEmpty())
1693 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
1694 else
1695 {
1696 /* no guest additions, check if it showed up in the mean time */
1697 alock.release();
1698 AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
1699 if (m->strDefaultAdditionsISO.isEmpty())
1700 {
1701 ErrorInfoKeeper eik;
1702 (void)setDefaultAdditionsISO("");
1703 }
1704 aDefaultAdditionsISO = m->strDefaultAdditionsISO;
1705 }
1706 return S_OK;
1707}
1708
1709// private methods
1710/////////////////////////////////////////////////////////////////////////////
1711
1712/**
1713 * Returns the user's home directory. Wrapper around RTPathUserHome().
1714 * @param strPath
1715 * @return
1716 */
1717HRESULT SystemProperties::i_getUserHomeDirectory(Utf8Str &strPath)
1718{
1719 char szHome[RTPATH_MAX];
1720 int vrc = RTPathUserHome(szHome, sizeof(szHome));
1721 if (RT_FAILURE(vrc))
1722 return setErrorBoth(E_FAIL, vrc,
1723 tr("Cannot determine user home directory (%Rrc)"),
1724 vrc);
1725 strPath = szHome;
1726 return S_OK;
1727}
1728
1729/**
1730 * Internal implementation to set the default machine folder. Gets called
1731 * from the public attribute setter as well as loadSettings(). With 4.0,
1732 * the "default default" machine folder has changed, and we now require
1733 * a full path always.
1734 * @param strPath
1735 * @return
1736 */
1737HRESULT SystemProperties::i_setDefaultMachineFolder(const Utf8Str &strPath)
1738{
1739 Utf8Str path(strPath); // make modifiable
1740 if ( path.isEmpty() // used by API calls to reset the default
1741 || path == "Machines" // this value (exactly like this, without path) is stored
1742 // in VirtualBox.xml if user upgrades from before 4.0 and
1743 // has not changed the default machine folder
1744 )
1745 {
1746 // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
1747 HRESULT rc = i_getUserHomeDirectory(path);
1748 if (FAILED(rc)) return rc;
1749 path += RTPATH_SLASH_STR "VirtualBox VMs";
1750 }
1751
1752 if (!RTPathStartsWithRoot(path.c_str()))
1753 return setError(E_INVALIDARG,
1754 tr("Given default machine folder '%s' is not fully qualified"),
1755 path.c_str());
1756
1757 m->strDefaultMachineFolder = path;
1758
1759 return S_OK;
1760}
1761
1762HRESULT SystemProperties::i_setLoggingLevel(const com::Utf8Str &aLoggingLevel)
1763{
1764 Utf8Str useLoggingLevel(aLoggingLevel);
1765 if (useLoggingLevel.isEmpty())
1766 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1767 int rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str());
1768 // If failed and not the default logging level - try to use the default logging level.
1769 if (RT_FAILURE(rc))
1770 {
1771 // If failed write message to the release log.
1772 LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
1773 // If attempted logging level not the default one then try the default one.
1774 if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
1775 {
1776 rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), VBOXSVC_LOG_DEFAULT);
1777 // If failed report this to the release log.
1778 if (RT_FAILURE(rc))
1779 LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
1780 }
1781 // On any failure - set default level as the one to be stored.
1782 useLoggingLevel = VBOXSVC_LOG_DEFAULT;
1783 }
1784 // Set to passed value or if default used/attempted (even if error condition) use empty string.
1785 m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
1786 return RT_SUCCESS(rc) ? S_OK : E_FAIL;
1787}
1788
1789HRESULT SystemProperties::i_setDefaultHardDiskFormat(const com::Utf8Str &aFormat)
1790{
1791 if (!aFormat.isEmpty())
1792 m->strDefaultHardDiskFormat = aFormat;
1793 else
1794 m->strDefaultHardDiskFormat = "VDI";
1795
1796 return S_OK;
1797}
1798
1799HRESULT SystemProperties::i_setVRDEAuthLibrary(const com::Utf8Str &aPath)
1800{
1801 if (!aPath.isEmpty())
1802 m->strVRDEAuthLibrary = aPath;
1803 else
1804 m->strVRDEAuthLibrary = "VBoxAuth";
1805
1806 return S_OK;
1807}
1808
1809HRESULT SystemProperties::i_setWebServiceAuthLibrary(const com::Utf8Str &aPath)
1810{
1811 if (!aPath.isEmpty())
1812 m->strWebServiceAuthLibrary = aPath;
1813 else
1814 m->strWebServiceAuthLibrary = "VBoxAuth";
1815
1816 return S_OK;
1817}
1818
1819HRESULT SystemProperties::i_setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
1820{
1821 m->strDefaultVRDEExtPack = aExtPack;
1822
1823 return S_OK;
1824}
1825
1826HRESULT SystemProperties::i_setAutostartDatabasePath(const com::Utf8Str &aPath)
1827{
1828 HRESULT rc = S_OK;
1829 AutostartDb *autostartDb = this->mParent->i_getAutostartDb();
1830
1831 if (!aPath.isEmpty())
1832 {
1833 /* Update path in the autostart database. */
1834 int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
1835 if (RT_SUCCESS(vrc))
1836 m->strAutostartDatabasePath = aPath;
1837 else
1838 rc = setErrorBoth(E_FAIL, vrc,
1839 tr("Cannot set the autostart database path (%Rrc)"),
1840 vrc);
1841 }
1842 else
1843 {
1844 int vrc = autostartDb->setAutostartDbPath(NULL);
1845 if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
1846 m->strAutostartDatabasePath = "";
1847 else
1848 rc = setErrorBoth(E_FAIL, vrc,
1849 tr("Deleting the autostart database path failed (%Rrc)"),
1850 vrc);
1851 }
1852
1853 return rc;
1854}
1855
1856HRESULT SystemProperties::i_setDefaultAdditionsISO(const com::Utf8Str &aPath)
1857{
1858 com::Utf8Str path(aPath);
1859 if (path.isEmpty())
1860 {
1861 char strTemp[RTPATH_MAX];
1862 int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
1863 AssertRC(vrc);
1864 Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
1865
1866 vrc = RTPathExecDir(strTemp, sizeof(strTemp));
1867 AssertRC(vrc);
1868 Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
1869
1870 vrc = RTPathUserHome(strTemp, sizeof(strTemp));
1871 AssertRC(vrc);
1872 Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%s.iso", strTemp, VirtualBox::i_getVersionNormalized().c_str());
1873
1874 /* Check the standard image locations */
1875 if (RTFileExists(strSrc1.c_str()))
1876 path = strSrc1;
1877 else if (RTFileExists(strSrc2.c_str()))
1878 path = strSrc2;
1879 else if (RTFileExists(strSrc3.c_str()))
1880 path = strSrc3;
1881 else
1882 return setError(E_FAIL,
1883 tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
1884 }
1885
1886 if (!RTPathStartsWithRoot(path.c_str()))
1887 return setError(E_INVALIDARG,
1888 tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
1889 path.c_str());
1890
1891 if (!RTFileExists(path.c_str()))
1892 return setError(E_INVALIDARG,
1893 tr("Given default machine Guest Additions ISO file '%s' does not exist"),
1894 path.c_str());
1895
1896 m->strDefaultAdditionsISO = path;
1897
1898 return S_OK;
1899}
1900
1901HRESULT SystemProperties::i_setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
1902{
1903 m->strDefaultFrontend = aDefaultFrontend;
1904
1905 return S_OK;
1906}
1907
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