Settings.cpp revision 85d78ebc068381ca25c84242e38ec4b2be4843a5
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** @file
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Settings File Manipulation API.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
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 *
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 *
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 *
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * So, to introduce a new setting:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync *
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * 1) Make sure the constructor of corresponding settings structure has a proper default.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync *
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 *
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * So far a corresponding method for MainConfigFile has not been necessary since there
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * have been no incompatible changes yet.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/*
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Copyright (C) 2007-2010 Oracle Corporation
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "VBox/com/string.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "VBox/settings.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <iprt/cpp/xml.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <iprt/stream.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <iprt/ctype.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include <iprt/file.h>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// generated header
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "SchemaDefs.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#include "Logging.h"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncusing namespace com;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncusing namespace settings;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Defines
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings namespace */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define VBOX_XML_NAMESPACE "http://www.innotek.de/VirtualBox-settings"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings version number substring ("x.y") */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define VBOX_XML_VERSION "1.10"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings version platform substring */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#if defined (RT_OS_DARWIN)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "macosx"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_FREEBSD)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "freebsd"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_LINUX)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "linux"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_NETBSD)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "netbsd"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_OPENBSD)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "openbsd"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_OS2)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "os2"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_SOLARIS)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "solaris"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#elif defined (RT_OS_WINDOWS)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# define VBOX_XML_PLATFORM "windows"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync# error Unsupported platform!
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/** VirtualBox XML settings full version string ("x.y-platform") */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#define VBOX_XML_VERSION_FULL VBOX_XML_VERSION "-" VBOX_XML_PLATFORM
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Internal data
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Opaque data structore for ConfigFileBase (only declared
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in header, defined only here).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncstruct ConfigFileBase::Data
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Data()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : pDoc(NULL),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmRoot(NULL),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sv(SettingsVersion_Null),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync svRead(SettingsVersion_Null)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ~Data()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync cleanup();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync iprt::MiniString strFilename;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fFileExists;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::Document *pDoc;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmRoot;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync com::Utf8Str strSettingsVersionFull; // e.g. "1.7-linux"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SettingsVersion_T sv; // e.g. SettingsVersion_v1_7
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SettingsVersion_T svRead; // settings version that the original file had when it was read,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // or SettingsVersion_Null if none
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync void copyFrom(const Data &d)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFilename = d.strFilename;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fFileExists = d.fFileExists;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strSettingsVersionFull = d.strSettingsVersionFull;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sv = d.sv;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync svRead = d.svRead;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync void cleanup()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pDoc)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync delete pDoc;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pDoc = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmRoot = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync};
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncclass settings::ConfigFileError : public xml::LogicError
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncpublic:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ConfigFileError(const ConfigFileBase *file,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::Node *pNode,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszFormat, ...)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : xml::LogicError()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync va_list args;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync va_start(args, pcszFormat);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8StrFmtVA strWhat(pcszFormat, args);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync va_end(args);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strLine;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pNode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strLine = Utf8StrFmt(" (line %RU32)", pNode->getLineNumber());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz = strLine.c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8StrFmt str(N_("Error in %s%s -- %s"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync file->m->strFilename.c_str(),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (pcsz) ? pcsz : "",
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strWhat.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync setWhat(str.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync};
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// ConfigFileBase
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor. Allocates the XML internals.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strFilename
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncConfigFileBase::ConfigFileBase(const com::Utf8Str *pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : m(new Data)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strMajor;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strMinor;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->fFileExists = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // reading existing settings file:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->strFilename = *pstrFilename;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::XmlFileParser parser;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->pDoc = new xml::Document;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parser.read(*pstrFilename,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *m->pDoc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->fFileExists = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->pelmRoot = m->pDoc->getRootElement();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!m->pelmRoot || !m->pelmRoot->nameEquals("VirtualBox"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("Root element in VirtualBox settings files must be \"VirtualBox\"."));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(m->pelmRoot->getAttributeValue("version", m->strSettingsVersionFull)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, m->pelmRoot, N_("Required VirtualBox/@version attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync LogRel(("Loading settings file \"%s\" with version \"%s\"\n", m->strFilename.c_str(), m->strSettingsVersionFull.c_str()));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse settings version; allow future versions but fail if file is older than 1.6
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_Null;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->strSettingsVersionFull.length() > 3)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz = m->strSettingsVersionFull.c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync char c;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ( (c = *pcsz)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && RT_C_IS_DIGIT(c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strMajor.append(c);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++pcsz;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (*pcsz++ == '.')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ( (c = *pcsz)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && RT_C_IS_DIGIT(c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strMinor.append(c);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++pcsz;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t ulMajor = RTStrToUInt32(strMajor.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t ulMinor = RTStrToUInt32(strMinor.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (ulMajor == 1)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (ulMinor == 3)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_3;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 4)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_4;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 5)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_5;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 6)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_6;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_7;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 8)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_8;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor == 10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMinor > 10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_Future;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (ulMajor > 1)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_Future;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync LogRel(("Parsed settings version %d.%d to enum value %d\n", ulMajor, ulMinor, m->sv));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv == SettingsVersion_Null)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, m->pelmRoot, N_("Cannot handle settings version '%s'"), m->strSettingsVersionFull.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // remember the settings version we read in case it gets upgraded later,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // so we know when to make backups
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->svRead = m->sv;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // creating new settings file:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->strSettingsVersionFull = VBOX_XML_VERSION_FULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Clean up.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncConfigFileBase::~ConfigFileBase()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync delete m;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::parseUUID(Guid &guid,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Utf8Str &strUUID) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // {5f102a55-a51b-48e3-b45a-b28d33469488}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 01234567890123456789012345678901234567
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 1 2 3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (strUUID[0] == '{')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strUUID[37] == '}')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync guid = strUUID.substr(1, 36).c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync guid = strUUID.c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (guid.isEmpty())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("UUID \"%s\" has invalid format"), strUUID.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::parseTimestamp(RTTIMESPEC &timestamp,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const com::Utf8Str &str) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz = str.c_str();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // yyyy-mm-ddThh:mm:ss
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // "2009-07-10T11:54:03Z"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 01234567890123456789
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // 1
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (str.length() > 19)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // timezone must either be unspecified or 'Z' for UTC
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pcsz[19])
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pcsz[19] != 'Z')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, NULL, N_("Cannot handle ISO timestamp '%s': is not UTC date"), str.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync int32_t yyyy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t mm, dd, hh, min, secs;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pcsz[4] == '-')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pcsz[7] == '-')
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pcsz[10] == 'T')
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (pcsz[13] == ':')
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (pcsz[16] == ':')
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync int rc;
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 )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync RTTIME time =
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync yyyy,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint8_t)mm,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync 0,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync 0,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint8_t)dd,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint8_t)hh,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint8_t)min,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint8_t)secs,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync 0,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync RTTIME_FLAGS_TYPE_UTC,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync 0
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync };
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (RTTimeNormalize(&time))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (RTTimeImplode(&timestamp, &time))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync return;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Cannot parse ISO timestamp '%s': runtime error, %Rra"), str.c_str(), rc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Cannot parse ISO timestamp '%s': invalid format"), str.c_str());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Helper to create a string for a RTTIMESPEC for writing out ISO timestamps.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param stamp
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @return
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsynccom::Utf8Str ConfigFileBase::makeString(const RTTIMESPEC &stamp)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync RTTIME time;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!RTTimeExplode(&time, &stamp))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Timespec %lld ms is invalid"), RTTimeSpecGetMilli(&stamp));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync return Utf8StrFmt("%04ld-%02hd-%02hdT%02hd:%02hd:%02hdZ",
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync time.i32Year,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint16_t)time.u8Month,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint16_t)time.u8MonthDay,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint16_t)time.u8Hour,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint16_t)time.u8Minute,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync (uint16_t)time.u8Second);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Helper to create a string for a GUID.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param guid
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @return
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsynccom::Utf8Str ConfigFileBase::makeString(const Guid &guid)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync Utf8Str str("{");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync str.append(guid.toString());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync str.append("}");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync return str;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::readExtraData(const xml::ElementNode &elmExtraData,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ExtraDataItemsMap &map)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nlLevel4(elmExtraData);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const xml::ElementNode *pelmExtraDataItem;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmExtraDataItem = nlLevel4.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmExtraDataItem->nameEquals("ExtraDataItem"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // <ExtraDataItem name="GUI/LastWindowPostion" value="97,88,981,858"/>
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync Utf8Str strName, strValue;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( ((pelmExtraDataItem->getAttributeValue("name", strName)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && ((pelmExtraDataItem->getAttributeValue("value", strValue)))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync map[strName] = strValue;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, pelmExtraDataItem, N_("Required ExtraDataItem/@name or @value attribute is missing"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync USBDeviceFiltersList &ll)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nl1(elmDeviceFilters, "DeviceFilter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const xml::ElementNode *pelmLevel4Child;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmLevel4Child = nl1.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync USBDeviceFilter flt;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync flt.action = USBDeviceFilterAction_Ignore;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync Utf8Str strAction;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( (pelmLevel4Child->getAttributeValue("name", flt.strName))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (pelmLevel4Child->getAttributeValue("active", flt.fActive))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // the next 2 are irrelevant for host USB objects
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("remote", flt.strRemote);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmLevel4Child->getAttributeValue("maskedInterfaces", flt.ulMaskedInterfaces);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // action is only used with host USB objects
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmLevel4Child->getAttributeValue("action", strAction))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (strAction == "Ignore")
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync flt.action = USBDeviceFilterAction_Ignore;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (strAction == "Hold")
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync flt.action = USBDeviceFilterAction_Hold;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, pelmLevel4Child, N_("Invalid value '%s' in DeviceFilter/@action attribute"), strAction.c_str());
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ll.push_back(flt);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::setVersionAttribute(xml::ElementNode &elm)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszVersion = NULL;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (m->sv)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case SettingsVersion_v1_8:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszVersion = "1.8";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case SettingsVersion_v1_9:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszVersion = "1.9";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case SettingsVersion_v1_10:
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 pcszVersion = "1.10";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->sv = SettingsVersion_v1_10;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // silently upgrade if this is less than 1.7 because that's the oldest we can write
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszVersion = "1.7";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->sv = SettingsVersion_v1_7;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elm.setAttribute("version", Utf8StrFmt("%s-%s",
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszVersion,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync VBOX_XML_PLATFORM)); // e.g. "linux"
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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 *
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 */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid ConfigFileBase::createStubDocument()
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync Assert(m->pDoc == NULL);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->pDoc = new xml::Document;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->pelmRoot = m->pDoc->createRootElement("VirtualBox");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // add settings version attribute to root element
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync setVersionAttribute(*m->pelmRoot);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
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 && (m->svRead < m->sv) // we're upgrading?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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("-");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFilenameNew.append(m->strSettingsVersionFull); // e.g. "1.3-linux"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFilenameNew.append(".xml");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync RTFileMove(m->strFilename.c_str(),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFilenameNew.c_str(),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync 0); // no RTFILEMOVE_FLAGS_REPLACE
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // do this only once
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->svRead = SettingsVersion_Null;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Creates an <ExtraData> node under the given parent element with
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * <ExtraDataItem> childern according to the contents of the given
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * map.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is in ConfigFileBase because it's used in both MainConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * MachineConfigFile, which both can have extradata.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param me
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::writeExtraData(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const ExtraDataItemsMap &me)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (me.size())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmExtraData = elmParent.createChild("ExtraData");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (ExtraDataItemsMap::const_iterator it = me.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != me.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Utf8Str &strName = it->first;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Utf8Str &strValue = it->second;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmThis = pelmExtraData->createChild("ExtraDataItem");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("name", strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("value", strValue);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmParent
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param fHostMode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::writeUSBDeviceFilters(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const USBDeviceFiltersList &ll,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fHostMode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (USBDeviceFiltersList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != ll.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const USBDeviceFilter &flt = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmFilter = elmParent.createChild("DeviceFilter");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("name", flt.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("active", flt.fActive);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strVendorId.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("vendorId", flt.strVendorId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strProductId.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("productId", flt.strProductId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strRevision.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("revision", flt.strRevision);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strManufacturer.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("manufacturer", flt.strManufacturer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strProduct.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("product", flt.strProduct);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strSerialNumber.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("serialNumber", flt.strSerialNumber);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strPort.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("port", flt.strPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fHostMode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcsz =
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (flt.action == USBDeviceFilterAction_Ignore) ? "Ignore"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : /*(flt.action == USBDeviceFilterAction_Hold) ?*/ "Hold";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("action", pcsz);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.strRemote.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("remote", flt.strRemote);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (flt.ulMaskedInterfaces)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFilter->setAttribute("maskedInterfaces", flt.ulMaskedInterfaces);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::clearDocument()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->cleanup();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 * @return
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool ConfigFileBase::fileExists()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return m->fFileExists;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param b
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid ConfigFileBase::copyBaseFrom(const ConfigFileBase &b)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->copyFrom(*b.m);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Structures shared between Machine XML and VirtualBox.xml
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool USBDeviceFilter::operator==(const USBDeviceFilter &u) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &u)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (strName == u.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fActive == u.fActive)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strVendorId == u.strVendorId)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strProductId == u.strProductId)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strRevision == u.strRevision)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strManufacturer == u.strManufacturer)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strProduct == u.strProduct)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strSerialNumber == u.strSerialNumber)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strPort == u.strPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (action == u.action)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strRemote == u.strRemote)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulMaskedInterfaces == u.ulMaskedInterfaces)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// MainConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads one <MachineEntry> from the main VirtualBox.xml file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachineRegistry
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readMachineRegistry(const xml::ElementNode &elmMachineRegistry)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <MachineEntry uuid="{ xxx }" src=" xxx "/>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmMachineRegistry);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmChild1;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmChild1 = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmChild1->nameEquals("MachineEntry"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync MachineRegistryEntry mre;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUUID;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pelmChild1->getAttributeValue("uuid", strUUID)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ((pelmChild1->getAttributeValue("src", mre.strSettingsFile)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(mre.uuid, strUUID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llMachines.push_back(mre);
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync }
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync else
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync throw ConfigFileError(this, pelmChild1, N_("Required MachineEntry/@uuid or @src attribute is missing"));
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync }
7dfba437bd13a51c7e3ff98ca483289fbdbf8df1vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads a media registry entry from the main VirtualBox.xml file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param t
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMedium
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param llMedia
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readMedium(MediaType t,
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{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <HardDisk uuid="{5471ecdb-1ddb-4012-a801-6d98e226868b}" location="/mnt/innotek-unix/vdis/Windows XP.vdi" format="VDI" type="Normal">
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync settings::Medium med;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUUID;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("uuid", strUUID)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@uuid attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(med.uuid, strUUID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fNeedsLocation = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (t == HardDisk)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_4)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // here the system is:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <HardDisk uuid="{....}" type="normal">
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // <VirtualDiskImage filePath="/path/to/xxx.vdi"/>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // </HardDisk>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNeedsLocation = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fNeedsFilePath = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmImage;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmImage = elmMedium.findChildElement("VirtualDiskImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strFormat = "VDI";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("VMDKImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strFormat = "VMDK";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("VHDImage")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strFormat = "VHD";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("ISCSIHardDisk")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strFormat = "iSCSI";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNeedsFilePath = false;
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 med.strLocation = "iscsi://";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUser, strServer, strPort, strTarget, strLun;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("userName", strUser))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append(strUser);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append("@");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strServerAndPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("server", strServer))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strServerAndPort = strServer;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("port", strPort))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strServerAndPort.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strServerAndPort.append(":");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strServerAndPort.append(strPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append(strServerAndPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("target", strTarget))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append("/");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append(strTarget);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("lun", strLun))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append("/");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.strLocation.append(strLun);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strServer.length() && strPort.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["TargetAddress"] = strServerAndPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTarget.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["TargetName"] = strTarget;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strUser.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["InitiatorUsername"] = strUser;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strPassword;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmImage->getAttributeValue("password", strPassword))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["InitiatorSecret"] = strPassword;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strLun.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties["LUN"] = strLun;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pelmImage = elmMedium.findChildElement("CustomHardDisk")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNeedsFilePath = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNeedsLocation = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // also requires @format attribute, which will be queried below
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/VirtualDiskImage element is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fNeedsFilePath)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmImage->getAttributeValue("filePath", med.strLocation)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("Required %s/@filePath attribute is missing"), elmMedium.getName());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(elmMedium.getAttributeValue("autoReset", med.fAutoReset)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.fAutoReset = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((elmMedium.getAttributeValue("type", strType)))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.4 used lower case, so make this case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strType.toUpper();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strType == "NORMAL")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.hdType = MediumType_Normal;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "IMMUTABLE")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.hdType = MediumType_Immutable;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "WRITETHROUGH")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.hdType = MediumType_Writethrough;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMedium, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (m->sv < SettingsVersion_v1_4)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNeedsLocation = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fNeedsLocation)
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMedium.getAttributeValue("Description", med.strDescription); // optional
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // recurse to handle children
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl2(elmMedium);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHDChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmHDChild = nl2.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( t == HardDisk
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( pelmHDChild->nameEquals("HardDisk")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (m->sv < SettingsVersion_v1_4)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmHDChild->nameEquals("DiffHardDisk"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // recurse with this element and push the child onto our current children list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMedium(t,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *pelmHDChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.llChildren);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHDChild->nameEquals("Property"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strPropName, strPropValue;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHDChild->getAttributeValue("name", strPropName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmHDChild->getAttributeValue("value", strPropValue))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync med.properties[strPropName] = strPropValue;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHDChild, N_("Required HardDisk/Property/@name or @value attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llMedia.push_back(med);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in the entire <MediaRegistry> chunk. For pre-1.4 files, this gets called
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * with the <DiskRegistry> chunk instead.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMediaRegistry
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readMediaRegistry(const xml::ElementNode &elmMediaRegistry)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmMediaRegistry);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmChild1;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmChild1 = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync MediaType t = Error;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmChild1->nameEquals("HardDisks"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = HardDisk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmChild1->nameEquals("DVDImages"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = DVDImage;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmChild1->nameEquals("FloppyImages"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync t = FloppyImage;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync continue;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl2(*pelmChild1);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmMedium;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmMedium = nl2.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( t == HardDisk
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMedium->nameEquals("HardDisk"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMedium(t,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *pelmMedium,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llHardDisks); // list to append hard disk data to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( t == DVDImage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMedium->nameEquals("Image"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMedium(t,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *pelmMedium,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llDvdImages); // list to append dvd images to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( t == FloppyImage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMedium->nameEquals("Image"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMedium(t,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *pelmMedium,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llFloppyImages); // list to append floppy images to: the root list
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Reads in the <DHCPServers> chunk.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmDHCPServers
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MainConfigFile::readDHCPServers(const xml::ElementNode &elmDHCPServers)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmDHCPServers);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmServer;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmServer = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmServer->nameEquals("DHCPServer"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync DHCPServer srv;
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 )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llDhcpServers.push_back(srv);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmServer, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
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 *
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param strFilename
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncMainConfigFile::MainConfigFile(const Utf8Str *pstrFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync : ConfigFileBase(pstrFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pstrFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // the ConfigFileBase constructor has loaded the XML file, so now
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // we need only analyze what is in there
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nlRootChildren(*m->pelmRoot);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const xml::ElementNode *pelmRootChild;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmRootChild = nlRootChildren.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmRootChild->nameEquals("Global"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nlGlobalChildren(*pelmRootChild);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const xml::ElementNode *pelmGlobalChild;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmGlobalChild = nlGlobalChildren.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmGlobalChild->nameEquals("SystemProperties"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("ExtraData"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readExtraData(*pelmGlobalChild, mapExtraDataItems);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("MachineRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readMachineRegistry(*pelmGlobalChild);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if ( (pelmGlobalChild->nameEquals("MediaRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync || ( (m->sv < SettingsVersion_v1_4)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && (pelmGlobalChild->nameEquals("DiskRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readMediaRegistry(*pelmGlobalChild);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("NetserviceRegistry"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::NodesLoop nlLevel4(*pelmGlobalChild);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const xml::ElementNode *pelmLevel4Child;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync while ((pelmLevel4Child = nlLevel4.forAllNodes()))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (pelmLevel4Child->nameEquals("DHCPServers"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readDHCPServers(*pelmLevel4Child);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (pelmGlobalChild->nameEquals("USBDeviceFilters"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync readUSBDeviceFilters(*pelmGlobalChild, host.llUSBDeviceFilters);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync } // end if (pelmRootChild->nameEquals("Global"))
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync clearDocument();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
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 if ( (!llDhcpServers.size())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && ( (!pstrFilename) // empty VirtualBox.xml file
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync || (m->sv < SettingsVersion_v1_7) // upgrading from before 1.7
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync DHCPServer srv;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.strNetworkName =
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync#ifdef RT_OS_WINDOWS
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync "HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync#else
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync "HostInterfaceNetworking-vboxnet0";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync#endif
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.strIPAddress = "192.168.56.100";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.strIPNetworkMask = "255.255.255.0";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.strIPLower = "192.168.56.101";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.strIPUpper = "192.168.56.254";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync srv.fEnabled = true;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync llDhcpServers.push_back(srv);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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 *
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmMedium
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param m
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param level
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MainConfigFile::writeHardDisk(xml::ElementNode &elmMedium,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const Medium &mdm,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync uint32_t level) // 0 for "root" call, incremented with each recursion
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
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 if (mdm.fAutoReset)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("autoReset", mdm.fAutoReset);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (mdm.strDescription.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (PropertiesMap::const_iterator it = mdm.properties.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != mdm.properties.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmProp = pelmHardDisk->createChild("Property");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("name", it->first);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("value", it->second);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // only for base hard disks, save the type
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (level == 0)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType =
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync mdm.hdType == MediumType_Normal ? "Normal" :
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync mdm.hdType == MediumType_Immutable ? "Immutable" :
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /*mdm.hdType == MediumType_Writethrough ?*/ "Writethrough";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmHardDisk->setAttribute("type", pcszType);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = mdm.llChildren.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != mdm.llChildren.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // recurse for children
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writeHardDisk(*pelmHardDisk, // parent
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync *it, // settings::Medium
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++level); // recursion level
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Called from the IVirtualBox interface to write out VirtualBox.xml. This
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * builds an XML DOM tree and writes it out to disk.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MainConfigFile::write(const com::Utf8Str strFilename)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->strFilename = strFilename;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync createStubDocument();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGlobal = m->pelmRoot->createChild("Global");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writeExtraData(*pelmGlobal, mapExtraDataItems);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachineRegistry = pelmGlobal->createChild("MachineRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MachinesRegistry::const_iterator it = llMachines.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != llMachines.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 const MachineRegistryEntry &mre = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachineEntry = pelmMachineRegistry->createChild("MachineEntry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMachineEntry->setAttribute("uuid", makeString(mre.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMachineEntry->setAttribute("src", mre.strSettingsFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMediaRegistry = pelmGlobal->createChild("MediaRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmHardDisks = pelmMediaRegistry->createChild("HardDisks");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llHardDisks.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != llHardDisks.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writeHardDisk(*pelmHardDisks, *it, 0);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDVDImages = pelmMediaRegistry->createChild("DVDImages");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llDvdImages.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != llDvdImages.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const Medium &mdm = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMedium = pelmDVDImages->createChild("Image");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("uuid", makeString(mdm.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("location", mdm.strLocation);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (mdm.strDescription.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmFloppyImages = pelmMediaRegistry->createChild("FloppyImages");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (MediaList::const_iterator it = llFloppyImages.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != llFloppyImages.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const Medium &mdm = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMedium = pelmFloppyImages->createChild("Image");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("uuid", makeString(mdm.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("location", mdm.strLocation);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (mdm.strDescription.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmMedium->setAttribute("Description", mdm.strDescription);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNetserviceRegistry = pelmGlobal->createChild("NetserviceRegistry");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDHCPServers = pelmNetserviceRegistry->createChild("DHCPServers");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (DHCPServersList::const_iterator it = llDhcpServers.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != llDhcpServers.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const DHCPServer &d = *it;
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("lowerIP", d.strIPLower);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("upperIP", d.strIPUpper);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmThis->setAttribute("enabled", (d.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync writeUSBDeviceFilters(*pelmGlobal->createChild("USBDeviceFilters"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync host.llUSBDeviceFilters,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync true); // fHostMode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // now go write the XML
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::XmlFileWriter writer(*m->pDoc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync writer.write(m->strFilename.c_str(), true /*fSafe*/);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->fFileExists = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync clearDocument();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// Machine XML structures
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool VRDPSettings::operator==(const VRDPSettings& v) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &v)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (fEnabled == v.fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strPort == v.strPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strNetAddress == v.strNetAddress)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (authType == v.authType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulAuthTimeout == v.ulAuthTimeout)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fAllowMultiConnection == v.fAllowMultiConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fReuseSingleConnection == v.fReuseSingleConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fVideoChannel == v.fVideoChannel)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulVideoChannelQuality == v.ulVideoChannelQuality)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool BIOSSettings::operator==(const BIOSSettings &d) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &d)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( fACPIEnabled == d.fACPIEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && fIOAPICEnabled == d.fIOAPICEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && fLogoFadeIn == d.fLogoFadeIn
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && fLogoFadeOut == d.fLogoFadeOut
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ulLogoDisplayTime == d.ulLogoDisplayTime
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && strLogoImagePath == d.strLogoImagePath
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && biosBootMenuMode == d.biosBootMenuMode
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && fPXEDebugEnabled == d.fPXEDebugEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && llTimeOffset == d.llTimeOffset)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool USBController::operator==(const USBController &u) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &u)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (fEnabled == u.fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fEnabledEHCI == u.fEnabledEHCI)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llDeviceFilters == u.llDeviceFilters)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool NetworkAdapter::operator==(const NetworkAdapter &n) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &n)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (ulSlot == n.ulSlot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (type == n.type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fEnabled == n.fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strMACAddress == n.strMACAddress)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fCableConnected == n.fCableConnected)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulLineSpeed == n.ulLineSpeed)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fTraceEnabled == n.fTraceEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strTraceFile == n.strTraceFile)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (mode == n.mode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (nat == n.nat)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strName == n.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulBootPriority == n.ulBootPriority)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fHasDisabledNAT == n.fHasDisabledNAT)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool SerialPort::operator==(const SerialPort &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (ulSlot == s.ulSlot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fEnabled == s.fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulIOBase == s.ulIOBase)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulIRQ == s.ulIRQ)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (portMode == s.portMode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strPath == s.strPath)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fServer == s.fServer)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool ParallelPort::operator==(const ParallelPort &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (ulSlot == s.ulSlot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fEnabled == s.fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulIOBase == s.ulIOBase)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulIRQ == s.ulIRQ)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strPath == s.strPath)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool SharedFolder::operator==(const SharedFolder &g) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &g)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (strName == g.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strHostPath == g.strHostPath)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fWritable == g.fWritable)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool GuestProperty::operator==(const GuestProperty &g) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &g)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (strName == g.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strValue == g.strValue)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (timestamp == g.timestamp)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strFlags == g.strFlags)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync #define HWVIRTEXCLUSIVEDEFAULT false
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync #define HWVIRTEXCLUSIVEDEFAULT true
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Hardware struct constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncHardware::Hardware()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : strVersion("1"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fHardwareVirt(true),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fHardwareVirtExclusive(HWVIRTEXCLUSIVEDEFAULT),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNestedPaging(true),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fLargePages(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fVPID(true),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fSyntheticCpu(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fPAE(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync cCPUs(1),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fCpuHotPlug(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fHpetEnabled(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulMemorySizeMB((uint32_t)-1),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulVRAMSizeMB(8),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync cMonitors(1),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fAccelerate3D(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fAccelerate2DVideo(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync firmwareType(FirmwareType_BIOS),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pointingHidType(PointingHidType_PS2Mouse),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync keyboardHidType(KeyboardHidType_PS2Keyboard),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync clipboardMode(ClipboardMode_Bidirectional),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulMemoryBalloonSize(0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync mapBootOrder[0] = DeviceType_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync mapBootOrder[1] = DeviceType_DVD;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync mapBootOrder[2] = DeviceType_HardDisk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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 */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#if HC_ARCH_BITS == 64 || defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fPAE = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool Hardware::operator==(const Hardware& h) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &h)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (strVersion == h.strVersion)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (uuid == h.uuid)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fHardwareVirt == h.fHardwareVirt)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fHardwareVirtExclusive == h.fHardwareVirtExclusive)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fNestedPaging == h.fNestedPaging)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fLargePages == h.fLargePages)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fVPID == h.fVPID)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fSyntheticCpu == h.fSyntheticCpu)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fPAE == h.fPAE)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (cCPUs == h.cCPUs)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fCpuHotPlug == h.fCpuHotPlug)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fHpetEnabled == h.fHpetEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llCpus == h.llCpus)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llCpuIdLeafs == h.llCpuIdLeafs)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulMemorySizeMB == h.ulMemorySizeMB)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (mapBootOrder == h.mapBootOrder)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulVRAMSizeMB == h.ulVRAMSizeMB)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (cMonitors == h.cMonitors)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fAccelerate3D == h.fAccelerate3D)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fAccelerate2DVideo == h.fAccelerate2DVideo)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (firmwareType == h.firmwareType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pointingHidType == h.pointingHidType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (keyboardHidType == h.keyboardHidType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (vrdpSettings == h.vrdpSettings)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (biosSettings == h.biosSettings)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (usbController == h.usbController)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llNetworkAdapters == h.llNetworkAdapters)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llSerialPorts == h.llSerialPorts)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llParallelPorts == h.llParallelPorts)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (audioAdapter == h.audioAdapter)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llSharedFolders == h.llSharedFolders)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (clipboardMode == h.clipboardMode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulMemoryBalloonSize == h.ulMemoryBalloonSize)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llGuestProperties == h.llGuestProperties)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strNotificationPatterns == h.strNotificationPatterns)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool AttachedDevice::operator==(const AttachedDevice &a) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &a)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (deviceType == a.deviceType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fPassThrough == a.fPassThrough)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lPort == a.lPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lDevice == a.lDevice)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (uuid == a.uuid)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strHostDriveSrc == a.strHostDriveSrc)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool StorageController::operator==(const StorageController &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (strName == s.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (storageBus == s.storageBus)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (controllerType == s.controllerType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulPortCount == s.ulPortCount)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ulInstance == s.ulInstance)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (ioBackendType == s.ioBackendType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE0MasterEmulationPort == s.lIDE0MasterEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE0SlaveEmulationPort == s.lIDE0SlaveEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE1MasterEmulationPort == s.lIDE1MasterEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (lIDE1SlaveEmulationPort == s.lIDE1SlaveEmulationPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llAttachedDevices == s.llAttachedDevices)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool Storage::operator==(const Storage &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (llStorageControllers == s.llStorageControllers) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool Snapshot::operator==(const Snapshot &s) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &s)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (uuid == s.uuid)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strName == s.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strDescription == s.strDescription)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (RTTimeSpecIsEqual(&timestamp, &s.timestamp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strStateFile == s.strStateFile)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (hardware == s.hardware) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (storage == s.storage) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (llChildSnapshots == s.llChildSnapshots) // deep compare
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * IoSettings constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncIoSettings::IoSettings()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ioMgrType = IoMgrType_Async;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ioBackendType = IoBackendType_Unbuffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fIoCacheEnabled = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulIoCacheSize = 5;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulIoBandwidthMax = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync};
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync// MachineConfigFile
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync//
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync////////////////////////////////////////////////////////////////////////////////
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Constructor.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strFilename
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncMachineConfigFile::MachineConfigFile(const Utf8Str *pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync : ConfigFileBase(pstrFilename),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNameSync(true),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fTeleporterEnabled(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uTeleporterPort(0),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fRTCUseUTC(false),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fCurrentStateModified(true),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fAborted(false)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync RTTimeNow(&timeLastStateChange);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pstrFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // the ConfigFileBase constructor has loaded the XML file, so now
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // we need only analyze what is in there
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlRootChildren(*m->pelmRoot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmRootChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmRootChild = nlRootChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmRootChild->nameEquals("Machine"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMachine(*pelmRootChild);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // clean up memory allocated by XML engine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync clearDocument();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is used by the OVF code if a <vbox:Machine> element has been encountered
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * in an OVF VirtualSystem element.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::importMachineXML(const xml::ElementNode &elmMachine)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readMachine(elmMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
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 *
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncbool MachineConfigFile::operator==(const MachineConfigFile &c) const
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync return ( (this == &c)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ( (uuid == c.uuid)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strName == c.strName)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fNameSync == c.fNameSync)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strDescription == c.strDescription)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strOsType == c.strOsType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strStateFile == c.strStateFile)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (uuidCurrentSnapshot == c.uuidCurrentSnapshot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strSnapshotFolder == c.strSnapshotFolder)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fTeleporterEnabled == c.fTeleporterEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (uTeleporterPort == c.uTeleporterPort)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strTeleporterAddress == c.strTeleporterAddress)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strTeleporterPassword == c.strTeleporterPassword)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fRTCUseUTC == c.fRTCUseUTC)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // skip fCurrentStateModified!
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (RTTimeSpecIsEqual(&timeLastStateChange, &c.timeLastStateChange))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fAborted == c.fAborted)
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 )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync );
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read cpu information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmCpuid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readCpuTree(const xml::ElementNode &elmCpu,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync CpuList &ll)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmCpu, "Cpu");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmCpu;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmCpu = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Cpu cpu;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmCpu->getAttributeValue("id", cpu.ulId))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmCpu, N_("Required Cpu/@id attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ll.push_back(cpu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to cpuid information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmCpuid
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readCpuIdTree(const xml::ElementNode &elmCpuid,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync CpuIdLeafsList &ll)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmCpuid, "CpuIdLeaf");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmCpuIdLeaf;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmCpuIdLeaf = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync CpuIdLeaf leaf;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmCpuIdLeaf->getAttributeValue("id", leaf.ulId))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmCpuIdLeaf, N_("Required CpuId/@id attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ll.push_back(leaf);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to network information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmNetwork
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readNetworkAdapters(const xml::ElementNode &elmNetwork,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync NetworkAdaptersList &ll)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmNetwork, "Adapter");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmAdapter;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmAdapter = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync NetworkAdapter nic;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAdapter->getAttributeValue("slot", nic.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Required Adapter/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmAdapter->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "Am79C970A")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_Am79C970A;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "Am79C973")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_Am79C973;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "82540EM")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_I82540EM;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "82543GC")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_I82543GC;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "82545EM")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_I82545EM;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "virtio")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.type = NetworkAdapterType_Virtio;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Invalid value '%s' in Adapter/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNodesList llNetworkModes;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAdapter->getChildElements(llNetworkModes);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNodesList::iterator it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* We should have only active mode descriptor and disabled modes set */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (llNetworkModes.size() > 2)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAdapter, N_("Invalid number of modes ('%d') attached to Adapter attribute"), llNetworkModes.size());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (it = llNetworkModes.begin(); it != llNetworkModes.end(); ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmNode = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmNode->nameEquals("DisabledModes"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNodesList llDisabledNetworkModes;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNodesList::iterator itDisabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmNode->getChildElements(llDisabledNetworkModes);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* run over disabled list and load settings */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (itDisabled = llDisabledNetworkModes.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync itDisabled != llDisabledNetworkModes.end(); ++itDisabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmDisabledNode = *itDisabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readAttachedNetworkMode(*pelmDisabledNode, false, nic);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readAttachedNetworkMode(*pelmNode, true, nic);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // else: default is NetworkAttachmentType_Null
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ll.push_back(nic);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, bool fEnabled, NetworkAdapter &nic)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmMode.nameEquals("NAT"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.mode = NetworkAttachmentType_NAT;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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("mtu", nic.nat.u32Mtu);
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 const xml::ElementNode *pelmDNS;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmDNS = elmMode.findChildElement("DNS")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmAlias;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmAlias = elmMode.findChildElement("Alias")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmTFTP;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmTFTP = elmMode.findChildElement("TFTP")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("prefix", nic.nat.strTftpPrefix);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("boot-file", nic.nat.strTftpBootFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmTFTP->getAttributeValue("next-server", nic.nat.strTftpNextServer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNodesList plstNatPF;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getChildElements(plstNatPF, "Forwarding");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (xml::ElementNodesList::iterator pf = plstNatPF.begin(); pf != plstNatPF.end(); ++pf)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync NATRule rule;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t port = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("name", rule.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("proto", rule.u32Proto);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("hostip", rule.strHostIP);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("hostport", port);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rule.u16HostPort = port;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("guestip", rule.strGuestIP);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync (*pf)->getAttributeValue("guestport", port);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync rule.u16GuestPort = port;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.nat.llRules.push_back(rule);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( (elmMode.nameEquals("HostInterface"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (elmMode.nameEquals("BridgedInterface")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.mode = NetworkAttachmentType_Bridged;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("name", nic.strName); // optional host interface name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && elmMode.nameEquals("InternalNetwork"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.mode = NetworkAttachmentType_Internal;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMode.getAttributeValue("name", nic.strName)) // required network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMode, N_("Required InternalNetwork/@name element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && elmMode.nameEquals("HostOnlyInterface"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.mode = NetworkAttachmentType_HostOnly;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMode.getAttributeValue("name", nic.strName)) // required network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMode, N_("Required HostOnlyInterface/@name element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#if defined(VBOX_WITH_VDE)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && elmMode.nameEquals("VDE"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync nic.mode = NetworkAttachmentType_VDE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMode.getAttributeValue("network", nic.strName); // optional network name
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync#endif
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read serial port information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmUART
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readSerialPorts(const xml::ElementNode &elmUART,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SerialPortsList &ll)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmUART, "Port");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmPort = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SerialPort port;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("slot", port.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // slot must be unique
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (SerialPortsList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != ll.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((*it).ulSlot == port.ulSlot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value %RU32 in UART/Port/@slot attribute: value is not unique"), port.ulSlot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strPortMode;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("hostMode", strPortMode))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required UART/Port/@hostMode attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strPortMode == "RawFile")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync port.portMode = PortMode_RawFile;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strPortMode == "HostPipe")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync port.portMode = PortMode_HostPipe;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strPortMode == "HostDevice")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync port.portMode = PortMode_HostDevice;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strPortMode == "Disconnected")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync port.portMode = PortMode_Disconnected;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value '%s' in UART/Port/@hostMode attribute"), strPortMode.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmPort->getAttributeValue("path", port.strPath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmPort->getAttributeValue("server", port.fServer);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ll.push_back(port);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read parallel port information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmLPT
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param ll
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readParallelPorts(const xml::ElementNode &elmLPT,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ParallelPortsList &ll)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmLPT, "Port");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmPort = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ParallelPort port;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmPort->getAttributeValue("slot", port.ulSlot))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Required LPT/Port/@slot attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // slot must be unique
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (ParallelPortsList::const_iterator it = ll.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != ll.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((*it).ulSlot == port.ulSlot)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmPort, N_("Invalid value %RU32 in LPT/Port/@slot attribute: value is not unique"), port.ulSlot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmPort->getAttributeValue("path", port.strPath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ll.push_back(port);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from MachineConfigFile::readHardware() to read guest property information.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmGuestProperties
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param hw
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readGuestProperties(const xml::ElementNode &elmGuestProperties,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Hardware &hw)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmGuestProperties, "GuestProperty");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmProp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmProp = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync GuestProperty prop;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("name", prop.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("value", prop.strValue);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("timestamp", prop.timestamp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmProp->getAttributeValue("flags", prop.strFlags);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.llGuestProperties.push_back(prop);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmGuestProperties.getAttributeValue("notificationPatterns", hw.strNotificationPatterns);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Helper function to read attributes that are common to <SATAController> (pre-1.7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * and <StorageController>.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmStorageController
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strg
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readStorageControllerAttributes(const xml::ElementNode &elmStorageController,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController &sctl)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strIoBackend;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmStorageController.getAttributeValue("IoBackend", strIoBackend))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strIoBackend == "Buffered")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.ioBackendType = IoBackendType_Buffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strIoBackend == "Unbuffered")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.ioBackendType = IoBackendType_Unbuffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync &elmStorageController,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%s' in StorageController/@IoBackend"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strIoBackend.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardware
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param hw
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readHardware(const xml::ElementNode &elmHardware,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Hardware &hw,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Storage &strg)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmHardware.getAttributeValue("version", hw.strVersion))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 of "1". */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.strVersion = "1";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.strVersion = "2";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUUID;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmHardware.getAttributeValue("uuid", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(hw.uuid, strUUID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmHardware);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHwChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmHwChild = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->nameEquals("CPU"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("count", hw.cCPUs))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.5 variant; not sure if this actually exists in the wild anywhere
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmCPUChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CPUCount")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("count", hw.cCPUs);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("hotplug", hw.fCpuHotPlug);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmCPUChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.fCpuHotPlug)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CpuTree")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readCpuTree(*pelmCPUChild, hw.llCpus);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtEx")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fHardwareVirt);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("exclusive", hw.fHardwareVirtExclusive); // settings version 1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmCPUChild = pelmHwChild->findChildElement("PAE")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync /* The default for pre 3.1 was false, so we must respect that. */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.fPAE = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fPAE);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("SyntheticCpu")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPUChild->getAttributeValue("enabled", hw.fSyntheticCpu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmCPUChild = pelmHwChild->findChildElement("CpuIdTree")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readCpuIdTree(*pelmCPUChild, hw.llCpuIdLeafs);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Memory"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("RAMSize", hw.ulMemorySizeMB);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Firmware"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strFirmwareType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("type", strFirmwareType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (strFirmwareType == "BIOS")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (strFirmwareType == "1") // some trunk builds used the number here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.firmwareType = FirmwareType_BIOS;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (strFirmwareType == "EFI")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (strFirmwareType == "2") // some trunk builds used the number here
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.firmwareType = FirmwareType_EFI;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( strFirmwareType == "EFI32")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.firmwareType = FirmwareType_EFI32;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( strFirmwareType == "EFI64")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.firmwareType = FirmwareType_EFI64;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( strFirmwareType == "EFIDUAL")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.firmwareType = FirmwareType_EFIDUAL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%s' in Firmware/@type"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strFirmwareType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("HID"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strHidType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("Keyboard", strHidType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strHidType == "None")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.keyboardHidType = KeyboardHidType_None;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "USBKeyboard")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.keyboardHidType = KeyboardHidType_USBKeyboard;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "PS2Keyboard")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.keyboardHidType = KeyboardHidType_PS2Keyboard;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "ComboKeyboard")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.keyboardHidType = KeyboardHidType_ComboKeyboard;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%s' in HID/Keyboard/@type"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strHidType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("Pointing", strHidType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strHidType == "None")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.pointingHidType = PointingHidType_None;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "USBMouse")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.pointingHidType = PointingHidType_USBMouse;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "USBTablet")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.pointingHidType = PointingHidType_USBTablet;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "PS2Mouse")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.pointingHidType = PointingHidType_PS2Mouse;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strHidType == "ComboMouse")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.pointingHidType = PointingHidType_ComboMouse;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%s' in HID/Pointing/@type"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strHidType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("HPET"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.fHpetEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Boot"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.mapBootOrder.clear();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl2(*pelmHwChild, "Order");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmOrder;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmOrder = nl2.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t ulPos;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strDevice;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmOrder->getAttributeValue("position", ulPos))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Required Boot/Order/@position attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ulPos < 1
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || ulPos > SchemaDefs::MaxBootPosition
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmOrder,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync N_("Invalid value '%RU32' in Boot/Order/@position: must be greater than 0 and less than %RU32"),
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ulPos,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SchemaDefs::MaxBootPosition + 1);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // XML is 1-based but internal data is 0-based
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync --ulPos;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmOrder->getAttributeValue("device", strDevice))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Required Boot/Order/@device attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync DeviceType_T type;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strDevice == "None")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync type = DeviceType_Null;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strDevice == "Floppy")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync type = DeviceType_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strDevice == "DVD")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync type = DeviceType_DVD;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strDevice == "HardDisk")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync type = DeviceType_HardDisk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strDevice == "Network")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync type = DeviceType_Network;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmOrder, N_("Invalid value '%s' in Boot/Order/@device attribute"), strDevice.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.mapBootOrder[ulPos] = type;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Display"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("RemoteDisplay"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.vrdpSettings.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("port", hw.vrdpSettings.strPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("netAddress", hw.vrdpSettings.strNetAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strAuthType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("authType", strAuthType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strAuthType.toUpper();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strAuthType == "NULL")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.vrdpSettings.authType = VRDPAuthType_Null;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strAuthType == "GUEST")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.vrdpSettings.authType = VRDPAuthType_Guest;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strAuthType == "EXTERNAL")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.vrdpSettings.authType = VRDPAuthType_External;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in RemoteDisplay/@authType attribute"), strAuthType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("authTimeout", hw.vrdpSettings.ulAuthTimeout);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("allowMultiConnection", hw.vrdpSettings.fAllowMultiConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("reuseSingleConnection", hw.vrdpSettings.fReuseSingleConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmVideoChannel;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmVideoChannel = pelmHwChild->findChildElement("VideoChannel")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("BIOS"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmBIOSChild;
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 {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmBIOSChild = pelmHwChild->findChildElement("BootMenu")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strBootMenuMode;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmBIOSChild->getAttributeValue("mode", strBootMenuMode))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strBootMenuMode.toUpper();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strBootMenuMode == "DISABLED")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_Disabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strBootMenuMode == "MENUONLY")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_MenuOnly;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strBootMenuMode == "MESSAGEANDMENU")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_MessageAndMenu;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmBIOSChild, N_("Invalid value '%s' in BootMenu/@mode attribute"), strBootMenuMode.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // legacy BIOS/IDEController (pre 1.7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv < SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ((pelmBIOSChild = pelmHwChild->findChildElement("IDEController")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController sctl;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "IDE Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_IDE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmBIOSChild->getAttributeValue("type", strType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strType == "PIIX3")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_PIIX3;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "PIIX4")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_PIIX4;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "ICH6")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_ICH6;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmBIOSChild, N_("Invalid value '%s' for IDEController/@type attribute"), strType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.ulPortCount = 2;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strg.llStorageControllers.push_back(sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("USBController"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.usbController.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabledEhci", hw.usbController.fEnabledEHCI);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readUSBDeviceFilters(*pelmHwChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.usbController.llDeviceFilters);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv < SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmHwChild->nameEquals("SATAController"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool f;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHwChild->getAttributeValue("enabled", f))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (f)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController sctl;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "SATA Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_SATA;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_IntelAhci;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllerAttributes(*pelmHwChild, sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strg.llStorageControllers.push_back(sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Network"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readNetworkAdapters(*pelmHwChild, hw.llNetworkAdapters);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("RTC"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strLocalOrUTC;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fRTCUseUTC = pelmHwChild->getAttributeValue("localOrUTC", strLocalOrUTC)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && strLocalOrUTC == "UTC";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (pelmHwChild->nameEquals("UART"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (pelmHwChild->nameEquals("Uart")) // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readSerialPorts(*pelmHwChild, hw.llSerialPorts);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (pelmHwChild->nameEquals("LPT"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (pelmHwChild->nameEquals("Lpt")) // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readParallelPorts(*pelmHwChild, hw.llParallelPorts);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("AudioAdapter"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("enabled", hw.audioAdapter.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("controller", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "SB16")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.controllerType = AudioControllerType_SB16;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "AC97")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.controllerType = AudioControllerType_AC97;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@controller attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("driver", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // settings before 1.3 used lower case so make sure this is case-insensitive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strTemp.toUpper();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "NULL")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_Null;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "WINMM")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_WinMM;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (strTemp == "DIRECTSOUND") || (strTemp == "DSOUND") )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_DirectSound;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "SOLAUDIO")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_SolAudio;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "ALSA")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_ALSA;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "PULSE")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_Pulse;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "OSS")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_OSS;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "COREAUDIO")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_CoreAudio;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "MMPM")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.audioAdapter.driverType = AudioDriverType_MMPM;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("SharedFolders"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl2(*pelmHwChild, "SharedFolder");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmFolder;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmFolder = nl2.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync SharedFolder sf;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFolder->getAttributeValue("name", sf.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFolder->getAttributeValue("hostPath", sf.strHostPath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFolder->getAttributeValue("writable", sf.fWritable);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.llSharedFolders.push_back(sf);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Clipboard"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->getAttributeValue("mode", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "Disabled")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.clipboardMode = ClipboardMode_Disabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "HostToGuest")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.clipboardMode = ClipboardMode_HostToGuest;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "GuestToHost")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.clipboardMode = ClipboardMode_GuestToHost;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "Bidirectional")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.clipboardMode = ClipboardMode_Bidirectional;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in Clipboard/@mode attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("Guest"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmHwChild->getAttributeValue("memoryBalloonSize", hw.ulMemoryBalloonSize))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("MemoryBalloonSize", hw.ulMemoryBalloonSize); // used before 1.3
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("GuestProperties"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readGuestProperties(*pelmHwChild, hw);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("IO"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmIoChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoMgr")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmIoChild->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "Async")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioMgrType = IoMgrType_Async;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "Simple")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioMgrType = IoMgrType_Simple;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoMgr/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoBackend")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmIoChild->getAttributeValue("type", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "Unbuffered")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioBackendType = IoBackendType_Unbuffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "Buffered")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync hw.ioSettings.ioBackendType = IoBackendType_Buffered;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmIoChild, N_("Invalid value '%s' in IoBackend/@type attribute"), strTemp.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoCache")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("enabled", hw.ioSettings.fIoCacheEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("size", hw.ioSettings.ulIoCacheSize);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ((pelmIoChild = pelmHwChild->findChildElement("IoBandwidth")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmIoChild->getAttributeValue("max", hw.ioSettings.ulIoBandwidthMax);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.ulMemorySizeMB == (uint32_t)-1)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmHardware, N_("Required Memory/@RAMSize element/attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Storage &strg)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController *pIDEController = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController *pSATAController = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::iterator it = strg.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != strg.llStorageControllers.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController &s = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (s.storageBus == StorageBus_IDE)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pIDEController = &s;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (s.storageBus == StorageBus_SATA)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pSATAController = &s;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmHardDiskAttachments, "HardDiskAttachment");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmAttachment;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmAttachment = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync AttachedDevice att;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUUID, strBus;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmAttachment->getAttributeValue("hardDisk", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("Required HardDiskAttachment/@hardDisk attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(att.uuid, strUUID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_HardDisk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strBus == "IDE")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pIDEController)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus is 'IDE' but cannot find IDE controller"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pIDEController->llAttachedDevices.push_back(att);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strBus == "SATA")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pSATAController)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus is 'SATA' but cannot find SATA controller"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pSATAController->llAttachedDevices.push_back(att);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmAttachment, N_("HardDiskAttachment/@bus attribute has illegal value '%s'"), strBus.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * This is only called for settings version 1.7 and above; see readHardDiskAttachments_pre1_7()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * for earlier versions.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmStorageControllers
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readStorageControllers(const xml::ElementNode &elmStorageControllers,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Storage &strg)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlStorageControllers(elmStorageControllers, "StorageController");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmController;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmController = nlStorageControllers.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController sctl;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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 // period.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sctl.strName == "IDE")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "IDE Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (sctl.strName == "SATA")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "SATA Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (sctl.strName == "SCSI")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "SCSI Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmController->getAttributeValue("Instance", sctl.ulInstance);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // default from constructor is 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmController->getAttributeValue("type", strType))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmController, N_("Required StorageController/@type attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strType == "AHCI")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_SATA;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_IntelAhci;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "LsiLogic")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_SCSI;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_LsiLogic;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "BusLogic")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_SCSI;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_BusLogic;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "PIIX3")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_IDE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_PIIX3;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "PIIX4")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_IDE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_PIIX4;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "ICH6")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_IDE;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_ICH6;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (strType == "I82078")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_I82078;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strType == "LsiLogicSas")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_SAS;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_LsiLogicSas;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmController, N_("Invalid value '%s' for StorageController/@type attribute"), strType.c_str());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllerAttributes(*pelmController, sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlAttached(*pelmController, "AttachedDevice");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmAttached;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmAttached = nlAttached.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync AttachedDevice att;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAttached->getAttributeValue("type", strTemp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "HardDisk")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_HardDisk;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // starting with 1.9 we list DVD and floppy drive info + attachments under <StorageControllers>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strTemp == "DVD")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_DVD;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmAttached->getAttributeValue("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (strTemp == "Floppy")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (att.deviceType != DeviceType_Null)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmImage;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // all types can have images attached, but for HardDisk it's required
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmImage = pelmAttached->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (att.deviceType == DeviceType_HardDisk)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/Image element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // DVDs and floppies can also have <HostDrive> instead of <Image>
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHostDrive;
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmImage->getAttributeValue("uuid", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/Image/@uuid attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(att.uuid, strTemp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.llAttachedDevices.push_back(att);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strg.llStorageControllers.push_back(sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmHardware
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param strg
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Storage &strg)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nl1(elmHardware);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHwChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmHwChild = nl1.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmHwChild->nameEquals("DVDDrive"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // create a DVD "attached device" and attach it to the existing IDE controller
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync AttachedDevice att;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_DVD;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // legacy DVD drive is always secondary master (port 1, device 0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.lPort = 1;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.lDevice = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwChild->getAttributeValue("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pDriveChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTmp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pDriveChild = pelmHwChild->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pDriveChild->getAttributeValue("uuid", strTmp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(att.uuid, strTmp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pDriveChild->getAttributeValue("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // find the IDE controller and attach the DVD drive
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fFound = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::iterator it = strg.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != strg.llStorageControllers.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController &sctl = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sctl.storageBus == StorageBus_IDE)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.llAttachedDevices.push_back(att);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fFound = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!fFound)
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmHwChild->nameEquals("FloppyDrive"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bool fEnabled;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (pelmHwChild->getAttributeValue("enabled", fEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (fEnabled)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // create a new floppy controller and attach a floppy "attached device"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync StorageController sctl;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.strName = "Floppy Controller";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.storageBus = StorageBus_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.controllerType = StorageControllerType_I82078;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.ulPortCount = 1;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync AttachedDevice att;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.deviceType = DeviceType_Floppy;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.lPort = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync att.lDevice = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pDriveChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTmp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( ((pDriveChild = pelmHwChild->findChildElement("Image")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pDriveChild->getAttributeValue("uuid", strTmp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(att.uuid, strTmp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pDriveChild->getAttributeValue("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // store attachment with controller
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync sctl.llAttachedDevices.push_back(att);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // store controller with storage
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strg.llStorageControllers.push_back(sctl);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmSnapshot
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param snap
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Snapshot &snap)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strTemp;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("uuid", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@uuid attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(snap.uuid, strTemp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("name", snap.strName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@name attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmSnapshot.getAttributeValue("timeStamp", strTemp))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@timeStamp attribute is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseTimestamp(snap.timestamp, strTemp);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmSnapshot.getAttributeValue("stateFile", snap.strStateFile); // online snapshots only
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse Hardware before the other elements because other things depend on it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHardware;
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlSnapshotChildren(elmSnapshot);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmSnapshotChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmSnapshotChild = nlSnapshotChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmSnapshotChild->nameEquals("Description"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync snap.strDescription = pelmSnapshotChild->getValue();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv < SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmSnapshotChild->nameEquals("HardDiskAttachments"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv >= SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmSnapshotChild->nameEquals("StorageControllers"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllers(*pelmSnapshotChild, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmSnapshotChild->nameEquals("Snapshots"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlChildSnapshots(*pelmSnapshotChild);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmChildSnapshot;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmChildSnapshot = nlChildSnapshots.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmChildSnapshot->nameEquals("Snapshot"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Snapshot child;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readSnapshot(*pelmChildSnapshot, child);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync snap.llChildSnapshots.push_back(child);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_9)
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);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncconst struct {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszOld;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszNew;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync} aConvertOSTypes[] =
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "unknown", "Other" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "dos", "DOS" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win31", "Windows31" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win95", "Windows95" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win98", "Windows98" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "winme", "WindowsMe" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "winnt4", "WindowsNT4" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win2k", "Windows2000" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "winxp", "WindowsXP" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win2k3", "Windows2003" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "winvista", "WindowsVista" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "win2k8", "Windows2008" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "os2warp3", "OS2Warp3" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "os2warp4", "OS2Warp4" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "os2warp45", "OS2Warp45" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "ecs", "OS2eCS" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "linux22", "Linux22" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "linux24", "Linux24" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "linux26", "Linux26" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "archlinux", "ArchLinux" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "debian", "Debian" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "opensuse", "OpenSUSE" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "fedoracore", "Fedora" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "gentoo", "Gentoo" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "mandriva", "Mandriva" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "redhat", "RedHat" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "ubuntu", "Ubuntu" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "xandros", "Xandros" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "freebsd", "FreeBSD" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "openbsd", "OpenBSD" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "netbsd", "NetBSD" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "netware", "Netware" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "solaris", "Solaris" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "opensolaris", "OpenSolaris" },
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync { "l4", "L4" }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync};
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::convertOldOSType_pre1_5(Utf8Str &str)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (unsigned u = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync u < RT_ELEMENTS(aConvertOSTypes);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++u)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (str == aConvertOSTypes[u].pcszOld)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync str = aConvertOSTypes[u].pcszNew;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Called from the constructor to actually read in the <Machine> element
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * of a machine config file.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::readMachine(const xml::ElementNode &elmMachine)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strUUID;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (elmMachine.getAttributeValue("uuid", strUUID))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (elmMachine.getAttributeValue("name", strName))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(uuid, strUUID);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMachine.getAttributeValue("nameSync", fNameSync))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fNameSync = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str str;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("Description", strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("OSType", strOsType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_5)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync convertOldOSType_pre1_5(strOsType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("stateFile", strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmMachine.getAttributeValue("currentSnapshot", str))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseUUID(uuidCurrentSnapshot, str);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.getAttributeValue("snapshotFolder", strSnapshotFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!elmMachine.getAttributeValue("currentStateModified", fCurrentStateModified))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fCurrentStateModified = true;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (elmMachine.getAttributeValue("lastStateChange", str))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync parseTimestamp(timeLastStateChange, str);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // constructor has called RTTimeNow(&timeLastStateChange) before
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // parse Hardware before the other elements because other things depend on it
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmHardware;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!(pelmHardware = elmMachine.findChildElement("Hardware")))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMachine, N_("Required Machine/Hardware element is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardware(*pelmHardware, hardwareMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::NodesLoop nlRootChildren(elmMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const xml::ElementNode *pelmMachineChild;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync while ((pelmMachineChild = nlRootChildren.forAllNodes()))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmMachineChild->nameEquals("ExtraData"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readExtraData(*pelmMachineChild,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync mapExtraDataItems);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv < SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMachineChild->nameEquals("HardDiskAttachments"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readHardDiskAttachments_pre1_7(*pelmMachineChild, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv >= SettingsVersion_v1_7)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (pelmMachineChild->nameEquals("StorageControllers"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readStorageControllers(*pelmMachineChild, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmMachineChild->nameEquals("Snapshot"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Snapshot snap;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // this will recurse into child snapshots, if necessary
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync readSnapshot(*pelmMachineChild, snap);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync llFirstSnapshot.push_back(snap);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmMachineChild->nameEquals("Description"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strDescription = pelmMachineChild->getValue();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (pelmMachineChild->nameEquals("Teleporter"))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("enabled", fTeleporterEnabled))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync fTeleporterEnabled = false;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("port", uTeleporterPort))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uTeleporterPort = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("address", strTeleporterAddress))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strTeleporterAddress = "";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!pelmMachineChild->getAttributeValue("password", strTeleporterPassword))
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strTeleporterPassword = "";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_9)
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync throw ConfigFileError(this, &elmMachine, N_("Required Machine/@uuid or @name attributes is missing"));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Hardware &hw,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Storage &strg)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHardware = elmParent.createChild("Hardware");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv >= SettingsVersion_v1_4)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHardware->setAttribute("version", hw.strVersion);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (!hw.uuid.isEmpty())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHardware->setAttribute("uuid", makeString(hw.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCPU = pelmHardware->createChild("CPU");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHwVirtEx = pelmCPU->createChild("HardwareVirtEx");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwVirtEx->setAttribute("enabled", hw.fHardwareVirt);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHwVirtEx->setAttribute("exclusive", hw.fHardwareVirtExclusive);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.fSyntheticCpu)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("SyntheticCpu")->setAttribute("enabled", hw.fSyntheticCpu);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->setAttribute("count", hw.cCPUs);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.fLargePages)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->createChild("HardwareVirtExLargePages")->setAttribute("enabled", hw.fLargePages);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv >= SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCPU->setAttribute("hotplug", hw.fCpuHotPlug);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpuTree = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (CpuList::const_iterator it = hw.llCpus.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != hw.llCpus.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Cpu &cpu = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmCpuTree == NULL)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuTree = pelmCPU->createChild("CpuTree");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpu = pelmCpuTree->createChild("Cpu");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpu->setAttribute("id", cpu.ulId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpuIdTree = NULL;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (CpuIdLeafsList::const_iterator it = hw.llCpuIdLeafs.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != hw.llCpuIdLeafs.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const CpuIdLeaf &leaf = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (pelmCpuIdTree == NULL)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdTree = pelmCPU->createChild("CpuIdTree");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmCpuIdLeaf = pelmCpuIdTree->createChild("CpuIdLeaf");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->setAttribute("id", leaf.ulId);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->setAttribute("eax", leaf.ulEax);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->setAttribute("ebx", leaf.ulEbx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->setAttribute("ecx", leaf.ulEcx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmCpuIdLeaf->setAttribute("edx", leaf.ulEdx);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmMemory = pelmHardware->createChild("Memory");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmMemory->setAttribute("RAMSize", hw.ulMemorySizeMB);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (hw.firmwareType >= FirmwareType_EFI)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmFirmware = pelmHardware->createChild("Firmware");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszFirmware;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (hw.firmwareType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 default: pcszFirmware = "None"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmFirmware->setAttribute("type", pcszFirmware);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv >= SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHid = pelmHardware->createChild("HID");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszHid;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (hw.pointingHidType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHid->setAttribute("Pointing", pcszHid);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (hw.keyboardHidType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHid->setAttribute("Keyboard", pcszHid);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv >= SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmHpet = pelmHardware->createChild("HPET");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmHpet->setAttribute("enabled", hw.fHpetEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmBoot = pelmHardware->createChild("Boot");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (BootOrderMap::const_iterator it = hw.mapBootOrder.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != hw.mapBootOrder.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t i = it->first;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync DeviceType_T type = it->second;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszDevice;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (type)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_Floppy: pcszDevice = "Floppy"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_DVD: pcszDevice = "DVD"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_HardDisk: pcszDevice = "HardDisk"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_Network: pcszDevice = "Network"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*case DeviceType_Null:*/ pcszDevice = "None"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmOrder = pelmBoot->createChild("Order");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmOrder->setAttribute("position",
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync i + 1); // XML is 1-based but internal data is 0-based
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmOrder->setAttribute("device", pcszDevice);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (m->sv >= SettingsVersion_v1_8)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDisplay->setAttribute("accelerate2DVideo", hw.fAccelerate2DVideo);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmVRDP = pelmHardware->createChild("RemoteDisplay");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("enabled", hw.vrdpSettings.fEnabled);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync Utf8Str strPort = hw.vrdpSettings.strPort;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!strPort.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync strPort = "3389";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("port", strPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.vrdpSettings.strNetAddress.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("netAddress", hw.vrdpSettings.strNetAddress);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszAuthType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (hw.vrdpSettings.authType)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case VRDPAuthType_Guest: pcszAuthType = "Guest"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case VRDPAuthType_External: pcszAuthType = "External"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*case VRDPAuthType_Null:*/ pcszAuthType = "Null"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("authType", pcszAuthType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.vrdpSettings.ulAuthTimeout != 0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("authTimeout", hw.vrdpSettings.ulAuthTimeout);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.vrdpSettings.fAllowMultiConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("allowMultiConnection", hw.vrdpSettings.fAllowMultiConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (hw.vrdpSettings.fReuseSingleConnection)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVRDP->setAttribute("reuseSingleConnection", hw.vrdpSettings.fReuseSingleConnection);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv >= SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmVideoChannel = pelmVRDP->createChild("VideoChannel");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->setAttribute("enabled", hw.vrdpSettings.fVideoChannel);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmVideoChannel->setAttribute("quality", hw.vrdpSettings.ulVideoChannelQuality);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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
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 if (hw.biosSettings.strLogoImagePath.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmLogo->setAttribute("imagePath", hw.biosSettings.strLogoImagePath);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const char *pcszBootMenu;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (hw.biosSettings.biosBootMenuMode)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case BIOSBootMenuMode_Disabled: pcszBootMenu = "Disabled"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case BIOSBootMenuMode_MenuOnly: pcszBootMenu = "MenuOnly"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync default: /*BIOSBootMenuMode_MessageAndMenu*/ pcszBootMenu = "MessageAndMenu"; break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (m->sv < SettingsVersion_v1_9)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 size_t cDVDs = 0;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync size_t cFloppies = 0;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDVD = pelmHardware->createChild("DVDDrive");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmFloppy = pelmHardware->createChild("FloppyDrive");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (StorageControllersList::const_iterator it = strg.llStorageControllers.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != strg.llStorageControllers.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const StorageController &sctl = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // in old settings format, the DVD drive could only have been under the IDE controller
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (sctl.storageBus == StorageBus_IDE)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it2 != sctl.llAttachedDevices.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it2)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const AttachedDevice &att = *it2;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (att.deviceType == DeviceType_DVD)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (cDVDs > 0)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: cannot save more than one DVD drive with old settings format"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++cDVDs;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->setAttribute("passthrough", att.fPassThrough);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!att.uuid.isEmpty())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (att.strHostDriveSrc.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDVD->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (sctl.storageBus == StorageBus_Floppy)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync size_t cFloppiesHere = sctl.llAttachedDevices.size();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (cFloppiesHere > 1)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: floppy controller cannot have more than one device attachment"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (cFloppiesHere)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const AttachedDevice &att = sctl.llAttachedDevices.front();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->setAttribute("enabled", true);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (!att.uuid.isEmpty())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (att.strHostDriveSrc.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync cFloppies += cFloppiesHere;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (cFloppies == 0)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmFloppy->setAttribute("enabled", false);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else if (cFloppies > 1)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw ConfigFileError(this, NULL, N_("Internal error: cannot save more than one floppy drive with old settings format"));
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmUSB = pelmHardware->createChild("USBController");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmUSB->setAttribute("enabled", hw.usbController.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmUSB->setAttribute("enabledEhci", hw.usbController.fEnabledEHCI);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writeUSBDeviceFilters(*pelmUSB,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync hw.usbController.llDeviceFilters,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync false); // fHostMode
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (NetworkAdaptersList::const_iterator it = hw.llNetworkAdapters.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != hw.llNetworkAdapters.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const NetworkAdapter &nic = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmAdapter = pelmNetwork->createChild("Adapter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("slot", nic.ulSlot);
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 if (nic.ulBootPriority != 0)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("bootPriority", nic.ulBootPriority);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.fTraceEnabled)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("trace", nic.fTraceEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("tracefile", nic.strTraceFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (nic.type)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->setAttribute("type", pcszType);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNAT;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (m->sv < SettingsVersion_v1_10)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (nic.mode)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_NAT:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT = pelmAdapter->createChild("NAT");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.strNetwork.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("network", nic.nat.strNetwork);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_Bridged:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_Internal:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_HostOnly:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync#if defined(VBOX_WITH_VDE)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_VDE:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT = pelmAdapter->createChild("VDE");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.strName.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("network", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync#endif
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case NetworkAttachmentType_Null:*/
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync else
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /* m->sv >= SettingsVersion_v1_10 */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDisabledNode;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.fHasDisabledNAT)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.fHasDisabledNAT)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync buildNetworkXML(nic.mode, *pelmAdapter, nic);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPorts = pelmHardware->createChild("UART");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (SerialPortsList::const_iterator it = hw.llSerialPorts.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != hw.llSerialPorts.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const SerialPort &port = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("slot", port.ulSlot);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("enabled", port.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttributeHex("IOBase", port.ulIOBase);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("IRQ", port.ulIRQ);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszHostMode;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (port.portMode)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (port.portMode)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_HostPipe:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("server", port.fServer);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync /* no break */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_HostDevice:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case PortMode_RawFile:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("path", port.strPath);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("hostMode", pcszHostMode);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPorts = pelmHardware->createChild("LPT");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (ParallelPortsList::const_iterator it = hw.llParallelPorts.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != hw.llParallelPorts.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const ParallelPort &port = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("slot", port.ulSlot);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("enabled", port.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttributeHex("IOBase", port.ulIOBase);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("IRQ", port.ulIRQ);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (port.strPath.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPort->setAttribute("path", port.strPath);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmAudio = pelmHardware->createChild("AudioAdapter");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAudio->setAttribute("controller", (hw.audioAdapter.controllerType == AudioControllerType_SB16) ? "SB16" : "AC97");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( m->sv >= SettingsVersion_v1_10)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmRTC = pelmHardware->createChild("RTC");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmRTC->setAttribute("localOrUTC", fRTCUseUTC ? "UTC" : "local");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszDriver;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (hw.audioAdapter.driverType)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAudio->setAttribute("driver", pcszDriver);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAudio->setAttribute("enabled", hw.audioAdapter.fEnabled);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmSharedFolders = pelmHardware->createChild("SharedFolders");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (SharedFoldersList::const_iterator it = hw.llSharedFolders.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != hw.llSharedFolders.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const SharedFolder &sf = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmThis = pelmSharedFolders->createChild("SharedFolder");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmThis->setAttribute("name", sf.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmThis->setAttribute("hostPath", sf.strHostPath);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmThis->setAttribute("writable", sf.fWritable);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmClip = pelmHardware->createChild("Clipboard");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszClip;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (hw.clipboardMode)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmClip->setAttribute("mode", pcszClip);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (m->sv >= SettingsVersion_v1_10)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmIo = pelmHardware->createChild("IO");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmIoCache;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmIoBandwidth;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszTemp;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (hw.ioSettings.ioMgrType)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoMgrType_Simple: pcszTemp = "Simple"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoMgrType_Async:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszTemp = "Async"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIo->createChild("IoMgr")->setAttribute("type", pcszTemp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (hw.ioSettings.ioBackendType)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoBackendType_Buffered: pcszTemp = "Buffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoBackendType_Unbuffered:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszTemp = "Unbuffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIo->createChild("IoBackend")->setAttribute("type", pcszTemp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmIoCache = pelmIo->createChild("IoCache");
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmGuestProps = pelmHardware->createChild("GuestProperties");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (GuestPropertiesList::const_iterator it = hw.llGuestProperties.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != hw.llGuestProperties.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const GuestProperty &prop = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmProp = pelmGuestProps->createChild("GuestProperty");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("name", prop.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("value", prop.strValue);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("timestamp", prop.timestamp);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmProp->setAttribute("flags", prop.strFlags);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (hw.strNotificationPatterns.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmGuestProps->setAttribute("notificationPatterns", hw.strNotificationPatterns);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * Fill a <Network> node. Only relevant for XML version >= v1_10.
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param mode
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param elmParent
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync * @param nice
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode &elmParent,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const NetworkAdapter &nic)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (mode)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_NAT:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmNAT;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT = elmParent.createChild("NAT");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.strBindIP.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("hostip", nic.nat.strBindIP);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.u32Mtu)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("mtu", nic.nat.u32Mtu);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.u32SockRcv)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.u32SockSnd)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.u32TcpRcv)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.u32TcpSnd)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDNS;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmDNS = pelmNAT->createChild("DNS");
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmAlias;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmAlias = pelmNAT->createChild("Alias");
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( nic.nat.strTftpPrefix.length()
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync || nic.nat.strTftpBootFile.length()
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync || nic.nat.strTftpNextServer.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmTFTP;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP = pelmNAT->createChild("TFTP");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.strTftpPrefix.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("prefix", nic.nat.strTftpPrefix);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.strTftpBootFile.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("boot-file", nic.nat.strTftpBootFile);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (nic.nat.strTftpNextServer.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmTFTP->setAttribute("next-server", nic.nat.strTftpNextServer);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (NATRuleList::const_iterator rule = nic.nat.llRules.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync rule != nic.nat.llRules.end(); ++rule)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmPF;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF = pelmNAT->createChild("Forwarding");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ((*rule).strName.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("name", (*rule).strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("proto", (*rule).u32Proto);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ((*rule).strHostIP.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("hostip", (*rule).strHostIP);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ((*rule).u16HostPort)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("hostport", (*rule).u16HostPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ((*rule).strGuestIP.length())
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("guestip", (*rule).strGuestIP);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ((*rule).u16GuestPort)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmPF->setAttribute("guestport", (*rule).u16GuestPort);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_Bridged:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_Internal:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case NetworkAttachmentType_HostOnly:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strName);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case NetworkAttachmentType_Null:*/
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync/**
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
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync */
f22cba796fd7499bf85058671a1af7cbe491c622vboxsyncvoid MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const Storage &st)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync{
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmStorageControllers = elmParent.createChild("StorageControllers");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (StorageControllersList::const_iterator it = st.llStorageControllers.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it != st.llStorageControllers.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const StorageController &sc = *it;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if ( (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (sc.controllerType == StorageControllerType_I82078)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // floppy controller already got written into <Hardware>/<FloppyController> in writeHardware()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // for pre-1.9 settings
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync continue;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmController = pelmStorageControllers->createChild("StorageController");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync com::Utf8Str name = sc.strName.raw();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync //
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_8)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // pre-1.8 settings use shorter controller names, they are
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // expanded when reading the settings
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (name == "IDE Controller")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync name = "IDE";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (name == "SATA Controller")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync name = "SATA";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (name == "SCSI Controller")
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync name = "SCSI";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmController->setAttribute("name", sc.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszType;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync switch (sc.controllerType)
f350d4fb2d12fd22c0905fe9c7a121499da7b52dvboxsync {
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;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("type", pcszType);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("PortCount", sc.ulPortCount);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sc.ulInstance)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmController->setAttribute("Instance", sc.ulInstance);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv >= SettingsVersion_v1_9)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const char *pcszIoBackend;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (sc.ioBackendType)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case IoBackendType_Unbuffered: pcszIoBackend = "Unbuffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync default: /*case IoBackendType_Buffered:*/ pcszIoBackend = "Buffered"; break;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pelmController->setAttribute("IoBackend", pcszIoBackend);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync if (sc.controllerType == StorageControllerType_IntelAhci)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
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 }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync for (AttachedDevicesList::const_iterator it2 = sc.llAttachedDevices.begin();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync it2 != sc.llAttachedDevices.end();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync ++it2)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync const AttachedDevice &att = *it2;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
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 if ( att.deviceType == DeviceType_DVD
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync && m->sv < SettingsVersion_v1_9
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync )
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync continue;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmDevice = pelmController->createChild("AttachedDevice");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszType = NULL;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync switch (att.deviceType)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync case DeviceType_HardDisk:
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync pcszType = "HardDisk";
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_DVD:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pcszType = "DVD";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->setAttribute("passthrough", att.fPassThrough);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync case DeviceType_Floppy:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pcszType = "Floppy";
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->setAttribute("type", pcszType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->setAttribute("port", att.lPort);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->setAttribute("device", att.lDevice);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!att.uuid.isEmpty())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->createChild("Image")->setAttribute("uuid", makeString(att.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if ( (m->sv >= SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (att.strHostDriveSrc.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmDevice->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Snapshot &snap)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmSnapshot = elmParent.createChild("Snapshot");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("uuid", makeString(snap.uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("name", snap.strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("timeStamp", makeString(snap.timestamp));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (snap.strStateFile.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->setAttribute("stateFile", snap.strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (snap.strDescription.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync pelmSnapshot->createChild("Description")->addContent(snap.strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildHardwareXML(*pelmSnapshot, snap.hardware, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildStorageControllersXML(*pelmSnapshot, snap.storage);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (snap.llChildSnapshots.size())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync xml::ElementNode *pelmChildren = pelmSnapshot->createChild("Snapshots");
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (SnapshotsList::const_iterator it = snap.llChildSnapshots.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != snap.llChildSnapshots.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const Snapshot &child = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildSnapshotXML(*pelmChildren, child);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * Builds the XML DOM tree for the machine config under the given XML element.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * As a result, this gets called from two locations:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- MachineConfigFile::write();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * -- Appliance::buildXMLForOneVirtualSystem()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * In fl, the following flag bits are recognized:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync *
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 *
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 *
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param elmMachine XML <Machine> element to add attributes and elements to.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync * @param fl Flags.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine,
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync uint32_t fl)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fl & BuildMachineXML_WriteVboxVersionAttribute)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // add settings version attribute to machine element
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync setVersionAttribute(elmMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("uuid", makeString(uuid));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("name", strName);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!fNameSync)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("nameSync", fNameSync);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strDescription.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.createChild("Description")->addContent(strDescription);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("OSType", strOsType);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strStateFile.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("stateFile", strStateFile);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (fl & BuildMachineXML_IncludeSnapshots)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && !uuidCurrentSnapshot.isEmpty())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("currentSnapshot", makeString(uuidCurrentSnapshot));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (strSnapshotFolder.length())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("snapshotFolder", strSnapshotFolder);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (!fCurrentStateModified)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("currentStateModified", fCurrentStateModified);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("lastStateChange", makeString(timeLastStateChange));
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (fAborted)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync elmMachine.setAttribute("aborted", fAborted);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( m->sv >= SettingsVersion_v1_9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( fTeleporterEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || uTeleporterPort
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !strTeleporterAddress.isEmpty()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !strTeleporterPassword.isEmpty()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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 }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync writeExtraData(elmMachine, mapExtraDataItems);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (fl & BuildMachineXML_IncludeSnapshots)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && llFirstSnapshot.size())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildSnapshotXML(elmMachine, llFirstSnapshot.front());
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildHardwareXML(elmMachine, hardwareMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync buildStorageControllersXML(elmMachine, storageMachine);
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::bumpSettingsVersionIfNeeded()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // The hardware versions other than "1" requires settings version 1.4 (2.1+).
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( m->sv < SettingsVersion_v1_4
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && hardwareMachine.strVersion != "1"
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_4;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // "accelerate 2d video" requires settings version 1.8
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv < SettingsVersion_v1_8)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && (hardwareMachine.fAccelerate2DVideo)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_8;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // all the following require settings version 1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( (hardwareMachine.firmwareType >= FirmwareType_EFI)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (hardwareMachine.fHardwareVirtExclusive != HWVIRTEXCLUSIVEDEFAULT)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || fTeleporterEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || uTeleporterPort
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !strTeleporterAddress.isEmpty()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !strTeleporterPassword.isEmpty()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !hardwareMachine.uuid.isEmpty()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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 if (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync size_t cDVDs = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync size_t cFloppies = 0;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // need to run thru all the storage controllers to figure this out
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it != storageMachine.llStorageControllers.end()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && m->sv < SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const StorageController &sctl = *it;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (AttachedDevicesList::const_iterator it2 = sctl.llAttachedDevices.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync it2 != sctl.llAttachedDevices.end();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++it2)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sctl.ulInstance != 0) // we can only write the StorageController/@Instance attribute with v1.9
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync const AttachedDevice &att = *it2;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (att.deviceType == DeviceType_DVD)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( (sctl.storageBus != StorageBus_IDE) // DVD at bus other than DVD?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (att.lPort != 1) // DVDs not at secondary master?
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (att.lDevice != 0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++cDVDs;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync else if (att.deviceType == DeviceType_Floppy)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync ++cFloppies;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // The I/O backend setting is only supported with v.10
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (sctl.ioBackendType != IoBackendType_Buffered)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
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 if ( (m->sv < SettingsVersion_v1_9)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( (cDVDs != 1)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || (cFloppies > 1)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_9;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds support for CPU hotplug, RTC timezone control, HID type and HPET
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( m->sv < SettingsVersion_v1_10
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( fRTCUseUTC
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.fCpuHotPlug
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.pointingHidType != PointingHidType_PS2Mouse
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.keyboardHidType != KeyboardHidType_PS2Keyboard
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.fHpetEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds NAT and boot priority to the NIC config in Main.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync NetworkAdaptersList::const_iterator netit;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync for (netit = hardwareMachine.llNetworkAdapters.begin();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync netit != hardwareMachine.llNetworkAdapters.end(); ++netit)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( netit->fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && netit->mode == NetworkAttachmentType_NAT
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( netit->nat.u32Mtu != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.u32SockRcv != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.u32SockSnd != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.u32TcpRcv != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.u32TcpSnd != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || !netit->nat.fDnsPassDomain
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.fDnsProxy
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.fDnsUseHostResolver
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.fAliasLog
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.fAliasProxyOnly
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.fAliasUseSamePorts
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.strTftpPrefix.length()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.strTftpBootFile.length()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.strTftpNextServer.length()
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || netit->nat.llRules.size())
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( netit->fEnabled
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && netit->ulBootPriority != 0)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync break;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // Check for non default I/O settings and bump the settings version.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if (m->sv < SettingsVersion_v1_10)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( hardwareMachine.ioSettings.fIoCacheEnabled != true
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ulIoCacheSize != 5
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ulIoBandwidthMax != 0
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ioMgrType != IoMgrType_Async
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync || hardwareMachine.ioSettings.ioBackendType != IoBackendType_Unbuffered)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync }
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync // VirtualBox 3.2 adds support for VRDP video channel
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync if ( m->sv < SettingsVersion_v1_10
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync && ( hardwareMachine.vrdpSettings.fVideoChannel
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync )
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->sv = SettingsVersion_v1_10;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync}
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync/**
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.
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync */
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsyncvoid MachineConfigFile::write(const com::Utf8Str &strFilename)
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync{
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync try
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync {
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:
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync bumpSettingsVersionIfNeeded();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync m->strFilename = strFilename;
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync createStubDocument();
e0e0c19eefceaf5d4ec40f9466b58a771f50e799vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::ElementNode *pelmMachine = m->pelmRoot->createChild("Machine");
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync buildMachineXML(*pelmMachine,
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync MachineConfigFile::BuildMachineXML_IncludeSnapshots);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // but not BuildMachineXML_WriteVboxVersionAttribute
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync // now go write the XML
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync xml::XmlFileWriter writer(*m->pDoc);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync writer.write(m->strFilename.c_str(), true /*fSafe*/);
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync m->fFileExists = true;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync clearDocument();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync catch (...)
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync {
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync clearDocument();
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync throw;
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync }
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync}
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync
f22cba796fd7499bf85058671a1af7cbe491c622vboxsync