settings.h revision bf88068260ded16af90b7da4867240fbdd9c8017
/** @file
* Settings file data structures.
*
* These structures are created by the settings file loader and filled with values
* copied from the raw XML data. This was all new with VirtualBox 3.1 and allows us
* to finally make the XML reader version-independent and read VirtualBox XML files
* from earlier and even newer (future) versions without requiring complicated,
* tedious and error-prone XSLT conversions.
*
* It is this file that defines all structures that map VirtualBox global and
* machine settings to XML files. These structures are used by the rest of Main,
* even though this header file does not require anything else in Main.
*
* Note: Headers in Main code have been tweaked to only declare the structures
* defined here so that this header need only be included from code files that
* actually use these structures.
*/
/*
* Copyright (C) 2007-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_settings_h
#define ___VBox_settings_h
#include "VBox/com/VirtualBox.h"
#include <list>
#include <map>
{
}
{
////////////////////////////////////////////////////////////////////////////////
//
// Structures shared between Machine XML and VirtualBox.xml
//
////////////////////////////////////////////////////////////////////////////////
/**
* USB device filter definition. This struct is used both in MainConfigFile
* (for global USB filters) and MachineConfigFile (for machine filters).
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct USBDeviceFilter
{
: fActive(false),
{}
bool operator==(const USBDeviceFilter&u) const;
bool fActive;
};
// ExtraDataItem (used by both VirtualBox.xml and machines XML)
struct USBDeviceFilter;
struct Medium;
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct Medium
{
// the following are for hard disks only:
bool fAutoReset; // optional, only for diffs, default is false
};
/**
* A media registry. Starting with VirtualBox 3.3, this can appear in both the
* VirtualBox.xml file as well as machine XML files with settings version 1.11
* or higher, so these lists are now in ConfigFileBase.
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct MediaRegistry
{
bool operator==(const MediaRegistry &m) const;
};
/**
* Common base class for both MainConfigFile and MachineConfigFile
* which contains some common logic for both.
*/
{
bool fileExists();
void copyBaseFrom(const ConfigFileBase &b);
~ConfigFileBase();
StringsMap &map);
void createStubDocument();
const USBDeviceFiltersList &ll,
bool fHostMode);
const Medium &m,
const MediaRegistry &mr);
void clearDocument();
struct Data;
Data *m;
// prohibit copying (Data contains pointers to XML which cannot be copied)
ConfigFileBase(const ConfigFileBase&);
};
////////////////////////////////////////////////////////////////////////////////
//
// VirtualBox.xml structures
//
////////////////////////////////////////////////////////////////////////////////
struct Host
{
};
struct SystemProperties
{
: ulLogHistoryCount(3)
{}
};
struct MachineRegistryEntry
{
};
struct DHCPServer
{
bool fEnabled;
};
{
};
////////////////////////////////////////////////////////////////////////////////
//
// Machine XML structures
//
////////////////////////////////////////////////////////////////////////////////
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct VRDESettings
{
: fEnabled(true),
ulAuthTimeout(5000),
fAllowMultiConnection(false),
fReuseSingleConnection(false),
fVideoChannel(false),
{}
bool operator==(const VRDESettings& v) const;
bool fEnabled;
bool fAllowMultiConnection,
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct BIOSSettings
{
: fACPIEnabled(true),
fIOAPICEnabled(false),
fLogoFadeIn(true),
fLogoFadeOut(true),
fPXEDebugEnabled(false),
llTimeOffset(0)
{}
bool operator==(const BIOSSettings &d) const;
bool fACPIEnabled,
bool fPXEDebugEnabled;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct USBController
{
: fEnabled(false),
fEnabledEHCI(false)
{}
bool operator==(const USBController &u) const;
bool fEnabled;
bool fEnabledEHCI;
};
struct NATRule
{
u16HostPort(0),
u16GuestPort(0){}
{
&& u16HostPort == r.u16HostPort
&& u16GuestPort == r.u16GuestPort
&& strGuestIP == r.strGuestIP;
}
};
struct NAT
{
u32SockRcv(0),
u32SockSnd(0),
u32TcpRcv(0),
u32TcpSnd(0),
fDnsPassDomain(true), /* historically this value is true */
fDnsProxy(false),
fDnsUseHostResolver(false),
fAliasLog(false),
fAliasProxyOnly(false),
fAliasUseSamePorts(false) {}
bool fDnsPassDomain;
bool fDnsProxy;
bool fDnsUseHostResolver;
bool fAliasLog;
bool fAliasProxyOnly;
bool fAliasUseSamePorts;
{
return strNetwork == n.strNetwork
&& u32SockRcv == n.u32SockRcv
&& u32SockSnd == n.u32SockSnd
&& strTftpPrefix == n.strTftpPrefix
&& strTftpBootFile == n.strTftpBootFile
&& strTftpNextServer == n.strTftpNextServer
&& fDnsPassDomain == n.fDnsPassDomain
&& fAliasProxyOnly == n.fAliasProxyOnly
&& fAliasUseSamePorts == n.fAliasUseSamePorts
}
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct NetworkAdapter
{
: ulSlot(0),
fEnabled(false),
fCableConnected(false),
ulLineSpeed(0),
fTraceEnabled(false),
ulBootPriority(0),
fHasDisabledNAT(false),
{}
bool operator==(const NetworkAdapter &n) const;
bool fEnabled;
bool fCableConnected;
bool fTraceEnabled;
// with bridged: host interface or empty;
// otherwise: network name (required)
bool fHasDisabledNAT;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct SerialPort
{
: ulSlot(0),
fEnabled(false),
ulIOBase(0x3f8),
ulIRQ(4),
fServer(false)
{}
bool operator==(const SerialPort &n) const;
bool fEnabled;
bool fServer;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct ParallelPort
{
: ulSlot(0),
fEnabled(false),
ulIOBase(0x378),
ulIRQ(4)
{}
bool operator==(const ParallelPort &d) const;
bool fEnabled;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct AudioAdapter
{
: fEnabled(true),
{}
bool operator==(const AudioAdapter &a) const
{
return (this == &a)
&& (controllerType == a.controllerType)
&& (driverType == a.driverType)
);
}
bool fEnabled;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct SharedFolder
{
: fWritable(false)
, fAutoMount(false)
{}
bool operator==(const SharedFolder &a) const;
bool fWritable;
bool fAutoMount;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct GuestProperty
{
: timestamp(0)
{};
bool operator==(const GuestProperty &g) const;
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct CpuIdLeaf
{
: ulId(UINT32_MAX),
ulEax(0),
ulEbx(0),
ulEcx(0),
ulEdx(0)
{}
{
return ( (this == &c)
)
);
}
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct Cpu
{
Cpu()
: ulId(UINT32_MAX)
{}
{
}
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct IoSettings
{
IoSettings();
bool operator==(const IoSettings &i) const
{
return ( (fIoCacheEnabled == i.fIoCacheEnabled)
&& (ulIoCacheSize == i.ulIoCacheSize));
}
bool fIoCacheEnabled;
};
/**
* Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
* field.
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct Hardware
{
Hardware();
bool fHardwareVirt,
fPAE;
bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
bool fAccelerate3D,
fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
// technically these two have no business in the hardware section, but for some
// clever reason <Hardware> is where they are in the XML....
bool fPageFusionEnabled;
};
/**
* A device attached to a storage controller. This can either be a
* hard disk or a DVD drive or a floppy drive and also specifies
* which medium is "in" the drive; as a result, this is a combination
* of the Main IMedium and IMediumAttachment interfaces.
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct AttachedDevice
{
fPassThrough(false),
lPort(0),
lDevice(0),
{}
bool operator==(const AttachedDevice &a) const;
// DVDs can be in pass-through mode:
bool fPassThrough;
// if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
// this is its UUID; it depends on deviceType which media registry this then needs to
// be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
// for DVDs and floppies, the attachment can also be a host device:
};
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct StorageController
{
ulPortCount(2),
ulInstance(0),
fUseHostIOCache(true),
fBootable(true),
{}
bool operator==(const StorageController &s) const;
bool fUseHostIOCache;
bool fBootable;
// only for when controllerType == StorageControllerType_IntelAhci:
};
/**
* We wrap the storage controllers list into an extra struct so we can
* use an undefined struct without needing std::list<> in all the headers.
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct Storage
{
};
struct Snapshot;
/**
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by MachineConfigFile::operator==(), or otherwise
* your settings might never get saved.
*/
struct Snapshot
{
strDescription; // optional
};
struct MachineUserData
{
: fNameSync(true),
fTeleporterEnabled(false),
uTeleporterPort(0),
fRTCUseUTC(false)
{ }
bool operator==(const MachineUserData &c) const
{
&& (strDescription == c.strDescription)
&& (strSnapshotFolder == c.strSnapshotFolder)
&& (fTeleporterEnabled == c.fTeleporterEnabled)
&& (uTeleporterPort == c.uTeleporterPort)
&& (strTeleporterAddress == c.strTeleporterAddress)
&& (strTeleporterPassword == c.strTeleporterPassword)
&& (enmFaultToleranceState == c.enmFaultToleranceState)
&& (uFaultTolerancePort == c.uFaultTolerancePort)
&& (fRTCUseUTC == c.fRTCUseUTC);
}
bool fNameSync;
bool fTeleporterEnabled;
bool fRTCUseUTC;
};
/**
* MachineConfigFile represents an XML machine configuration. All the machine settings
* that go out to the XML (or are read from it) are in here.
*
* NOTE: If you add any fields in here, you must update a) the constructor and b)
* the operator== which is used by Machine::saveSettings(), or otherwise your settings
* might never get saved.
*/
{
bool fCurrentStateModified; // optional, default is true
bool fAborted; // optional, default is false
bool operator==(const MachineConfigFile &m) const;
bool canHaveOwnMediaRegistry() const;
enum
{
BuildMachineXML_IncludeSnapshots = 0x01,
BuildMachineXML_MediaRegistry = 0x08,
};
static AudioDriverType_T getHostDefaultAudioDriver();
void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, const NetworkAdapter &nic);
bool fSkipRemovableMedia,
void bumpSettingsVersionIfNeeded();
};
} // namespace settings
#endif /* ___VBox_settings_h */