diff options
Diffstat (limited to 'include/VBox/settings.h')
-rw-r--r-- | include/VBox/settings.h | 213 |
1 files changed, 172 insertions, 41 deletions
diff --git a/include/VBox/settings.h b/include/VBox/settings.h index 4c69a0e2..eb931d68 100644 --- a/include/VBox/settings.h +++ b/include/VBox/settings.h @@ -17,7 +17,7 @@ */ /* - * Copyright (C) 2007-2012 Oracle Corporation + * Copyright (C) 2007-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -50,6 +50,14 @@ #include <list> #include <map> +/** + * Maximum depth of the snapshot tree, to prevent stack overflows. + * XPCOM has a relatively low stack size for its workers, and we have + * to avoid crashes due to exceeding the limit both on reading and + * writing config files. + */ +#define SETTINGS_SNAPSHOT_DEPTH_MAX 250 + namespace xml { class ElementNode; @@ -154,6 +162,54 @@ struct MediaRegistry }; /** + * + */ +struct NATRule +{ + NATRule() + : proto(NATProtocol_TCP), + u16HostPort(0), + u16GuestPort(0) + {} + + bool operator==(const NATRule &r) const + { + return strName == r.strName + && proto == r.proto + && u16HostPort == r.u16HostPort + && strHostIP == r.strHostIP + && u16GuestPort == r.u16GuestPort + && strGuestIP == r.strGuestIP; + } + + com::Utf8Str strName; + NATProtocol_T proto; + uint16_t u16HostPort; + com::Utf8Str strHostIP; + uint16_t u16GuestPort; + com::Utf8Str strGuestIP; +}; +typedef std::list<NATRule> NATRuleList; + + +struct NATHostLoopbackOffset +{ + /** Note: 128/8 is only acceptable */ + com::Utf8Str strLoopbackHostAddress; + uint32_t u32Offset; + bool operator == (const com::Utf8Str& strAddr) + { + return (strLoopbackHostAddress == strAddr); + } + + bool operator == (uint32_t off) + { + return (this->u32Offset == off); + } +}; +typedef std::list<NATHostLoopbackOffset> NATLoopbackOffsetList; + +/** * Common base class for both MainConfigFile and MachineConfigFile * which contains some common logic for both. */ @@ -186,6 +242,8 @@ protected: typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType; void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia); void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr); + void readNATForwardRuleList(const xml::ElementNode &elmParent, NATRuleList &llRules); + void readNATLoopbacks(const xml::ElementNode &elmParent, NATLoopbackOffsetList &llLoopBacks); void setVersionAttribute(xml::ElementNode &elm); void createStubDocument(); @@ -200,6 +258,8 @@ protected: uint32_t level); void buildMediaRegistry(xml::ElementNode &elmParent, const MediaRegistry &mr); + void buildNATForwardRuleList(xml::ElementNode &elmParent, const NATRuleList &natRuleList); + void buildNATLoopbacks(xml::ElementNode &elmParent, const NATLoopbackOffsetList &natLoopbackList); void clearDocument(); struct Data; @@ -223,6 +283,11 @@ struct SystemProperties { SystemProperties() : ulLogHistoryCount(3) +#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) + , fExclusiveHwVirt(false) +#else + , fExclusiveHwVirt(true) +#endif {} com::Utf8Str strDefaultMachineFolder; @@ -233,7 +298,10 @@ struct SystemProperties com::Utf8Str strDefaultVRDEExtPack; com::Utf8Str strAutostartDatabasePath; com::Utf8Str strDefaultAdditionsISO; + com::Utf8Str strDefaultFrontend; + com::Utf8Str strLoggingLevel; uint32_t ulLogHistoryCount; + bool fExclusiveHwVirt; }; struct MachineRegistryEntry @@ -243,6 +311,29 @@ struct MachineRegistryEntry }; typedef std::list<MachineRegistryEntry> MachinesRegistry; +typedef std::map<DhcpOpt_T, com::Utf8Str> DhcpOptionMap; +typedef DhcpOptionMap::value_type DhcpOptValuePair; +typedef DhcpOptionMap::iterator DhcpOptIterator; +typedef DhcpOptionMap::const_iterator DhcpOptConstIterator; + +typedef struct VmNameSlotKey +{ + VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot): VmName(aVmName), + Slot(aSlot){} + const com::Utf8Str VmName; + LONG Slot; + bool operator< (const VmNameSlotKey& that) const + { + if (VmName == that.VmName) + return Slot < that.Slot; + else return VmName < that.VmName; + } +} VmNameSlotKey; +typedef std::map<VmNameSlotKey, DhcpOptionMap> VmSlot2OptionsMap; +typedef VmSlot2OptionsMap::value_type VmSlot2OptionsPair; +typedef VmSlot2OptionsMap::iterator VmSlot2OptionsIterator; +typedef VmSlot2OptionsMap::const_iterator VmSlot2OptionsConstIterator; + struct DHCPServer { DHCPServer() @@ -251,13 +342,45 @@ struct DHCPServer com::Utf8Str strNetworkName, strIPAddress, - strIPNetworkMask, strIPLower, strIPUpper; bool fEnabled; + std::map<DhcpOpt_T, com::Utf8Str> GlobalDhcpOptions; + VmSlot2OptionsMap VmSlot2OptionsM; }; typedef std::list<DHCPServer> DHCPServersList; + +/** + * Nat Networking settings (NAT service). + */ +struct NATNetwork +{ + com::Utf8Str strNetworkName; + bool fEnabled; + com::Utf8Str strNetwork; + bool fIPv6; + com::Utf8Str strIPv6Prefix; + uint32_t u32HostLoopback6Offset; + NATLoopbackOffsetList llHostLoopbackOffsetList; + bool fAdvertiseDefaultIPv6Route; + bool fNeedDhcpServer; + NATRuleList llPortForwardRules4; + NATRuleList llPortForwardRules6; + NATNetwork():fEnabled(true), + fAdvertiseDefaultIPv6Route(false), + fNeedDhcpServer(true) + {} + bool operator==(const NATNetwork &n) const + { + return strNetworkName == n.strNetworkName + && strNetwork == n.strNetwork; + } + +}; +typedef std::list<NATNetwork> NATNetworksList; + + class MainConfigFile : public ConfigFileBase { public: @@ -265,6 +388,8 @@ public: void readMachineRegistry(const xml::ElementNode &elmMachineRegistry); void readDHCPServers(const xml::ElementNode &elmDHCPServers); + void readDhcpOptions(DhcpOptionMap& map, const xml::ElementNode& options); + void readNATNetworks(const xml::ElementNode &elmNATNetworks); void write(const com::Utf8Str strFilename); @@ -273,7 +398,11 @@ public: MediaRegistry mediaRegistry; MachinesRegistry llMachines; DHCPServersList llDhcpServers; + NATNetworksList llNATNetworks; StringsMap mapExtraDataItems; + +private: + void bumpSettingsVersionIfNeeded(); }; //////////////////////////////////////////////////////////////////////////////// @@ -348,43 +477,27 @@ struct BIOSSettings struct USBController { USBController() - : fEnabled(false), - fEnabledEHCI(false) + : enmType(USBControllerType_Null) {} bool operator==(const USBController &u) const; - bool fEnabled; - bool fEnabledEHCI; - USBDeviceFiltersList llDeviceFilters; + com::Utf8Str strName; + USBControllerType_T enmType; }; +typedef std::list<USBController> USBControllerList; - struct NATRule - { - NATRule() - : proto(NATProtocol_TCP), - u16HostPort(0), - u16GuestPort(0) - {} +struct USB +{ + USB() {} - bool operator==(const NATRule &r) const - { - return strName == r.strName - && proto == r.proto - && u16HostPort == r.u16HostPort - && strHostIP == r.strHostIP - && u16GuestPort == r.u16GuestPort - && strGuestIP == r.strGuestIP; - } + bool operator==(const USB &u) const; - com::Utf8Str strName; - NATProtocol_T proto; - uint16_t u16HostPort; - com::Utf8Str strHostIP; - uint16_t u16GuestPort; - com::Utf8Str strGuestIP; - }; - typedef std::list<NATRule> NATRuleList; + /** List of USB controllers present. */ + USBControllerList llUSBControllers; + /** List of USB device filters. */ + USBDeviceFiltersList llDeviceFilters; +}; struct NAT { @@ -441,6 +554,7 @@ struct USBController bool fAliasUseSamePorts; NATRuleList llRules; }; + /** * 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 @@ -480,6 +594,7 @@ struct NetworkAdapter com::Utf8Str strInternalNetworkName; com::Utf8Str strGenericDriver; StringsMap genericProperties; + com::Utf8Str strNATNetworkName; uint32_t ulBootPriority; com::Utf8Str strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2) }; @@ -754,13 +869,16 @@ struct Hardware com::Guid uuid; // hardware uuid, optional (null). bool fHardwareVirt, - fHardwareVirtExclusive, fNestedPaging, fLargePages, fVPID, + fUnrestrictedExecution, fHardwareVirtForce, fSyntheticCpu, + fTripleFaultReset, fPAE; + typedef enum LongModeType { LongMode_Enabled, LongMode_Disabled, LongMode_Legacy } LongModeType; + LongModeType enmLongMode; uint32_t cCPUs; bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2) CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2) @@ -773,14 +891,20 @@ struct Hardware BootOrderMap mapBootOrder; // item 0 has highest priority + GraphicsControllerType_T graphicsControllerType; uint32_t ulVRAMSizeMB; uint32_t cMonitors; bool fAccelerate3D, fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1) - uint32_t ulVideoCaptureHorzRes; - uint32_t ulVideoCaptureVertRes; - bool fVideoCaptureEnabled; - com::Utf8Str strVideoCaptureFile; + + uint32_t ulVideoCaptureHorzRes; // requires settings version 1.14 (VirtualBox 4.3) + uint32_t ulVideoCaptureVertRes; // requires settings version 1.14 (VirtualBox 4.3) + uint32_t ulVideoCaptureRate; // requires settings version 1.14 (VirtualBox 4.3) + uint32_t ulVideoCaptureFPS; // requires settings version 1.14 (VirtualBox 4.3) + bool fVideoCaptureEnabled; // requires settings version 1.14 (VirtualBox 4.3) + uint64_t u64VideoCaptureScreens; // requires settings version 1.14 (VirtualBox 4.3) + com::Utf8Str strVideoCaptureFile; // requires settings version 1.14 (VirtualBox 4.3) + FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1) PointingHIDType_T pointingHIDType; // requires settings version 1.10 (VirtualBox 3.2) @@ -793,7 +917,7 @@ struct Hardware VRDESettings vrdeSettings; BIOSSettings biosSettings; - USBController usbController; + USB usbSettings; NetworkAdaptersList llNetworkAdapters; SerialPortsList llSerialPorts; ParallelPortsList llParallelPorts; @@ -813,6 +937,8 @@ struct Hardware IOSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2) HostPCIDeviceAttachmentList pciAttachments; // requires settings version 1.12 (VirtualBox 4.1) + + com::Utf8Str strDefaultFrontend; // requires settings version 1.14 (VirtualBox 4.3) }; /** @@ -853,6 +979,9 @@ struct AttachedDevice // Whether the medium supports discarding unused blocks: bool fDiscard; + // Whether the medium is hot-pluggable: + bool fHotPluggable; + int32_t lPort; int32_t lDevice; @@ -1045,7 +1174,8 @@ struct MachineUserData && (uFaultToleranceInterval == c.uFaultToleranceInterval) && (strFaultToleranceAddress == c.strFaultToleranceAddress) && (strFaultTolerancePassword == c.strFaultTolerancePassword) - && (fRTCUseUTC == c.fRTCUseUTC); + && (fRTCUseUTC == c.fRTCUseUTC) + && (ovIcon == c.ovIcon); } com::Utf8Str strName; @@ -1065,6 +1195,7 @@ struct MachineUserData com::Utf8Str strFaultTolerancePassword; uint32_t uFaultToleranceInterval; bool fRTCUseUTC; + com::Utf8Str ovIcon; }; /** @@ -1112,7 +1243,7 @@ public: enum { BuildMachineXML_IncludeSnapshots = 0x01, - BuildMachineXML_WriteVboxVersionAttribute = 0x02, + BuildMachineXML_WriteVBoxVersionAttribute = 0x02, BuildMachineXML_SkipRemovableMedia = 0x04, BuildMachineXML_MediaRegistry = 0x08, BuildMachineXML_SuppressSavedState = 0x10 @@ -1142,7 +1273,7 @@ private: void readDebugging(const xml::ElementNode *pElmDbg, Debugging *pDbg); void readAutostart(const xml::ElementNode *pElmAutostart, Autostart *pAutostart); void readGroups(const xml::ElementNode *elmGroups, StringsList *pllGroups); - void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap); + bool readSnapshot(const com::Guid &curSnapshotUuid, uint32_t depth, const xml::ElementNode &elmSnapshot, Snapshot &snap); void convertOldOSType_pre1_5(com::Utf8Str &str); void readMachine(const xml::ElementNode &elmMachine); @@ -1155,7 +1286,7 @@ private: void buildDebuggingXML(xml::ElementNode *pElmParent, const Debugging *pDbg); void buildAutostartXML(xml::ElementNode *pElmParent, const Autostart *pAutostart); void buildGroupsXML(xml::ElementNode *pElmParent, const StringsList *pllGroups); - void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap); + void buildSnapshotXML(uint32_t depth, xml::ElementNode &elmParent, const Snapshot &snap); void bumpSettingsVersionIfNeeded(); }; |