Changeset 28195 in vbox
- Timestamp:
- Apr 12, 2010 10:38:51 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r28189 r28195 104 104 USBDeviceFiltersList &ll); 105 105 106 void setVersionAttribute(xml::ElementNode &elm); 106 107 void createStubDocument(); 107 108 … … 862 863 863 864 void write(const com::Utf8Str &strFilename); 864 void buildMachineXML(xml::ElementNode &elmMachine, bool fIncludeSnapshots); 865 866 enum 867 { 868 BuildMachineXML_IncludeSnapshots = 0x01, 869 BuildMachineXML_WriteVboxVersionAttribute = 0x02 870 }; 871 void buildMachineXML(xml::ElementNode &elmMachine, uint32_t fl); 865 872 866 873 private: -
trunk/src/VBox/Main/ApplianceImplExport.cpp
r28162 r28195 1230 1230 vsdescThis->m->pMachine->copyMachineDataToSettings(*pConfig); 1231 1231 pConfig->buildMachineXML(*pelmVBoxMachine, 1232 false /* fIncludeSnapshots */); 1232 settings::MachineConfigFile::BuildMachineXML_WriteVboxVersionAttribute); 1233 // but not BuildMachineXML_IncludeSnapshots 1233 1234 delete pConfig; 1234 1235 } -
trunk/src/VBox/Main/xml/Settings.cpp
r28165 r28195 526 526 } 527 527 528 void ConfigFileBase::setVersionAttribute(xml::ElementNode &elm) 529 { 530 const char *pcszVersion = NULL; 531 switch (m->sv) 532 { 533 case SettingsVersion_v1_8: 534 pcszVersion = "1.8"; 535 break; 536 537 case SettingsVersion_v1_9: 538 pcszVersion = "1.9"; 539 break; 540 541 case SettingsVersion_v1_10: 542 case SettingsVersion_Future: // can be set if this code runs on XML files that were created by a future version of VBox; 543 // in that case, downgrade to current version when writing since we can't write future versions... 544 pcszVersion = "1.10"; 545 m->sv = SettingsVersion_v1_10; 546 break; 547 548 default: 549 // silently upgrade if this is less than 1.7 because that's the oldest we can write 550 pcszVersion = "1.7"; 551 m->sv = SettingsVersion_v1_7; 552 break; 553 } 554 555 elm.setAttribute("version", Utf8StrFmt("%s-%s", 556 pcszVersion, 557 VBOX_XML_PLATFORM)); // e.g. "linux" 558 } 559 528 560 /** 529 561 * Creates a new stub xml::Document in the m->pDoc member with the … … 549 581 m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE); 550 582 551 const char *pcszVersion = NULL; 552 switch (m->sv) 553 { 554 case SettingsVersion_v1_8: 555 pcszVersion = "1.8"; 556 break; 557 558 case SettingsVersion_v1_9: 559 pcszVersion = "1.9"; 560 break; 561 562 case SettingsVersion_v1_10: 563 case SettingsVersion_Future: // can be set if this code runs on XML files that were created by a future version of VBox; 564 // in that case, downgrade to current version when writing since we can't write future versions... 565 pcszVersion = "1.10"; 566 m->sv = SettingsVersion_v1_10; 567 break; 568 569 default: 570 // silently upgrade if this is less than 1.7 because that's the oldest we can write 571 pcszVersion = "1.7"; 572 m->sv = SettingsVersion_v1_7; 573 break; 574 } 575 576 m->pelmRoot->setAttribute("version", Utf8StrFmt("%s-%s", 577 pcszVersion, 578 VBOX_XML_PLATFORM)); // e.g. "linux" 579 580 // since this gets called before the XML document is actually written out 581 // do this, this is where we must check whether we're upgrading the settings 582 // version and need to make a backup, so the user can go back to an earlier 583 // add settings version attribute to root element 584 setVersionAttribute(*m->pelmRoot); 585 586 // since this gets called before the XML document is actually written out, 587 // this is where we must check whether we're upgrading the settings version 588 // and need to make a backup, so the user can go back to an earlier 583 589 // VirtualBox version and recover his old settings files. 584 590 if ( (m->svRead != SettingsVersion_Null) // old file exists? … … 3701 3707 * -- Appliance::buildXMLForOneVirtualSystem() 3702 3708 * 3709 * In fl, the following flag bits are recognized: 3710 * 3711 * -- BuildMachineXML_IncludeSnapshots: If set, descend into the snapshots tree 3712 * of the machine and write out <Snapshot> and possibly more snapshots under 3713 * that, if snapshots are present. Otherwise all snapshots are suppressed. 3714 * 3715 * -- BuildMachineXML_WriteVboxVersionAttribute: If set, add a settingsVersion 3716 * attribute to the machine tag with the vbox settings version. This is for 3717 * the OVF export case in which we don't have the settings version set in 3718 * the root element. 3719 * 3703 3720 * @param elmMachine XML <Machine> element to add attributes and elements to. 3704 * @param f WriteSnapshots If false, we omit snapshots entirely (we don't recurse then).3721 * @param fl Flags. 3705 3722 */ 3706 3723 void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine, 3707 bool fIncludeSnapshots) 3708 { 3724 uint32_t fl) 3725 { 3726 if (fl & BuildMachineXML_WriteVboxVersionAttribute) 3727 // add settings version attribute to machine element 3728 setVersionAttribute(elmMachine); 3729 3709 3730 elmMachine.setAttribute("uuid", makeString(uuid)); 3710 3731 elmMachine.setAttribute("name", strName); … … 3716 3737 if (strStateFile.length()) 3717 3738 elmMachine.setAttribute("stateFile", strStateFile); 3718 if (fIncludeSnapshots && !uuidCurrentSnapshot.isEmpty()) 3739 if ( (fl & BuildMachineXML_IncludeSnapshots) 3740 && !uuidCurrentSnapshot.isEmpty()) 3719 3741 elmMachine.setAttribute("currentSnapshot", makeString(uuidCurrentSnapshot)); 3720 3742 if (strSnapshotFolder.length()) … … 3742 3764 writeExtraData(elmMachine, mapExtraDataItems); 3743 3765 3744 if (fIncludeSnapshots && llFirstSnapshot.size()) 3766 if ( (fl & BuildMachineXML_IncludeSnapshots) 3767 && llFirstSnapshot.size()) 3745 3768 buildSnapshotXML(elmMachine, llFirstSnapshot.front()); 3746 3769 … … 3919 3942 xml::ElementNode *pelmMachine = m->pelmRoot->createChild("Machine"); 3920 3943 buildMachineXML(*pelmMachine, 3921 true /* fIncludeSnapshots */); 3944 MachineConfigFile::BuildMachineXML_IncludeSnapshots); 3945 // but not BuildMachineXML_WriteVboxVersionAttribute 3922 3946 3923 3947 // now go write the XML
Note:
See TracChangeset
for help on using the changeset viewer.