1 | /* $Id: SystemPropertiesImpl.cpp 63256 2016-08-10 12:04:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 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 | #include "SystemPropertiesImpl.h"
|
---|
19 | #include "VirtualBoxImpl.h"
|
---|
20 | #include "MachineImpl.h"
|
---|
21 | #ifdef VBOX_WITH_EXTPACK
|
---|
22 | # include "ExtPackManagerImpl.h"
|
---|
23 | #endif
|
---|
24 | #include "AutoCaller.h"
|
---|
25 | #include "Global.h"
|
---|
26 | #include "Logging.h"
|
---|
27 | #include "AutostartDb.h"
|
---|
28 |
|
---|
29 | // generated header
|
---|
30 | #include "SchemaDefs.h"
|
---|
31 |
|
---|
32 | #include <iprt/dir.h>
|
---|
33 | #include <iprt/ldr.h>
|
---|
34 | #include <iprt/path.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/cpp/utils.h>
|
---|
37 |
|
---|
38 | #include <VBox/err.h>
|
---|
39 | #include <VBox/param.h>
|
---|
40 | #include <VBox/settings.h>
|
---|
41 | #include <VBox/vd.h>
|
---|
42 |
|
---|
43 | // defines
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 |
|
---|
46 | // constructor / destructor
|
---|
47 | /////////////////////////////////////////////////////////////////////////////
|
---|
48 |
|
---|
49 | SystemProperties::SystemProperties()
|
---|
50 | : mParent(NULL),
|
---|
51 | m(new settings::SystemProperties)
|
---|
52 | {
|
---|
53 | }
|
---|
54 |
|
---|
55 | SystemProperties::~SystemProperties()
|
---|
56 | {
|
---|
57 | delete m;
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | HRESULT SystemProperties::FinalConstruct()
|
---|
62 | {
|
---|
63 | return BaseFinalConstruct();
|
---|
64 | }
|
---|
65 |
|
---|
66 | void SystemProperties::FinalRelease()
|
---|
67 | {
|
---|
68 | uninit();
|
---|
69 | BaseFinalRelease();
|
---|
70 | }
|
---|
71 |
|
---|
72 | // public methods only for internal purposes
|
---|
73 | /////////////////////////////////////////////////////////////////////////////
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Initializes the system information object.
|
---|
77 | *
|
---|
78 | * @returns COM result indicator
|
---|
79 | */
|
---|
80 | HRESULT SystemProperties::init(VirtualBox *aParent)
|
---|
81 | {
|
---|
82 | LogFlowThisFunc(("aParent=%p\n", aParent));
|
---|
83 |
|
---|
84 | ComAssertRet(aParent, E_FAIL);
|
---|
85 |
|
---|
86 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
87 | AutoInitSpan autoInitSpan(this);
|
---|
88 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
89 |
|
---|
90 | unconst(mParent) = aParent;
|
---|
91 |
|
---|
92 | i_setDefaultMachineFolder(Utf8Str::Empty);
|
---|
93 | i_setLoggingLevel(Utf8Str::Empty);
|
---|
94 | i_setDefaultHardDiskFormat(Utf8Str::Empty);
|
---|
95 |
|
---|
96 | i_setVRDEAuthLibrary(Utf8Str::Empty);
|
---|
97 | i_setDefaultVRDEExtPack(Utf8Str::Empty);
|
---|
98 |
|
---|
99 | m->ulLogHistoryCount = 3;
|
---|
100 |
|
---|
101 |
|
---|
102 | /* On Windows and OS X, HW virtualization use isn't exclusive by
|
---|
103 | * default so that VT-x or AMD-V can be shared with other
|
---|
104 | * hypervisors without requiring user intervention.
|
---|
105 | * NB: See also SystemProperties constructor in settings.h
|
---|
106 | */
|
---|
107 | #if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
|
---|
108 | m->fExclusiveHwVirt = false;
|
---|
109 | #else
|
---|
110 | m->fExclusiveHwVirt = true;
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | HRESULT rc = S_OK;
|
---|
114 |
|
---|
115 | /* Fetch info of all available hd backends. */
|
---|
116 |
|
---|
117 | /// @todo NEWMEDIA VDBackendInfo needs to be improved to let us enumerate
|
---|
118 | /// any number of backends
|
---|
119 |
|
---|
120 | VDBACKENDINFO aVDInfo[100];
|
---|
121 | unsigned cEntries;
|
---|
122 | int vrc = VDBackendInfo(RT_ELEMENTS(aVDInfo), aVDInfo, &cEntries);
|
---|
123 | AssertRC(vrc);
|
---|
124 | if (RT_SUCCESS(vrc))
|
---|
125 | {
|
---|
126 | for (unsigned i = 0; i < cEntries; ++ i)
|
---|
127 | {
|
---|
128 | ComObjPtr<MediumFormat> hdf;
|
---|
129 | rc = hdf.createObject();
|
---|
130 | if (FAILED(rc)) break;
|
---|
131 |
|
---|
132 | rc = hdf->init(&aVDInfo[i]);
|
---|
133 | if (FAILED(rc)) break;
|
---|
134 |
|
---|
135 | m_llMediumFormats.push_back(hdf);
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | /* Confirm a successful initialization */
|
---|
140 | if (SUCCEEDED(rc))
|
---|
141 | autoInitSpan.setSucceeded();
|
---|
142 |
|
---|
143 | return rc;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
148 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
149 | */
|
---|
150 | void SystemProperties::uninit()
|
---|
151 | {
|
---|
152 | LogFlowThisFunc(("\n"));
|
---|
153 |
|
---|
154 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
155 | AutoUninitSpan autoUninitSpan(this);
|
---|
156 | if (autoUninitSpan.uninitDone())
|
---|
157 | return;
|
---|
158 |
|
---|
159 | unconst(mParent) = NULL;
|
---|
160 | }
|
---|
161 |
|
---|
162 | // wrapped ISystemProperties properties
|
---|
163 | /////////////////////////////////////////////////////////////////////////////
|
---|
164 |
|
---|
165 | HRESULT SystemProperties::getMinGuestRAM(ULONG *minRAM)
|
---|
166 |
|
---|
167 | {
|
---|
168 | /* no need to lock, this is const */
|
---|
169 | AssertCompile(MM_RAM_MIN_IN_MB >= SchemaDefs::MinGuestRAM);
|
---|
170 | *minRAM = MM_RAM_MIN_IN_MB;
|
---|
171 |
|
---|
172 | return S_OK;
|
---|
173 | }
|
---|
174 |
|
---|
175 | HRESULT SystemProperties::getMaxGuestRAM(ULONG *maxRAM)
|
---|
176 | {
|
---|
177 | /* no need to lock, this is const */
|
---|
178 | AssertCompile(MM_RAM_MAX_IN_MB <= SchemaDefs::MaxGuestRAM);
|
---|
179 | ULONG maxRAMSys = MM_RAM_MAX_IN_MB;
|
---|
180 | ULONG maxRAMArch = maxRAMSys;
|
---|
181 | *maxRAM = RT_MIN(maxRAMSys, maxRAMArch);
|
---|
182 |
|
---|
183 | return S_OK;
|
---|
184 | }
|
---|
185 |
|
---|
186 | HRESULT SystemProperties::getMinGuestVRAM(ULONG *minVRAM)
|
---|
187 | {
|
---|
188 | /* no need to lock, this is const */
|
---|
189 | *minVRAM = SchemaDefs::MinGuestVRAM;
|
---|
190 |
|
---|
191 | return S_OK;
|
---|
192 | }
|
---|
193 |
|
---|
194 | HRESULT SystemProperties::getMaxGuestVRAM(ULONG *maxVRAM)
|
---|
195 | {
|
---|
196 | /* no need to lock, this is const */
|
---|
197 | *maxVRAM = SchemaDefs::MaxGuestVRAM;
|
---|
198 |
|
---|
199 | return S_OK;
|
---|
200 | }
|
---|
201 |
|
---|
202 | HRESULT SystemProperties::getMinGuestCPUCount(ULONG *minCPUCount)
|
---|
203 | {
|
---|
204 | /* no need to lock, this is const */
|
---|
205 | *minCPUCount = SchemaDefs::MinCPUCount; // VMM_MIN_CPU_COUNT
|
---|
206 |
|
---|
207 | return S_OK;
|
---|
208 | }
|
---|
209 |
|
---|
210 | HRESULT SystemProperties::getMaxGuestCPUCount(ULONG *maxCPUCount)
|
---|
211 | {
|
---|
212 | /* no need to lock, this is const */
|
---|
213 | *maxCPUCount = SchemaDefs::MaxCPUCount; // VMM_MAX_CPU_COUNT
|
---|
214 |
|
---|
215 | return S_OK;
|
---|
216 | }
|
---|
217 |
|
---|
218 | HRESULT SystemProperties::getMaxGuestMonitors(ULONG *maxMonitors)
|
---|
219 | {
|
---|
220 |
|
---|
221 | /* no need to lock, this is const */
|
---|
222 | *maxMonitors = SchemaDefs::MaxGuestMonitors;
|
---|
223 |
|
---|
224 | return S_OK;
|
---|
225 | }
|
---|
226 |
|
---|
227 |
|
---|
228 | HRESULT SystemProperties::getInfoVDSize(LONG64 *infoVDSize)
|
---|
229 | {
|
---|
230 | /*
|
---|
231 | * The BIOS supports currently 32 bit LBA numbers (implementing the full
|
---|
232 | * 48 bit range is in theory trivial, but the crappy compiler makes things
|
---|
233 | * more difficult). This translates to almost 2 TiBytes (to be on the safe
|
---|
234 | * side, the reported limit is 1 MiByte less than that, as the total number
|
---|
235 | * of sectors should fit in 32 bits, too), which should be enough for the
|
---|
236 | * moment. Since the MBR partition tables support only 32bit sector numbers
|
---|
237 | * and thus the BIOS can only boot from disks smaller than 2T this is a
|
---|
238 | * rather hard limit.
|
---|
239 | *
|
---|
240 | * The virtual ATA/SATA disks support complete LBA48, and SCSI supports
|
---|
241 | * LBA64 (almost, more like LBA55 in practice), so the theoretical maximum
|
---|
242 | * disk size is 128 PiByte/16 EiByte. The GUI works nicely with 6 orders
|
---|
243 | * of magnitude, but not with 11..13 orders of magnitude.
|
---|
244 | */
|
---|
245 | /* no need to lock, this is const */
|
---|
246 | *infoVDSize = 2 * _1T - _1M;
|
---|
247 |
|
---|
248 | return S_OK;
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | HRESULT SystemProperties::getSerialPortCount(ULONG *count)
|
---|
253 | {
|
---|
254 | /* no need to lock, this is const */
|
---|
255 | *count = SchemaDefs::SerialPortCount;
|
---|
256 |
|
---|
257 | return S_OK;
|
---|
258 | }
|
---|
259 |
|
---|
260 |
|
---|
261 | HRESULT SystemProperties::getParallelPortCount(ULONG *count)
|
---|
262 | {
|
---|
263 | /* no need to lock, this is const */
|
---|
264 | *count = SchemaDefs::ParallelPortCount;
|
---|
265 |
|
---|
266 | return S_OK;
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 | HRESULT SystemProperties::getMaxBootPosition(ULONG *aMaxBootPosition)
|
---|
271 | {
|
---|
272 | /* no need to lock, this is const */
|
---|
273 | *aMaxBootPosition = SchemaDefs::MaxBootPosition;
|
---|
274 |
|
---|
275 | return S_OK;
|
---|
276 | }
|
---|
277 |
|
---|
278 |
|
---|
279 | HRESULT SystemProperties::getRawModeSupported(BOOL *aRawModeSupported)
|
---|
280 | {
|
---|
281 | #ifdef VBOX_WITH_RAW_MODE
|
---|
282 | *aRawModeSupported = TRUE;
|
---|
283 | #else
|
---|
284 | *aRawModeSupported = FALSE;
|
---|
285 | #endif
|
---|
286 | return S_OK;
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 | HRESULT SystemProperties::getExclusiveHwVirt(BOOL *aExclusiveHwVirt)
|
---|
291 | {
|
---|
292 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
293 |
|
---|
294 | *aExclusiveHwVirt = m->fExclusiveHwVirt;
|
---|
295 |
|
---|
296 | return S_OK;
|
---|
297 | }
|
---|
298 |
|
---|
299 | HRESULT SystemProperties::setExclusiveHwVirt(BOOL aExclusiveHwVirt)
|
---|
300 | {
|
---|
301 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
302 | m->fExclusiveHwVirt = !!aExclusiveHwVirt;
|
---|
303 | alock.release();
|
---|
304 |
|
---|
305 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
306 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
307 | HRESULT rc = mParent->i_saveSettings();
|
---|
308 |
|
---|
309 | return rc;
|
---|
310 | }
|
---|
311 |
|
---|
312 | HRESULT SystemProperties::getMaxNetworkAdapters(ChipsetType_T aChipset, ULONG *aMaxNetworkAdapters)
|
---|
313 | {
|
---|
314 | /* no need for locking, no state */
|
---|
315 | uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
|
---|
316 | if (uResult == 0)
|
---|
317 | AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
|
---|
318 | *aMaxNetworkAdapters = uResult;
|
---|
319 | return S_OK;
|
---|
320 | }
|
---|
321 |
|
---|
322 | HRESULT SystemProperties::getMaxNetworkAdaptersOfType(ChipsetType_T aChipset, NetworkAttachmentType_T aType, ULONG *count)
|
---|
323 | {
|
---|
324 | /* no need for locking, no state */
|
---|
325 | uint32_t uResult = Global::getMaxNetworkAdapters(aChipset);
|
---|
326 | if (uResult == 0)
|
---|
327 | AssertMsgFailed(("Invalid chipset type %d\n", aChipset));
|
---|
328 |
|
---|
329 | switch (aType)
|
---|
330 | {
|
---|
331 | case NetworkAttachmentType_NAT:
|
---|
332 | case NetworkAttachmentType_Internal:
|
---|
333 | case NetworkAttachmentType_NATNetwork:
|
---|
334 | /* chipset default is OK */
|
---|
335 | break;
|
---|
336 | case NetworkAttachmentType_Bridged:
|
---|
337 | /* Maybe use current host interface count here? */
|
---|
338 | break;
|
---|
339 | case NetworkAttachmentType_HostOnly:
|
---|
340 | uResult = RT_MIN(uResult, 8);
|
---|
341 | break;
|
---|
342 | default:
|
---|
343 | AssertMsgFailed(("Unhandled attachment type %d\n", aType));
|
---|
344 | }
|
---|
345 |
|
---|
346 | *count = uResult;
|
---|
347 |
|
---|
348 | return S_OK;
|
---|
349 | }
|
---|
350 |
|
---|
351 |
|
---|
352 | HRESULT SystemProperties::getMaxDevicesPerPortForStorageBus(StorageBus_T aBus,
|
---|
353 | ULONG *aMaxDevicesPerPort)
|
---|
354 | {
|
---|
355 | /* no need to lock, this is const */
|
---|
356 | switch (aBus)
|
---|
357 | {
|
---|
358 | case StorageBus_SATA:
|
---|
359 | case StorageBus_SCSI:
|
---|
360 | case StorageBus_SAS:
|
---|
361 | case StorageBus_USB:
|
---|
362 | case StorageBus_PCIe:
|
---|
363 | {
|
---|
364 | /* SATA and both SCSI controllers only support one device per port. */
|
---|
365 | *aMaxDevicesPerPort = 1;
|
---|
366 | break;
|
---|
367 | }
|
---|
368 | case StorageBus_IDE:
|
---|
369 | case StorageBus_Floppy:
|
---|
370 | {
|
---|
371 | /* The IDE and Floppy controllers support 2 devices. One as master
|
---|
372 | * and one as slave (or floppy drive 0 and 1). */
|
---|
373 | *aMaxDevicesPerPort = 2;
|
---|
374 | break;
|
---|
375 | }
|
---|
376 | default:
|
---|
377 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
378 | }
|
---|
379 |
|
---|
380 | return S_OK;
|
---|
381 | }
|
---|
382 |
|
---|
383 | HRESULT SystemProperties::getMinPortCountForStorageBus(StorageBus_T aBus,
|
---|
384 | ULONG *aMinPortCount)
|
---|
385 | {
|
---|
386 | /* no need to lock, this is const */
|
---|
387 | switch (aBus)
|
---|
388 | {
|
---|
389 | case StorageBus_SATA:
|
---|
390 | case StorageBus_SAS:
|
---|
391 | case StorageBus_PCIe:
|
---|
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 |
|
---|
423 | HRESULT 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 | default:
|
---|
461 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
462 | }
|
---|
463 |
|
---|
464 | return S_OK;
|
---|
465 | }
|
---|
466 |
|
---|
467 | HRESULT SystemProperties::getMaxInstancesOfStorageBus(ChipsetType_T aChipset,
|
---|
468 | StorageBus_T aBus,
|
---|
469 | ULONG *aMaxInstances)
|
---|
470 | {
|
---|
471 | ULONG cCtrs = 0;
|
---|
472 |
|
---|
473 | /* no need to lock, this is const */
|
---|
474 | switch (aBus)
|
---|
475 | {
|
---|
476 | case StorageBus_SATA:
|
---|
477 | case StorageBus_SCSI:
|
---|
478 | case StorageBus_SAS:
|
---|
479 | case StorageBus_PCIe:
|
---|
480 | cCtrs = aChipset == ChipsetType_ICH9 ? 8 : 1;
|
---|
481 | break;
|
---|
482 | case StorageBus_USB:
|
---|
483 | case StorageBus_IDE:
|
---|
484 | case StorageBus_Floppy:
|
---|
485 | {
|
---|
486 | cCtrs = 1;
|
---|
487 | break;
|
---|
488 | }
|
---|
489 | default:
|
---|
490 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
491 | }
|
---|
492 |
|
---|
493 | *aMaxInstances = cCtrs;
|
---|
494 |
|
---|
495 | return S_OK;
|
---|
496 | }
|
---|
497 |
|
---|
498 | HRESULT SystemProperties::getDeviceTypesForStorageBus(StorageBus_T aBus,
|
---|
499 | std::vector<DeviceType_T> &aDeviceTypes)
|
---|
500 | {
|
---|
501 | aDeviceTypes.resize(0);
|
---|
502 |
|
---|
503 | /* no need to lock, this is const */
|
---|
504 | switch (aBus)
|
---|
505 | {
|
---|
506 | case StorageBus_IDE:
|
---|
507 | case StorageBus_SATA:
|
---|
508 | case StorageBus_SCSI:
|
---|
509 | case StorageBus_SAS:
|
---|
510 | case StorageBus_USB:
|
---|
511 | {
|
---|
512 | aDeviceTypes.resize(2);
|
---|
513 | aDeviceTypes[0] = DeviceType_DVD;
|
---|
514 | aDeviceTypes[1] = DeviceType_HardDisk;
|
---|
515 | break;
|
---|
516 | }
|
---|
517 | case StorageBus_Floppy:
|
---|
518 | {
|
---|
519 | aDeviceTypes.resize(1);
|
---|
520 | aDeviceTypes[0] = DeviceType_Floppy;
|
---|
521 | break;
|
---|
522 | }
|
---|
523 | case StorageBus_PCIe:
|
---|
524 | {
|
---|
525 | aDeviceTypes.resize(1);
|
---|
526 | aDeviceTypes[0] = DeviceType_HardDisk;
|
---|
527 | break;
|
---|
528 | }
|
---|
529 | default:
|
---|
530 | AssertMsgFailed(("Invalid bus type %d\n", aBus));
|
---|
531 | }
|
---|
532 |
|
---|
533 | return S_OK;
|
---|
534 | }
|
---|
535 |
|
---|
536 | HRESULT SystemProperties::getDefaultIoCacheSettingForStorageController(StorageControllerType_T aControllerType,
|
---|
537 | BOOL *aEnabled)
|
---|
538 | {
|
---|
539 | /* no need to lock, this is const */
|
---|
540 | switch (aControllerType)
|
---|
541 | {
|
---|
542 | case StorageControllerType_LsiLogic:
|
---|
543 | case StorageControllerType_BusLogic:
|
---|
544 | case StorageControllerType_IntelAhci:
|
---|
545 | case StorageControllerType_LsiLogicSas:
|
---|
546 | case StorageControllerType_USB:
|
---|
547 | case StorageControllerType_NVMe:
|
---|
548 | *aEnabled = false;
|
---|
549 | break;
|
---|
550 | case StorageControllerType_PIIX3:
|
---|
551 | case StorageControllerType_PIIX4:
|
---|
552 | case StorageControllerType_ICH6:
|
---|
553 | case StorageControllerType_I82078:
|
---|
554 | *aEnabled = true;
|
---|
555 | break;
|
---|
556 | default:
|
---|
557 | AssertMsgFailed(("Invalid controller type %d\n", aControllerType));
|
---|
558 | }
|
---|
559 | return S_OK;
|
---|
560 | }
|
---|
561 |
|
---|
562 | HRESULT SystemProperties::getStorageControllerHotplugCapable(StorageControllerType_T aControllerType,
|
---|
563 | BOOL *aHotplugCapable)
|
---|
564 | {
|
---|
565 | switch (aControllerType)
|
---|
566 | {
|
---|
567 | case StorageControllerType_IntelAhci:
|
---|
568 | case StorageControllerType_USB:
|
---|
569 | *aHotplugCapable = true;
|
---|
570 | break;
|
---|
571 | case StorageControllerType_LsiLogic:
|
---|
572 | case StorageControllerType_LsiLogicSas:
|
---|
573 | case StorageControllerType_BusLogic:
|
---|
574 | case StorageControllerType_NVMe:
|
---|
575 | case StorageControllerType_PIIX3:
|
---|
576 | case StorageControllerType_PIIX4:
|
---|
577 | case StorageControllerType_ICH6:
|
---|
578 | case StorageControllerType_I82078:
|
---|
579 | *aHotplugCapable = false;
|
---|
580 | break;
|
---|
581 | default:
|
---|
582 | AssertMsgFailedReturn(("Invalid controller type %d\n", aControllerType), E_FAIL);
|
---|
583 | }
|
---|
584 |
|
---|
585 | return S_OK;
|
---|
586 | }
|
---|
587 |
|
---|
588 | HRESULT SystemProperties::getMaxInstancesOfUSBControllerType(ChipsetType_T aChipset,
|
---|
589 | USBControllerType_T aType,
|
---|
590 | ULONG *aMaxInstances)
|
---|
591 | {
|
---|
592 | NOREF(aChipset);
|
---|
593 | ULONG cCtrs = 0;
|
---|
594 |
|
---|
595 | /* no need to lock, this is const */
|
---|
596 | switch (aType)
|
---|
597 | {
|
---|
598 | case USBControllerType_OHCI:
|
---|
599 | case USBControllerType_EHCI:
|
---|
600 | case USBControllerType_XHCI:
|
---|
601 | {
|
---|
602 | cCtrs = 1;
|
---|
603 | break;
|
---|
604 | }
|
---|
605 | default:
|
---|
606 | AssertMsgFailed(("Invalid bus type %d\n", aType));
|
---|
607 | }
|
---|
608 |
|
---|
609 | *aMaxInstances = cCtrs;
|
---|
610 |
|
---|
611 | return S_OK;
|
---|
612 | }
|
---|
613 |
|
---|
614 | HRESULT SystemProperties::getDefaultMachineFolder(com::Utf8Str &aDefaultMachineFolder)
|
---|
615 | {
|
---|
616 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
617 | aDefaultMachineFolder = m->strDefaultMachineFolder;
|
---|
618 | return S_OK;
|
---|
619 | }
|
---|
620 |
|
---|
621 | HRESULT SystemProperties::setDefaultMachineFolder(const com::Utf8Str &aDefaultMachineFolder)
|
---|
622 | {
|
---|
623 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
624 | HRESULT rc = i_setDefaultMachineFolder(aDefaultMachineFolder);
|
---|
625 | alock.release();
|
---|
626 | if (SUCCEEDED(rc))
|
---|
627 | {
|
---|
628 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
629 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
630 | rc = mParent->i_saveSettings();
|
---|
631 | }
|
---|
632 |
|
---|
633 | return rc;
|
---|
634 | }
|
---|
635 |
|
---|
636 | HRESULT SystemProperties::getLoggingLevel(com::Utf8Str &aLoggingLevel)
|
---|
637 | {
|
---|
638 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
639 |
|
---|
640 | aLoggingLevel = m->strLoggingLevel;
|
---|
641 |
|
---|
642 | if (aLoggingLevel.isEmpty())
|
---|
643 | aLoggingLevel = VBOXSVC_LOG_DEFAULT;
|
---|
644 |
|
---|
645 | return S_OK;
|
---|
646 | }
|
---|
647 |
|
---|
648 |
|
---|
649 | HRESULT SystemProperties::setLoggingLevel(const com::Utf8Str &aLoggingLevel)
|
---|
650 | {
|
---|
651 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
652 | HRESULT rc = i_setLoggingLevel(aLoggingLevel);
|
---|
653 | alock.release();
|
---|
654 |
|
---|
655 | if (SUCCEEDED(rc))
|
---|
656 | {
|
---|
657 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
658 | rc = mParent->i_saveSettings();
|
---|
659 | }
|
---|
660 | else
|
---|
661 | LogRel(("Cannot set passed logging level=%s, or the default one - Error=%Rhrc \n", aLoggingLevel.c_str(), rc));
|
---|
662 |
|
---|
663 | return rc;
|
---|
664 | }
|
---|
665 |
|
---|
666 | HRESULT SystemProperties::getMediumFormats(std::vector<ComPtr<IMediumFormat> > &aMediumFormats)
|
---|
667 | {
|
---|
668 | MediumFormatList mediumFormats(m_llMediumFormats);
|
---|
669 | aMediumFormats.resize(mediumFormats.size());
|
---|
670 | size_t i = 0;
|
---|
671 | for (MediumFormatList::const_iterator it = mediumFormats.begin(); it != mediumFormats.end(); ++it, ++i)
|
---|
672 | (*it).queryInterfaceTo(aMediumFormats[i].asOutParam());
|
---|
673 | return S_OK;
|
---|
674 | }
|
---|
675 |
|
---|
676 | HRESULT SystemProperties::getDefaultHardDiskFormat(com::Utf8Str &aDefaultHardDiskFormat)
|
---|
677 | {
|
---|
678 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
679 | aDefaultHardDiskFormat = m->strDefaultHardDiskFormat;
|
---|
680 | return S_OK;
|
---|
681 | }
|
---|
682 |
|
---|
683 |
|
---|
684 | HRESULT SystemProperties::setDefaultHardDiskFormat(const com::Utf8Str &aDefaultHardDiskFormat)
|
---|
685 | {
|
---|
686 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
687 | HRESULT rc = i_setDefaultHardDiskFormat(aDefaultHardDiskFormat);
|
---|
688 | alock.release();
|
---|
689 | if (SUCCEEDED(rc))
|
---|
690 | {
|
---|
691 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
692 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
693 | rc = mParent->i_saveSettings();
|
---|
694 | }
|
---|
695 |
|
---|
696 | return rc;
|
---|
697 | }
|
---|
698 |
|
---|
699 | HRESULT SystemProperties::getFreeDiskSpaceWarning(LONG64 *aFreeSpace)
|
---|
700 | {
|
---|
701 | NOREF(aFreeSpace);
|
---|
702 | ReturnComNotImplemented();
|
---|
703 | }
|
---|
704 |
|
---|
705 | HRESULT SystemProperties::setFreeDiskSpaceWarning(LONG64 /* aFreeSpace */)
|
---|
706 | {
|
---|
707 | ReturnComNotImplemented();
|
---|
708 | }
|
---|
709 |
|
---|
710 | HRESULT SystemProperties::getFreeDiskSpacePercentWarning(ULONG *aFreeSpacePercent)
|
---|
711 | {
|
---|
712 | NOREF(aFreeSpacePercent);
|
---|
713 | ReturnComNotImplemented();
|
---|
714 | }
|
---|
715 |
|
---|
716 | HRESULT SystemProperties::setFreeDiskSpacePercentWarning(ULONG /* aFreeSpacePercent */)
|
---|
717 | {
|
---|
718 | ReturnComNotImplemented();
|
---|
719 | }
|
---|
720 |
|
---|
721 | HRESULT SystemProperties::getFreeDiskSpaceError(LONG64 *aFreeSpace)
|
---|
722 | {
|
---|
723 | NOREF(aFreeSpace);
|
---|
724 | ReturnComNotImplemented();
|
---|
725 | }
|
---|
726 |
|
---|
727 | HRESULT SystemProperties::setFreeDiskSpaceError(LONG64 /* aFreeSpace */)
|
---|
728 | {
|
---|
729 | ReturnComNotImplemented();
|
---|
730 | }
|
---|
731 |
|
---|
732 | HRESULT SystemProperties::getFreeDiskSpacePercentError(ULONG *aFreeSpacePercent)
|
---|
733 | {
|
---|
734 | NOREF(aFreeSpacePercent);
|
---|
735 | ReturnComNotImplemented();
|
---|
736 | }
|
---|
737 |
|
---|
738 | HRESULT SystemProperties::setFreeDiskSpacePercentError(ULONG /* aFreeSpacePercent */)
|
---|
739 | {
|
---|
740 | ReturnComNotImplemented();
|
---|
741 | }
|
---|
742 |
|
---|
743 | HRESULT SystemProperties::getVRDEAuthLibrary(com::Utf8Str &aVRDEAuthLibrary)
|
---|
744 | {
|
---|
745 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
746 |
|
---|
747 | aVRDEAuthLibrary = m->strVRDEAuthLibrary;
|
---|
748 |
|
---|
749 | return S_OK;
|
---|
750 | }
|
---|
751 |
|
---|
752 | HRESULT SystemProperties::setVRDEAuthLibrary(const com::Utf8Str &aVRDEAuthLibrary)
|
---|
753 | {
|
---|
754 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
755 | HRESULT rc = i_setVRDEAuthLibrary(aVRDEAuthLibrary);
|
---|
756 | alock.release();
|
---|
757 | if (SUCCEEDED(rc))
|
---|
758 | {
|
---|
759 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
760 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
761 | rc = mParent->i_saveSettings();
|
---|
762 | }
|
---|
763 |
|
---|
764 | return rc;
|
---|
765 | }
|
---|
766 |
|
---|
767 | HRESULT SystemProperties::getWebServiceAuthLibrary(com::Utf8Str &aWebServiceAuthLibrary)
|
---|
768 | {
|
---|
769 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
770 |
|
---|
771 | aWebServiceAuthLibrary = m->strWebServiceAuthLibrary;
|
---|
772 |
|
---|
773 | return S_OK;
|
---|
774 | }
|
---|
775 |
|
---|
776 | HRESULT SystemProperties::setWebServiceAuthLibrary(const com::Utf8Str &aWebServiceAuthLibrary)
|
---|
777 | {
|
---|
778 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
779 | HRESULT rc = i_setWebServiceAuthLibrary(aWebServiceAuthLibrary);
|
---|
780 | alock.release();
|
---|
781 |
|
---|
782 | if (SUCCEEDED(rc))
|
---|
783 | {
|
---|
784 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
785 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
786 | rc = mParent->i_saveSettings();
|
---|
787 | }
|
---|
788 |
|
---|
789 | return rc;
|
---|
790 | }
|
---|
791 |
|
---|
792 | HRESULT SystemProperties::getDefaultVRDEExtPack(com::Utf8Str &aExtPack)
|
---|
793 | {
|
---|
794 | HRESULT hrc = S_OK;
|
---|
795 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
796 | Utf8Str strExtPack(m->strDefaultVRDEExtPack);
|
---|
797 | if (strExtPack.isNotEmpty())
|
---|
798 | {
|
---|
799 | if (strExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
|
---|
800 | hrc = S_OK;
|
---|
801 | else
|
---|
802 | #ifdef VBOX_WITH_EXTPACK
|
---|
803 | hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&strExtPack);
|
---|
804 | #else
|
---|
805 | hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), strExtPack.c_str());
|
---|
806 | #endif
|
---|
807 | }
|
---|
808 | else
|
---|
809 | {
|
---|
810 | #ifdef VBOX_WITH_EXTPACK
|
---|
811 | hrc = mParent->i_getExtPackManager()->i_getDefaultVrdeExtPack(&strExtPack);
|
---|
812 | #endif
|
---|
813 | if (strExtPack.isEmpty())
|
---|
814 | {
|
---|
815 | /*
|
---|
816 | * Klugde - check if VBoxVRDP.dll/.so/.dylib is installed.
|
---|
817 | * This is hardcoded uglyness, sorry.
|
---|
818 | */
|
---|
819 | char szPath[RTPATH_MAX];
|
---|
820 | int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath));
|
---|
821 | if (RT_SUCCESS(vrc))
|
---|
822 | vrc = RTPathAppend(szPath, sizeof(szPath), "VBoxVRDP");
|
---|
823 | if (RT_SUCCESS(vrc))
|
---|
824 | vrc = RTStrCat(szPath, sizeof(szPath), RTLdrGetSuff());
|
---|
825 | if (RT_SUCCESS(vrc) && RTFileExists(szPath))
|
---|
826 | {
|
---|
827 | /* Illegal extpack name, so no conflict. */
|
---|
828 | strExtPack = VBOXVRDP_KLUDGE_EXTPACK_NAME;
|
---|
829 | }
|
---|
830 | }
|
---|
831 | }
|
---|
832 |
|
---|
833 | if (SUCCEEDED(hrc))
|
---|
834 | aExtPack = strExtPack;
|
---|
835 |
|
---|
836 | return S_OK;
|
---|
837 | }
|
---|
838 |
|
---|
839 |
|
---|
840 | HRESULT SystemProperties::setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
|
---|
841 | {
|
---|
842 | HRESULT hrc = S_OK;
|
---|
843 | if (aExtPack.isNotEmpty())
|
---|
844 | {
|
---|
845 | if (aExtPack.equals(VBOXVRDP_KLUDGE_EXTPACK_NAME))
|
---|
846 | hrc = S_OK;
|
---|
847 | else
|
---|
848 | #ifdef VBOX_WITH_EXTPACK
|
---|
849 | hrc = mParent->i_getExtPackManager()->i_checkVrdeExtPack(&aExtPack);
|
---|
850 | #else
|
---|
851 | hrc = setError(E_FAIL, tr("The extension pack '%s' does not exist"), aExtPack.c_str());
|
---|
852 | #endif
|
---|
853 | }
|
---|
854 | if (SUCCEEDED(hrc))
|
---|
855 | {
|
---|
856 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
857 | hrc = i_setDefaultVRDEExtPack(aExtPack);
|
---|
858 | if (SUCCEEDED(hrc))
|
---|
859 | {
|
---|
860 | /* VirtualBox::i_saveSettings() needs the VirtualBox write lock. */
|
---|
861 | alock.release();
|
---|
862 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
863 | hrc = mParent->i_saveSettings();
|
---|
864 | }
|
---|
865 | }
|
---|
866 |
|
---|
867 | return hrc;
|
---|
868 | }
|
---|
869 |
|
---|
870 |
|
---|
871 | HRESULT SystemProperties::getLogHistoryCount(ULONG *count)
|
---|
872 | {
|
---|
873 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
874 |
|
---|
875 | *count = m->ulLogHistoryCount;
|
---|
876 |
|
---|
877 | return S_OK;
|
---|
878 | }
|
---|
879 |
|
---|
880 |
|
---|
881 | HRESULT SystemProperties::setLogHistoryCount(ULONG count)
|
---|
882 | {
|
---|
883 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
884 | m->ulLogHistoryCount = count;
|
---|
885 | alock.release();
|
---|
886 |
|
---|
887 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
888 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
889 | HRESULT rc = mParent->i_saveSettings();
|
---|
890 |
|
---|
891 | return rc;
|
---|
892 | }
|
---|
893 |
|
---|
894 | HRESULT SystemProperties::getDefaultAudioDriver(AudioDriverType_T *aAudioDriver)
|
---|
895 | {
|
---|
896 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
897 |
|
---|
898 | *aAudioDriver = settings::MachineConfigFile::getHostDefaultAudioDriver();
|
---|
899 |
|
---|
900 | return S_OK;
|
---|
901 | }
|
---|
902 |
|
---|
903 | HRESULT SystemProperties::getAutostartDatabasePath(com::Utf8Str &aAutostartDbPath)
|
---|
904 | {
|
---|
905 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
906 |
|
---|
907 | aAutostartDbPath = m->strAutostartDatabasePath;
|
---|
908 |
|
---|
909 | return S_OK;
|
---|
910 | }
|
---|
911 |
|
---|
912 | HRESULT SystemProperties::setAutostartDatabasePath(const com::Utf8Str &aAutostartDbPath)
|
---|
913 | {
|
---|
914 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
915 | HRESULT rc = i_setAutostartDatabasePath(aAutostartDbPath);
|
---|
916 | alock.release();
|
---|
917 |
|
---|
918 | if (SUCCEEDED(rc))
|
---|
919 | {
|
---|
920 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
921 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
922 | rc = mParent->i_saveSettings();
|
---|
923 | }
|
---|
924 |
|
---|
925 | return rc;
|
---|
926 | }
|
---|
927 |
|
---|
928 | HRESULT SystemProperties::getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO)
|
---|
929 | {
|
---|
930 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
931 |
|
---|
932 | if (m->strDefaultAdditionsISO.isEmpty())
|
---|
933 | {
|
---|
934 | /* no guest additions, check if it showed up in the mean time */
|
---|
935 | alock.release();
|
---|
936 | {
|
---|
937 | AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS);
|
---|
938 | ErrorInfoKeeper eik;
|
---|
939 | (void)setDefaultAdditionsISO("");
|
---|
940 | }
|
---|
941 | alock.acquire();
|
---|
942 | }
|
---|
943 | aDefaultAdditionsISO = m->strDefaultAdditionsISO;
|
---|
944 |
|
---|
945 | return S_OK;
|
---|
946 | }
|
---|
947 |
|
---|
948 | HRESULT SystemProperties::setDefaultAdditionsISO(const com::Utf8Str &aDefaultAdditionsISO)
|
---|
949 | {
|
---|
950 | RT_NOREF(aDefaultAdditionsISO);
|
---|
951 | /** @todo not yet implemented, settings handling is missing */
|
---|
952 | ReturnComNotImplemented();
|
---|
953 | #if 0 /* not implemented */
|
---|
954 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
955 | HRESULT rc = i_setDefaultAdditionsISO(aDefaultAdditionsISO);
|
---|
956 | alock.release();
|
---|
957 |
|
---|
958 | if (SUCCEEDED(rc))
|
---|
959 | {
|
---|
960 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
961 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
962 | rc = mParent->i_saveSettings();
|
---|
963 | }
|
---|
964 |
|
---|
965 | return rc;
|
---|
966 | #endif
|
---|
967 | }
|
---|
968 |
|
---|
969 | HRESULT SystemProperties::getDefaultFrontend(com::Utf8Str &aDefaultFrontend)
|
---|
970 | {
|
---|
971 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
972 | aDefaultFrontend = m->strDefaultFrontend;
|
---|
973 | return S_OK;
|
---|
974 | }
|
---|
975 |
|
---|
976 | HRESULT SystemProperties::setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
|
---|
977 | {
|
---|
978 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
979 | if (m->strDefaultFrontend == Utf8Str(aDefaultFrontend))
|
---|
980 | return S_OK;
|
---|
981 | HRESULT rc = i_setDefaultFrontend(aDefaultFrontend);
|
---|
982 | alock.release();
|
---|
983 |
|
---|
984 | if (SUCCEEDED(rc))
|
---|
985 | {
|
---|
986 | // VirtualBox::i_saveSettings() needs vbox write lock
|
---|
987 | AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
|
---|
988 | rc = mParent->i_saveSettings();
|
---|
989 | }
|
---|
990 |
|
---|
991 | return rc;
|
---|
992 | }
|
---|
993 |
|
---|
994 | HRESULT SystemProperties::getScreenShotFormats(std::vector<BitmapFormat_T> &aBitmapFormats)
|
---|
995 | {
|
---|
996 | aBitmapFormats.push_back(BitmapFormat_BGR0);
|
---|
997 | aBitmapFormats.push_back(BitmapFormat_BGRA);
|
---|
998 | aBitmapFormats.push_back(BitmapFormat_RGBA);
|
---|
999 | aBitmapFormats.push_back(BitmapFormat_PNG);
|
---|
1000 | return S_OK;
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | // public methods only for internal purposes
|
---|
1004 | /////////////////////////////////////////////////////////////////////////////
|
---|
1005 |
|
---|
1006 | HRESULT SystemProperties::i_loadSettings(const settings::SystemProperties &data)
|
---|
1007 | {
|
---|
1008 | AutoCaller autoCaller(this);
|
---|
1009 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
1010 |
|
---|
1011 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1012 | HRESULT rc = S_OK;
|
---|
1013 | rc = i_setDefaultMachineFolder(data.strDefaultMachineFolder);
|
---|
1014 | if (FAILED(rc)) return rc;
|
---|
1015 |
|
---|
1016 | rc = i_setLoggingLevel(data.strLoggingLevel);
|
---|
1017 | if (FAILED(rc)) return rc;
|
---|
1018 |
|
---|
1019 | rc = i_setDefaultHardDiskFormat(data.strDefaultHardDiskFormat);
|
---|
1020 | if (FAILED(rc)) return rc;
|
---|
1021 |
|
---|
1022 | rc = i_setVRDEAuthLibrary(data.strVRDEAuthLibrary);
|
---|
1023 | if (FAILED(rc)) return rc;
|
---|
1024 |
|
---|
1025 | rc = i_setWebServiceAuthLibrary(data.strWebServiceAuthLibrary);
|
---|
1026 | if (FAILED(rc)) return rc;
|
---|
1027 |
|
---|
1028 | rc = i_setDefaultVRDEExtPack(data.strDefaultVRDEExtPack);
|
---|
1029 | if (FAILED(rc)) return rc;
|
---|
1030 |
|
---|
1031 | m->ulLogHistoryCount = data.ulLogHistoryCount;
|
---|
1032 | m->fExclusiveHwVirt = data.fExclusiveHwVirt;
|
---|
1033 |
|
---|
1034 | rc = i_setAutostartDatabasePath(data.strAutostartDatabasePath);
|
---|
1035 | if (FAILED(rc)) return rc;
|
---|
1036 |
|
---|
1037 | {
|
---|
1038 | /* must ignore errors signalled here, because the guest additions
|
---|
1039 | * file may not exist, and in this case keep the empty string */
|
---|
1040 | ErrorInfoKeeper eik;
|
---|
1041 | (void)i_setDefaultAdditionsISO(data.strDefaultAdditionsISO);
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | rc = i_setDefaultFrontend(data.strDefaultFrontend);
|
---|
1045 | if (FAILED(rc)) return rc;
|
---|
1046 |
|
---|
1047 | return S_OK;
|
---|
1048 | }
|
---|
1049 |
|
---|
1050 | HRESULT SystemProperties::i_saveSettings(settings::SystemProperties &data)
|
---|
1051 | {
|
---|
1052 | AutoCaller autoCaller(this);
|
---|
1053 | if (FAILED(autoCaller.rc())) return autoCaller.rc();
|
---|
1054 |
|
---|
1055 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1056 |
|
---|
1057 | data = *m;
|
---|
1058 |
|
---|
1059 | return S_OK;
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | /**
|
---|
1063 | * Returns a medium format object corresponding to the given format
|
---|
1064 | * identifier or null if no such format.
|
---|
1065 | *
|
---|
1066 | * @param aFormat Format identifier.
|
---|
1067 | *
|
---|
1068 | * @return ComObjPtr<MediumFormat>
|
---|
1069 | */
|
---|
1070 | ComObjPtr<MediumFormat> SystemProperties::i_mediumFormat(const Utf8Str &aFormat)
|
---|
1071 | {
|
---|
1072 | ComObjPtr<MediumFormat> format;
|
---|
1073 |
|
---|
1074 | AutoCaller autoCaller(this);
|
---|
1075 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
1076 |
|
---|
1077 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1078 |
|
---|
1079 | for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
|
---|
1080 | it != m_llMediumFormats.end();
|
---|
1081 | ++ it)
|
---|
1082 | {
|
---|
1083 | /* MediumFormat is all const, no need to lock */
|
---|
1084 |
|
---|
1085 | if ((*it)->i_getId().compare(aFormat, Utf8Str::CaseInsensitive) == 0)
|
---|
1086 | {
|
---|
1087 | format = *it;
|
---|
1088 | break;
|
---|
1089 | }
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | return format;
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | /**
|
---|
1096 | * Returns a medium format object corresponding to the given file extension or
|
---|
1097 | * null if no such format.
|
---|
1098 | *
|
---|
1099 | * @param aExt File extension.
|
---|
1100 | *
|
---|
1101 | * @return ComObjPtr<MediumFormat>
|
---|
1102 | */
|
---|
1103 | ComObjPtr<MediumFormat> SystemProperties::i_mediumFormatFromExtension(const Utf8Str &aExt)
|
---|
1104 | {
|
---|
1105 | ComObjPtr<MediumFormat> format;
|
---|
1106 |
|
---|
1107 | AutoCaller autoCaller(this);
|
---|
1108 | AssertComRCReturn (autoCaller.rc(), format);
|
---|
1109 |
|
---|
1110 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1111 |
|
---|
1112 | bool fFound = false;
|
---|
1113 | for (MediumFormatList::const_iterator it = m_llMediumFormats.begin();
|
---|
1114 | it != m_llMediumFormats.end() && !fFound;
|
---|
1115 | ++it)
|
---|
1116 | {
|
---|
1117 | /* MediumFormat is all const, no need to lock */
|
---|
1118 | MediumFormat::StrArray aFileList = (*it)->i_getFileExtensions();
|
---|
1119 | for (MediumFormat::StrArray::const_iterator it1 = aFileList.begin();
|
---|
1120 | it1 != aFileList.end();
|
---|
1121 | ++it1)
|
---|
1122 | {
|
---|
1123 | if ((*it1).compare(aExt, Utf8Str::CaseInsensitive) == 0)
|
---|
1124 | {
|
---|
1125 | format = *it;
|
---|
1126 | fFound = true;
|
---|
1127 | break;
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | return format;
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 |
|
---|
1136 | /**
|
---|
1137 | * VD plugin load
|
---|
1138 | */
|
---|
1139 | int SystemProperties::i_loadVDPlugin(const char *pszPluginLibrary)
|
---|
1140 | {
|
---|
1141 | return VDPluginLoadFromFilename(pszPluginLibrary);
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | /**
|
---|
1145 | * VD plugin unload
|
---|
1146 | */
|
---|
1147 | int SystemProperties::i_unloadVDPlugin(const char *pszPluginLibrary)
|
---|
1148 | {
|
---|
1149 | return VDPluginUnloadFromFilename(pszPluginLibrary);
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 | // private methods
|
---|
1153 | /////////////////////////////////////////////////////////////////////////////
|
---|
1154 |
|
---|
1155 | /**
|
---|
1156 | * Returns the user's home directory. Wrapper around RTPathUserHome().
|
---|
1157 | * @param strPath
|
---|
1158 | * @return
|
---|
1159 | */
|
---|
1160 | HRESULT SystemProperties::i_getUserHomeDirectory(Utf8Str &strPath)
|
---|
1161 | {
|
---|
1162 | char szHome[RTPATH_MAX];
|
---|
1163 | int vrc = RTPathUserHome(szHome, sizeof(szHome));
|
---|
1164 | if (RT_FAILURE(vrc))
|
---|
1165 | return setError(E_FAIL,
|
---|
1166 | tr("Cannot determine user home directory (%Rrc)"),
|
---|
1167 | vrc);
|
---|
1168 | strPath = szHome;
|
---|
1169 | return S_OK;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | /**
|
---|
1173 | * Internal implementation to set the default machine folder. Gets called
|
---|
1174 | * from the public attribute setter as well as loadSettings(). With 4.0,
|
---|
1175 | * the "default default" machine folder has changed, and we now require
|
---|
1176 | * a full path always.
|
---|
1177 | * @param aPath
|
---|
1178 | * @return
|
---|
1179 | */
|
---|
1180 | HRESULT SystemProperties::i_setDefaultMachineFolder(const Utf8Str &strPath)
|
---|
1181 | {
|
---|
1182 | Utf8Str path(strPath); // make modifiable
|
---|
1183 | if ( path.isEmpty() // used by API calls to reset the default
|
---|
1184 | || path == "Machines" // this value (exactly like this, without path) is stored
|
---|
1185 | // in VirtualBox.xml if user upgrades from before 4.0 and
|
---|
1186 | // has not changed the default machine folder
|
---|
1187 | )
|
---|
1188 | {
|
---|
1189 | // new default with VirtualBox 4.0: "$HOME/VirtualBox VMs"
|
---|
1190 | HRESULT rc = i_getUserHomeDirectory(path);
|
---|
1191 | if (FAILED(rc)) return rc;
|
---|
1192 | path += RTPATH_SLASH_STR "VirtualBox VMs";
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | if (!RTPathStartsWithRoot(path.c_str()))
|
---|
1196 | return setError(E_INVALIDARG,
|
---|
1197 | tr("Given default machine folder '%s' is not fully qualified"),
|
---|
1198 | path.c_str());
|
---|
1199 |
|
---|
1200 | m->strDefaultMachineFolder = path;
|
---|
1201 |
|
---|
1202 | return S_OK;
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | HRESULT SystemProperties::i_setLoggingLevel(const com::Utf8Str &aLoggingLevel)
|
---|
1206 | {
|
---|
1207 | Utf8Str useLoggingLevel(aLoggingLevel);
|
---|
1208 | if (useLoggingLevel.isEmpty())
|
---|
1209 | useLoggingLevel = VBOXSVC_LOG_DEFAULT;
|
---|
1210 | int rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), useLoggingLevel.c_str());
|
---|
1211 | // If failed and not the default logging level - try to use the default logging level.
|
---|
1212 | if (RT_FAILURE(rc))
|
---|
1213 | {
|
---|
1214 | // If failed write message to the release log.
|
---|
1215 | LogRel(("Cannot set passed logging level=%s Error=%Rrc \n", useLoggingLevel.c_str(), rc));
|
---|
1216 | // If attempted logging level not the default one then try the default one.
|
---|
1217 | if (!useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT))
|
---|
1218 | {
|
---|
1219 | rc = RTLogGroupSettings(RTLogRelGetDefaultInstance(), VBOXSVC_LOG_DEFAULT);
|
---|
1220 | // If failed report this to the release log.
|
---|
1221 | if (RT_FAILURE(rc))
|
---|
1222 | LogRel(("Cannot set default logging level Error=%Rrc \n", rc));
|
---|
1223 | }
|
---|
1224 | // On any failure - set default level as the one to be stored.
|
---|
1225 | useLoggingLevel = VBOXSVC_LOG_DEFAULT;
|
---|
1226 | }
|
---|
1227 | // Set to passed value or if default used/attempted (even if error condition) use empty string.
|
---|
1228 | m->strLoggingLevel = (useLoggingLevel.equals(VBOXSVC_LOG_DEFAULT) ? "" : useLoggingLevel);
|
---|
1229 | return RT_SUCCESS(rc) ? S_OK : E_FAIL;
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | HRESULT SystemProperties::i_setDefaultHardDiskFormat(const com::Utf8Str &aFormat)
|
---|
1233 | {
|
---|
1234 | if (!aFormat.isEmpty())
|
---|
1235 | m->strDefaultHardDiskFormat = aFormat;
|
---|
1236 | else
|
---|
1237 | m->strDefaultHardDiskFormat = "VDI";
|
---|
1238 |
|
---|
1239 | return S_OK;
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | HRESULT SystemProperties::i_setVRDEAuthLibrary(const com::Utf8Str &aPath)
|
---|
1243 | {
|
---|
1244 | if (!aPath.isEmpty())
|
---|
1245 | m->strVRDEAuthLibrary = aPath;
|
---|
1246 | else
|
---|
1247 | m->strVRDEAuthLibrary = "VBoxAuth";
|
---|
1248 |
|
---|
1249 | return S_OK;
|
---|
1250 | }
|
---|
1251 |
|
---|
1252 | HRESULT SystemProperties::i_setWebServiceAuthLibrary(const com::Utf8Str &aPath)
|
---|
1253 | {
|
---|
1254 | if (!aPath.isEmpty())
|
---|
1255 | m->strWebServiceAuthLibrary = aPath;
|
---|
1256 | else
|
---|
1257 | m->strWebServiceAuthLibrary = "VBoxAuth";
|
---|
1258 |
|
---|
1259 | return S_OK;
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | HRESULT SystemProperties::i_setDefaultVRDEExtPack(const com::Utf8Str &aExtPack)
|
---|
1263 | {
|
---|
1264 | m->strDefaultVRDEExtPack = aExtPack;
|
---|
1265 |
|
---|
1266 | return S_OK;
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | HRESULT SystemProperties::i_setAutostartDatabasePath(const com::Utf8Str &aPath)
|
---|
1270 | {
|
---|
1271 | HRESULT rc = S_OK;
|
---|
1272 | AutostartDb *autostartDb = this->mParent->i_getAutostartDb();
|
---|
1273 |
|
---|
1274 | if (!aPath.isEmpty())
|
---|
1275 | {
|
---|
1276 | /* Update path in the autostart database. */
|
---|
1277 | int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
|
---|
1278 | if (RT_SUCCESS(vrc))
|
---|
1279 | m->strAutostartDatabasePath = aPath;
|
---|
1280 | else
|
---|
1281 | rc = setError(E_FAIL,
|
---|
1282 | tr("Cannot set the autostart database path (%Rrc)"),
|
---|
1283 | vrc);
|
---|
1284 | }
|
---|
1285 | else
|
---|
1286 | {
|
---|
1287 | int vrc = autostartDb->setAutostartDbPath(NULL);
|
---|
1288 | if (RT_SUCCESS(vrc) || vrc == VERR_NOT_SUPPORTED)
|
---|
1289 | m->strAutostartDatabasePath = "";
|
---|
1290 | else
|
---|
1291 | rc = setError(E_FAIL,
|
---|
1292 | tr("Deleting the autostart database path failed (%Rrc)"),
|
---|
1293 | vrc);
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | return rc;
|
---|
1297 | }
|
---|
1298 |
|
---|
1299 | HRESULT SystemProperties::i_setDefaultAdditionsISO(const com::Utf8Str &aPath)
|
---|
1300 | {
|
---|
1301 | com::Utf8Str path(aPath);
|
---|
1302 | if (path.isEmpty())
|
---|
1303 | {
|
---|
1304 | char strTemp[RTPATH_MAX];
|
---|
1305 | int vrc = RTPathAppPrivateNoArch(strTemp, sizeof(strTemp));
|
---|
1306 | AssertRC(vrc);
|
---|
1307 | Utf8Str strSrc1 = Utf8Str(strTemp).append("/VBoxGuestAdditions.iso");
|
---|
1308 |
|
---|
1309 | vrc = RTPathExecDir(strTemp, sizeof(strTemp));
|
---|
1310 | AssertRC(vrc);
|
---|
1311 | Utf8Str strSrc2 = Utf8Str(strTemp).append("/additions/VBoxGuestAdditions.iso");
|
---|
1312 |
|
---|
1313 | vrc = RTPathUserHome(strTemp, sizeof(strTemp));
|
---|
1314 | AssertRC(vrc);
|
---|
1315 | Utf8Str strSrc3 = Utf8StrFmt("%s/VBoxGuestAdditions_%s.iso", strTemp, VirtualBox::i_getVersionNormalized().c_str());
|
---|
1316 |
|
---|
1317 | /* Check the standard image locations */
|
---|
1318 | if (RTFileExists(strSrc1.c_str()))
|
---|
1319 | path = strSrc1;
|
---|
1320 | else if (RTFileExists(strSrc2.c_str()))
|
---|
1321 | path = strSrc2;
|
---|
1322 | else if (RTFileExists(strSrc3.c_str()))
|
---|
1323 | path = strSrc3;
|
---|
1324 | else
|
---|
1325 | return setError(E_FAIL,
|
---|
1326 | tr("Cannot determine default Guest Additions ISO location. Most likely they are not available"));
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | if (!RTPathStartsWithRoot(path.c_str()))
|
---|
1330 | return setError(E_INVALIDARG,
|
---|
1331 | tr("Given default machine Guest Additions ISO file '%s' is not fully qualified"),
|
---|
1332 | path.c_str());
|
---|
1333 |
|
---|
1334 | if (!RTFileExists(path.c_str()))
|
---|
1335 | return setError(E_INVALIDARG,
|
---|
1336 | tr("Given default machine Guest Additions ISO file '%s' does not exist"),
|
---|
1337 | path.c_str());
|
---|
1338 |
|
---|
1339 | m->strDefaultAdditionsISO = path;
|
---|
1340 |
|
---|
1341 | return S_OK;
|
---|
1342 | }
|
---|
1343 |
|
---|
1344 | HRESULT SystemProperties::i_setDefaultFrontend(const com::Utf8Str &aDefaultFrontend)
|
---|
1345 | {
|
---|
1346 | m->strDefaultFrontend = aDefaultFrontend;
|
---|
1347 |
|
---|
1348 | return S_OK;
|
---|
1349 | }
|
---|