1 | /* $Id: BIOSSettingsImpl.cpp 76592 2019-01-01 20:13:07Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation - Machine BIOS settings.
|
---|
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_BIOSSETTINGS
|
---|
19 | #include "BIOSSettingsImpl.h"
|
---|
20 | #include "MachineImpl.h"
|
---|
21 | #include "GuestOSTypeImpl.h"
|
---|
22 |
|
---|
23 | #include <iprt/cpp/utils.h>
|
---|
24 | #include <VBox/settings.h>
|
---|
25 |
|
---|
26 | #include "AutoStateDep.h"
|
---|
27 | #include "AutoCaller.h"
|
---|
28 | #include "LoggingNew.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | ////////////////////////////////////////////////////////////////////////////////
|
---|
32 | //
|
---|
33 | // BIOSSettings private data definition
|
---|
34 | //
|
---|
35 | ////////////////////////////////////////////////////////////////////////////////
|
---|
36 |
|
---|
37 | struct BIOSSettings::Data
|
---|
38 | {
|
---|
39 | Data()
|
---|
40 | : pMachine(NULL)
|
---|
41 | { }
|
---|
42 |
|
---|
43 | Machine * const pMachine;
|
---|
44 | ComObjPtr<BIOSSettings> pPeer;
|
---|
45 |
|
---|
46 | // use the XML settings structure in the members for simplicity
|
---|
47 | Backupable<settings::BIOSSettings> bd;
|
---|
48 | };
|
---|
49 |
|
---|
50 | // constructor / destructor
|
---|
51 | /////////////////////////////////////////////////////////////////////////////
|
---|
52 |
|
---|
53 | DEFINE_EMPTY_CTOR_DTOR(BIOSSettings)
|
---|
54 |
|
---|
55 | HRESULT BIOSSettings::FinalConstruct()
|
---|
56 | {
|
---|
57 | return BaseFinalConstruct();
|
---|
58 | }
|
---|
59 |
|
---|
60 | void BIOSSettings::FinalRelease()
|
---|
61 | {
|
---|
62 | uninit();
|
---|
63 | BaseFinalRelease();
|
---|
64 | }
|
---|
65 |
|
---|
66 | // public initializer/uninitializer for internal purposes only
|
---|
67 | /////////////////////////////////////////////////////////////////////////////
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * Initializes the BIOS settings object.
|
---|
71 | *
|
---|
72 | * @returns COM result indicator
|
---|
73 | */
|
---|
74 | HRESULT BIOSSettings::init(Machine *aParent)
|
---|
75 | {
|
---|
76 | LogFlowThisFuncEnter();
|
---|
77 | LogFlowThisFunc(("aParent: %p\n", aParent));
|
---|
78 |
|
---|
79 | ComAssertRet(aParent, E_INVALIDARG);
|
---|
80 |
|
---|
81 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
82 | AutoInitSpan autoInitSpan(this);
|
---|
83 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
84 |
|
---|
85 | m = new Data();
|
---|
86 |
|
---|
87 | /* share the parent weakly */
|
---|
88 | unconst(m->pMachine) = aParent;
|
---|
89 |
|
---|
90 | m->bd.allocate();
|
---|
91 |
|
---|
92 | autoInitSpan.setSucceeded();
|
---|
93 |
|
---|
94 | LogFlowThisFuncLeave();
|
---|
95 | return S_OK;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Initializes the BIOS settings object given another BIOS settings object
|
---|
100 | * (a kind of copy constructor). This object shares data with
|
---|
101 | * the object passed as an argument.
|
---|
102 | *
|
---|
103 | * @note This object must be destroyed before the original object
|
---|
104 | * it shares data with is destroyed.
|
---|
105 | */
|
---|
106 | HRESULT BIOSSettings::init(Machine *aParent, BIOSSettings *that)
|
---|
107 | {
|
---|
108 | LogFlowThisFuncEnter();
|
---|
109 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
110 |
|
---|
111 | ComAssertRet(aParent && that, E_INVALIDARG);
|
---|
112 |
|
---|
113 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
114 | AutoInitSpan autoInitSpan(this);
|
---|
115 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
116 |
|
---|
117 | m = new Data();
|
---|
118 |
|
---|
119 | unconst(m->pMachine) = aParent;
|
---|
120 | m->pPeer = that;
|
---|
121 |
|
---|
122 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
123 | m->bd.share(that->m->bd);
|
---|
124 |
|
---|
125 | autoInitSpan.setSucceeded();
|
---|
126 |
|
---|
127 | LogFlowThisFuncLeave();
|
---|
128 | return S_OK;
|
---|
129 | }
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * Initializes the guest object given another guest object
|
---|
133 | * (a kind of copy constructor). This object makes a private copy of data
|
---|
134 | * of the original object passed as an argument.
|
---|
135 | */
|
---|
136 | HRESULT BIOSSettings::initCopy(Machine *aParent, BIOSSettings *that)
|
---|
137 | {
|
---|
138 | LogFlowThisFuncEnter();
|
---|
139 | LogFlowThisFunc(("aParent: %p, that: %p\n", aParent, that));
|
---|
140 |
|
---|
141 | ComAssertRet(aParent && that, E_INVALIDARG);
|
---|
142 |
|
---|
143 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
144 | AutoInitSpan autoInitSpan(this);
|
---|
145 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
146 |
|
---|
147 | m = new Data();
|
---|
148 |
|
---|
149 | unconst(m->pMachine) = aParent;
|
---|
150 | // mPeer is left null
|
---|
151 |
|
---|
152 | AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS);
|
---|
153 | m->bd.attachCopy(that->m->bd);
|
---|
154 |
|
---|
155 | autoInitSpan.setSucceeded();
|
---|
156 |
|
---|
157 | LogFlowThisFuncLeave();
|
---|
158 | return S_OK;
|
---|
159 | }
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
163 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
164 | */
|
---|
165 | void BIOSSettings::uninit()
|
---|
166 | {
|
---|
167 | LogFlowThisFuncEnter();
|
---|
168 |
|
---|
169 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
170 | AutoUninitSpan autoUninitSpan(this);
|
---|
171 | if (autoUninitSpan.uninitDone())
|
---|
172 | return;
|
---|
173 |
|
---|
174 | m->bd.free();
|
---|
175 |
|
---|
176 | unconst(m->pPeer) = NULL;
|
---|
177 | unconst(m->pMachine) = NULL;
|
---|
178 |
|
---|
179 | delete m;
|
---|
180 | m = NULL;
|
---|
181 |
|
---|
182 | LogFlowThisFuncLeave();
|
---|
183 | }
|
---|
184 |
|
---|
185 | // IBIOSSettings properties
|
---|
186 | /////////////////////////////////////////////////////////////////////////////
|
---|
187 |
|
---|
188 |
|
---|
189 | HRESULT BIOSSettings::getLogoFadeIn(BOOL *enabled)
|
---|
190 | {
|
---|
191 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
192 |
|
---|
193 | *enabled = m->bd->fLogoFadeIn;
|
---|
194 |
|
---|
195 | return S_OK;
|
---|
196 | }
|
---|
197 |
|
---|
198 | HRESULT BIOSSettings::setLogoFadeIn(BOOL enable)
|
---|
199 | {
|
---|
200 | /* the machine needs to be mutable */
|
---|
201 | AutoMutableStateDependency adep(m->pMachine);
|
---|
202 | if (FAILED(adep.rc())) return adep.rc();
|
---|
203 |
|
---|
204 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
205 |
|
---|
206 | m->bd.backup();
|
---|
207 | m->bd->fLogoFadeIn = RT_BOOL(enable);
|
---|
208 |
|
---|
209 | alock.release();
|
---|
210 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
211 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
212 |
|
---|
213 | return S_OK;
|
---|
214 | }
|
---|
215 |
|
---|
216 |
|
---|
217 | HRESULT BIOSSettings::getLogoFadeOut(BOOL *enabled)
|
---|
218 | {
|
---|
219 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
220 |
|
---|
221 | *enabled = m->bd->fLogoFadeOut;
|
---|
222 |
|
---|
223 | return S_OK;
|
---|
224 | }
|
---|
225 |
|
---|
226 |
|
---|
227 | HRESULT BIOSSettings::setLogoFadeOut(BOOL enable)
|
---|
228 | {
|
---|
229 | /* the machine needs to be mutable */
|
---|
230 | AutoMutableStateDependency adep(m->pMachine);
|
---|
231 | if (FAILED(adep.rc())) return adep.rc();
|
---|
232 |
|
---|
233 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
234 |
|
---|
235 | m->bd.backup();
|
---|
236 | m->bd->fLogoFadeOut = RT_BOOL(enable);
|
---|
237 |
|
---|
238 | alock.release();
|
---|
239 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
240 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
241 |
|
---|
242 | return S_OK;
|
---|
243 | }
|
---|
244 |
|
---|
245 |
|
---|
246 | HRESULT BIOSSettings::getLogoDisplayTime(ULONG *displayTime)
|
---|
247 | {
|
---|
248 | if (!displayTime)
|
---|
249 | return E_POINTER;
|
---|
250 |
|
---|
251 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
252 |
|
---|
253 | *displayTime = m->bd->ulLogoDisplayTime;
|
---|
254 |
|
---|
255 | return S_OK;
|
---|
256 | }
|
---|
257 |
|
---|
258 |
|
---|
259 | HRESULT BIOSSettings::setLogoDisplayTime(ULONG displayTime)
|
---|
260 | {
|
---|
261 | /* the machine needs to be mutable */
|
---|
262 | AutoMutableStateDependency adep(m->pMachine);
|
---|
263 | if (FAILED(adep.rc())) return adep.rc();
|
---|
264 |
|
---|
265 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
266 |
|
---|
267 | m->bd.backup();
|
---|
268 | m->bd->ulLogoDisplayTime = displayTime;
|
---|
269 |
|
---|
270 | alock.release();
|
---|
271 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
272 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
273 |
|
---|
274 | return S_OK;
|
---|
275 | }
|
---|
276 |
|
---|
277 |
|
---|
278 | HRESULT BIOSSettings::getLogoImagePath(com::Utf8Str &imagePath)
|
---|
279 | {
|
---|
280 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
281 |
|
---|
282 | imagePath = m->bd->strLogoImagePath;
|
---|
283 | return S_OK;
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | HRESULT BIOSSettings::setLogoImagePath(const com::Utf8Str &imagePath)
|
---|
288 | {
|
---|
289 | /* the machine needs to be mutable */
|
---|
290 | AutoMutableStateDependency adep(m->pMachine);
|
---|
291 | if (FAILED(adep.rc())) return adep.rc();
|
---|
292 |
|
---|
293 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
294 |
|
---|
295 | m->bd.backup();
|
---|
296 | m->bd->strLogoImagePath = imagePath;
|
---|
297 |
|
---|
298 | alock.release();
|
---|
299 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
300 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
301 |
|
---|
302 | return S_OK;
|
---|
303 | }
|
---|
304 |
|
---|
305 | HRESULT BIOSSettings::getBootMenuMode(BIOSBootMenuMode_T *bootMenuMode)
|
---|
306 | {
|
---|
307 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
308 |
|
---|
309 | *bootMenuMode = m->bd->biosBootMenuMode;
|
---|
310 | return S_OK;
|
---|
311 | }
|
---|
312 |
|
---|
313 |
|
---|
314 | HRESULT BIOSSettings::setBootMenuMode(BIOSBootMenuMode_T bootMenuMode)
|
---|
315 | {
|
---|
316 | /* the machine needs to be mutable */
|
---|
317 | AutoMutableStateDependency adep(m->pMachine);
|
---|
318 | if (FAILED(adep.rc())) return adep.rc();
|
---|
319 |
|
---|
320 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
321 |
|
---|
322 | m->bd.backup();
|
---|
323 | m->bd->biosBootMenuMode = bootMenuMode;
|
---|
324 |
|
---|
325 | alock.release();
|
---|
326 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
327 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
328 |
|
---|
329 | return S_OK;
|
---|
330 | }
|
---|
331 |
|
---|
332 |
|
---|
333 | HRESULT BIOSSettings::getACPIEnabled(BOOL *enabled)
|
---|
334 | {
|
---|
335 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
336 |
|
---|
337 | *enabled = m->bd->fACPIEnabled;
|
---|
338 |
|
---|
339 | return S_OK;
|
---|
340 | }
|
---|
341 |
|
---|
342 |
|
---|
343 | HRESULT BIOSSettings::setACPIEnabled(BOOL enable)
|
---|
344 | {
|
---|
345 | /* the machine needs to be mutable */
|
---|
346 | AutoMutableStateDependency adep(m->pMachine);
|
---|
347 | if (FAILED(adep.rc())) return adep.rc();
|
---|
348 |
|
---|
349 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
350 |
|
---|
351 | m->bd.backup();
|
---|
352 | m->bd->fACPIEnabled = RT_BOOL(enable);
|
---|
353 |
|
---|
354 | alock.release();
|
---|
355 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
356 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
357 |
|
---|
358 | return S_OK;
|
---|
359 | }
|
---|
360 |
|
---|
361 |
|
---|
362 | HRESULT BIOSSettings::getIOAPICEnabled(BOOL *aIOAPICEnabled)
|
---|
363 | {
|
---|
364 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
365 |
|
---|
366 | *aIOAPICEnabled = m->bd->fIOAPICEnabled;
|
---|
367 |
|
---|
368 | return S_OK;
|
---|
369 | }
|
---|
370 |
|
---|
371 |
|
---|
372 | HRESULT BIOSSettings::setIOAPICEnabled(BOOL aIOAPICEnabled)
|
---|
373 | {
|
---|
374 | /* the machine needs to be mutable */
|
---|
375 | AutoMutableStateDependency adep(m->pMachine);
|
---|
376 | if (FAILED(adep.rc())) return adep.rc();
|
---|
377 |
|
---|
378 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
379 |
|
---|
380 | m->bd.backup();
|
---|
381 |
|
---|
382 | m->bd->fIOAPICEnabled = RT_BOOL(aIOAPICEnabled);
|
---|
383 | alock.release();
|
---|
384 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
385 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
386 |
|
---|
387 | return S_OK;
|
---|
388 | }
|
---|
389 |
|
---|
390 |
|
---|
391 | HRESULT BIOSSettings::getAPICMode(APICMode_T *aAPICMode)
|
---|
392 | {
|
---|
393 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
394 |
|
---|
395 | *aAPICMode = m->bd->apicMode;
|
---|
396 |
|
---|
397 | return S_OK;
|
---|
398 | }
|
---|
399 |
|
---|
400 |
|
---|
401 | HRESULT BIOSSettings::setAPICMode(APICMode_T aAPICMode)
|
---|
402 | {
|
---|
403 | /* the machine needs to be mutable */
|
---|
404 | AutoMutableStateDependency adep(m->pMachine);
|
---|
405 | if (FAILED(adep.rc())) return adep.rc();
|
---|
406 |
|
---|
407 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
408 |
|
---|
409 | m->bd.backup();
|
---|
410 |
|
---|
411 | m->bd->apicMode = aAPICMode;
|
---|
412 | alock.release();
|
---|
413 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
414 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
415 |
|
---|
416 | return S_OK;
|
---|
417 | }
|
---|
418 |
|
---|
419 |
|
---|
420 | HRESULT BIOSSettings::getPXEDebugEnabled(BOOL *enabled)
|
---|
421 | {
|
---|
422 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
423 |
|
---|
424 | *enabled = m->bd->fPXEDebugEnabled;
|
---|
425 |
|
---|
426 | return S_OK;
|
---|
427 | }
|
---|
428 |
|
---|
429 |
|
---|
430 | HRESULT BIOSSettings::setPXEDebugEnabled(BOOL enable)
|
---|
431 | {
|
---|
432 | /* the machine needs to be mutable */
|
---|
433 | AutoMutableStateDependency adep(m->pMachine);
|
---|
434 | if (FAILED(adep.rc())) return adep.rc();
|
---|
435 |
|
---|
436 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
437 |
|
---|
438 | m->bd.backup();
|
---|
439 | m->bd->fPXEDebugEnabled = RT_BOOL(enable);
|
---|
440 |
|
---|
441 | alock.release();
|
---|
442 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
443 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
444 |
|
---|
445 | return S_OK;
|
---|
446 | }
|
---|
447 |
|
---|
448 | HRESULT BIOSSettings::getTimeOffset(LONG64 *offset)
|
---|
449 | {
|
---|
450 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
451 |
|
---|
452 | *offset = m->bd->llTimeOffset;
|
---|
453 |
|
---|
454 | return S_OK;
|
---|
455 | }
|
---|
456 |
|
---|
457 |
|
---|
458 | HRESULT BIOSSettings::setTimeOffset(LONG64 offset)
|
---|
459 | {
|
---|
460 | /* the machine needs to be mutable */
|
---|
461 | AutoMutableStateDependency adep(m->pMachine);
|
---|
462 | if (FAILED(adep.rc())) return adep.rc();
|
---|
463 |
|
---|
464 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
465 |
|
---|
466 | m->bd.backup();
|
---|
467 | m->bd->llTimeOffset = offset;
|
---|
468 |
|
---|
469 | alock.release();
|
---|
470 | AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); // mParent is const, needs no locking
|
---|
471 | m->pMachine->i_setModified(Machine::IsModified_BIOS);
|
---|
472 |
|
---|
473 | return S_OK;
|
---|
474 | }
|
---|
475 |
|
---|
476 | HRESULT BIOSSettings::getNonVolatileStorageFile(com::Utf8Str &aNonVolatileStorageFile)
|
---|
477 | {
|
---|
478 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
479 |
|
---|
480 | aNonVolatileStorageFile = "";
|
---|
481 |
|
---|
482 | return S_OK;
|
---|
483 | }
|
---|
484 |
|
---|
485 |
|
---|
486 |
|
---|
487 | // IBIOSSettings methods
|
---|
488 | /////////////////////////////////////////////////////////////////////////////
|
---|
489 |
|
---|
490 | // public methods only for internal purposes
|
---|
491 | /////////////////////////////////////////////////////////////////////////////
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Loads settings from the given machine node.
|
---|
495 | * May be called once right after this object creation.
|
---|
496 | *
|
---|
497 | * @param data Configuration settings.
|
---|
498 | *
|
---|
499 | * @note Locks this object for writing.
|
---|
500 | */
|
---|
501 | HRESULT BIOSSettings::i_loadSettings(const settings::BIOSSettings &data)
|
---|
502 | {
|
---|
503 | AutoCaller autoCaller(this);
|
---|
504 | AssertComRCReturnRC(autoCaller.rc());
|
---|
505 |
|
---|
506 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
507 |
|
---|
508 | // simply copy
|
---|
509 | m->bd.assignCopy(&data);
|
---|
510 |
|
---|
511 | return S_OK;
|
---|
512 | }
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Saves settings to the given machine node.
|
---|
516 | *
|
---|
517 | * @param data Configuration settings.
|
---|
518 | *
|
---|
519 | * @note Locks this object for reading.
|
---|
520 | */
|
---|
521 | HRESULT BIOSSettings::i_saveSettings(settings::BIOSSettings &data)
|
---|
522 | {
|
---|
523 | AutoCaller autoCaller(this);
|
---|
524 | AssertComRCReturnRC(autoCaller.rc());
|
---|
525 |
|
---|
526 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
527 |
|
---|
528 | data = *m->bd.data();
|
---|
529 |
|
---|
530 | return S_OK;
|
---|
531 | }
|
---|
532 |
|
---|
533 | void BIOSSettings::i_rollback()
|
---|
534 | {
|
---|
535 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
536 | m->bd.rollback();
|
---|
537 | }
|
---|
538 |
|
---|
539 | void BIOSSettings::i_commit()
|
---|
540 | {
|
---|
541 | /* sanity */
|
---|
542 | AutoCaller autoCaller(this);
|
---|
543 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
544 |
|
---|
545 | /* sanity too */
|
---|
546 | AutoCaller peerCaller(m->pPeer);
|
---|
547 | AssertComRCReturnVoid(peerCaller.rc());
|
---|
548 |
|
---|
549 | /* lock both for writing since we modify both (mPeer is "master" so locked
|
---|
550 | * first) */
|
---|
551 | AutoMultiWriteLock2 alock(m->pPeer, this COMMA_LOCKVAL_SRC_POS);
|
---|
552 |
|
---|
553 | if (m->bd.isBackedUp())
|
---|
554 | {
|
---|
555 | m->bd.commit();
|
---|
556 | if (m->pPeer)
|
---|
557 | {
|
---|
558 | /* attach new data to the peer and reshare it */
|
---|
559 | AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS);
|
---|
560 | m->pPeer->m->bd.attach(m->bd);
|
---|
561 | }
|
---|
562 | }
|
---|
563 | }
|
---|
564 |
|
---|
565 | void BIOSSettings::i_copyFrom(BIOSSettings *aThat)
|
---|
566 | {
|
---|
567 | AssertReturnVoid(aThat != NULL);
|
---|
568 |
|
---|
569 | /* sanity */
|
---|
570 | AutoCaller autoCaller(this);
|
---|
571 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
572 |
|
---|
573 | /* sanity too */
|
---|
574 | AutoCaller thatCaller(aThat);
|
---|
575 | AssertComRCReturnVoid(thatCaller.rc());
|
---|
576 |
|
---|
577 | /* peer is not modified, lock it for reading (aThat is "master" so locked
|
---|
578 | * first) */
|
---|
579 | AutoReadLock rl(aThat COMMA_LOCKVAL_SRC_POS);
|
---|
580 | AutoWriteLock wl(this COMMA_LOCKVAL_SRC_POS);
|
---|
581 |
|
---|
582 | /* this will back up current data */
|
---|
583 | m->bd.assignCopy(aThat->m->bd);
|
---|
584 | }
|
---|
585 |
|
---|
586 | void BIOSSettings::i_applyDefaults(GuestOSType *aOsType)
|
---|
587 | {
|
---|
588 | /* sanity */
|
---|
589 | AutoCaller autoCaller(this);
|
---|
590 | AssertComRCReturnVoid(autoCaller.rc());
|
---|
591 |
|
---|
592 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
593 |
|
---|
594 | /* Initialize default BIOS settings here */
|
---|
595 | if (aOsType)
|
---|
596 | m->bd->fIOAPICEnabled = aOsType->i_recommendedIOAPIC();
|
---|
597 | else
|
---|
598 | m->bd->fIOAPICEnabled = true;
|
---|
599 | }
|
---|
600 |
|
---|
601 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|