Settings.cpp revision 85d78ebc068381ca25c84242e38ec4b2be4843a5
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Settings File Manipulation API.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Two classes, MainConfigFile and MachineConfigFile, represent the VirtualBox.xml and
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine XML files. They share a common ancestor class, ConfigFileBase, which shares
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * functionality such as talking to the XML back-end classes and settings version management.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * The code can read all VirtualBox settings files version 1.3 and higher. That version was
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * written by VirtualBox 2.0. It can write settings version 1.7 (used by VirtualBox 2.2 and
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * 3.0) and 1.9 (used by VirtualBox 3.1).
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Rules for introducing new settings: If an element or attribute is introduced that was not
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * present before VirtualBox 3.1, then settings version checks need to be introduced. The
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * settings version for VirtualBox 3.1 is 1.9; see the SettingsVersion enumeration in
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * src/VBox/Main/idl/VirtualBox.xidl for details about which version was used when.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * The settings versions checks are necessary because VirtualBox 3.1 no longer automatically
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * converts XML settings files but only if necessary, that is, if settings are present that
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the old format does not support. If we write an element or attribute to a settings file
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * of an older version, then an old VirtualBox (before 3.1) will attempt to validate it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * with XML schema, and that will certainly fail.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * So, to introduce a new setting:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * 1) Make sure the constructor of corresponding settings structure has a proper default.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * 2) In the settings reader method, try to read the setting; if it's there, great, if not,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the default value will have been set by the constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * 3) In the settings writer method, write the setting _only_ if the current settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * version (stored in m->sv) is high enough. That is, for VirtualBox 3.2, write it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * only if (m->sv >= SettingsVersion_v1_10).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * 4) In MachineConfigFile::bumpSettingsVersionIfNeeded(), check if the new setting has
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * a non-default value (i.e. that differs from the constructor). If so, bump the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * settings version to the current version so the settings writer (3) can write out
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the non-default value properly.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * So far a corresponding method for MainConfigFile has not been necessary since there
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * have been no incompatible changes yet.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Copyright (C) 2007-2010 Oracle Corporation
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * available from http://www.virtualbox.org. This file is free software;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * you can redistribute it and/or modify it under the terms of the GNU
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * General Public License (GPL) as published by the Free Software
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// generated header
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncusing namespace com;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncusing namespace settings;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings namespace */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define VBOX_XML_NAMESPACE "http://www.innotek.de/VirtualBox-settings"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings version number substring ("x.y") */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings version platform substring */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings full version string ("x.y-platform") */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define VBOX_XML_VERSION_FULL VBOX_XML_VERSION "-" VBOX_XML_PLATFORM
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Internal data
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Opaque data structore for ConfigFileBase (only declared
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in header, defined only here).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync com::Utf8Str strSettingsVersionFull; // e.g. "1.7-linux"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SettingsVersion_T svRead; // settings version that the original file had when it was read,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // or SettingsVersion_Null if none
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Private exception class (not in the header file) that makes
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * throwing xml::LogicError instances easier. That class is public
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * and should be caught by client code.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncclass settings::ConfigFileError : public xml::LogicError
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszFormat, ...)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strLine = Utf8StrFmt(" (line %RU32)", pNode->getLineNumber());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// ConfigFileBase
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor. Allocates the XML internals.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strFilename
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncConfigFileBase::ConfigFileBase(const com::Utf8Str *pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // reading existing settings file:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!m->pelmRoot || !m->pelmRoot->nameEquals("VirtualBox"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("Root element in VirtualBox settings files must be \"VirtualBox\"."));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(m->pelmRoot->getAttributeValue("version", m->strSettingsVersionFull)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, m->pelmRoot, N_("Required VirtualBox/@version attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync LogRel(("Loading settings file \"%s\" with version \"%s\"\n", m->strFilename.c_str(), m->strSettingsVersionFull.c_str()));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse settings version; allow future versions but fail if file is older than 1.6
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz = m->strSettingsVersionFull.c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ( (c = *pcsz)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ( (c = *pcsz)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t ulMajor = RTStrToUInt32(strMajor.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t ulMinor = RTStrToUInt32(strMinor.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync LogRel(("Parsed settings version %d.%d to enum value %d\n", ulMajor, ulMinor, m->sv));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, m->pelmRoot, N_("Cannot handle settings version '%s'"), m->strSettingsVersionFull.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // remember the settings version we read in case it gets upgraded later,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // so we know when to make backups
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // creating new settings file:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Clean up.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Helper function that parses a UUID in string form into
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * a com::Guid item. Since that uses an IPRT function which
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * does not accept "{}" characters around the UUID string,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * we handle that here. Throws on errors.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param guid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strUUID
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // {5f102a55-a51b-48e3-b45a-b28d33469488}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 01234567890123456789012345678901234567
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("UUID \"%s\" has invalid format"), strUUID.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Parses the given string in str and attempts to treat it as an ISO
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * date/time stamp to put into timestamp. Throws on errors.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param timestamp
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param str
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::parseTimestamp(RTTIMESPEC ×tamp,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // yyyy-mm-ddThh:mm:ss
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // "2009-07-10T11:54:03Z"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 01234567890123456789
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // timezone must either be unspecified or 'Z' for UTC
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("Cannot handle ISO timestamp '%s': is not UTC date"), str.c_str());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( (RT_SUCCESS(rc = RTStrToInt32Ex(pcsz, NULL, 0, &yyyy)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // could theoretically be negative but let's assume that nobody
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // created virtual machines before the Christian era
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (RT_SUCCESS(rc = RTStrToUInt32Ex(pcsz + 5, NULL, 0, &mm)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (RT_SUCCESS(rc = RTStrToUInt32Ex(pcsz + 8, NULL, 0, &dd)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (RT_SUCCESS(rc = RTStrToUInt32Ex(pcsz + 11, NULL, 0, &hh)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (RT_SUCCESS(rc = RTStrToUInt32Ex(pcsz + 14, NULL, 0, &min)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (RT_SUCCESS(rc = RTStrToUInt32Ex(pcsz + 17, NULL, 0, &secs)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Cannot parse ISO timestamp '%s': runtime error, %Rra"), str.c_str(), rc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Cannot parse ISO timestamp '%s': invalid format"), str.c_str());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Helper to create a string for a RTTIMESPEC for writing out ISO timestamps.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param stamp
f22cba796fd7499bf85058671a1af7cbe491c622vboxsynccom::Utf8Str ConfigFileBase::makeString(const RTTIMESPEC &stamp)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Timespec %lld ms is invalid"), RTTimeSpecGetMilli(&stamp));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync return Utf8StrFmt("%04ld-%02hd-%02hdT%02hd:%02hd:%02hdZ",
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Helper to create a string for a GUID.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param guid
f22cba796fd7499bf85058671a1af7cbe491c622vboxsynccom::Utf8Str ConfigFileBase::makeString(const Guid &guid)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Helper method to read in an ExtraData subtree and stores its contents
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * in the given map of extradata items. Used for both main and machine
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * extradata (MainConfigFile and MachineConfigFile).
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmExtraData
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param map
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::readExtraData(const xml::ElementNode &elmExtraData,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmExtraDataItem = nlLevel4.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmExtraDataItem->nameEquals("ExtraDataItem"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // <ExtraDataItem name="GUI/LastWindowPostion" value="97,88,981,858"/>
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( ((pelmExtraDataItem->getAttributeValue("name", strName)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && ((pelmExtraDataItem->getAttributeValue("value", strValue)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, pelmExtraDataItem, N_("Required ExtraDataItem/@name or @value attribute is missing"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Reads <USBDeviceFilter> entries from under the given elmDeviceFilters node and
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * stores them in the given linklist. This is in ConfigFileBase because it's used
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * from both MainConfigFile (for host filters) and MachineConfigFile (for machine
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * filters).
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmDeviceFilters
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param ll
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nl1(elmDeviceFilters, "DeviceFilter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( (pelmLevel4Child->getAttributeValue("name", flt.strName))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (pelmLevel4Child->getAttributeValue("active", flt.fActive))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!pelmLevel4Child->getAttributeValue("vendorId", flt.strVendorId))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("vendorid", flt.strVendorId); // used before 1.3
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!pelmLevel4Child->getAttributeValue("productId", flt.strProductId))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("productid", flt.strProductId); // used before 1.3
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("revision", flt.strRevision);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("manufacturer", flt.strManufacturer);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("product", flt.strProduct);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!pelmLevel4Child->getAttributeValue("serialNumber", flt.strSerialNumber))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("serialnumber", flt.strSerialNumber); // used before 1.3
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("port", flt.strPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // the next 2 are irrelevant for host USB objects
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("remote", flt.strRemote);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("maskedInterfaces", flt.ulMaskedInterfaces);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // action is only used with host USB objects
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmLevel4Child->getAttributeValue("action", strAction))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, pelmLevel4Child, N_("Invalid value '%s' in DeviceFilter/@action attribute"), strAction.c_str());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Adds a "version" attribute to the given XML element with the
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * VirtualBox settings version (e.g. "1.10-linux"). Used by
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the XML format for the root element and by the OVF export
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * for the vbox:Machine element.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elm
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::setVersionAttribute(xml::ElementNode &elm)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (m->sv)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case SettingsVersion_Future: // can be set if this code runs on XML files that were created by a future version of VBox;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // in that case, downgrade to current version when writing since we can't write future versions...
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // silently upgrade if this is less than 1.7 because that's the oldest we can write
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Creates a new stub xml::Document in the m->pDoc member with the
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * root "VirtualBox" element set up. This is used by both
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * MainConfigFile and MachineConfigFile at the beginning of writing
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * out their XML.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Before calling this, it is the responsibility of the caller to
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * set the "sv" member to the required settings version that is to
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * be written. For newly created files, the settings version will be
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the latest (1.9); for files read in from disk earlier, it will be
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the settings version indicated in the file. However, this method
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * will silently make sure that the settings version is always
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * at least 1.7 and change it if necessary, since there is no write
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * support for earlier settings versions.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->pelmRoot = m->pDoc->createRootElement("VirtualBox");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // add settings version attribute to root element
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // since this gets called before the XML document is actually written out,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // this is where we must check whether we're upgrading the settings version
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // and need to make a backup, so the user can go back to an earlier
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // VirtualBox version and recover his old settings files.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->svRead != SettingsVersion_Null) // old file exists?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // compose new filename: strip off trailing ".xml"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strFilenameNew = m->strFilename.substr(0, m->strFilename.length() - 4);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // and append something likd "-1.3-linux.xml"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFilenameNew.append(m->strSettingsVersionFull); // e.g. "1.3-linux"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync 0); // no RTFILEMOVE_FLAGS_REPLACE
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // do this only once
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Creates an <ExtraData> node under the given parent element with
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * <ExtraDataItem> childern according to the contents of the given
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is in ConfigFileBase because it's used in both MainConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * MachineConfigFile, which both can have extradata.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param me
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::writeExtraData(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmExtraData = elmParent.createChild("ExtraData");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (ExtraDataItemsMap::const_iterator it = me.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmThis = pelmExtraData->createChild("ExtraDataItem");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Creates <DeviceFilter> nodes under the given parent element according to
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the contents of the given USBDeviceFiltersList. This is in ConfigFileBase
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * because it's used in both MainConfigFile (for host filters) and
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * MachineConfigFile (for machine filters).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * If fHostMode is true, this means that we're supposed to write filters
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * for the IHost interface (respect "action", omit "strRemote" and
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * "ulMaskedInterfaces" in struct USBDeviceFilter).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param fHostMode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::writeUSBDeviceFilters(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (USBDeviceFiltersList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmFilter = elmParent.createChild("DeviceFilter");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("vendorId", flt.strVendorId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("productId", flt.strProductId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("revision", flt.strRevision);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("manufacturer", flt.strManufacturer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("product", flt.strProduct);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("serialNumber", flt.strSerialNumber);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz =
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (flt.action == USBDeviceFilterAction_Ignore) ? "Ignore"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : /*(flt.action == USBDeviceFilterAction_Hold) ?*/ "Hold";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("maskedInterfaces", flt.ulMaskedInterfaces);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Cleans up memory allocated by the internal XML parser. To be called by
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * descendant classes when they're done analyzing the DOM tree to discard it.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Returns true only if the underlying config file exists on disk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * either because the file has been loaded from disk, or it's been written
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * to disk, or both.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Copies the base variables from another instance. Used by Machine::saveSettings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * so that the settings version does not get lost when a copy of the Machine settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * file is made to see if settings have actually changed.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::copyBaseFrom(const ConfigFileBase &b)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Structures shared between Machine XML and VirtualBox.xml
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool USBDeviceFilter::operator==(const USBDeviceFilter &u) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &u)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// MainConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads one <MachineEntry> from the main VirtualBox.xml file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachineRegistry
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readMachineRegistry(const xml::ElementNode &elmMachineRegistry)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <MachineEntry uuid="{ xxx }" src=" xxx "/>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pelmChild1->getAttributeValue("uuid", strUUID)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ((pelmChild1->getAttributeValue("src", mre.strSettingsFile)))
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync throw ConfigFileError(this, pelmChild1, N_("Required MachineEntry/@uuid or @src attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads a media registry entry from the main VirtualBox.xml file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Whereas the current media registry code is fairly straightforward, it was quite a mess
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * with settings format before 1.4 (VirtualBox 2.0 used settings format 1.3). The elements
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in the media registry were much more inconsistent, and different elements were used
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * depending on the type of device and image.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMedium
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param llMedia
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode &elmMedium, // HardDisk node if root; if recursing,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // child HardDisk node or DiffHardDisk node for pre-1.4
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync MediaList &llMedia) // list to append medium to (root disk or child list)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <HardDisk uuid="{5471ecdb-1ddb-4012-a801-6d98e226868b}" location="/mnt/innotek-unix/vdis/Windows XP.vdi" format="VDI" type="Normal">
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("uuid", strUUID)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@uuid attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // here the system is:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <HardDisk uuid="{....}" type="normal">
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <VirtualDiskImage filePath="/path/to/xxx.vdi"/>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // </HardDisk>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmImage = elmMedium.findChildElement("VirtualDiskImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("VMDKImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("VHDImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("ISCSIHardDisk")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // location is special here: current settings specify an "iscsi://user@server:port/target/lun"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // string for the location and also have several disk properties for these, whereas this used
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // to be hidden in several sub-elements before 1.4, so compose a location string and set up
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // the properties:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUser, strServer, strPort, strTarget, strLun;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("userName", strUser))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("server", strServer))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("target", strTarget))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["TargetAddress"] = strServerAndPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("password", strPassword))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("CustomHardDisk")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // also requires @format attribute, which will be queried below
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/VirtualDiskImage element is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmImage->getAttributeValue("filePath", med.strLocation)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@filePath attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (med.strFormat.isEmpty()) // not set with 1.4 format above, or 1.4 Custom format?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("format", med.strFormat)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@format attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("autoReset", med.fAutoReset)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((elmMedium.getAttributeValue("type", strType)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.4 used lower case, so make this case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // DVD and floppy images before 1.4 had "src" attribute instead of "location"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("src", med.strLocation)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // current files and 1.4 CustomHardDisk elements must have a location attribute
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("location", med.strLocation)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@location attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMedium.getAttributeValue("Description", med.strDescription); // optional
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // recurse to handle children
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // recurse with this element and push the child onto our current children list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHDChild->getAttributeValue("name", strPropName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmHDChild->getAttributeValue("value", strPropValue))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHDChild, N_("Required HardDisk/Property/@name or @value attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in the entire <MediaRegistry> chunk. For pre-1.4 files, this gets called
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * with the <DiskRegistry> chunk instead.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMediaRegistry
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readMediaRegistry(const xml::ElementNode &elmMediaRegistry)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llHardDisks); // list to append hard disk data to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( t == DVDImage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llDvdImages); // list to append dvd images to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( t == FloppyImage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llFloppyImages); // list to append floppy images to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in the <DHCPServers> chunk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmDHCPServers
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readDHCPServers(const xml::ElementNode &elmDHCPServers)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmServer->getAttributeValue("networkName", srv.strNetworkName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmServer->getAttributeValue("IPAddress", srv.strIPAddress))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmServer->getAttributeValue("networkMask", srv.strIPNetworkMask))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmServer->getAttributeValue("lowerIP", srv.strIPLower))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmServer->getAttributeValue("upperIP", srv.strIPUpper))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmServer->getAttributeValue("enabled", srv.fEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmServer, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * If pstrFilename is != NULL, this reads the given settings file into the member
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * variables and various substructures and lists. Otherwise, the member variables
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * are initialized with default values.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Throws variants of xml::Error for I/O, XML and logical content errors, which
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * the caller should catch; if this constructor does not throw, then the member
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * variables contain meaningful values (either from the file or defaults).
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param strFilename
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncMainConfigFile::MainConfigFile(const Utf8Str *pstrFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // the ConfigFileBase constructor has loaded the XML file, so now
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // we need only analyze what is in there
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmRootChild = nlRootChildren.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmGlobalChild = nlGlobalChildren.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmGlobalChild->nameEquals("SystemProperties"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("defaultMachineFolder", systemProperties.strDefaultMachineFolder);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!pelmGlobalChild->getAttributeValue("defaultHardDiskFolder", systemProperties.strDefaultHardDiskFolder))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // pre-1.4 used @defaultVDIFolder instead
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("defaultVDIFolder", systemProperties.strDefaultHardDiskFolder);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("defaultHardDiskFormat", systemProperties.strDefaultHardDiskFormat);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("remoteDisplayAuthLibrary", systemProperties.strRemoteDisplayAuthLibrary);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("webServiceAuthLibrary", systemProperties.strWebServiceAuthLibrary);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGlobalChild->getAttributeValue("LogHistoryCount", systemProperties.ulLogHistoryCount);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readExtraData(*pelmGlobalChild, mapExtraDataItems);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("MachineRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if ( (pelmGlobalChild->nameEquals("MediaRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("NetserviceRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("USBDeviceFilters"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readUSBDeviceFilters(*pelmGlobalChild, host.llUSBDeviceFilters);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync } // end if (pelmRootChild->nameEquals("Global"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // DHCP servers were introduced with settings version 1.7; if we're loading
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // from an older version OR this is a fresh install, then add one DHCP server
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // with default settings
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync || (m->sv < SettingsVersion_v1_7) // upgrading from before 1.7
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync "HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync "HostInterfaceNetworking-vboxnet0";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Creates a single <HardDisk> element for the given Medium structure
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * and recurses to write the child hard disks underneath. Called from
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * MainConfigFile::write().
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmMedium
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param level
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MainConfigFile::writeHardDisk(xml::ElementNode &elmMedium,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync uint32_t level) // 0 for "root" call, incremented with each recursion
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmHardDisk = elmMedium.createChild("HardDisk");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("uuid", makeString(mdm.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("location", mdm.strLocation);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("format", mdm.strFormat);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("autoReset", mdm.fAutoReset);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (PropertiesMap::const_iterator it = mdm.properties.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmProp = pelmHardDisk->createChild("Property");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // only for base hard disks, save the type
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType =
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /*mdm.hdType == MediumType_Writethrough ?*/ "Writethrough";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = mdm.llChildren.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // recurse for children
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Called from the IVirtualBox interface to write out VirtualBox.xml. This
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * builds an XML DOM tree and writes it out to disk.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MainConfigFile::write(const com::Utf8Str strFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGlobal = m->pelmRoot->createChild("Global");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachineRegistry = pelmGlobal->createChild("MachineRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MachinesRegistry::const_iterator it = llMachines.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // <MachineEntry uuid="{5f102a55-a51b-48e3-b45a-b28d33469488}" src="/mnt/innotek-unix/vbox-machines/Windows 5.1 XP 1 (Office 2003)/Windows 5.1 XP 1 (Office 2003).xml"/>
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachineEntry = pelmMachineRegistry->createChild("MachineEntry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMachineEntry->setAttribute("uuid", makeString(mre.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMachineEntry->setAttribute("src", mre.strSettingsFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMediaRegistry = pelmGlobal->createChild("MediaRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmHardDisks = pelmMediaRegistry->createChild("HardDisks");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llHardDisks.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDVDImages = pelmMediaRegistry->createChild("DVDImages");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llDvdImages.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMedium = pelmDVDImages->createChild("Image");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("uuid", makeString(mdm.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("location", mdm.strLocation);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmFloppyImages = pelmMediaRegistry->createChild("FloppyImages");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llFloppyImages.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMedium = pelmFloppyImages->createChild("Image");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("uuid", makeString(mdm.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("location", mdm.strLocation);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNetserviceRegistry = pelmGlobal->createChild("NetserviceRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDHCPServers = pelmNetserviceRegistry->createChild("DHCPServers");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (DHCPServersList::const_iterator it = llDhcpServers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmThis = pelmDHCPServers->createChild("DHCPServer");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("networkName", d.strNetworkName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("IPAddress", d.strIPAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("networkMask", d.strIPNetworkMask);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("enabled", (d.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmSysProps = pelmGlobal->createChild("SystemProperties");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (systemProperties.strDefaultMachineFolder.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("defaultMachineFolder", systemProperties.strDefaultMachineFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (systemProperties.strDefaultHardDiskFolder.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("defaultHardDiskFolder", systemProperties.strDefaultHardDiskFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (systemProperties.strDefaultHardDiskFormat.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("defaultHardDiskFormat", systemProperties.strDefaultHardDiskFormat);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (systemProperties.strRemoteDisplayAuthLibrary.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("remoteDisplayAuthLibrary", systemProperties.strRemoteDisplayAuthLibrary);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (systemProperties.strWebServiceAuthLibrary.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("webServiceAuthLibrary", systemProperties.strWebServiceAuthLibrary);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSysProps->setAttribute("LogHistoryCount", systemProperties.ulLogHistoryCount);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync writeUSBDeviceFilters(*pelmGlobal->createChild("USBDeviceFilters"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync true); // fHostMode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // now go write the XML
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync writer.write(m->strFilename.c_str(), true /*fSafe*/);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Machine XML structures
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool VRDPSettings::operator==(const VRDPSettings& v) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &v)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fAllowMultiConnection == v.fAllowMultiConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fReuseSingleConnection == v.fReuseSingleConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulVideoChannelQuality == v.ulVideoChannelQuality)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool BIOSSettings::operator==(const BIOSSettings &d) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &d)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool USBController::operator==(const USBController &u) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &u)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool NetworkAdapter::operator==(const NetworkAdapter &n) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &n)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool SerialPort::operator==(const SerialPort &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool ParallelPort::operator==(const ParallelPort &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool SharedFolder::operator==(const SharedFolder &g) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &g)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool GuestProperty::operator==(const GuestProperty &g) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &g)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// use a define for the platform-dependent default value of
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// hwvirt exclusivity, since we'll need to check that value
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// in bumpSettingsVersionIfNeeded()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Hardware struct constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* The default value for PAE depends on the host:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * - 64 bits host -> always true
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * - 32 bits host -> true for Windows & Darwin (masked off if the host cpu doesn't support it anyway)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#if HC_ARCH_BITS == 64 || defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &h)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fHardwareVirtExclusive == h.fHardwareVirtExclusive)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strNotificationPatterns == h.strNotificationPatterns)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool AttachedDevice::operator==(const AttachedDevice &a) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &a)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool StorageController::operator==(const StorageController &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE0MasterEmulationPort == s.lIDE0MasterEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE0SlaveEmulationPort == s.lIDE0SlaveEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE1MasterEmulationPort == s.lIDE1MasterEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE1SlaveEmulationPort == s.lIDE1SlaveEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (llStorageControllers == s.llStorageControllers) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from MachineConfigFile::operator==,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * which in turn gets called from Machine::saveSettings to figure out whether
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llChildSnapshots == s.llChildSnapshots) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * IoSettings constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// MachineConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * If pstrFilename is != NULL, this reads the given settings file into the member
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * variables and various substructures and lists. Otherwise, the member variables
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * are initialized with default values.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Throws variants of xml::Error for I/O, XML and logical content errors, which
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the caller should catch; if this constructor does not throw, then the member
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * variables contain meaningful values (either from the file or defaults).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strFilename
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncMachineConfigFile::MachineConfigFile(const Utf8Str *pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // the ConfigFileBase constructor has loaded the XML file, so now
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // we need only analyze what is in there
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmRootChild = nlRootChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // clean up memory allocated by XML engine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Public routine which allows for importing machine XML from an external DOM tree.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Use this after having called the constructor with a NULL argument.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is used by the OVF code if a <vbox:Machine> element has been encountered
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in an OVF VirtualSystem element.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::importMachineXML(const xml::ElementNode &elmMachine)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Comparison operator. This gets called from Machine::saveSettings to figure out
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * whether machine settings have really changed and thus need to be written out to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Even though this is called operator==, this does NOT compare all fields; the "equals"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * should be understood as "has the same machine config as". The following fields are
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * NOT compared:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- settings versions and file names inherited from ConfigFileBase;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- fCurrentStateModified because that is considered separately in Machine::saveSettings!!
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * The "deep" comparisons marked below will invoke the operator== functions of the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * structs defined in this file, which may in turn go into comparing lists of
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * other structures. As a result, invoking this can be expensive, but it's
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * less expensive than writing out XML to disk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool MachineConfigFile::operator==(const MachineConfigFile &c) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strTeleporterAddress == c.strTeleporterAddress)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strTeleporterPassword == c.strTeleporterPassword)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // skip fCurrentStateModified!
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (RTTimeSpecIsEqual(&timeLastStateChange, &c.timeLastStateChange))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (hardwareMachine == c.hardwareMachine) // this one's deep
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (storageMachine == c.storageMachine) // this one's deep
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (mapExtraDataItems == c.mapExtraDataItems) // this one's deep
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llFirstSnapshot == c.llFirstSnapshot) // this one's deep
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read cpu information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmCpuid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readCpuTree(const xml::ElementNode &elmCpu,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmCpu, N_("Required Cpu/@id attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to cpuid information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmCpuid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readCpuIdTree(const xml::ElementNode &elmCpuid,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmCpuIdLeaf->getAttributeValue("id", leaf.ulId))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmCpuIdLeaf, N_("Required CpuId/@id attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->getAttributeValue("eax", leaf.ulEax);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->getAttributeValue("ebx", leaf.ulEbx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->getAttributeValue("ecx", leaf.ulEcx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->getAttributeValue("edx", leaf.ulEdx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to network information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmNetwork
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readNetworkAdapters(const xml::ElementNode &elmNetwork,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAdapter->getAttributeValue("slot", nic.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Required Adapter/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmAdapter->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Invalid value '%s' in Adapter/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("enabled", nic.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("MACAddress", nic.strMACAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("cable", nic.fCableConnected);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("speed", nic.ulLineSpeed);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("trace", nic.fTraceEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("tracefile", nic.strTraceFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getAttributeValue("bootPriority", nic.ulBootPriority);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* We should have only active mode descriptor and disabled modes set */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Invalid number of modes ('%d') attached to Adapter attribute"), llNetworkModes.size());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (it = llNetworkModes.begin(); it != llNetworkModes.end(); ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmNode->getChildElements(llDisabledNetworkModes);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* run over disabled list and load settings */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync itDisabled != llDisabledNetworkModes.end(); ++itDisabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmDisabledNode = *itDisabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readAttachedNetworkMode(*pelmDisabledNode, false, nic);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // else: default is NetworkAttachmentType_Null
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, bool fEnabled, NetworkAdapter &nic)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.fHasDisabledNAT = (nic.mode != NetworkAttachmentType_NAT && !fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("network", nic.nat.strNetwork); // optional network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("hostip", nic.nat.strBindIP);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("sockrcv", nic.nat.u32SockRcv);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("socksnd", nic.nat.u32SockSnd);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("tcprcv", nic.nat.u32TcpRcv);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("tcpsnd", nic.nat.u32TcpSnd);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDNS->getAttributeValue("pass-domain", nic.nat.fDnsPassDomain);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDNS->getAttributeValue("use-proxy", nic.nat.fDnsProxy);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDNS->getAttributeValue("use-host-resolver", nic.nat.fDnsUseHostResolver);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmAlias = elmMode.findChildElement("Alias")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAlias->getAttributeValue("logging", nic.nat.fAliasLog);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAlias->getAttributeValue("proxy-only", nic.nat.fAliasProxyOnly);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAlias->getAttributeValue("use-same-ports", nic.nat.fAliasUseSamePorts);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("prefix", nic.nat.strTftpPrefix);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("boot-file", nic.nat.strTftpBootFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("next-server", nic.nat.strTftpNextServer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (xml::ElementNodesList::iterator pf = plstNatPF.begin(); pf != plstNatPF.end(); ++pf)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("hostip", rule.strHostIP);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("guestip", rule.strGuestIP);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("name", nic.strName); // optional host interface name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMode.getAttributeValue("name", nic.strName)) // required network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMode, N_("Required InternalNetwork/@name element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMode.getAttributeValue("name", nic.strName)) // required network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMode, N_("Required HostOnlyInterface/@name element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("network", nic.strName); // optional network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read serial port information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmUART
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readSerialPorts(const xml::ElementNode &elmUART,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("slot", port.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // slot must be unique
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (SerialPortsList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value %RU32 in UART/Port/@slot attribute: value is not unique"), port.ulSlot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("enabled", port.fEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@enabled attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("IOBase", port.ulIOBase))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@IOBase attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("IRQ", port.ulIRQ))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@IRQ attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("hostMode", strPortMode))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@hostMode attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value '%s' in UART/Port/@hostMode attribute"), strPortMode.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmPort->getAttributeValue("server", port.fServer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read parallel port information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmLPT
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readParallelPorts(const xml::ElementNode &elmLPT,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("slot", port.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required LPT/Port/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // slot must be unique
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (ParallelPortsList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value %RU32 in LPT/Port/@slot attribute: value is not unique"), port.ulSlot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("enabled", port.fEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required LPT/Port/@enabled attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("IOBase", port.ulIOBase))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required LPT/Port/@IOBase attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("IRQ", port.ulIRQ))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required LPT/Port/@IRQ attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read guest property information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmGuestProperties
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param hw
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readGuestProperties(const xml::ElementNode &elmGuestProperties,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmGuestProperties, "GuestProperty");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("value", prop.strValue);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("timestamp", prop.timestamp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("flags", prop.strFlags);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmGuestProperties.getAttributeValue("notificationPatterns", hw.strNotificationPatterns);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Helper function to read attributes that are common to <SATAController> (pre-1.7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * and <StorageController>.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmStorageController
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strg
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readStorageControllerAttributes(const xml::ElementNode &elmStorageController,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmStorageController.getAttributeValue("PortCount", sctl.ulPortCount);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmStorageController.getAttributeValue("IDE0MasterEmulationPort", sctl.lIDE0MasterEmulationPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmStorageController.getAttributeValue("IDE0SlaveEmulationPort", sctl.lIDE0SlaveEmulationPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmStorageController.getAttributeValue("IDE1MasterEmulationPort", sctl.lIDE1MasterEmulationPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmStorageController.getAttributeValue("IDE1SlaveEmulationPort", sctl.lIDE1SlaveEmulationPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmStorageController.getAttributeValue("IoBackend", strIoBackend))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%s' in StorageController/@IoBackend"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in a <Hardware> block and stores it in the given structure. Used
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * both directly from readMachine and from readSnapshot, since snapshots
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * have their own hardware sections.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * For legacy pre-1.7 settings we also need a storage structure because
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the IDE and SATA controllers used to be defined under <Hardware>.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardware
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param hw
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readHardware(const xml::ElementNode &elmHardware,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmHardware.getAttributeValue("version", hw.strVersion))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* KLUDGE ALERT! For a while during the 3.1 development this was not
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync written because it was thought to have a default value of "2". For
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sv <= 1.3 it defaults to "1" because the attribute didn't exist,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while for 1.4+ it is sort of mandatory. Now, the buggy XML writer
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync code only wrote 1.7 and later. So, if it's a 1.7+ XML file and it's
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync missing the hardware version, then it probably should be "2" instead
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmHardware.getAttributeValue("uuid", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("count", hw.cCPUs))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.5 variant; not sure if this actually exists in the wild anywhere
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CPUCount")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("count", hw.cCPUs);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("hotplug", hw.fCpuHotPlug);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CpuTree")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtEx")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fHardwareVirt);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("exclusive", hw.fHardwareVirtExclusive); // settings version 1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExNestedPaging")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fNestedPaging);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExLargePages")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fLargePages);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExVPID")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fVPID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmCPUChild = pelmHwChild->findChildElement("PAE")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* The default for pre 3.1 was false, so we must respect that. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fPAE);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("SyntheticCpu")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fSyntheticCpu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CpuIdTree")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("RAMSize", hw.ulMemorySizeMB);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("type", strFirmwareType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (strFirmwareType == "1") // some trunk builds used the number here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (strFirmwareType == "2") // some trunk builds used the number here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("Keyboard", strHidType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.keyboardHidType = KeyboardHidType_ComboKeyboard;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("Pointing", strHidType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.fHpetEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmOrder->getAttributeValue("position", ulPos))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Required Boot/Order/@position attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%RU32' in Boot/Order/@position: must be greater than 0 and less than %RU32"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // XML is 1-based but internal data is 0-based
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.mapBootOrder.find(ulPos) != hw.mapBootOrder.end())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Invalid value '%RU32' in Boot/Order/@position: value is not unique"), ulPos);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmOrder->getAttributeValue("device", strDevice))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Required Boot/Order/@device attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Invalid value '%s' in Boot/Order/@device attribute"), strDevice.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("VRAMSize", hw.ulVRAMSizeMB);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("monitorCount", hw.cMonitors))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("MonitorCount", hw.cMonitors); // pre-v1.5 variant
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("accelerate3D", hw.fAccelerate3D))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("Accelerate3D", hw.fAccelerate3D); // pre-v1.5 variant
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("accelerate2DVideo", hw.fAccelerate2DVideo);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.vrdpSettings.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("port", hw.vrdpSettings.strPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("netAddress", hw.vrdpSettings.strNetAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("authType", strAuthType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in RemoteDisplay/@authType attribute"), strAuthType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("authTimeout", hw.vrdpSettings.ulAuthTimeout);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("allowMultiConnection", hw.vrdpSettings.fAllowMultiConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("reuseSingleConnection", hw.vrdpSettings.fReuseSingleConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmVideoChannel = pelmHwChild->findChildElement("VideoChannel")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->getAttributeValue("enabled", hw.vrdpSettings.fVideoChannel);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->getAttributeValue("quality", hw.vrdpSettings.ulVideoChannelQuality);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.vrdpSettings.ulVideoChannelQuality = RT_CLAMP(hw.vrdpSettings.ulVideoChannelQuality, 10, 100);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("ACPI")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("enabled", hw.biosSettings.fACPIEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("IOAPIC")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("enabled", hw.biosSettings.fIOAPICEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("Logo")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("fadeIn", hw.biosSettings.fLogoFadeIn);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("fadeOut", hw.biosSettings.fLogoFadeOut);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("displayTime", hw.biosSettings.ulLogoDisplayTime);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("imagePath", hw.biosSettings.strLogoImagePath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("BootMenu")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmBIOSChild->getAttributeValue("mode", strBootMenuMode))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_Disabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_MenuOnly;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmBIOSChild, N_("Invalid value '%s' in BootMenu/@mode attribute"), strBootMenuMode.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("PXEDebug")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("enabled", hw.biosSettings.fPXEDebugEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("TimeOffset")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOSChild->getAttributeValue("value", hw.biosSettings.llTimeOffset);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // legacy BIOS/IDEController (pre 1.7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ((pelmBIOSChild = pelmHwChild->findChildElement("IDEController")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmBIOSChild->getAttributeValue("type", strType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmBIOSChild, N_("Invalid value '%s' for IDEController/@type attribute"), strType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.usbController.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabledEhci", hw.usbController.fEnabledEHCI);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHwChild->getAttributeValue("enabled", f))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_IntelAhci;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllerAttributes(*pelmHwChild, sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readNetworkAdapters(*pelmHwChild, hw.llNetworkAdapters);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fRTCUseUTC = pelmHwChild->getAttributeValue("localOrUTC", strLocalOrUTC)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (pelmHwChild->nameEquals("Uart")) // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (pelmHwChild->nameEquals("Lpt")) // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readParallelPorts(*pelmHwChild, hw.llParallelPorts);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.audioAdapter.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("controller", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.controllerType = AudioControllerType_SB16;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.controllerType = AudioControllerType_AC97;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@controller attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("driver", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_WinMM;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (strTemp == "DIRECTSOUND") || (strTemp == "DSOUND") )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_DirectSound;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_SolAudio;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_Pulse;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_CoreAudio;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFolder->getAttributeValue("hostPath", sf.strHostPath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFolder->getAttributeValue("writable", sf.fWritable);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("mode", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in Clipboard/@mode attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("memoryBalloonSize", hw.ulMemoryBalloonSize))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("MemoryBalloonSize", hw.ulMemoryBalloonSize); // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("GuestProperties"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoMgr")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmIoChild->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoMgr/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoBackend")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmIoChild->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioBackendType = IoBackendType_Unbuffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioBackendType = IoBackendType_Buffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoBackend/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoCache")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("enabled", hw.ioSettings.fIoCacheEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("size", hw.ioSettings.ulIoCacheSize);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoBandwidth")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("max", hw.ioSettings.ulIoBandwidthMax);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmHardware, N_("Required Memory/@RAMSize element/attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This gets called instead of readStorageControllers() for legacy pre-1.7 settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * files which have a <HardDiskAttachments> node and storage controller settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * hidden in the <Hardware> settings. We set the StorageControllers fields just the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * same, just from different sources.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardware <Hardware> XML node.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardDiskAttachments <HardDiskAttachments> XML node.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strg
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::iterator it = strg.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmHardDiskAttachments, "HardDiskAttachment");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttachment->getAttributeValue("hardDisk", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("Required HardDiskAttachment/@hardDisk attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttachment->getAttributeValue("bus", strBus))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("Required HardDiskAttachment/@bus attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.7 'channel' is now port
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttachment->getAttributeValue("channel", att.lPort))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("Required HardDiskAttachment/@channel attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.7 'device' is still device
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttachment->getAttributeValue("device", att.lDevice))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("Required HardDiskAttachment/@device attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus is 'IDE' but cannot find IDE controller"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus is 'SATA' but cannot find SATA controller"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus attribute has illegal value '%s'"), strBus.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in a <StorageControllers> block and stores it in the given Storage structure.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Used both directly from readMachine and from readSnapshot, since snapshots
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * have their own storage controllers sections.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is only called for settings version 1.7 and above; see readHardDiskAttachments_pre1_7()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * for earlier versions.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmStorageControllers
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readStorageControllers(const xml::ElementNode &elmStorageControllers,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlStorageControllers(elmStorageControllers, "StorageController");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmController = nlStorageControllers.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmController->getAttributeValue("name", sctl.strName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmController, N_("Required StorageController/@name attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // canonicalize storage controller names for configs in the switchover
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmController->getAttributeValue("Instance", sctl.ulInstance);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // default from constructor is 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmController->getAttributeValue("type", strType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmController, N_("Required StorageController/@type attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_IntelAhci;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_LsiLogic;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_BusLogic;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_I82078;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_LsiLogicSas;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmController, N_("Invalid value '%s' for StorageController/@type attribute"), strType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllerAttributes(*pelmController, sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlAttached(*pelmController, "AttachedDevice");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // starting with 1.9 we list DVD and floppy drive info + attachments under <StorageControllers>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAttached->getAttributeValue("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // all types can have images attached, but for HardDisk it's required
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmImage = pelmAttached->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/Image element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // DVDs and floppies can also have <HostDrive> instead of <Image>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmHostDrive = pelmAttached->findChildElement("HostDrive")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHostDrive->getAttributeValue("src", att.strHostDriveSrc))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHostDrive, N_("Required AttachedDevice/HostDrive/@src attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmImage->getAttributeValue("uuid", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/Image/@uuid attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttached->getAttributeValue("port", att.lPort))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/@port attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttached->getAttributeValue("device", att.lDevice))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/@device attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This gets called for legacy pre-1.9 settings files after having parsed the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * <Hardware> and <StorageControllers> sections to parse <Hardware> once more
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * for the <DVDDrive> and <FloppyDrive> sections.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Before settings version 1.9, DVD and floppy drives were specified separately
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * under <Hardware>; we then need this extra loop to make sure the storage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * controller structs are already set up so we can add stuff to them.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardware
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strg
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // create a DVD "attached device" and attach it to the existing IDE controller
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // legacy DVD drive is always secondary master (port 1, device 0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pDriveChild = pelmHwChild->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pDriveChild->getAttributeValue("uuid", strTmp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pDriveChild->getAttributeValue("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // find the IDE controller and attach the DVD drive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fFound = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::iterator it = strg.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Internal error: found DVD drive but IDE controller does not exist"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // shouldn't happen because pre-1.9 settings files always had at least one IDE controller in the settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // which should have gotten parsed in <StorageControllers> before this got called
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHwChild->getAttributeValue("enabled", fEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // create a new floppy controller and attach a floppy "attached device"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_I82078;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pDriveChild = pelmHwChild->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pDriveChild->getAttributeValue("uuid", strTmp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pDriveChild->getAttributeValue("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // store attachment with controller
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // store controller with storage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called initially for the <Snapshot> element under <Machine>, if present,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * to store the snapshot's data into the given Snapshot structure (which is
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * then the one in the Machine struct). This might then recurse if
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * a <Snapshots> (plural) element is found in the snapshot, which should
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * contain a list of child snapshots; such lists are maintained in the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Snapshot structure.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmSnapshot
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param snap
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("uuid", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@uuid attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("name", snap.strName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@name attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // earlier 3.1 trunk builds had a bug and added Description as an attribute, read it silently and write it back as an element
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmSnapshot.getAttributeValue("Description", snap.strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("timeStamp", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@timeStamp attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmSnapshot.getAttributeValue("stateFile", snap.strStateFile); // online snapshots only
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse Hardware before the other elements because other things depend on it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmHardware = elmSnapshot.findChildElement("Hardware")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@Hardware element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardware(*pelmHardware, snap.hardware, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmSnapshotChild = nlSnapshotChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync snap.strDescription = pelmSnapshotChild->getValue();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmSnapshotChild->nameEquals("HardDiskAttachments"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmSnapshotChild->nameEquals("StorageControllers"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllers(*pelmSnapshotChild, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmSnapshotChild->nameEquals("Snapshots"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlChildSnapshots(*pelmSnapshotChild);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmChildSnapshot = nlChildSnapshots.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // go through Hardware once more to repair the settings controller structures
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // with data from old DVDDrive and FloppyDrive elements
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readDVDAndFloppies_pre1_9(*pelmHardware, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncconst struct {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszOld;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszNew;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::convertOldOSType_pre1_5(Utf8Str &str)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (unsigned u = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from the constructor to actually read in the <Machine> element
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * of a machine config file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readMachine(const xml::ElementNode &elmMachine)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (elmMachine.getAttributeValue("uuid", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMachine.getAttributeValue("nameSync", fNameSync))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("Description", strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("stateFile", strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmMachine.getAttributeValue("currentSnapshot", str))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("snapshotFolder", strSnapshotFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMachine.getAttributeValue("currentStateModified", fCurrentStateModified))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmMachine.getAttributeValue("lastStateChange", str))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // constructor has called RTTimeNow(&timeLastStateChange) before
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse Hardware before the other elements because other things depend on it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmHardware = elmMachine.findChildElement("Hardware")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMachine, N_("Required Machine/Hardware element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardware(*pelmHardware, hardwareMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmMachineChild = nlRootChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMachineChild->nameEquals("HardDiskAttachments"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardDiskAttachments_pre1_7(*pelmMachineChild, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMachineChild->nameEquals("StorageControllers"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllers(*pelmMachineChild, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // this will recurse into child snapshots, if necessary
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmMachineChild->nameEquals("Description"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmMachineChild->nameEquals("Teleporter"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("enabled", fTeleporterEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("port", uTeleporterPort))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("address", strTeleporterAddress))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("password", strTeleporterPassword))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // go through Hardware once more to repair the settings controller structures
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // with data from old DVDDrive and FloppyDrive elements
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readDVDAndFloppies_pre1_9(*pelmHardware, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMachine, N_("Required Machine/@uuid or @name attributes is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Creates a <Hardware> node under elmParent and then writes out the XML
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * keys under that. Called for both the <Machine> node and for snapshots.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param st
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHardware = elmParent.createChild("Hardware");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHardware->setAttribute("version", hw.strVersion);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHardware->setAttribute("uuid", makeString(hw.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCPU = pelmHardware->createChild("CPU");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHwVirtEx = pelmCPU->createChild("HardwareVirtEx");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwVirtEx->setAttribute("enabled", hw.fHardwareVirt);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwVirtEx->setAttribute("exclusive", hw.fHardwareVirtExclusive);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("HardwareVirtExNestedPaging")->setAttribute("enabled", hw.fNestedPaging);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("HardwareVirtExVPID")->setAttribute("enabled", hw.fVPID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("PAE")->setAttribute("enabled", hw.fPAE);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("SyntheticCpu")->setAttribute("enabled", hw.fSyntheticCpu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("HardwareVirtExLargePages")->setAttribute("enabled", hw.fLargePages);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (CpuList::const_iterator it = hw.llCpus.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpu = pelmCpuTree->createChild("Cpu");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (CpuIdLeafsList::const_iterator it = hw.llCpuIdLeafs.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpuIdLeaf = pelmCpuIdTree->createChild("CpuIdLeaf");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmMemory = pelmHardware->createChild("Memory");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmMemory->setAttribute("RAMSize", hw.ulMemorySizeMB);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmFirmware = pelmHardware->createChild("Firmware");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case FirmwareType_EFI: pcszFirmware = "EFI"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case FirmwareType_EFI32: pcszFirmware = "EFI32"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case FirmwareType_EFI64: pcszFirmware = "EFI64"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case FirmwareType_EFIDUAL: pcszFirmware = "EFIDUAL"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHid = pelmHardware->createChild("HID");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszHid;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case PointingHidType_USBMouse: pcszHid = "USBMouse"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case PointingHidType_USBTablet: pcszHid = "USBTablet"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case PointingHidType_PS2Mouse: pcszHid = "PS2Mouse"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case PointingHidType_ComboMouse: pcszHid = "ComboMouse"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case PointingHidType_None: pcszHid = "None"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: Assert(false); pcszHid = "PS2Mouse"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case KeyboardHidType_USBKeyboard: pcszHid = "USBKeyboard"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case KeyboardHidType_PS2Keyboard: pcszHid = "PS2Keyboard"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case KeyboardHidType_ComboKeyboard: pcszHid = "ComboKeyboard"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case KeyboardHidType_None: pcszHid = "None"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: Assert(false); pcszHid = "PS2Keyboard"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHpet = pelmHardware->createChild("HPET");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHpet->setAttribute("enabled", hw.fHpetEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmBoot = pelmHardware->createChild("Boot");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (BootOrderMap::const_iterator it = hw.mapBootOrder.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_Floppy: pcszDevice = "Floppy"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_HardDisk: pcszDevice = "HardDisk"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_Network: pcszDevice = "Network"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*case DeviceType_Null:*/ pcszDevice = "None"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmOrder = pelmBoot->createChild("Order");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync i + 1); // XML is 1-based but internal data is 0-based
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmDisplay = pelmHardware->createChild("Display");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDisplay->setAttribute("VRAMSize", hw.ulVRAMSizeMB);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDisplay->setAttribute("monitorCount", hw.cMonitors);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDisplay->setAttribute("accelerate3D", hw.fAccelerate3D);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDisplay->setAttribute("accelerate2DVideo", hw.fAccelerate2DVideo);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmVRDP = pelmHardware->createChild("RemoteDisplay");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("enabled", hw.vrdpSettings.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("netAddress", hw.vrdpSettings.strNetAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case VRDPAuthType_Guest: pcszAuthType = "Guest"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case VRDPAuthType_External: pcszAuthType = "External"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*case VRDPAuthType_Null:*/ pcszAuthType = "Null"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("authTimeout", hw.vrdpSettings.ulAuthTimeout);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("allowMultiConnection", hw.vrdpSettings.fAllowMultiConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("reuseSingleConnection", hw.vrdpSettings.fReuseSingleConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmVideoChannel = pelmVRDP->createChild("VideoChannel");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->setAttribute("enabled", hw.vrdpSettings.fVideoChannel);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->setAttribute("quality", hw.vrdpSettings.ulVideoChannelQuality);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmBIOS = pelmHardware->createChild("BIOS");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOS->createChild("ACPI")->setAttribute("enabled", hw.biosSettings.fACPIEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOS->createChild("IOAPIC")->setAttribute("enabled", hw.biosSettings.fIOAPICEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmLogo = pelmBIOS->createChild("Logo");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmLogo->setAttribute("fadeIn", hw.biosSettings.fLogoFadeIn);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmLogo->setAttribute("fadeOut", hw.biosSettings.fLogoFadeOut);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmLogo->setAttribute("displayTime", hw.biosSettings.ulLogoDisplayTime);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmLogo->setAttribute("imagePath", hw.biosSettings.strLogoImagePath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case BIOSBootMenuMode_Disabled: pcszBootMenu = "Disabled"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case BIOSBootMenuMode_MenuOnly: pcszBootMenu = "MenuOnly"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*BIOSBootMenuMode_MessageAndMenu*/ pcszBootMenu = "MessageAndMenu"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOS->createChild("BootMenu")->setAttribute("mode", pcszBootMenu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmBIOS->createChild("TimeOffset")->setAttribute("value", hw.biosSettings.llTimeOffset);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmBIOS->createChild("PXEDebug")->setAttribute("enabled", hw.biosSettings.fPXEDebugEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // settings formats before 1.9 had separate DVDDrive and FloppyDrive items under Hardware;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // run thru the storage controllers to see if we have a DVD or floppy drives
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDVD = pelmHardware->createChild("DVDDrive");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmFloppy = pelmHardware->createChild("FloppyDrive");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (StorageControllersList::const_iterator it = strg.llStorageControllers.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // in old settings format, the DVD drive could only have been under the IDE controller
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: cannot save more than one DVD drive with old settings format"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->setAttribute("passthrough", att.fPassThrough);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync size_t cFloppiesHere = sctl.llAttachedDevices.size();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: floppy controller cannot have more than one device attachment"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const AttachedDevice &att = sctl.llAttachedDevices.front();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: cannot save more than one floppy drive with old settings format"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmUSB = pelmHardware->createChild("USBController");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmUSB->setAttribute("enabled", hw.usbController.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmUSB->setAttribute("enabledEhci", hw.usbController.fEnabledEHCI);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync false); // fHostMode
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (NetworkAdaptersList::const_iterator it = hw.llNetworkAdapters.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmAdapter = pelmNetwork->createChild("Adapter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("enabled", nic.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("MACAddress", nic.strMACAddress);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("cable", nic.fCableConnected);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("speed", nic.ulLineSpeed);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("bootPriority", nic.ulBootPriority);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("trace", nic.fTraceEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("tracefile", nic.strTraceFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAdapterType_Am79C973: pcszType = "Am79C973"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAdapterType_I82540EM: pcszType = "82540EM"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAdapterType_I82543GC: pcszType = "82543GC"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAdapterType_I82545EM: pcszType = "82545EM"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAdapterType_Virtio: pcszType = "virtio"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case NetworkAdapterType_Am79C970A:*/ pcszType = "Am79C970A"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("network", nic.nat.strNetwork);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case NetworkAttachmentType_Null:*/
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /* m->sv >= SettingsVersion_v1_10 */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPorts = pelmHardware->createChild("UART");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (SerialPortsList::const_iterator it = hw.llSerialPorts.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttributeHex("IOBase", port.ulIOBase);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_HostPipe: pcszHostMode = "HostPipe"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_HostDevice: pcszHostMode = "HostDevice"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_RawFile: pcszHostMode = "RawFile"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case PortMode_Disconnected:*/ pcszHostMode = "Disconnected"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /* no break */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (ParallelPortsList::const_iterator it = hw.llParallelPorts.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttributeHex("IOBase", port.ulIOBase);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmAudio = pelmHardware->createChild("AudioAdapter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAudio->setAttribute("controller", (hw.audioAdapter.controllerType == AudioControllerType_SB16) ? "SB16" : "AC97");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmRTC = pelmHardware->createChild("RTC");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmRTC->setAttribute("localOrUTC", fRTCUseUTC ? "UTC" : "local");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_WinMM: pcszDriver = "WinMM"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_DirectSound: pcszDriver = "DirectSound"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_SolAudio: pcszDriver = "SolAudio"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_OSS: pcszDriver = "OSS"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case AudioDriverType_MMPM: pcszDriver = "MMPM"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case AudioDriverType_Null:*/ pcszDriver = "Null"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAudio->setAttribute("enabled", hw.audioAdapter.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmSharedFolders = pelmHardware->createChild("SharedFolders");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (SharedFoldersList::const_iterator it = hw.llSharedFolders.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmThis = pelmSharedFolders->createChild("SharedFolder");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmThis->setAttribute("hostPath", sf.strHostPath);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmClip = pelmHardware->createChild("Clipboard");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszClip;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case ClipboardMode_Disabled: pcszClip = "Disabled"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case ClipboardMode_HostToGuest: pcszClip = "HostToGuest"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case ClipboardMode_GuestToHost: pcszClip = "GuestToHost"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case ClipboardMode_Bidirectional:*/ pcszClip = "Bidirectional"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmIo = pelmHardware->createChild("IO");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszTemp;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIo->createChild("IoMgr")->setAttribute("type", pcszTemp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoBackendType_Buffered: pcszTemp = "Buffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIo->createChild("IoBackend")->setAttribute("type", pcszTemp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIoCache->setAttribute("enabled", hw.ioSettings.fIoCacheEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIoCache->setAttribute("size", hw.ioSettings.ulIoCacheSize);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIoBandwidth = pelmIo->createChild("IoBandwidth");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIoBandwidth->setAttribute("max", hw.ioSettings.ulIoBandwidthMax);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGuestProps = pelmHardware->createChild("GuestProperties");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (GuestPropertiesList::const_iterator it = hw.llGuestProperties.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmProp = pelmGuestProps->createChild("GuestProperty");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("timestamp", prop.timestamp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGuestProps->setAttribute("notificationPatterns", hw.strNotificationPatterns);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Fill a <Network> node. Only relevant for XML version >= v1_10.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param mode
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmParent
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param nice
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("hostip", nic.nat.strBindIP);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDNS->setAttribute("pass-domain", nic.nat.fDnsPassDomain);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDNS->setAttribute("use-proxy", nic.nat.fDnsProxy);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDNS->setAttribute("use-host-resolver", nic.nat.fDnsUseHostResolver);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAlias->setAttribute("logging", nic.nat.fAliasLog);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAlias->setAttribute("proxy-only", nic.nat.fAliasProxyOnly);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAlias->setAttribute("use-same-ports", nic.nat.fAliasUseSamePorts);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("prefix", nic.nat.strTftpPrefix);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("boot-file", nic.nat.strTftpBootFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("next-server", nic.nat.strTftpNextServer);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (NATRuleList::const_iterator rule = nic.nat.llRules.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("hostport", (*rule).u16HostPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("guestip", (*rule).strGuestIP);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("guestport", (*rule).u16GuestPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case NetworkAttachmentType_Null:*/
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Creates a <StorageControllers> node under elmParent and then writes out the XML
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * keys under that. Called for both the <Machine> node and for snapshots.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmParent
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param st
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmStorageControllers = elmParent.createChild("StorageControllers");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (StorageControllersList::const_iterator it = st.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (sc.controllerType == StorageControllerType_I82078)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // floppy controller already got written into <Hardware>/<FloppyController> in writeHardware()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // for pre-1.9 settings
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmController = pelmStorageControllers->createChild("StorageController");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.8 settings use shorter controller names, they are
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // expanded when reading the settings
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_IntelAhci: pcszType = "AHCI"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_LsiLogic: pcszType = "LsiLogic"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_BusLogic: pcszType = "BusLogic"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_PIIX4: pcszType = "PIIX4"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_ICH6: pcszType = "ICH6"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_I82078: pcszType = "I82078"; break;
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync case StorageControllerType_LsiLogicSas: pcszType = "LsiLogicSas"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*case StorageControllerType_PIIX3:*/ pcszType = "PIIX3"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("PortCount", sc.ulPortCount);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmController->setAttribute("Instance", sc.ulInstance);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoBackendType_Unbuffered: pcszIoBackend = "Unbuffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case IoBackendType_Buffered:*/ pcszIoBackend = "Buffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IoBackend", pcszIoBackend);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (sc.controllerType == StorageControllerType_IntelAhci)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IDE0MasterEmulationPort", sc.lIDE0MasterEmulationPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IDE0SlaveEmulationPort", sc.lIDE0SlaveEmulationPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IDE1MasterEmulationPort", sc.lIDE1MasterEmulationPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IDE1SlaveEmulationPort", sc.lIDE1SlaveEmulationPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (AttachedDevicesList::const_iterator it2 = sc.llAttachedDevices.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // For settings version before 1.9, DVDs and floppies are in hardware, not storage controllers,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // so we shouldn't write them here; we only get here for DVDs though because we ruled out
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // the floppy controller at the top of the loop
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDevice = pelmController->createChild("AttachedDevice");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->setAttribute("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * <Machine> node to which <Snapshot> must be added. This may then recurse for child snapshots.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param snap
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmSnapshot = elmParent.createChild("Snapshot");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("uuid", makeString(snap.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("timeStamp", makeString(snap.timestamp));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("stateFile", snap.strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->createChild("Description")->addContent(snap.strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildHardwareXML(*pelmSnapshot, snap.hardware, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildStorageControllersXML(*pelmSnapshot, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmChildren = pelmSnapshot->createChild("Snapshots");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (SnapshotsList::const_iterator it = snap.llChildSnapshots.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Builds the XML DOM tree for the machine config under the given XML element.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This has been separated out from write() so it can be called from elsewhere,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * such as the OVF code, to build machine XML in an existing XML tree.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * As a result, this gets called from two locations:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- MachineConfigFile::write();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- Appliance::buildXMLForOneVirtualSystem()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * In fl, the following flag bits are recognized:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- BuildMachineXML_IncludeSnapshots: If set, descend into the snapshots tree
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * of the machine and write out <Snapshot> and possibly more snapshots under
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * that, if snapshots are present. Otherwise all snapshots are suppressed.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- BuildMachineXML_WriteVboxVersionAttribute: If set, add a settingsVersion
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * attribute to the machine tag with the vbox settings version. This is for
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the OVF export case in which we don't have the settings version set in
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the root element.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine XML <Machine> element to add attributes and elements to.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param fl Flags.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fl & BuildMachineXML_WriteVboxVersionAttribute)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // add settings version attribute to machine element
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.createChild("Description")->addContent(strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("stateFile", strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("currentSnapshot", makeString(uuidCurrentSnapshot));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("snapshotFolder", strSnapshotFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("currentStateModified", fCurrentStateModified);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("lastStateChange", makeString(timeLastStateChange));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmTeleporter = elmMachine.createChild("Teleporter");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTeleporter->setAttribute("enabled", fTeleporterEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTeleporter->setAttribute("port", uTeleporterPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTeleporter->setAttribute("address", strTeleporterAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTeleporter->setAttribute("password", strTeleporterPassword);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildSnapshotXML(elmMachine, llFirstSnapshot.front());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildHardwareXML(elmMachine, hardwareMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildStorageControllersXML(elmMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from write() before calling ConfigFileBase::createStubDocument().
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This adjusts the settings version in m->sv if incompatible settings require
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * a settings bump, whereas otherwise we try to preserve the settings version
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * to avoid breaking compatibility with older versions.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::bumpSettingsVersionIfNeeded()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // The hardware versions other than "1" requires settings version 1.4 (2.1+).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // "accelerate 2d video" requires settings version 1.8
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // all the following require settings version 1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( (hardwareMachine.firmwareType >= FirmwareType_EFI)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (hardwareMachine.fHardwareVirtExclusive != HWVIRTEXCLUSIVEDEFAULT)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings version 1.9 is also required if there is not exactly one DVD
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // or more than one floppy drive present or the DVD is not at the secondary
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // master; this check is a bit more complicated
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // need to run thru all the storage controllers to figure this out
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sctl.ulInstance != 0) // we can only write the StorageController/@Instance attribute with v1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (att.lPort != 1) // DVDs not at secondary master?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // The I/O backend setting is only supported with v.10
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox before 3.1 had zero or one floppy and exactly one DVD,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // so any deviation from that will require settings version 1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds support for CPU hotplug, RTC timezone control, HID type and HPET
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.pointingHidType != PointingHidType_PS2Mouse
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.keyboardHidType != KeyboardHidType_PS2Keyboard
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds NAT and boot priority to the NIC config in Main.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (netit = hardwareMachine.llNetworkAdapters.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync netit != hardwareMachine.llNetworkAdapters.end(); ++netit)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // Check for non default I/O settings and bump the settings version.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( hardwareMachine.ioSettings.fIoCacheEnabled != true
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ulIoBandwidthMax != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ioMgrType != IoMgrType_Async
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ioBackendType != IoBackendType_Unbuffered)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds support for VRDP video channel
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from Main code to write a machine config file to disk. This builds a DOM tree from
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * the member variables and then writes the XML file; it throws xml::Error instances on errors,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in particular if the file cannot be written.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::write(const com::Utf8Str &strFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // createStubDocument() sets the settings version to at least 1.7; however,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // we might need to enfore a later settings version if incompatible settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // are present:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachine = m->pelmRoot->createChild("Machine");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync MachineConfigFile::BuildMachineXML_IncludeSnapshots);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // but not BuildMachineXML_WriteVboxVersionAttribute
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // now go write the XML
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writer.write(m->strFilename.c_str(), true /*fSafe*/);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync catch (...)