- Timestamp:
- Jun 26, 2012 9:17:43 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r41842 r41914 947 947 }; 948 948 949 /** 950 * Settings that has to do with autostart. 951 */ 952 struct Autostart 953 { 954 Autostart() 955 : fAutostartEnabled(false), 956 uAutostartDelay(0), 957 enmAutostopType(AutostopType_Disabled) 958 { } 959 960 bool operator==(const Autostart &rOther) const 961 { 962 return fAutostartEnabled == rOther.fAutostartEnabled 963 && uAutostartDelay == rOther.uAutostartDelay 964 && enmAutostopType == rOther.enmAutostopType; 965 } 966 967 bool areDefaultSettings() const 968 { 969 return !fAutostartEnabled 970 && !uAutostartDelay 971 && enmAutostopType == AutostopType_Disabled; 972 } 973 974 bool fAutostartEnabled; 975 uint32_t uAutostartDelay; 976 AutostopType_T enmAutostopType; 977 }; 978 949 979 struct Snapshot; 950 980 typedef std::list<Snapshot> SnapshotsList; … … 970 1000 971 1001 Debugging debugging; 1002 Autostart autostart; 972 1003 973 1004 SnapshotsList llChildSnapshots; … … 1048 1079 MediaRegistry mediaRegistry; 1049 1080 Debugging debugging; 1081 Autostart autostart; 1050 1082 1051 1083 StringsMap mapExtraDataItems; … … 1093 1125 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg); 1094 1126 void readTeleporter(const xml::ElementNode *pElmTeleporter, MachineUserData *pUserData); 1095 void readDebugging(const xml::ElementNode *pElmTeleporter, Debugging *pDbg); 1127 void readDebugging(const xml::ElementNode *pElmDbg, Debugging *pDbg); 1128 void readAutostart(const xml::ElementNode *pElmAutostart, Autostart *pAutostart); 1096 1129 void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap); 1097 1130 void convertOldOSType_pre1_5(com::Utf8Str &str); … … 1105 1138 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes); 1106 1139 void buildDebuggingXML(xml::ElementNode *pElmParent, const Debugging *pDbg); 1140 void buildAutostartXML(xml::ElementNode *pElmParent, const Autostart *pAutostart); 1107 1141 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap); 1108 1142 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r41888 r41914 3667 3667 </enum> 3668 3668 3669 <enum 3670 name="AutostopType" extends="$unknown" 3671 uuid="6bb96740-cf34-470d-aab2-2cd48ea2e10e" 3672 > 3673 3674 <desc> 3675 Autostop types, used with <link to="IMachine::autostopType" />. 3676 </desc> 3677 3678 <const name="Disabled" value="1"> 3679 <desc>Stopping the VM during system shutdown is disabled.</desc> 3680 </const> 3681 <const name="SaveState" value="2"> 3682 <desc>The state of the VM will be saved when the system shuts down.</desc> 3683 </const> 3684 <const name="PowerOff" value="3"> 3685 <desc>The VM is powered off when the system shuts down.</desc> 3686 </const> 3687 <const name="AcpiShutdown" value="4"> 3688 <desc>An ACPI shutdown event is generated.</desc> 3689 </const> 3690 3691 </enum> 3692 3669 3693 3670 3694 <interface 3671 3695 name="IMachine" extends="$unknown" 3672 uuid=" e7c78fee-f20d-4b4f-ac28-37af30d79ddf"3696 uuid="d6406544-910e-43b2-a8fb-5528e56ce3b4" 3673 3697 wsmap="managed" 3674 3698 > … … 4319 4343 business accessing the VMCPU or VM structures, and are therefore unable 4320 4344 to get any pointers to these. 4345 </desc> 4346 </attribute> 4347 4348 <attribute name="autostartEnabled" type="boolean"> 4349 <desc> 4350 Enables autostart of the VM during system boot. 4351 </desc> 4352 </attribute> 4353 4354 <attribute name="autostartDelay" type="unsigned long"> 4355 <desc> 4356 Number of seconds to wait until the VM should be started during system boot. 4357 </desc> 4358 </attribute> 4359 4360 <attribute name="autostopType" type="AutostopType"> 4361 <desc> 4362 Action type to do when the system is shutting down. 4321 4363 </desc> 4322 4364 </attribute> -
trunk/src/VBox/Main/include/MachineImpl.h
r41371 r41914 300 300 301 301 settings::Debugging mDebugging; 302 settings::Autostart mAutostart; 302 303 }; 303 304 … … 477 478 STDMETHOD(COMGETTER(AllowTracingToAccessVM))(BOOL *pfAllow); 478 479 STDMETHOD(COMSETTER(AllowTracingToAccessVM))(BOOL fAllow); 480 STDMETHOD(COMGETTER(AutostartEnabled))(BOOL *pfEnabled); 481 STDMETHOD(COMSETTER(AutostartEnabled))(BOOL fEnabled); 482 STDMETHOD(COMGETTER(AutostartDelay))(ULONG *puDelay); 483 STDMETHOD(COMSETTER(AutostartDelay))(ULONG uDelay); 484 STDMETHOD(COMGETTER(AutostopType))(AutostopType_T *penmAutostopType); 485 STDMETHOD(COMSETTER(AutostopType))(AutostopType_T enmAutostopType); 479 486 480 487 // IMachine methods … … 795 802 const Guid &aCurSnapshotId, 796 803 Snapshot *aParentSnapshot); 797 HRESULT loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg); 804 HRESULT loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg, 805 const settings::Autostart *pAutostart); 798 806 HRESULT loadDebugging(const settings::Debugging *pDbg); 807 HRESULT loadAutostart(const settings::Autostart *pAutostart); 799 808 HRESULT loadStorageControllers(const settings::Storage &data, 800 809 const Guid *puuidRegistry, … … 836 845 void copyMachineDataToSettings(settings::MachineConfigFile &config); 837 846 HRESULT saveAllSnapshots(settings::MachineConfigFile &config); 838 HRESULT saveHardware(settings::Hardware &data, settings::Debugging *pDbg); 847 HRESULT saveHardware(settings::Hardware &data, settings::Debugging *pDbg, 848 settings::Autostart *pAutostart); 839 849 HRESULT saveStorageControllers(settings::Storage &data); 840 850 HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController, … … 1206 1216 const settings::Hardware &hardware, 1207 1217 const settings::Debugging *pDbg, 1218 const settings::Autostart *pAutostart, 1208 1219 const settings::Storage &storage, 1209 1220 IN_GUID aSnapshotId, -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r41774 r41914 6548 6548 } 6549 6549 6550 STDMETHODIMP Machine::COMGETTER(AutostartEnabled)(BOOL *pfEnabled) 6551 { 6552 CheckComArgOutPointerValid(pfEnabled); 6553 AutoCaller autoCaller(this); 6554 HRESULT hrc = autoCaller.rc(); 6555 if (SUCCEEDED(hrc)) 6556 { 6557 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 6558 *pfEnabled = mHWData->mAutostart.fAutostartEnabled; 6559 } 6560 return hrc; 6561 } 6562 6563 STDMETHODIMP Machine::COMSETTER(AutostartEnabled)(BOOL fEnabled) 6564 { 6565 AutoCaller autoCaller(this); 6566 HRESULT hrc = autoCaller.rc(); 6567 if (SUCCEEDED(hrc)) 6568 { 6569 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 6570 hrc = checkStateDependency(MutableStateDep); 6571 if (SUCCEEDED(hrc)) 6572 { 6573 hrc = mHWData.backupEx(); 6574 if (SUCCEEDED(hrc)) 6575 { 6576 setModified(IsModified_MachineData); 6577 mHWData->mAutostart.fAutostartEnabled = fEnabled != FALSE; 6578 } 6579 } 6580 } 6581 return hrc; 6582 } 6583 6584 STDMETHODIMP Machine::COMGETTER(AutostartDelay)(ULONG *puDelay) 6585 { 6586 CheckComArgOutPointerValid(puDelay); 6587 AutoCaller autoCaller(this); 6588 HRESULT hrc = autoCaller.rc(); 6589 if (SUCCEEDED(hrc)) 6590 { 6591 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 6592 *puDelay = mHWData->mAutostart.uAutostartDelay; 6593 } 6594 return hrc; 6595 } 6596 6597 STDMETHODIMP Machine::COMSETTER(AutostartDelay)(ULONG uDelay) 6598 { 6599 AutoCaller autoCaller(this); 6600 HRESULT hrc = autoCaller.rc(); 6601 if (SUCCEEDED(hrc)) 6602 { 6603 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 6604 hrc = checkStateDependency(MutableStateDep); 6605 if (SUCCEEDED(hrc)) 6606 { 6607 hrc = mHWData.backupEx(); 6608 if (SUCCEEDED(hrc)) 6609 { 6610 setModified(IsModified_MachineData); 6611 mHWData->mAutostart.uAutostartDelay = uDelay; 6612 } 6613 } 6614 } 6615 return hrc; 6616 } 6617 6618 STDMETHODIMP Machine::COMGETTER(AutostopType)(AutostopType_T *penmAutostopType) 6619 { 6620 CheckComArgOutPointerValid(penmAutostopType); 6621 AutoCaller autoCaller(this); 6622 HRESULT hrc = autoCaller.rc(); 6623 if (SUCCEEDED(hrc)) 6624 { 6625 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 6626 *penmAutostopType = mHWData->mAutostart.enmAutostopType; 6627 } 6628 return hrc; 6629 } 6630 6631 STDMETHODIMP Machine::COMSETTER(AutostopType)(AutostopType_T enmAutostopType) 6632 { 6633 AutoCaller autoCaller(this); 6634 HRESULT hrc = autoCaller.rc(); 6635 if (SUCCEEDED(hrc)) 6636 { 6637 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 6638 hrc = checkStateDependency(MutableStateDep); 6639 if (SUCCEEDED(hrc)) 6640 { 6641 hrc = mHWData.backupEx(); 6642 if (SUCCEEDED(hrc)) 6643 { 6644 setModified(IsModified_MachineData); 6645 mHWData->mAutostart.enmAutostopType = enmAutostopType; 6646 } 6647 } 6648 } 6649 return hrc; 6650 } 6550 6651 6551 6652 … … 7893 7994 7894 7995 // hardware data 7895 rc = loadHardware(config.hardwareMachine, &config.debugging );7996 rc = loadHardware(config.hardwareMachine, &config.debugging, &config.autostart); 7896 7997 if (FAILED(rc)) return rc; 7897 7998 … … 7964 8065 data.hardware, 7965 8066 &data.debugging, 8067 &data.autostart, 7966 8068 data.storage, 7967 8069 data.uuid.ref(), … … 8011 8113 * Loads settings into mHWData. 8012 8114 * 8013 * @param data Reference to the hardware settings. 8014 * @param pDbg Pointer to the debugging settings. 8115 * @param data Reference to the hardware settings. 8116 * @param pDbg Pointer to the debugging settings. 8117 * @param pAutostart Pointer to the autostart settings. 8015 8118 */ 8016 HRESULT Machine::loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg) 8119 HRESULT Machine::loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg, 8120 const settings::Autostart *pAutostart) 8017 8121 { 8018 8122 AssertReturn(!isSessionMachine(), E_FAIL); … … 8266 8370 if (FAILED(rc)) 8267 8371 return rc; 8372 8373 mHWData->mAutostart = *pAutostart; 8268 8374 } 8269 8375 catch(std::bad_alloc &) … … 9106 9212 /// @todo Live Migration: config.fTeleported = (mData->mMachineState == MachineState_Teleported); 9107 9213 9108 HRESULT rc = saveHardware(config.hardwareMachine, &config.debugging );9214 HRESULT rc = saveHardware(config.hardwareMachine, &config.debugging, &config.autostart); 9109 9215 if (FAILED(rc)) throw rc; 9110 9216 … … 9179 9285 * given node is empty. 9180 9286 * 9181 * @param data Reference to the settings object for the hardware config. 9182 * @param pDbg Pointer to the settings object for the debugging config 9183 * which happens to live in mHWData. 9287 * @param data Reference to the settings object for the hardware config. 9288 * @param pDbg Pointer to the settings object for the debugging config 9289 * which happens to live in mHWData. 9290 * @param pAutostart Pointer to the settings object for the autostart config 9291 * which happens to live in mHWData. 9184 9292 */ 9185 HRESULT Machine::saveHardware(settings::Hardware &data, settings::Debugging *pDbg) 9293 HRESULT Machine::saveHardware(settings::Hardware &data, settings::Debugging *pDbg, 9294 settings::Autostart *pAutostart) 9186 9295 { 9187 9296 HRESULT rc = S_OK; … … 9417 9526 9418 9527 *pDbg = mHWData->mDebugging; 9528 *pAutostart = mHWData->mAutostart; 9419 9529 } 9420 9530 catch(std::bad_alloc &) -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r40565 r41914 773 773 data.strStateFile.setNull(); 774 774 775 HRESULT rc = m->pMachine->saveHardware(data.hardware, &data.debugging );775 HRESULT rc = m->pMachine->saveHardware(data.hardware, &data.debugging, &data.autostart); 776 776 if (FAILED(rc)) return rc; 777 777 … … 1081 1081 const settings::Hardware &hardware, 1082 1082 const settings::Debugging *pDbg, 1083 const settings::Autostart *pAutostart, 1083 1084 const settings::Storage &storage, 1084 1085 IN_GUID aSnapshotId, … … 1157 1158 /* load hardware and harddisk settings */ 1158 1159 1159 HRESULT rc = loadHardware(hardware, pDbg );1160 HRESULT rc = loadHardware(hardware, pDbg, pAutostart); 1160 1161 if (SUCCEEDED(rc)) 1161 1162 rc = loadStorageControllers(storage, -
trunk/src/VBox/Main/xml/Settings.cpp
r41842 r41914 1763 1763 && (llChildSnapshots == s.llChildSnapshots) // deep compare 1764 1764 && debugging == s.debugging 1765 && autostart == s.autostart 1765 1766 ) 1766 1767 ); … … 3198 3199 3199 3200 /** 3201 * Called for reading the <Autostart> element under <Machine> or <Snapshot>. 3202 */ 3203 void MachineConfigFile::readAutostart(const xml::ElementNode *pElmAutostart, Autostart *pAutostart) 3204 { 3205 Utf8Str strAutostop; 3206 3207 if (!pElmAutostart || m->sv < SettingsVersion_v1_13) 3208 return; 3209 3210 pElmAutostart->getAttributeValue("enabled", pAutostart->fAutostartEnabled); 3211 pElmAutostart->getAttributeValue("delay", pAutostart->uAutostartDelay); 3212 pElmAutostart->getAttributeValue("autostop", strAutostop); 3213 if (strAutostop == "Disabled") 3214 pAutostart->enmAutostopType = AutostopType_Disabled; 3215 else if (strAutostop == "SaveState") 3216 pAutostart->enmAutostopType = AutostopType_SaveState; 3217 else if (strAutostop == "PowerOff") 3218 pAutostart->enmAutostopType = AutostopType_PowerOff; 3219 else if (strAutostop == "AcpiShutdown") 3220 pAutostart->enmAutostopType = AutostopType_AcpiShutdown; 3221 else 3222 throw ConfigFileError(this, pElmAutostart, N_("Invalid value '%s' for Autostart/@autostop attribute"), strAutostop.c_str()); 3223 } 3224 3225 /** 3200 3226 * Called initially for the <Snapshot> element under <Machine>, if present, 3201 3227 * to store the snapshot's data into the given Snapshot structure (which is … … 3271 3297 3272 3298 readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging); 3299 readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart); 3273 3300 } 3274 3301 … … 3421 3448 else if (pelmMachineChild->nameEquals("Debugging")) 3422 3449 readDebugging(pelmMachineChild, &debugging); 3450 else if (pelmMachineChild->nameEquals("Autostart")) 3451 readAutostart(pelmMachineChild, &autostart); 3423 3452 } 3424 3453 … … 4373 4402 4374 4403 /** 4404 * Creates a <Autostart> node under elmParent and then writes out the XML 4405 * keys under that. Called for both the <Machine> node and for snapshots. 4406 * 4407 * @param pElmParent Pointer to the parent element. 4408 * @param pAutostart Pointer to the autostart settings. 4409 */ 4410 void MachineConfigFile::buildAutostartXML(xml::ElementNode *pElmParent, const Autostart *pAutostart) 4411 { 4412 const char *pcszAutostop = NULL; 4413 4414 if (m->sv < SettingsVersion_v1_13 || pAutostart->areDefaultSettings()) 4415 return; 4416 4417 xml::ElementNode *pElmAutostart = pElmParent->createChild("Autostart"); 4418 pElmAutostart->setAttribute("enabled", pAutostart->fAutostartEnabled); 4419 pElmAutostart->setAttribute("delay", pAutostart->uAutostartDelay); 4420 4421 switch (pAutostart->enmAutostopType) 4422 { 4423 case AutostopType_Disabled: pcszAutostop = "Disabled"; break; 4424 case AutostopType_SaveState: pcszAutostop = "SaveState"; break; 4425 case AutostopType_PowerOff: pcszAutostop = "PowerOff"; break; 4426 case AutostopType_AcpiShutdown: pcszAutostop = "AcpiShutdown"; break; 4427 default: Assert(false); pcszAutostop = "Disabled"; break; 4428 } 4429 pElmAutostart->setAttribute("autostop", pcszAutostop); 4430 } 4431 4432 /** 4375 4433 * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write() 4376 4434 * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the … … 4402 4460 // since snapshots never get written then 4403 4461 buildDebuggingXML(pelmSnapshot, &snap.debugging); 4462 buildAutostartXML(pelmSnapshot, &snap.autostart); 4404 4463 4405 4464 if (snap.llChildSnapshots.size()) … … 4550 4609 pllElementsWithUuidAttributes); 4551 4610 buildDebuggingXML(&elmMachine, &debugging); 4611 buildAutostartXML(&elmMachine, &autostart); 4552 4612 } 4553 4613 … … 4667 4727 if (m->sv < SettingsVersion_v1_13) 4668 4728 { 4669 // VirtualBox 4.2 adds tracing. 4670 if (!debugging.areDefaultSettings()) 4729 // VirtualBox 4.2 adds tracing and autostart. 4730 if ( !debugging.areDefaultSettings() 4731 || !autostart.areDefaultSettings()) 4671 4732 m->sv = SettingsVersion_v1_13; 4672 4733 }
Note:
See TracChangeset
for help on using the changeset viewer.