VirtualBox

Changeset 42176 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jul 17, 2012 12:23:50 PM (13 years ago)
Author:
vboxsync
Message:

Main+Frontends/VBoxManage: implement saving the settings, and add the matching VBoxManage support

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r42133 r42176  
    491491      <desc>Settings version "1.13", written by VirtualBox 4.2.x.</desc>
    492492      <!--
    493           Machine changes: tracing config;
     493          Machine changes: tracing config, groups, autostart;
     494          NetworkAdapter changes: unit for bandwidth group limits.
    494495      -->
    495496    </const>
  • trunk/src/VBox/Main/xml/Settings.cpp

    r41914 r42176  
    1717 *
    1818 * Certainly ConfigFileBase::ConfigFileBase() will. Change VBOX_XML_VERSION below as well.
     19 * VBOX_XML_VERSION does not have to be changed if the settings for a default VM do not
     20 * touch newly introduced attributes or tags. It has the benefit that older VirtualBox
     21 * versions do not trigger their "newer" code path.
    1922 *
    2023 * Once a new settings version has been added, these are the rules for introducing a new
     
    323326                else if (ulMinor == 12)
    324327                    m->sv = SettingsVersion_v1_12;
    325                 else if (ulMinor > 12)
     328                else if (ulMinor == 13)
     329                    m->sv = SettingsVersion_v1_13;
     330                else if (ulMinor > 13)
    326331                    m->sv = SettingsVersion_Future;
    327332            }
     
    32243229
    32253230/**
     3231 * Called for reading the <Groups> element under <Machine>.
     3232 */
     3233void MachineConfigFile::readGroups(const xml::ElementNode *pElmGroups, StringsList *pllGroups)
     3234{
     3235    pllGroups->clear();
     3236    if (!pElmGroups || m->sv < SettingsVersion_v1_13)
     3237    {
     3238        pllGroups->push_back("/");
     3239        return;
     3240    }
     3241
     3242    xml::NodesLoop nlGroups(*pElmGroups);
     3243    const xml::ElementNode *pelmGroup;
     3244    while ((pelmGroup = nlGroups.forAllNodes()))
     3245    {
     3246        if (pelmGroup->nameEquals("Group"))
     3247        {
     3248            Utf8Str strGroup;
     3249            if (!pelmGroup->getAttributeValue("name", strGroup))
     3250                throw ConfigFileError(this, pelmGroup, N_("Required Group/@name attribute is missing"));
     3251            pllGroups->push_back(strGroup);
     3252        }
     3253    }
     3254}
     3255
     3256/**
    32263257 * Called initially for the <Snapshot> element under <Machine>, if present,
    32273258 * to store the snapshot's data into the given Snapshot structure (which is
     
    32983329    readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging);
    32993330    readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart);
     3331    // note: Groups exist only for Machine, not for Snapshot
    33003332}
    33013333
     
    34503482            else if (pelmMachineChild->nameEquals("Autostart"))
    34513483                readAutostart(pelmMachineChild, &autostart);
     3484            else if (pelmMachineChild->nameEquals("Groups"))
     3485                readGroups(pelmMachineChild, &machineUserData.llGroups);
    34523486        }
    34533487
     
    44314465
    44324466/**
     4467 * Creates a <Groups> node under elmParent and then writes out the XML
     4468 * keys under that. Called for the <Machine> node only.
     4469 *
     4470 * @param pElmParent    Pointer to the parent element.
     4471 * @param pllGroups     Pointer to the groups list.
     4472 */
     4473void MachineConfigFile::buildGroupsXML(xml::ElementNode *pElmParent, const StringsList *pllGroups)
     4474{
     4475    if (   m->sv < SettingsVersion_v1_13 || pllGroups->size() == 0
     4476        || (pllGroups->size() == 1 && pllGroups->front() == "/"))
     4477        return;
     4478
     4479    xml::ElementNode *pElmGroups = pElmParent->createChild("Groups");
     4480    for (StringsList::const_iterator it = pllGroups->begin();
     4481         it != pllGroups->end();
     4482         ++it)
     4483    {
     4484        const Utf8Str &group = *it;
     4485        xml::ElementNode *pElmGroup = pElmGroups->createChild("Group");
     4486        pElmGroup->setAttribute("name", group);
     4487    }
     4488}
     4489
     4490/**
    44334491 * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write()
    44344492 * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the
     
    44614519    buildDebuggingXML(pelmSnapshot, &snap.debugging);
    44624520    buildAutostartXML(pelmSnapshot, &snap.autostart);
     4521    // note: Groups exist only for Machine, not for Snapshot
    44634522
    44644523    if (snap.llChildSnapshots.size())
     
    46104669    buildDebuggingXML(&elmMachine, &debugging);
    46114670    buildAutostartXML(&elmMachine, &autostart);
     4671    buildGroupsXML(&elmMachine, &machineUserData.llGroups);
    46124672}
    46134673
     
    47274787    if (m->sv < SettingsVersion_v1_13)
    47284788    {
    4729         // VirtualBox 4.2 adds tracing and autostart.
     4789        // VirtualBox 4.2 adds tracing, autostart and groups.
    47304790        if (   !debugging.areDefaultSettings()
    4731             || !autostart.areDefaultSettings())
     4791            || !autostart.areDefaultSettings()
     4792            || machineUserData.llGroups.size() > 1
     4793            || machineUserData.llGroups.front() != "/")
    47324794            m->sv = SettingsVersion_v1_13;
    47334795    }
Note: See TracChangeset for help on using the changeset viewer.

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