VirtualBox

Changeset 27835 in vbox for trunk/src/VBox/Main/xml


Ignore:
Timestamp:
Mar 30, 2010 4:40:44 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59510
Message:

Main/OVF: dump vbox machine XML into OVF's VirtualSystem element on export, first try

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/xml/Settings.cpp

    r27830 r27835  
    29522952 * @param st
    29532953 */
    2954 void MachineConfigFile::writeHardware(xml::ElementNode &elmParent,
    2955                                       const Hardware &hw,
    2956                                       const Storage &strg)
     2954void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent,
     2955                                         const Hardware &hw,
     2956                                         const Storage &strg)
    29572957{
    29582958    xml::ElementNode *pelmHardware = elmParent.createChild("Hardware");
     
    34423442 * @param st
    34433443 */
    3444 void MachineConfigFile::writeStorageControllers(xml::ElementNode &elmParent,
    3445                                                 const Storage &st)
     3444void MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent,
     3445                                                   const Storage &st)
    34463446{
    34473447    xml::ElementNode *pelmStorageControllers = elmParent.createChild("StorageControllers");
     
    35603560 * @param snap
    35613561 */
    3562 void MachineConfigFile::writeSnapshot(xml::ElementNode &elmParent,
    3563                                       const Snapshot &snap)
     3562void MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent,
     3563                                         const Snapshot &snap)
    35643564{
    35653565    xml::ElementNode *pelmSnapshot = elmParent.createChild("Snapshot");
     
    35753575        pelmSnapshot->createChild("Description")->addContent(snap.strDescription);
    35763576
    3577     writeHardware(*pelmSnapshot, snap.hardware, snap.storage);
    3578     writeStorageControllers(*pelmSnapshot, snap.storage);
     3577    buildHardwareXML(*pelmSnapshot, snap.hardware, snap.storage);
     3578    buildStorageControllersXML(*pelmSnapshot, snap.storage);
    35793579
    35803580    if (snap.llChildSnapshots.size())
     
    35863586        {
    35873587            const Snapshot &child = *it;
    3588             writeSnapshot(*pelmChildren, child);
    3589         }
    3590     }
     3588            buildSnapshotXML(*pelmChildren, child);
     3589        }
     3590    }
     3591}
     3592
     3593/**
     3594 * Builds the XML DOM tree for the machine config under the given XML element.
     3595 * This has been separated out from write() so it can be called from elsewhere,
     3596 * such as the OVF code, to build machine XML in an existing XML tree.
     3597 * @param elmMachine
     3598 */
     3599void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine)
     3600{
     3601    elmMachine.setAttribute("uuid", makeString(uuid));
     3602    elmMachine.setAttribute("name", strName);
     3603    if (!fNameSync)
     3604        elmMachine.setAttribute("nameSync", fNameSync);
     3605    if (strDescription.length())
     3606        elmMachine.createChild("Description")->addContent(strDescription);
     3607    elmMachine.setAttribute("OSType", strOsType);
     3608    if (strStateFile.length())
     3609        elmMachine.setAttribute("stateFile", strStateFile);
     3610    if (!uuidCurrentSnapshot.isEmpty())
     3611        elmMachine.setAttribute("currentSnapshot", makeString(uuidCurrentSnapshot));
     3612    if (strSnapshotFolder.length())
     3613        elmMachine.setAttribute("snapshotFolder", strSnapshotFolder);
     3614    if (!fCurrentStateModified)
     3615        elmMachine.setAttribute("currentStateModified", fCurrentStateModified);
     3616    elmMachine.setAttribute("lastStateChange", makeString(timeLastStateChange));
     3617    if (fAborted)
     3618        elmMachine.setAttribute("aborted", fAborted);
     3619    if (    m->sv >= SettingsVersion_v1_9
     3620        &&  (   fTeleporterEnabled
     3621            ||  uTeleporterPort
     3622            ||  !strTeleporterAddress.isEmpty()
     3623            ||  !strTeleporterPassword.isEmpty()
     3624            )
     3625       )
     3626    {
     3627        xml::ElementNode *pelmTeleporter = elmMachine.createChild("Teleporter");
     3628        pelmTeleporter->setAttribute("enabled", fTeleporterEnabled);
     3629        pelmTeleporter->setAttribute("port", uTeleporterPort);
     3630        pelmTeleporter->setAttribute("address", strTeleporterAddress);
     3631        pelmTeleporter->setAttribute("password", strTeleporterPassword);
     3632    }
     3633
     3634    writeExtraData(elmMachine, mapExtraDataItems);
     3635
     3636    if (llFirstSnapshot.size())
     3637        buildSnapshotXML(elmMachine, llFirstSnapshot.front());
     3638
     3639    buildHardwareXML(elmMachine, hardwareMachine, storageMachine);
     3640    buildStorageControllersXML(elmMachine, storageMachine);
    35913641}
    35923642
     
    37263776
    37273777        xml::ElementNode *pelmMachine = m->pelmRoot->createChild("Machine");
    3728 
    3729         pelmMachine->setAttribute("uuid", makeString(uuid));
    3730         pelmMachine->setAttribute("name", strName);
    3731         if (!fNameSync)
    3732             pelmMachine->setAttribute("nameSync", fNameSync);
    3733         if (strDescription.length())
    3734             pelmMachine->createChild("Description")->addContent(strDescription);
    3735         pelmMachine->setAttribute("OSType", strOsType);
    3736         if (strStateFile.length())
    3737             pelmMachine->setAttribute("stateFile", strStateFile);
    3738         if (!uuidCurrentSnapshot.isEmpty())
    3739             pelmMachine->setAttribute("currentSnapshot", makeString(uuidCurrentSnapshot));
    3740         if (strSnapshotFolder.length())
    3741             pelmMachine->setAttribute("snapshotFolder", strSnapshotFolder);
    3742         if (!fCurrentStateModified)
    3743             pelmMachine->setAttribute("currentStateModified", fCurrentStateModified);
    3744         pelmMachine->setAttribute("lastStateChange", makeString(timeLastStateChange));
    3745         if (fAborted)
    3746             pelmMachine->setAttribute("aborted", fAborted);
    3747         if (    m->sv >= SettingsVersion_v1_9
    3748             &&  (   fTeleporterEnabled
    3749                  || uTeleporterPort
    3750                  || !strTeleporterAddress.isEmpty()
    3751                  || !strTeleporterPassword.isEmpty()
    3752                 )
    3753            )
    3754         {
    3755            xml::ElementNode *pelmTeleporter = pelmMachine->createChild("Teleporter");
    3756            pelmTeleporter->setAttribute("enabled", fTeleporterEnabled);
    3757            pelmTeleporter->setAttribute("port", uTeleporterPort);
    3758            pelmTeleporter->setAttribute("address", strTeleporterAddress);
    3759            pelmTeleporter->setAttribute("password", strTeleporterPassword);
    3760         }
    3761 
    3762         writeExtraData(*pelmMachine, mapExtraDataItems);
    3763 
    3764         if (llFirstSnapshot.size())
    3765             writeSnapshot(*pelmMachine, llFirstSnapshot.front());
    3766 
    3767         writeHardware(*pelmMachine, hardwareMachine, storageMachine);
    3768         writeStorageControllers(*pelmMachine, storageMachine);
     3778        buildMachineXML(*pelmMachine);
    37693779
    37703780        // now go write the XML
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette