settings.h revision 1cd59fdf671ca60c64d77e3f7046aaecf7003824
/** @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-2012 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
{
Medium()
: fAutoReset(false),
{}
// 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);
/* Note: this copy constructor doesn't create a full copy of other, cause
* the file based stuff (xml doc) could not be copied. */
~ConfigFileBase();
StringsMap &map);
void createStubDocument();
const USBDeviceFiltersList &ll,
bool fHostMode);
const Medium &m,
const MediaRegistry &mr);
void clearDocument();
struct Data;
Data *m;
};
////////////////////////////////////////////////////////////////////////////////
//
// VirtualBox.xml structures
//
////////////////////////////////////////////////////////////////////////////////
struct Host
{
};
struct SystemProperties
{
: ulLogHistoryCount(3)
{}
};
struct MachineRegistryEntry
{
};
struct DHCPServer
{
: fEnabled(false)
{}
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)
{}
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
{
NATRule()
: proto(NATProtocol_TCP),
u16HostPort(0),
u16GuestPort(0)
{}
{
&& u16HostPort == r.u16HostPort
&& u16GuestPort == r.u16GuestPort
&& strGuestIP == r.strGuestIP;
}
};
struct NAT
{
NAT()
: u32Mtu(0),
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)
{}
{
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
}
bool fDNSPassDomain;
bool fDNSProxy;
bool fDNSUseHostResolver;
bool fAliasLog;
bool fAliasProxyOnly;
bool 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),
{}
bool operator==(const NetworkAdapter &n) const;
bool fEnabled;
bool fCableConnected;
bool fTraceEnabled;
};
/**
* 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(7)
{}
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 BandwidthGroup
{
: cMaxBytesPerSec(0),
{}
bool operator==(const BandwidthGroup &i) const
{
&& (cMaxBytesPerSec == i.cMaxBytesPerSec)
}
};
/**
* 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)
&& (llBandwidthGroups == i.llBandwidthGroups));
}
bool fIOCacheEnabled;
};
/**
* 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 HostPCIDeviceAttachment
{
: uHostAddress(0),
{}
bool operator==(const HostPCIDeviceAttachment &a) const
{
return ( (uHostAddress == a.uHostAddress)
&& (uGuestAddress == a.uGuestAddress)
&& (strDeviceName == a.strDeviceName)
);
}
};
/**
* 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)
bool fEmulatedUSBCardReader; // 1.12 (VirtualBox 4.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),
fTempEject(false),
fNonRotational(false),
lPort(0),
lDevice(0)
{}
bool operator==(const AttachedDevice &a) const;
// DVDs can be in pass-through mode:
bool fPassThrough;
// Whether guest-triggered eject of DVDs will keep the medium in the
// VM config or not:
bool fTempEject;
// Whether the medium is non-rotational:
bool fNonRotational;
// Whether the medium supports discarding unused blocks:
bool fDiscard;
// 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:
// Bandwidth group the device is attached to.
};
/**
* 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
{
};
/**
* Settings that has to do with debugging.
*/
struct Debugging
{
: fTracingEnabled(false),
fAllowTracingToAccessVM(false),
{ }
{
}
bool areDefaultSettings() const
{
return !fTracingEnabled
&& strTracingConfig.isEmpty();
}
bool fTracingEnabled;
bool fAllowTracingToAccessVM;
};
/**
* Settings that has to do with autostart.
*/
struct Autostart
{
: fAutostartEnabled(false),
uAutostartDelay(0),
{ }
{
}
bool areDefaultSettings() const
{
return !fAutostartEnabled
&& !uAutostartDelay
}
bool fAutostartEnabled;
};
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, bool fEnabled, const NetworkAdapter &nic);
bool fSkipRemovableMedia,
void bumpSettingsVersionIfNeeded();
};
} // namespace settings
#endif /* ___VBox_settings_h */