VirtualBox

Changeset 61009 in vbox for trunk


Ignore:
Timestamp:
May 17, 2016 5:18:29 PM (8 years ago)
Author:
vboxsync
Message:

Main: big settings cleanup and writing optimization. Moved constructors/equality/default checks into the .cpp file, and write only settings which aren't at the default value. Greatly reduces the effort needed to write everything out, especially when a lot of snapshots have to be dealt with. Move the storage controllers to the hardware settings, where they always belonged. No change to the XML file (yet). Lots of settings related cleanups in the API code.

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r60786 r61009  
    5050#include <list>
    5151#include <map>
     52#include <vector>
    5253
    5354/**
     
    8586////////////////////////////////////////////////////////////////////////////////
    8687
     88typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
     89typedef std::list<com::Utf8Str> StringsList;
     90
    8791/**
    8892 * USB device filter definition. This struct is used both in MainConfigFile
     
    9599struct USBDeviceFilter
    96100{
    97     USBDeviceFilter()
    98         : fActive(false),
    99           action(USBDeviceFilterAction_Null),
    100           ulMaskedInterfaces(0)
    101     {}
     101    USBDeviceFilter();
    102102
    103103    bool operator==(const USBDeviceFilter&u) const;
     
    117117};
    118118
    119 typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
    120 typedef std::list<com::Utf8Str> StringsList;
    121 
    122 // ExtraDataItem (used by both VirtualBox.xml and machines XML)
    123 struct USBDeviceFilter;
    124119typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
    125120
     
    134129struct Medium
    135130{
    136     Medium()
    137         : fAutoReset(false),
    138           hdType(MediumType_Normal)
    139     {}
     131    Medium();
     132
     133    bool operator==(const Medium &m) const;
    140134
    141135    com::Guid       uuid;
     
    151145    MediaList       llChildren;         // only used with hard disks
    152146
    153     bool operator==(const Medium &m) const;
    154 };
    155 
    156 extern const struct Medium g_MediumEmpty;
     147    static const struct Medium Empty;
     148};
    157149
    158150/**
     
    167159struct MediaRegistry
    168160{
     161    bool operator==(const MediaRegistry &m) const;
     162
    169163    MediaList               llHardDisks,
    170164                            llDvdImages,
    171165                            llFloppyImages;
    172 
    173     bool operator==(const MediaRegistry &m) const;
    174 };
    175 
    176 /**
    177  *
     166};
     167
     168/**
     169 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     170 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     171 * your settings might never get saved.
    178172 */
    179173struct NATRule
    180174{
    181     NATRule()
    182     : proto(NATProtocol_TCP),
    183       u16HostPort(0),
    184       u16GuestPort(0)
    185     {}
    186 
    187     bool operator==(const NATRule &r) const
    188     {
    189         return    strName == r.strName
    190                && proto == r.proto
    191                && u16HostPort == r.u16HostPort
    192                && strHostIP == r.strHostIP
    193                && u16GuestPort == r.u16GuestPort
    194                && strGuestIP == r.strGuestIP;
    195     }
     175    NATRule();
     176
     177    bool operator==(const NATRule &r) const;
    196178
    197179    com::Utf8Str            strName;
     
    204186typedef std::map<com::Utf8Str, NATRule> NATRulesMap;
    205187
    206 
    207188struct NATHostLoopbackOffset
    208189{
    209     /** Note: 128/8 is only acceptable */
    210     com::Utf8Str strLoopbackHostAddress;
    211     uint32_t u32Offset;
     190    NATHostLoopbackOffset();
     191
     192    bool operator==(const NATHostLoopbackOffset &o) const;
     193
    212194    bool operator==(const com::Utf8Str& strAddr)
    213195    {
     
    220202    }
    221203
    222     bool operator==(const NATHostLoopbackOffset &o) const
    223     {
    224         return strLoopbackHostAddress == o.strLoopbackHostAddress
    225             && u32Offset == o.u32Offset;
    226     }
    227 };
     204    /** Note: 128/8 is only acceptable */
     205    com::Utf8Str strLoopbackHostAddress;
     206    uint32_t u32Offset;
     207};
     208
    228209typedef std::list<NATHostLoopbackOffset> NATLoopbackOffsetList;
     210
     211typedef std::vector<uint8_t> IconBlob;
    229212
    230213/**
     
    254237    void parseTimestamp(RTTIMESPEC &timestamp,
    255238                        const com::Utf8Str &str) const;
     239    void parseBase64(IconBlob &binary,
     240                     const com::Utf8Str &str) const;
    256241    com::Utf8Str stringifyTimestamp(const RTTIMESPEC &tm) const;
     242    void toBase64(com::Utf8Str &str,
     243                  const IconBlob &binary) const;
    257244
    258245    void readExtraData(const xml::ElementNode &elmExtraData,
     
    313300struct SystemProperties
    314301{
    315     SystemProperties()
    316         : ulLogHistoryCount(3)
    317 #if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
    318         , fExclusiveHwVirt(false)
    319 #else
    320         , fExclusiveHwVirt(true)
    321 #endif
    322     {}
     302    SystemProperties();
    323303
    324304    com::Utf8Str            strDefaultMachineFolder;
     
    341321    com::Utf8Str    strSettingsFile;
    342322};
     323
    343324typedef std::list<MachineRegistryEntry> MachinesRegistry;
    344325
    345326struct DhcpOptValue
    346327{
    347     enum Encoding {
    348         LEGACY = DhcpOptEncoding_Legacy,
    349         HEX = DhcpOptEncoding_Hex
    350     };
     328    DhcpOptValue();
     329    DhcpOptValue(const com::Utf8Str &aText, DhcpOptEncoding_T aEncoding = DhcpOptEncoding_Legacy);
    351330
    352331    com::Utf8Str text;
    353     Encoding encoding;
    354 
    355     DhcpOptValue()
    356       : text(), encoding(LEGACY) {}
    357 
    358     DhcpOptValue(const com::Utf8Str &aText, Encoding aEncoding = LEGACY)
    359       : text(aText), encoding(aEncoding) {}
     332    DhcpOptEncoding_T encoding;
    360333};
    361334
     
    367340typedef struct VmNameSlotKey
    368341{
    369     VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot): VmName(aVmName),
    370       Slot(aSlot){}
     342    VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot);
     343
     344    bool operator<(const VmNameSlotKey& that) const;
     345
    371346    const com::Utf8Str VmName;
    372347    LONG      Slot;
    373     bool operator< (const VmNameSlotKey& that) const
    374     {
    375         if (VmName == that.VmName)
    376             return Slot < that.Slot;
    377         else return VmName < that.VmName;
    378     }
    379348} VmNameSlotKey;
     349
    380350typedef std::map<VmNameSlotKey, DhcpOptionMap> VmSlot2OptionsMap;
    381351typedef VmSlot2OptionsMap::value_type VmSlot2OptionsPair;
     
    385355struct DHCPServer
    386356{
    387     DHCPServer()
    388         : fEnabled(false)
    389     {}
     357    DHCPServer();
    390358
    391359    com::Utf8Str    strNetworkName,
     
    397365    VmSlot2OptionsMap VmSlot2OptionsM;
    398366};
     367
    399368typedef std::list<DHCPServer> DHCPServersList;
    400369
    401370
    402371/**
    403  * Nat Networking settings (NAT service).
     372 * NAT Networking settings (NAT service).
    404373 */
    405374struct NATNetwork
    406375{
     376    NATNetwork();
     377
    407378    com::Utf8Str strNetworkName;
    408379    com::Utf8Str strIPv4NetworkCidr;
     
    416387    NATRulesMap  mapPortForwardRules4;
    417388    NATRulesMap  mapPortForwardRules6;
    418     NATNetwork() :
    419       fEnabled(true),
    420       fIPv6Enabled(false),
    421       fAdvertiseDefaultIPv6Route(false),
    422       fNeedDhcpServer(true),
    423       u32HostLoopback6Offset(0)
    424       {}
    425     bool operator==(const NATNetwork &n) const
    426     {
    427         return strNetworkName               == n.strNetworkName
    428             && strIPv4NetworkCidr           == n.strIPv4NetworkCidr
    429             && strIPv6Prefix                == n.strIPv6Prefix
    430             && fEnabled                     == n.fEnabled
    431             && fIPv6Enabled                 == n.fIPv6Enabled
    432             && fAdvertiseDefaultIPv6Route   == n.fAdvertiseDefaultIPv6Route
    433             && fNeedDhcpServer              == n.fNeedDhcpServer
    434             && u32HostLoopback6Offset       == n.u32HostLoopback6Offset
    435             && llHostLoopbackOffsetList     == n.llHostLoopbackOffsetList
    436             && mapPortForwardRules4         == n.mapPortForwardRules4
    437             && mapPortForwardRules6         == n.mapPortForwardRules6;
    438     }
    439 
    440 };
     389};
     390
    441391typedef std::list<NATNetwork> NATNetworksList;
    442392
     
    481431struct VRDESettings
    482432{
    483     VRDESettings()
    484         : fEnabled(true),
    485           authType(AuthType_Null),
    486           ulAuthTimeout(5000),
    487           fAllowMultiConnection(false),
    488           fReuseSingleConnection(false)
    489     {}
     433    VRDESettings();
     434
     435    bool areDefaultSettings() const;
    490436
    491437    bool operator==(const VRDESettings& v) const;
     
    508454struct BIOSSettings
    509455{
    510     BIOSSettings()
    511         : fACPIEnabled(true),
    512           fIOAPICEnabled(false),
    513           fLogoFadeIn(true),
    514           fLogoFadeOut(true),
    515           ulLogoDisplayTime(0),
    516           biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
    517           fPXEDebugEnabled(false),
    518           llTimeOffset(0)
    519     {}
     456    BIOSSettings();
     457
     458    bool areDefaultSettings() const;
    520459
    521460    bool operator==(const BIOSSettings &d) const;
     
    539478struct USBController
    540479{
    541     USBController()
    542         : enmType(USBControllerType_Null)
    543     {}
     480    USBController();
    544481
    545482    bool operator==(const USBController &u) const;
     
    548485    USBControllerType_T     enmType;
    549486};
     487
    550488typedef std::list<USBController> USBControllerList;
    551489
    552490struct USB
    553491{
    554     USB() {}
     492    USB();
    555493
    556494    bool operator==(const USB &u) const;
     
    564502struct NAT
    565503{
    566     NAT()
    567         : u32Mtu(0),
    568           u32SockRcv(0),
    569           u32SockSnd(0),
    570           u32TcpRcv(0),
    571           u32TcpSnd(0),
    572           fDNSPassDomain(true), /* historically this value is true */
    573           fDNSProxy(false),
    574           fDNSUseHostResolver(false),
    575           fAliasLog(false),
    576           fAliasProxyOnly(false),
    577           fAliasUseSamePorts(false)
    578     {}
    579 
    580     bool operator==(const NAT &n) const
    581     {
    582        return strNetwork           == n.strNetwork
    583             && strBindIP           == n.strBindIP
    584             && u32Mtu              == n.u32Mtu
    585             && u32SockRcv          == n.u32SockRcv
    586             && u32SockSnd          == n.u32SockSnd
    587             && u32TcpSnd           == n.u32TcpSnd
    588             && u32TcpRcv           == n.u32TcpRcv
    589             && strTFTPPrefix       == n.strTFTPPrefix
    590             && strTFTPBootFile     == n.strTFTPBootFile
    591             && strTFTPNextServer   == n.strTFTPNextServer
    592             && fDNSPassDomain      == n.fDNSPassDomain
    593             && fDNSProxy           == n.fDNSProxy
    594             && fDNSUseHostResolver == n.fDNSUseHostResolver
    595             && fAliasLog           == n.fAliasLog
    596             && fAliasProxyOnly     == n.fAliasProxyOnly
    597             && fAliasUseSamePorts  == n.fAliasUseSamePorts
    598             && mapRules            == n.mapRules;
    599     }
     504    NAT();
     505
     506    bool areDNSDefaultSettings() const;
     507    bool areAliasDefaultSettings() const;
     508    bool areTFTPDefaultSettings() const;
     509    bool areDefaultSettings() const;
     510
     511    bool operator==(const NAT &n) const;
    600512
    601513    com::Utf8Str            strNetwork;
     
    625537struct NetworkAdapter
    626538{
    627     NetworkAdapter()
    628         : ulSlot(0),
    629           type(NetworkAdapterType_Am79C970A),
    630           fEnabled(false),
    631           fCableConnected(false),
    632           ulLineSpeed(0),
    633           enmPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
    634           fTraceEnabled(false),
    635           mode(NetworkAttachmentType_Null),
    636           ulBootPriority(0)
    637     {}
     539    NetworkAdapter();
     540
     541    bool areGenericDriverDefaultSettings() const;
     542    bool areDefaultSettings() const;
     543    bool areDisabledDefaultSettings() const;
    638544
    639545    bool operator==(const NetworkAdapter &n) const;
     
    661567    com::Utf8Str                        strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2)
    662568};
     569
    663570typedef std::list<NetworkAdapter> NetworkAdaptersList;
    664571
     
    670577struct SerialPort
    671578{
    672     SerialPort()
    673         : ulSlot(0),
    674           fEnabled(false),
    675           ulIOBase(0x3f8),
    676           ulIRQ(4),
    677           portMode(PortMode_Disconnected),
    678           fServer(false)
    679     {}
     579    SerialPort();
    680580
    681581    bool operator==(const SerialPort &n) const;
     
    690590    bool            fServer;
    691591};
     592
    692593typedef std::list<SerialPort> SerialPortsList;
    693594
     
    699600struct ParallelPort
    700601{
    701     ParallelPort()
    702         : ulSlot(0),
    703           fEnabled(false),
    704           ulIOBase(0x378),
    705           ulIRQ(7)
    706     {}
     602    ParallelPort();
    707603
    708604    bool operator==(const ParallelPort &d) const;
     
    715611    com::Utf8Str    strPath;
    716612};
     613
    717614typedef std::list<ParallelPort> ParallelPortsList;
    718615
     
    724621struct AudioAdapter
    725622{
    726     AudioAdapter()
    727         : fEnabled(true),
    728           controllerType(AudioControllerType_AC97),
    729           codecType(AudioCodecType_STAC9700),
    730           driverType(AudioDriverType_Null)
    731     {}
    732 
    733     bool operator==(const AudioAdapter &a) const
    734     {
    735         return     (this == &a)
    736                 || (    (fEnabled        == a.fEnabled)
    737                      && (controllerType  == a.controllerType)
    738                      && (codecType       == a.codecType)
    739                      && (driverType      == a.driverType)
    740                      && (properties      == a.properties)
    741                    );
    742     }
     623    AudioAdapter();
     624
     625    bool areDefaultSettings() const;
     626
     627    bool operator==(const AudioAdapter &a) const;
    743628
    744629    bool                    fEnabled;
     
    756641struct SharedFolder
    757642{
    758     SharedFolder()
    759         : fWritable(false)
    760         , fAutoMount(false)
    761     {}
     643    SharedFolder();
    762644
    763645    bool operator==(const SharedFolder &a) const;
     
    768650    bool            fAutoMount;
    769651};
     652
    770653typedef std::list<SharedFolder> SharedFoldersList;
    771654
     
    777660struct GuestProperty
    778661{
    779     GuestProperty()
    780         : timestamp(0)
    781     {};
     662    GuestProperty();
    782663
    783664    bool operator==(const GuestProperty &g) const;
     
    788669    com::Utf8Str    strFlags;
    789670};
     671
    790672typedef std::list<GuestProperty> GuestPropertiesList;
    791673
     
    799681struct CpuIdLeaf
    800682{
    801     CpuIdLeaf()
    802         : ulId(UINT32_MAX),
    803           ulEax(0),
    804           ulEbx(0),
    805           ulEcx(0),
    806           ulEdx(0)
    807     {}
    808 
    809     bool operator==(const CpuIdLeaf &c) const
    810     {
    811         return (    (this == &c)
    812                  || (    (ulId      == c.ulId)
    813                       && (ulEax     == c.ulEax)
    814                       && (ulEbx     == c.ulEbx)
    815                       && (ulEcx     == c.ulEcx)
    816                       && (ulEdx     == c.ulEdx)
    817                     )
    818                );
    819     }
     683    CpuIdLeaf();
     684
     685    bool operator==(const CpuIdLeaf &c) const;
    820686
    821687    uint32_t                ulId;
     
    825691    uint32_t                ulEdx;
    826692};
     693
    827694typedef std::list<CpuIdLeaf> CpuIdLeafsList;
    828695
     
    834701struct Cpu
    835702{
    836     Cpu()
    837         : ulId(UINT32_MAX)
    838     {}
    839 
    840     bool operator==(const Cpu &c) const
    841     {
    842         return (ulId == c.ulId);
    843     }
     703    Cpu();
     704
     705    bool operator==(const Cpu &c) const;
    844706
    845707    uint32_t                ulId;
    846708};
     709
    847710typedef std::list<Cpu> CpuList;
    848711
     
    854717struct BandwidthGroup
    855718{
    856     BandwidthGroup()
    857         : cMaxBytesPerSec(0),
    858           enmType(BandwidthGroupType_Null)
    859     {}
    860 
    861     bool operator==(const BandwidthGroup &i) const
    862     {
    863         return (   (strName      == i.strName)
    864                 && (cMaxBytesPerSec == i.cMaxBytesPerSec)
    865                 && (enmType      == i.enmType));
    866     }
     719    BandwidthGroup();
     720
     721    bool operator==(const BandwidthGroup &i) const;
    867722
    868723    com::Utf8Str         strName;
     
    870725    BandwidthGroupType_T enmType;
    871726};
     727
    872728typedef std::list<BandwidthGroup> BandwidthGroupList;
    873729
     
    881737    IOSettings();
    882738
    883     bool operator==(const IOSettings &i) const
    884     {
    885         return (   (fIOCacheEnabled   == i.fIOCacheEnabled)
    886                 && (ulIOCacheSize     == i.ulIOCacheSize)
    887                 && (llBandwidthGroups == i.llBandwidthGroups));
    888     }
     739    bool areIOCacheDefaultSettings() const;
     740    bool areDefaultSettings() const;
     741
     742    bool operator==(const IOSettings &i) const;
    889743
    890744    bool               fIOCacheEnabled;
     
    900754struct HostPCIDeviceAttachment
    901755{
    902     HostPCIDeviceAttachment()
    903         : uHostAddress(0),
    904           uGuestAddress(0)
    905     {}
    906 
    907     bool operator==(const HostPCIDeviceAttachment &a) const
    908     {
    909         return (   (uHostAddress   == a.uHostAddress)
    910                 && (uGuestAddress  == a.uGuestAddress)
    911                 && (strDeviceName  == a.strDeviceName)
    912                );
    913     }
     756    HostPCIDeviceAttachment();
     757
     758    bool operator==(const HostPCIDeviceAttachment &a) const;
    914759
    915760    com::Utf8Str    strDeviceName;
     
    917762    uint32_t        uGuestAddress;
    918763};
     764
    919765typedef std::list<HostPCIDeviceAttachment> HostPCIDeviceAttachmentList;
     766
     767/**
     768 * A device attached to a storage controller. This can either be a
     769 * hard disk or a DVD drive or a floppy drive and also specifies
     770 * which medium is "in" the drive; as a result, this is a combination
     771 * of the Main IMedium and IMediumAttachment interfaces.
     772 *
     773 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     774 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     775 * your settings might never get saved.
     776 */
     777struct AttachedDevice
     778{
     779    AttachedDevice();
     780
     781    bool operator==(const AttachedDevice &a) const;
     782
     783    DeviceType_T        deviceType;         // only HardDisk, DVD or Floppy are allowed
     784
     785    // DVDs can be in pass-through mode:
     786    bool                fPassThrough;
     787
     788    // Whether guest-triggered eject of DVDs will keep the medium in the
     789    // VM config or not:
     790    bool                fTempEject;
     791
     792    // Whether the medium is non-rotational:
     793    bool                fNonRotational;
     794
     795    // Whether the medium supports discarding unused blocks:
     796    bool                fDiscard;
     797
     798    // Whether the medium is hot-pluggable:
     799    bool                fHotPluggable;
     800
     801    int32_t             lPort;
     802    int32_t             lDevice;
     803
     804    // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
     805    // this is its UUID; it depends on deviceType which media registry this then needs to
     806    // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
     807    com::Guid           uuid;
     808
     809    // for DVDs and floppies, the attachment can also be a host device:
     810    com::Utf8Str        strHostDriveSrc;        // if != NULL, value of <HostDrive>/@src
     811
     812    // Bandwidth group the device is attached to.
     813    com::Utf8Str        strBwGroup;
     814};
     815
     816typedef std::list<AttachedDevice> AttachedDevicesList;
     817
     818/**
     819 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     820 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     821 * your settings might never get saved.
     822 */
     823struct StorageController
     824{
     825    StorageController();
     826
     827    bool operator==(const StorageController &s) const;
     828
     829    com::Utf8Str            strName;
     830    StorageBus_T            storageBus;             // _SATA, _SCSI, _IDE, _SAS
     831    StorageControllerType_T controllerType;
     832    uint32_t                ulPortCount;
     833    uint32_t                ulInstance;
     834    bool                    fUseHostIOCache;
     835    bool                    fBootable;
     836
     837    // only for when controllerType == StorageControllerType_IntelAhci:
     838    int32_t                 lIDE0MasterEmulationPort,
     839                            lIDE0SlaveEmulationPort,
     840                            lIDE1MasterEmulationPort,
     841                            lIDE1SlaveEmulationPort;
     842
     843    AttachedDevicesList     llAttachedDevices;
     844};
     845
     846typedef std::list<StorageController> StorageControllersList;
     847
     848/**
     849 * We wrap the storage controllers list into an extra struct so we can
     850 * use an undefined struct without needing std::list<> in all the headers.
     851 *
     852 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     853 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     854 * your settings might never get saved.
     855 */
     856struct Storage
     857{
     858    bool operator==(const Storage &s) const;
     859
     860    StorageControllersList  llStorageControllers;
     861};
    920862
    921863/**
     
    931873    Hardware();
    932874
     875    bool areParavirtDefaultSettings() const;
     876    bool areBootOrderDefaultSettings() const;
     877    bool areDisplayDefaultSettings() const;
     878    bool areVideoCaptureDefaultSettings() const;
     879    bool areAllNetworkAdaptersDefaultSettings() const;
     880
    933881    bool operator==(const Hardware&) const;
    934 
    935     bool areParavirtDefaultSettings() const
    936     {
    937         return paravirtProvider == ParavirtProvider_Legacy;
    938     }
    939882
    940883    com::Utf8Str        strVersion;             // hardware version, optional
     
    1001944    ParallelPortsList   llParallelPorts;
    1002945    AudioAdapter        audioAdapter;
     946    Storage             storage;
    1003947
    1004948    // technically these two have no business in the hardware section, but for some
     
    1020964
    1021965/**
    1022  * A device attached to a storage controller. This can either be a
    1023  * hard disk or a DVD drive or a floppy drive and also specifies
    1024  * which medium is "in" the drive; as a result, this is a combination
    1025  * of the Main IMedium and IMediumAttachment interfaces.
    1026  *
    1027  * NOTE: If you add any fields in here, you must update a) the constructor and b)
    1028  * the operator== which is used by MachineConfigFile::operator==(), or otherwise
    1029  * your settings might never get saved.
    1030  */
    1031 struct AttachedDevice
    1032 {
    1033     AttachedDevice()
    1034         : deviceType(DeviceType_Null),
    1035           fPassThrough(false),
    1036           fTempEject(false),
    1037           fNonRotational(false),
    1038           fDiscard(false),
    1039           fHotPluggable(false),
    1040           lPort(0),
    1041           lDevice(0)
    1042     {}
    1043 
    1044     bool operator==(const AttachedDevice &a) const;
    1045 
    1046     DeviceType_T        deviceType;         // only HardDisk, DVD or Floppy are allowed
    1047 
    1048     // DVDs can be in pass-through mode:
    1049     bool                fPassThrough;
    1050 
    1051     // Whether guest-triggered eject of DVDs will keep the medium in the
    1052     // VM config or not:
    1053     bool                fTempEject;
    1054 
    1055     // Whether the medium is non-rotational:
    1056     bool                fNonRotational;
    1057 
    1058     // Whether the medium supports discarding unused blocks:
    1059     bool                fDiscard;
    1060 
    1061     // Whether the medium is hot-pluggable:
    1062     bool                fHotPluggable;
    1063 
    1064     int32_t             lPort;
    1065     int32_t             lDevice;
    1066 
    1067     // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
    1068     // this is its UUID; it depends on deviceType which media registry this then needs to
    1069     // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
    1070     com::Guid           uuid;
    1071 
    1072     // for DVDs and floppies, the attachment can also be a host device:
    1073     com::Utf8Str        strHostDriveSrc;        // if != NULL, value of <HostDrive>/@src
    1074 
    1075     // Bandwidth group the device is attached to.
    1076     com::Utf8Str        strBwGroup;
    1077 };
    1078 typedef std::list<AttachedDevice> AttachedDevicesList;
    1079 
    1080 /**
    1081  * NOTE: If you add any fields in here, you must update a) the constructor and b)
    1082  * the operator== which is used by MachineConfigFile::operator==(), or otherwise
    1083  * your settings might never get saved.
    1084  */
    1085 struct StorageController
    1086 {
    1087     StorageController()
    1088         : storageBus(StorageBus_IDE),
    1089           controllerType(StorageControllerType_PIIX3),
    1090           ulPortCount(2),
    1091           ulInstance(0),
    1092           fUseHostIOCache(true),
    1093           fBootable(true)
    1094     {}
    1095 
    1096     bool operator==(const StorageController &s) const;
    1097 
    1098     com::Utf8Str            strName;
    1099     StorageBus_T            storageBus;             // _SATA, _SCSI, _IDE, _SAS
    1100     StorageControllerType_T controllerType;
    1101     uint32_t                ulPortCount;
    1102     uint32_t                ulInstance;
    1103     bool                    fUseHostIOCache;
    1104     bool                    fBootable;
    1105 
    1106     // only for when controllerType == StorageControllerType_IntelAhci:
    1107     int32_t                 lIDE0MasterEmulationPort,
    1108                             lIDE0SlaveEmulationPort,
    1109                             lIDE1MasterEmulationPort,
    1110                             lIDE1SlaveEmulationPort;
    1111 
    1112     AttachedDevicesList     llAttachedDevices;
    1113 };
    1114 typedef std::list<StorageController> StorageControllersList;
    1115 
    1116 /**
    1117  * We wrap the storage controllers list into an extra struct so we can
    1118  * use an undefined struct without needing std::list<> in all the headers.
    1119  *
    1120  * NOTE: If you add any fields in here, you must update a) the constructor and b)
    1121  * the operator== which is used by MachineConfigFile::operator==(), or otherwise
    1122  * your settings might never get saved.
    1123  */
    1124 struct Storage
    1125 {
    1126     bool operator==(const Storage &s) const;
    1127 
    1128     StorageControllersList  llStorageControllers;
    1129 };
    1130 
    1131 /**
    1132966 * Settings that has to do with debugging.
    1133967 */
    1134968struct Debugging
    1135969{
    1136     Debugging()
    1137         : fTracingEnabled(false),
    1138           fAllowTracingToAccessVM(false),
    1139           strTracingConfig()
    1140     { }
    1141 
    1142     bool operator==(const Debugging &rOther) const
    1143     {
    1144         return fTracingEnabled          == rOther.fTracingEnabled
    1145             && fAllowTracingToAccessVM  == rOther.fAllowTracingToAccessVM
    1146             && strTracingConfig         == rOther.strTracingConfig;
    1147     }
    1148 
    1149     bool areDefaultSettings() const
    1150     {
    1151         return !fTracingEnabled
    1152             && !fAllowTracingToAccessVM
    1153             && strTracingConfig.isEmpty();
    1154     }
     970    Debugging();
     971
     972    bool areDefaultSettings() const;
     973
     974    bool operator==(const Debugging &rOther) const;
    1155975
    1156976    bool                    fTracingEnabled;
     
    1164984struct Autostart
    1165985{
    1166     Autostart()
    1167         : fAutostartEnabled(false),
    1168           uAutostartDelay(0),
    1169           enmAutostopType(AutostopType_Disabled)
    1170     { }
    1171 
    1172     bool operator==(const Autostart &rOther) const
    1173     {
    1174         return fAutostartEnabled == rOther.fAutostartEnabled
    1175             && uAutostartDelay   == rOther.uAutostartDelay
    1176             && enmAutostopType   == rOther.enmAutostopType;
    1177     }
    1178 
    1179     bool areDefaultSettings() const
    1180     {
    1181         return !fAutostartEnabled
    1182             && !uAutostartDelay
    1183             && enmAutostopType == AutostopType_Disabled;
    1184     }
     986    Autostart();
     987
     988    bool areDefaultSettings() const;
     989
     990    bool operator==(const Autostart &rOther) const;
    1185991
    1186992    bool                    fAutostartEnabled;
     
    11991005struct Snapshot
    12001006{
    1201     Snapshot()
    1202     {
    1203         RTTimeSpecSetNano(&timestamp, 0);
    1204     }
     1007    Snapshot();
    12051008
    12061009    bool operator==(const Snapshot &s) const;
     
    12141017
    12151018    Hardware        hardware;
    1216     Storage         storage;
    12171019
    12181020    Debugging       debugging;
     
    12201022
    12211023    SnapshotsList   llChildSnapshots;
    1222 };
    1223 
     1024
     1025    static const struct Snapshot Empty;
     1026};
     1027
     1028/**
     1029 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     1030 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     1031 * your settings might never get saved.
     1032 */
    12241033struct MachineUserData
    12251034{
    1226     MachineUserData()
    1227         : fDirectoryIncludesUUID(false),
    1228           fNameSync(true),
    1229           fTeleporterEnabled(false),
    1230           uTeleporterPort(0),
    1231           enmFaultToleranceState(FaultToleranceState_Inactive),
    1232           uFaultTolerancePort(0),
    1233           uFaultToleranceInterval(0),
    1234           fRTCUseUTC(false),
    1235           strVMPriority("")
    1236     {
    1237         llGroups.push_back("/");
    1238     }
    1239 
    1240     bool operator==(const MachineUserData &c) const
    1241     {
    1242         return    (strName                    == c.strName)
    1243                && (fDirectoryIncludesUUID     == c.fDirectoryIncludesUUID)
    1244                && (fNameSync                  == c.fNameSync)
    1245                && (strDescription             == c.strDescription)
    1246                && (llGroups                   == c.llGroups)
    1247                && (strOsType                  == c.strOsType)
    1248                && (strSnapshotFolder          == c.strSnapshotFolder)
    1249                && (fTeleporterEnabled         == c.fTeleporterEnabled)
    1250                && (uTeleporterPort            == c.uTeleporterPort)
    1251                && (strTeleporterAddress       == c.strTeleporterAddress)
    1252                && (strTeleporterPassword      == c.strTeleporterPassword)
    1253                && (enmFaultToleranceState     == c.enmFaultToleranceState)
    1254                && (uFaultTolerancePort        == c.uFaultTolerancePort)
    1255                && (uFaultToleranceInterval    == c.uFaultToleranceInterval)
    1256                && (strFaultToleranceAddress   == c.strFaultToleranceAddress)
    1257                && (strFaultTolerancePassword  == c.strFaultTolerancePassword)
    1258                && (fRTCUseUTC                 == c.fRTCUseUTC)
    1259                && (ovIcon                     == c.ovIcon)
    1260                && (strVMPriority              == c.strVMPriority);
    1261     }
     1035    MachineUserData();
     1036
     1037    bool operator==(const MachineUserData &c) const;
    12621038
    12631039    com::Utf8Str            strName;
     
    12781054    uint32_t                uFaultToleranceInterval;
    12791055    bool                    fRTCUseUTC;
    1280     com::Utf8Str            ovIcon;
     1056    IconBlob                ovIcon;
    12811057    com::Utf8Str            strVMPriority;
    12821058};
    12831059
    1284 extern const struct Snapshot g_SnapshotEmpty;
    12851060
    12861061/**
     
    13071082
    13081083    Hardware                hardwareMachine;
    1309     Storage                 storageMachine;
    13101084    MediaRegistry           mediaRegistry;
    13111085    Debugging               debugging;
     
    13511125    void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
    13521126    void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
    1353     void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
     1127    void readHardware(const xml::ElementNode &elmHardware, Hardware &hw);
    13541128    void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
    13551129    void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
     
    13631137    void readMachine(const xml::ElementNode &elmMachine);
    13641138
    1365     void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
    1366     void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, bool fEnabled, const NetworkAdapter &nic);
     1139    void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, uint32_t fl, std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
     1140    void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, const NetworkAdapter &nic);
    13671141    void buildStorageControllersXML(xml::ElementNode &elmParent,
    13681142                                    const Storage &st,
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r60608 r61009  
    33<!--
    44
    5     Copyright (C) 2006-2015 Oracle Corporation
     5    Copyright (C) 2006-2016 Oracle Corporation
    66
    77    This file is part of VirtualBox Open Source Edition (OSE), as
     
    74257425        transferred except the VM name and the hardware UUID. You can set the
    74267426        VM name and the new hardware UUID when creating the target machine. The
    7427         network MAC addresses are newly created for all network adapters. You
    7428         can change that behaviour with the options parameter. The operation is
    7429         performed asynchronously, so the machine object will be not be usable
    7430         until the @a progress object signals completion.
     7427        network MAC addresses are newly created for all enabled network
     7428        adapters. You can change that behaviour with the options parameter.
     7429        The operation is performed asynchronously, so the machine object will
     7430        be not be usable until the @a progress object signals completion.
    74317431
    74327432        <result name="E_INVALIDARG">
     
    1713417134    <attribute name="MACAddress" type="wstring">
    1713517135      <desc>
    17136         Ethernet MAC address of the adapter, 12 hexadecimal characters. When setting
    17137         it to @c null or an empty string, VirtualBox will generate a unique MAC address.
     17136        Ethernet MAC address of the adapter, 12 hexadecimal characters. When
     17137        setting it to @c null or an empty string for an enabled adapter,
     17138        VirtualBox will generate a unique MAC address. Disabled adapters can
     17139        have an empty MAC address.
    1713817140      </desc>
    1713917141    </attribute>
  • trunk/src/VBox/Main/include/BusAssignmentManager.h

    r51612 r61009  
    77
    88/*
    9  * Copyright (C) 2010-2014 Oracle Corporation
     9 * Copyright (C) 2010-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2929private:
    3030    struct State;
    31     State* pState;
     31    State *pState;
    3232
    3333    BusAssignmentManager();
    3434    virtual ~BusAssignmentManager();
    3535
    36     HRESULT assignPCIDeviceImpl(const char* pszDevName, PCFGMNODE pCfg, PCIBusAddress& GuestAddress,
     36    HRESULT assignPCIDeviceImpl(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress& GuestAddress,
    3737                                PCIBusAddress HostAddress, bool fGuestAddressRequired = false);
    3838
    3939public:
    40     static BusAssignmentManager* createInstance(ChipsetType_T chipsetType);
     40    struct PCIDeviceInfo
     41    {
     42        com::Utf8Str strDeviceName;
     43        PCIBusAddress guestAddress;
     44        PCIBusAddress hostAddress;
     45    };
     46
     47    static BusAssignmentManager *createInstance(ChipsetType_T chipsetType);
    4148    virtual void AddRef();
    4249    virtual void Release();
    4350
    44     virtual HRESULT assignHostPCIDevice(const char* pszDevName, PCFGMNODE pCfg, PCIBusAddress HostAddress,
     51    virtual HRESULT assignHostPCIDevice(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress HostAddress,
    4552                                        PCIBusAddress& GuestAddress, bool fAddressRequired = false)
    4653    {
     
    4855    }
    4956
    50     virtual HRESULT assignPCIDevice(const char* pszDevName, PCFGMNODE pCfg, PCIBusAddress& Address, bool fAddressRequired = false)
     57    virtual HRESULT assignPCIDevice(const char *pszDevName, PCFGMNODE pCfg, PCIBusAddress& Address, bool fAddressRequired = false)
    5158    {
    5259        PCIBusAddress HostAddress;
     
    5461    }
    5562
    56     virtual HRESULT assignPCIDevice(const char* pszDevName, PCFGMNODE pCfg)
     63    virtual HRESULT assignPCIDevice(const char *pszDevName, PCFGMNODE pCfg)
    5764    {
    5865        PCIBusAddress GuestAddress;
     
    6067        return assignPCIDeviceImpl(pszDevName, pCfg, GuestAddress, HostAddress, false);
    6168    }
    62     virtual bool findPCIAddress(const char* pszDevName, int iInstance, PCIBusAddress& Address);
    63     virtual bool hasPCIDevice(const char* pszDevName, int iInstance)
     69    virtual bool findPCIAddress(const char *pszDevName, int iInstance, PCIBusAddress& Address);
     70    virtual bool hasPCIDevice(const char *pszDevName, int iInstance)
    6471    {
    6572        PCIBusAddress Address;
    6673        return findPCIAddress(pszDevName, iInstance, Address);
    6774    }
    68     virtual void listAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttached);
     75    virtual void listAttachedPCIDevices(std::vector<PCIDeviceInfo> &aAttached);
    6976};
    7077
  • trunk/src/VBox/Main/include/DHCPServerImpl.h

    r56319 r61009  
    77
    88/*
    9  * Copyright (C) 2006-2013 Oracle Corporation
     9 * Copyright (C) 2006-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121#define ____H_H_DHCPSERVERIMPL
    2222
    23 #include <VBox/settings.h>
    2423#include "DHCPServerWrap.h"
     24
     25namespace settings
     26{
     27    struct DHCPServer;
     28    struct DhcpOptValue;
     29    typedef std::map<DhcpOpt_T, DhcpOptValue> DhcpOptionMap;
     30}
     31
    2532
    2633#ifdef VBOX_WITH_HOSTNETIF_API
     
    5865 */
    5966
    60 using settings::DhcpOptValue;
    61 using settings::DhcpOptionMap;
    62 using settings::DhcpOptValuePair;
    63 using settings::DhcpOptConstIterator;
    64 using settings::DhcpOptIterator;
    65 
    66 using settings::VmNameSlotKey;
    67 using settings::VmSlot2OptionsMap;
    68 using settings::VmSlot2OptionsPair;
    69 using settings::VmSlot2OptionsIterator;
    70 
    71 
    7267class ATL_NO_VTABLE DHCPServer :
    7368    public DHCPServerWrap
     
    8883    // Public internal methids.
    8984    HRESULT i_saveSettings(settings::DHCPServer &data);
    90     DhcpOptionMap& i_findOptMapByVmNameSlot(const com::Utf8Str& aVmName,
    91                                             LONG Slot);
     85    settings::DhcpOptionMap &i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName,
     86                                                      LONG Slot);
    9287
    9388private:
    9489    HRESULT encodeOption(com::Utf8Str &aEncoded,
    95                          uint32_t aOptCode, const DhcpOptValue &aOptValue);
    96     int addOption(DhcpOptionMap &aMap,
     90                         uint32_t aOptCode, const settings::DhcpOptValue &aOptValue);
     91    int addOption(settings::DhcpOptionMap &aMap,
    9792                  DhcpOpt_T aOption, const com::Utf8Str &aValue);
    9893
     
    134129    Data *m;
    135130    /** weak VirtualBox parent */
    136     VirtualBox * const mVirtualBox;
    137     const Bstr mName;
    138 
     131    VirtualBox *const mVirtualBox;
     132    const Utf8Str mName;
    139133};
    140134
  • trunk/src/VBox/Main/include/MachineImpl.h

    r60765 r61009  
    3636#include "BandwidthControlImpl.h"
    3737#include "BandwidthGroupImpl.h"
    38 #include "VBox/settings.h"
    3938#ifdef VBOX_WITH_RESOURCE_USAGE_API
    4039#include "Performance.h"
     
    5554
    5655#include "MachineWrap.h"
     56
     57/** @todo r=klaus after moving the various Machine settings structs to
     58 * MachineImpl.cpp it should be possible to eliminate this include. */
     59#include <VBox/settings.h>
    5760
    5861// defines
     
    7679class SessionMachine;
    7780
    78 namespace settings
    79 {
    80     class MachineConfigFile;
    81     struct Snapshot;
    82     struct Hardware;
    83     struct Storage;
    84     struct StorageController;
    85     struct MachineRegistryEntry;
    86 }
    87 
    8881// Machine class
    8982////////////////////////////////////////////////////////////////////////////////
     
    229222    {
    230223        settings::MachineUserData s;
    231         typedef  std::vector<uint8_t> IconBlob;
    232         IconBlob mIcon;
    233224    };
    234225
     
    643634                           const Guid &aCurSnapshotId,
    644635                           Snapshot *aParentSnapshot);
    645     HRESULT i_loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg,
     636    HRESULT i_loadHardware(const Guid *puuidRegistry,
     637                           const Guid *puuidSnapshot,
     638                           const settings::Hardware &data,
     639                           const settings::Debugging *pDbg,
    646640                           const settings::Autostart *pAutostart);
    647641    HRESULT i_loadDebugging(const settings::Debugging *pDbg);
     
    15701564                             const settings::Debugging *pDbg,
    15711565                             const settings::Autostart *pAutostart,
    1572                              const settings::Storage &storage,
    15731566                             IN_GUID aSnapshotId,
    15741567                             const Utf8Str &aStateFilePath);
  • trunk/src/VBox/Main/include/NATEngineImpl.h

    r57694 r61009  
    2121#define ____H_NATENGINE
    2222
    23 
    24 #include <VBox/settings.h>
    2523#include "NATEngineWrap.h"
    2624
  • trunk/src/VBox/Main/include/NATNetworkImpl.h

    r60786 r61009  
    2929    struct NATNetwork;
    3030    struct NATRule;
     31    typedef std::map<com::Utf8Str, NATRule> NATRulesMap;
    3132}
    3233
  • trunk/src/VBox/Main/include/PCIDeviceAttachmentImpl.h

    r50922 r61009  
    77
    88/*
    9  * Copyright (C) 2010-2012 Oracle Corporation
     9 * Copyright (C) 2010-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2222
    2323#include "PCIDeviceAttachmentWrap.h"
    24 #include <VBox/settings.h>
     24
     25namespace settings
     26{
     27    struct HostPCIDeviceAttachment;
     28}
    2529
    2630class ATL_NO_VTABLE PCIDeviceAttachment :
     
    3337    // public initializer/uninitializer for internal purposes only
    3438    HRESULT init(IMachine *    aParent,
    35                  const Bstr    &aName,
     39                 const Utf8Str &aName,
    3640                 LONG          aHostAddess,
    3741                 LONG          aGuestAddress,
  • trunk/src/VBox/Main/include/USBProxyService.h

    r60742 r61009  
    2222#include <VBox/usb.h>
    2323#include <VBox/usbfilter.h>
    24 #include <VBox/settings.h>
    2524
    2625#include "VirtualBoxBase.h"
     
    2827#include "HostUSBDeviceImpl.h"
    2928#include "USBProxyBackend.h"
     29
    3030class Host;
     31
     32namespace settings
     33{
     34    struct USBDeviceSource;
     35    typedef std::list<USBDeviceSource> USBDeviceSourcesList;
     36}
     37
    3138
    3239/**
  • trunk/src/VBox/Main/include/VRDEServerImpl.h

    r49644 r61009  
    77
    88/*
    9  * Copyright (C) 2006-2013 Oracle Corporation
     9 * Copyright (C) 2006-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121#define ____H_VRDPSERVER
    2222
    23 #include <VBox/settings.h>
    2423#include "VRDEServerWrap.h"
     24
     25namespace settings
     26{
     27    struct VRDESettings;
     28}
    2529
    2630class ATL_NO_VTABLE VRDEServer :
     
    2832{
    2933public:
    30 
    31     typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
    3234
    3335    DECLARE_EMPTY_CTOR_DTOR(VRDEServer)
     
    7476                            com::Utf8Str &aValue);
    7577
    76     struct Data
    77     {
    78         BOOL         mEnabled;
    79         com::Utf8Str mAuthLibrary;
    80         AuthType_T   mAuthType;
    81         ULONG        mAuthTimeout;
    82         BOOL         mAllowMultiConnection;
    83         BOOL         mReuseSingleConnection;
    84         Utf8Str      mVrdeExtPack;
    85         StringsMap   mProperties;
    86     };
    87 
    8878    Machine * const     mParent;
    8979    const ComObjPtr<VRDEServer> mPeer;
    9080
    91     Backupable<Data>    mData;
     81    Backupable<settings::VRDESettings> mData;
    9282};
    9383
  • trunk/src/VBox/Main/src-all/PCIDeviceAttachmentImpl.cpp

    r58959 r61009  
    77
    88/*
    9  * Copyright (C) 2010-2012 Oracle Corporation
     9 * Copyright (C) 2010-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2323#include "Logging.h"
    2424
     25#include <VBox/settings.h>
     26
    2527struct PCIDeviceAttachment::Data
    2628{
    27     Data(const Bstr    &aDevName,
     29    Data(const Utf8Str &aDevName,
    2830         LONG          aHostAddress,
    2931         LONG          aGuestAddress,
     
    3537    }
    3638
    37     Bstr             DevName;
     39    Utf8Str          DevName;
    3840    LONG             HostAddress;
    3941    LONG             GuestAddress;
     
    6163/////////////////////////////////////////////////////////////////////////////
    6264HRESULT PCIDeviceAttachment::init(IMachine      *aParent,
    63                                   const Bstr  &aDevName,
     65                                  const Utf8Str &aDevName,
    6466                                  LONG          aHostAddress,
    6567                                  LONG          aGuestAddress,
     
    8385                                            const settings::HostPCIDeviceAttachment &hpda)
    8486{
    85     Bstr bname(hpda.strDeviceName);
    86     return init(aParent, bname,  hpda.uHostAddress, hpda.uGuestAddress, TRUE);
     87    return init(aParent, hpda.strDeviceName, hpda.uHostAddress, hpda.uGuestAddress, TRUE);
    8788}
    8889
  • trunk/src/VBox/Main/src-client/BusAssignmentManager.cpp

    r57809 r61009  
    77
    88/*
    9  * Copyright (C) 2010-2014 Oracle Corporation
     9 * Copyright (C) 2010-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2424#include <VBox/vmm/cfgm.h>
    2525#include <VBox/com/array.h>
    26 
    27 
    28 #include "PCIDeviceAttachmentImpl.h"
    2926
    3027#include <map>
     
    253250    };
    254251
    255     typedef std::map <PCIBusAddress,PCIDeviceRecord > PCIMap;
     252    typedef std::map<PCIBusAddress,PCIDeviceRecord>  PCIMap;
    256253    typedef std::vector<PCIBusAddress>                PCIAddrList;
    257     typedef std::vector<const DeviceAssignmentRule*> PCIRulesList;
    258     typedef std::map <PCIDeviceRecord,PCIAddrList >   ReversePCIMap;
     254    typedef std::vector<const DeviceAssignmentRule *> PCIRulesList;
     255    typedef std::map<PCIDeviceRecord,PCIAddrList>     ReversePCIMap;
    259256
    260257    volatile int32_t cRefCnt;
     
    278275    const char* findAlias(const char* pszName);
    279276    void addMatchingRules(const char* pszName, PCIRulesList& aList);
    280     void listAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttached);
     277    void listAttachedPCIDevices(std::vector<PCIDeviceInfo> &aAttached);
    281278};
    282279
     
    404401}
    405402
    406 void BusAssignmentManager::State::listAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttached)
     403void BusAssignmentManager::State::listAttachedPCIDevices(std::vector<PCIDeviceInfo> &aAttached)
    407404{
    408405    aAttached.resize(mPCIMap.size());
    409406
    410407    size_t i = 0;
    411     ComObjPtr<PCIDeviceAttachment> dev;
     408    PCIDeviceInfo dev;
    412409    for (PCIMap::const_iterator it = mPCIMap.begin(); it !=  mPCIMap.end(); ++it, ++i)
    413410    {
    414         dev.createObject();
    415         com::Bstr devname(it->second.szDevName);
    416         dev->init(NULL, devname,
    417                   it->second.HostAddress.valid() ? it->second.HostAddress.asLong() : -1,
    418                   it->first.asLong(), it->second.HostAddress.valid());
    419         dev.queryInterfaceTo(aAttached[i].asOutParam());
     411        dev.strDeviceName = it->second.szDevName;
     412        dev.guestAddress = it->first;
     413        dev.hostAddress = it->second.HostAddress;
     414        aAttached[i] = dev;
    420415    }
    421416}
     
    514509    return pState->findPCIAddress(pszDevName, iInstance, Address);
    515510}
    516 void BusAssignmentManager::listAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttached)
     511void BusAssignmentManager::listAttachedPCIDevices(std::vector<PCIDeviceInfo> &aAttached)
    517512{
    518513    pState->listAttachedPCIDevices(aAttached);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r60404 r61009  
    55
    66/*
    7  * Copyright (C) 2005-2015 Oracle Corporation
     7 * Copyright (C) 2005-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6868#endif
    6969#include "BusAssignmentManager.h"
     70#include "PCIDeviceAttachmentImpl.h"
    7071#include "EmulatedUSBImpl.h"
    7172
     
    20002001
    20012002    if (mBusMgr)
    2002         mBusMgr->listAttachedPCIDevices(aAttachedPCIDevices);
     2003    {
     2004        std::vector<BusAssignmentManager::PCIDeviceInfo> devInfos;
     2005        mBusMgr->listAttachedPCIDevices(devInfos);
     2006        ComObjPtr<PCIDeviceAttachment> dev;
     2007        aAttachedPCIDevices.resize(devInfos.size());
     2008        for (size_t i = 0; i < devInfos.size(); i++)
     2009        {
     2010            const BusAssignmentManager::PCIDeviceInfo &devInfo = devInfos[i];
     2011            dev.createObject();
     2012            dev->init(NULL, devInfo.strDeviceName,
     2013                      devInfo.hostAddress.valid() ? devInfo.hostAddress.asLong() : -1,
     2014                      devInfo.guestAddress.asLong(),
     2015                      devInfo.hostAddress.valid());
     2016            dev.queryInterfaceTo(aAttachedPCIDevices[i].asOutParam());
     2017        }
     2018    }
    20032019    else
    20042020        aAttachedPCIDevices.resize(0);
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r61005 r61009  
    469469            if (vsysThis.pelmVBoxMachine)
    470470            {
    471                 settings::StorageControllersList &llControllers = pNewDesc->m->pConfig->storageMachine.llStorageControllers;
     471                settings::StorageControllersList &llControllers = pNewDesc->m->pConfig->hardwareMachine.storage.llStorageControllers;
    472472                settings::StorageControllersList::iterator it3;
    473473                for (it3 = llControllers.begin();
     
    35793579     * attachments pointing to the last hard disk image, which causes import
    35803580     * failures. A long fixed bug, however the OVF files are long lived. */
    3581     settings::StorageControllersList &llControllers = config.storageMachine.llStorageControllers;
     3581    settings::StorageControllersList &llControllers = config.hardwareMachine.storage.llStorageControllers;
    35823582    Guid hdUuid;
    35833583    uint32_t cDisks = 0;
     
    37923792
    37933793        // for each storage controller...
    3794         for (settings::StorageControllersList::iterator sit = config.storageMachine.llStorageControllers.begin();
    3795              sit != config.storageMachine.llStorageControllers.end();
     3794        for (settings::StorageControllersList::iterator sit = config.hardwareMachine.storage.llStorageControllers.begin();
     3795             sit != config.hardwareMachine.storage.llStorageControllers.end();
    37963796             ++sit)
    37973797        {
     
    39103910                break;
    39113911            } // for (settings::AttachedDevicesList::const_iterator dit = sc.llAttachedDevices.begin();
    3912         } // for (settings::StorageControllersList::const_iterator sit = config.storageMachine.llStorageControllers.begin();
     3912        } // for (settings::StorageControllersList::const_iterator sit = config.hardwareMachine.storage.llStorageControllers.begin();
    39133913
    39143914            // no disk with such a UUID found:
     
    40934093    HRESULT rc = S_OK;
    40944094
    4095     settings::StorageControllersList &llControllers = config->storageMachine.llStorageControllers;
     4095    settings::StorageControllersList &llControllers = config->hardwareMachine.storage.llStorageControllers;
    40964096    settings::StorageControllersList::iterator itscl;
    40974097    for (itscl = llControllers.begin();
  • trunk/src/VBox/Main/src-server/DHCPServerImpl.cpp

    r54705 r61009  
    77
    88/*
    9  * Copyright (C) 2006-2013 Oracle Corporation
     9 * Copyright (C) 2006-2016 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5353    DHCPServerRunner dhcp;
    5454
    55     DhcpOptionMap GlobalDhcpOptions;
    56     VmSlot2OptionsMap VmSlot2Options;
     55    settings::DhcpOptionMap GlobalDhcpOptions;
     56    settings::VmSlot2OptionsMap VmSlot2Options;
    5757};
    5858
     
    113113    unconst(mName) = aName;
    114114    m->IPAddress = "0.0.0.0";
    115     m->GlobalDhcpOptions[DhcpOpt_SubnetMask] = DhcpOptValue("0.0.0.0");
     115    m->GlobalDhcpOptions[DhcpOpt_SubnetMask] = settings::DhcpOptValue("0.0.0.0");
    116116    m->enabled = FALSE;
    117117
     
    275275
    276276HRESULT DHCPServer::encodeOption(com::Utf8Str &aEncoded,
    277                                  uint32_t aOptCode, const DhcpOptValue &aOptValue)
     277                                 uint32_t aOptCode,
     278                                 const settings::DhcpOptValue &aOptValue)
    278279{
    279280    switch (aOptValue.encoding)
    280281    {
    281         case DhcpOptValue::LEGACY:
     282        case DhcpOptEncoding_Legacy:
    282283        {
    283284            /*
     
    293294        }
    294295
    295         case DhcpOptValue::HEX:
     296        case DhcpOptEncoding_Hex:
    296297        {
    297298            /*
     
    323324
    324325
    325 int DHCPServer::addOption(DhcpOptionMap &aMap,
     326int DHCPServer::addOption(settings::DhcpOptionMap &aMap,
    326327                          DhcpOpt_T aOption, const com::Utf8Str &aValue)
    327328{
    328     DhcpOptValue OptValue;
     329    settings::DhcpOptValue OptValue;
    329330
    330331    if (aOption != 0)
    331332    {
    332         OptValue = DhcpOptValue(aValue, DhcpOptValue::LEGACY);
     333        OptValue = settings::DhcpOptValue(aValue, DhcpOptEncoding_Legacy);
    333334    }
    334335    /*
     
    353354            case ':':           /* support legacy format too */
    354355            {
    355                 u32Enc = DhcpOptValue::LEGACY;
     356                u32Enc = DhcpOptEncoding_Legacy;
    356357                break;
    357358            }
     
    359360            case '=':
    360361            {
    361                 u32Enc = DhcpOptValue::HEX;
     362                u32Enc = DhcpOptEncoding_Hex;
    362363                break;
    363364            }
     
    378379
    379380        aOption = (DhcpOpt_T)u8Code;
    380         OptValue = DhcpOptValue(pszNext + 1, (DhcpOptValue::Encoding)u32Enc);
     381        OptValue = settings::DhcpOptValue(pszNext + 1, (DhcpOptEncoding_T)u32Enc);
    381382    }
    382383
     
    412413    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    413414    aValues.resize(m->GlobalDhcpOptions.size());
    414     DhcpOptionMap::const_iterator it;
     415    settings::DhcpOptionMap::const_iterator it;
    415416    size_t i = 0;
    416417    for (it = m->GlobalDhcpOptions.begin(); it != m->GlobalDhcpOptions.end(); ++it, ++i)
    417418    {
    418419        uint32_t OptCode = (*it).first;
    419         const DhcpOptValue &OptValue = (*it).second;
     420        const settings::DhcpOptValue &OptValue = (*it).second;
    420421
    421422        encodeOption(aValues[i], OptCode, OptValue);
     
    429430    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    430431    aValues.resize(m->VmSlot2Options.size());
    431     VmSlot2OptionsMap::const_iterator it;
     432    settings::VmSlot2OptionsMap::const_iterator it;
    432433    size_t i = 0;
    433434    for (it = m->VmSlot2Options.begin(); it != m->VmSlot2Options.end(); ++it, ++i)
     
    447448    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    448449
    449     DhcpOptionMap &map = m->VmSlot2Options[VmNameSlotKey(aVmName, aSlot)];
     450    settings::DhcpOptionMap &map = m->VmSlot2Options[settings::VmNameSlotKey(aVmName, aSlot)];
    450451    int rc = addOption(map, aOption, aValue);
    451452    if (!RT_SUCCESS(rc))
     
    462463{
    463464    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    464     DhcpOptionMap& map = i_findOptMapByVmNameSlot(aVmName, aSlot);
     465    settings::DhcpOptionMap &map = i_findOptMapByVmNameSlot(aVmName, aSlot);
    465466    map.clear();
    466467
     
    480481
    481482    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    482     DhcpOptionMap& map = i_findOptMapByVmNameSlot(aVmName, aSlot);
     483    settings::DhcpOptionMap &map = i_findOptMapByVmNameSlot(aVmName, aSlot);
    483484    aValues.resize(map.size());
    484485    size_t i = 0;
    485     DhcpOptionMap::const_iterator it;
     486    settings::DhcpOptionMap::const_iterator it;
    486487    for (it = map.begin(); it != map.end(); ++it, ++i)
    487488    {
    488489        uint32_t OptCode = (*it).first;
    489         const DhcpOptValue &OptValue = (*it).second;
     490        const settings::DhcpOptValue &OptValue = (*it).second;
    490491
    491492        encodeOption(aValues[i], OptCode, OptValue);
     
    502503    ComPtr<IMachine> machine;
    503504    ComPtr<INetworkAdapter> nic;
    504     VmSlot2OptionsIterator it;
     505    settings::VmSlot2OptionsIterator it;
    505506    for(it = m->VmSlot2Options.begin(); it != m->VmSlot2Options.end(); ++it)
    506507    {
     
    585586
    586587
    587 DhcpOptionMap& DHCPServer::i_findOptMapByVmNameSlot(const com::Utf8Str& aVmName,
    588                                                   LONG aSlot)
     588settings::DhcpOptionMap &DHCPServer::i_findOptMapByVmNameSlot(const com::Utf8Str &aVmName,
     589                                                              LONG aSlot)
    589590{
    590591    return m->VmSlot2Options[settings::VmNameSlotKey(aVmName, aSlot)];
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r60809 r61009  
    6767#include <iprt/sha.h>
    6868#include <iprt/string.h>
    69 #include <iprt/base64.h>
    7069
    7170#include <VBox/com/array.h>
     
    20362035{
    20372036    /* check VRAM limits */
    2038     if (aVRAMSize < SchemaDefs::MinGuestVRAM ||
    2039         aVRAMSize > SchemaDefs::MaxGuestVRAM)
     2037    if (aVRAMSize > SchemaDefs::MaxGuestVRAM)
    20402038        return setError(E_INVALIDARG,
    20412039                        tr("Invalid VRAM size: %lu MB (must be in range [%lu, %lu] MB)"),
     
    70507048{
    70517049    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    7052     size_t cbIcon = mUserData->mIcon.size();
     7050    size_t cbIcon = mUserData->s.ovIcon.size();
    70537051    aIcon.resize(cbIcon);
    70547052    if (cbIcon)
    7055         memcpy(&aIcon.front(), &mUserData->mIcon[0], cbIcon);
     7053        memcpy(&aIcon.front(), &mUserData->s.ovIcon[0], cbIcon);
    70567054    return S_OK;
    70577055}
     
    70667064        mUserData.backup();
    70677065        size_t cbIcon = aIcon.size();
    7068         mUserData->mIcon.resize(cbIcon);
     7066        mUserData->s.ovIcon.resize(cbIcon);
    70697067        if (cbIcon)
    7070             memcpy(&mUserData->mIcon[0], &aIcon.front(), cbIcon);
     7068            memcpy(&mUserData->s.ovIcon[0], &aIcon.front(), cbIcon);
    70717069    }
    70727070    return hrc;
     
    86318629    mUserData->s = config.machineUserData;
    86328630
    8633     // Decode the Icon overide data from config userdata and set onto Machine.
    8634     #define DECODE_STR_MAX _1M
    8635     const char* pszStr = config.machineUserData.ovIcon.c_str();
    8636     ssize_t cbOut = RTBase64DecodedSize(pszStr, NULL);
    8637     if (cbOut > DECODE_STR_MAX)
    8638         return setError(E_FAIL,
    8639                         tr("Icon Data too long.'%d' > '%d'"),
    8640                         cbOut,
    8641                         DECODE_STR_MAX);
    8642     mUserData->mIcon.resize(cbOut);
    8643     int vrc = VINF_SUCCESS;
    8644     if (cbOut)
    8645         vrc = RTBase64Decode(pszStr, &mUserData->mIcon.front(), cbOut, NULL, NULL);
    8646     if (RT_FAILURE(vrc))
    8647     {
    8648         mUserData->mIcon.resize(0);
    8649         return setError(E_FAIL,
    8650                         tr("Failure to Decode Icon Data. '%s' (%Rrc)"),
    8651                         pszStr,
    8652                         vrc);
    8653     }
    8654 
    86558631    // look up the object by Id to check it is valid
    86568632    ComPtr<IGuestOSType> guestOSType;
     
    86658641    {
    86668642        Utf8Str stateFilePathFull(config.strStateFile);
    8667         vrc = i_calculateFullPath(stateFilePathFull, stateFilePathFull);
     8643        int vrc = i_calculateFullPath(stateFilePathFull, stateFilePathFull);
    86688644        if (RT_FAILURE(vrc))
    86698645            return setError(E_FAIL,
     
    87238699
    87248700    // hardware data
    8725     rc = i_loadHardware(config.hardwareMachine, &config.debugging, &config.autostart);
    8726     if (FAILED(rc)) return rc;
    8727 
    8728     // load storage controllers
    8729     rc = i_loadStorageControllers(config.storageMachine,
    8730                                   puuidRegistry,
    8731                                   NULL /* puuidSnapshot */);
     8701    rc = i_loadHardware(puuidRegistry, NULL, config.hardwareMachine, &config.debugging, &config.autostart);
    87328702    if (FAILED(rc)) return rc;
    87338703
     
    87958765                                            &data.debugging,
    87968766                                            &data.autostart,
    8797                                             data.storage,
    87988767                                            data.uuid.ref(),
    87998768                                            strStateFile);
     
    88468815 *  @param pAutostart     Pointer to the autostart settings.
    88478816 */
    8848 HRESULT Machine::i_loadHardware(const settings::Hardware &data, const settings::Debugging *pDbg,
     8817HRESULT Machine::i_loadHardware(const Guid *puuidRegistry,
     8818                                const Guid *puuidSnapshot,
     8819                                const settings::Hardware &data,
     8820                                const settings::Debugging *pDbg,
    88498821                                const settings::Autostart *pAutostart)
    88508822{
     
    90509022        /* AudioAdapter */
    90519023        rc = mAudioAdapter->i_loadSettings(data.audioAdapter);
     9024        if (FAILED(rc)) return rc;
     9025
     9026        /* storage controllers */
     9027        rc = i_loadStorageControllers(data.storage,
     9028                                      puuidRegistry,
     9029                                      puuidSnapshot);
    90529030        if (FAILED(rc)) return rc;
    90539031
     
    1004910027    config.machineUserData = mUserData->s;
    1005010028
    10051     // Encode the Icon Override data from Machine and store on config userdata.
    10052     std::vector<BYTE> iconByte;
    10053     getIcon(iconByte);
    10054     ssize_t cbData = iconByte.size();
    10055     if (cbData > 0)
    10056     {
    10057         ssize_t cchOut = RTBase64EncodedLength(cbData);
    10058         Utf8Str strIconData;
    10059         strIconData.reserve(cchOut+1);
    10060         int vrc = RTBase64Encode(&iconByte.front(), cbData,
    10061                                  strIconData.mutableRaw(), strIconData.capacity(),
    10062                                  NULL);
    10063         if (RT_FAILURE(vrc))
    10064             throw setError(E_FAIL, tr("Failure to Encode Icon Data. '%s' (%Rrc)"), strIconData.mutableRaw(), vrc);
    10065         strIconData.jolt();
    10066         config.machineUserData.ovIcon = strIconData;
    10067     }
    10068     else
    10069         config.machineUserData.ovIcon.setNull();
    10070 
    1007110029    if (    mData->mMachineState == MachineState_Saved
    1007210030         || mData->mMachineState == MachineState_Restoring
     
    1010210060    if (FAILED(rc)) throw rc;
    1010310061
    10104     rc = i_saveStorageControllers(config.storageMachine);
    10105     if (FAILED(rc)) throw rc;
    10106 
    1010710062    // save machine's media registry if this is VirtualBox 4.0 or later
    1010810063    if (config.canHaveOwnMediaRegistry())
     
    1014110096        {
    1014210097            // the settings use a list for "the first snapshot"
    10143             config.llFirstSnapshot.push_back(settings::g_SnapshotEmpty);
     10098            config.llFirstSnapshot.push_back(settings::Snapshot::Empty);
    1014410099
    1014510100            // get reference to the snapshot on the list and work on that
     
    1036010315        /* Audio adapter */
    1036110316        rc = mAudioAdapter->i_saveSettings(data.audioAdapter);
     10317        if (FAILED(rc)) return rc;
     10318
     10319        rc = i_saveStorageControllers(data.storage);
    1036210320        if (FAILED(rc)) return rc;
    1036310321
  • trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp

    r60627 r61009  
    673673         ++it)
    674674    {
    675         updateStorageLists(it->storage.llStorageControllers, bstrOldId, bstrNewId);
     675        updateStorageLists(it->hardware.storage.llStorageControllers, bstrOldId, bstrNewId);
    676676        if (!it->llChildSnapshots.empty())
    677677            updateSnapshotStorageLists(it->llChildSnapshots, bstrOldId, bstrNewId);
     
    10211021        {
    10221022            if (sn.uuid.isValid() && !sn.uuid.isZero())
    1023             {
    10241023                trgMCF.hardwareMachine = sn.hardware;
    1025                 trgMCF.storageMachine  = sn.storage;
    1026             }
    10271024
    10281025            /* Remove any hint on snapshots. */
     
    10381035                /* Copy the snapshot data to the current machine. */
    10391036                trgMCF.hardwareMachine = sn.hardware;
    1040                 trgMCF.storageMachine  = sn.storage;
    10411037
    10421038                /* Current state is under root snapshot. */
     
    13501346            }
    13511347            /* update 'Current State' configuration */
    1352             d->updateStorageLists(trgMCF.storageMachine.llStorageControllers, bstrSrcId, bstrTrgId);
     1348            d->updateStorageLists(trgMCF.hardwareMachine.storage.llStorageControllers, bstrSrcId, bstrTrgId);
    13531349        }
    13541350        /* Make sure all disks know of the new machine uuid. We do this last to
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r60628 r61009  
    42524252        // settings sub-tree is copied) and the stack footprint (the settings
    42534253        // need almost 1K, and there can be VMs with long image chains.
    4254         llSettingsChildren.push_back(settings::g_MediumEmpty);
     4254        llSettingsChildren.push_back(settings::Medium::Empty);
    42554255        HRESULT rc = (*it)->i_saveSettings(llSettingsChildren.back(), strHardDiskFolder);
    42564256        if (FAILED(rc))
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r60808 r61009  
    55
    66/*
    7  * Copyright (C) 2006-2015 Oracle Corporation
     7 * Copyright (C) 2006-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8989    /* default to Am79C973 */
    9090    mData->mAdapterType = NetworkAdapterType_Am79C973;
    91 
    92     /* generate the MAC address early to guarantee it is the same both after
    93      * changing some other property (i.e. after mData.backup()) and after the
    94      * subsequent mData.rollback(). */
    95     i_generateMACAddress();
    9691
    9792    /* Confirm a successful initialization */
     
    303298        mData.backup();
    304299        mData->mEnabled = aEnabled;
     300        if (aEnabled && mData->mMACAddress.isEmpty())
     301            i_generateMACAddress();
    305302
    306303        // leave the lock before informing callbacks
     
    323320    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    324321
    325     ComAssertRet(!mData->mMACAddress.isEmpty(), E_FAIL);
     322    ComAssertRet(!mData->mEnabled || !mData->mMACAddress.isEmpty(), E_FAIL);
    326323
    327324    aMACAddress = mData->mMACAddress;
     
    337334     * Are we supposed to generate a MAC?
    338335     */
    339     if (aMACAddress.isEmpty())
     336    if (mData->mEnabled && aMACAddress.isEmpty())
    340337        i_generateMACAddress();
    341338    else
     
    343340        if (mData->mMACAddress != aMACAddress)
    344341        {
    345             /*
    346              * Verify given MAC address
    347              */
    348             char *macAddressStr = aMACAddress.mutableRaw();
    349             int i = 0;
    350             while ((i < 13) && macAddressStr && *macAddressStr && (rc == S_OK))
     342            if (mData->mEnabled || !aMACAddress.isEmpty())
    351343            {
    352                 char c = *macAddressStr;
    353                 /* canonicalize hex digits to capital letters */
    354                 if (c >= 'a' && c <= 'f')
     344                /*
     345                 * Verify given MAC address
     346                 */
     347                char *macAddressStr = aMACAddress.mutableRaw();
     348                int i = 0;
     349                while ((i < 13) && macAddressStr && *macAddressStr && (rc == S_OK))
    355350                {
    356                     /** @todo the runtime lacks an ascii lower/upper conv */
    357                     c &= 0xdf;
    358                     *macAddressStr = c;
     351                    char c = *macAddressStr;
     352                    /* canonicalize hex digits to capital letters */
     353                    if (c >= 'a' && c <= 'f')
     354                    {
     355                        /** @todo the runtime lacks an ascii lower/upper conv */
     356                        c &= 0xdf;
     357                        *macAddressStr = c;
     358                    }
     359                    /* we only accept capital letters */
     360                    if (((c < '0') || (c > '9')) &&
     361                        ((c < 'A') || (c > 'F')))
     362                        rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
     363                    /* the second digit must have even value for unicast addresses */
     364                    if ((i == 1) && (!!(c & 1) == (c >= '0' && c <= '9')))
     365                        rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
     366
     367                    macAddressStr++;
     368                    i++;
    359369                }
    360                 /* we only accept capital letters */
    361                 if (((c < '0') || (c > '9')) &&
    362                     ((c < 'A') || (c > 'F')))
     370                /* we must have parsed exactly 12 characters */
     371                if (i != 12)
    363372                    rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
    364                 /* the second digit must have even value for unicast addresses */
    365                 if ((i == 1) && (!!(c & 1) == (c >= '0' && c <= '9')))
    366                     rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
    367 
    368                 macAddressStr++;
    369                 i++;
    370373            }
    371             /* we must have parsed exactly 12 characters */
    372             if (i != 12)
    373                 rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
    374374
    375375            if (SUCCEEDED(rc))
  • trunk/src/VBox/Main/src-server/SnapshotImpl.cpp

    r60288 r61009  
    758758    if (FAILED(rc)) return rc;
    759759
    760     rc = m->pMachine->i_saveStorageControllers(data.storage);
    761     if (FAILED(rc)) return rc;
    762 
    763760    return S_OK;
    764761}
     
    786783        // need a lot of stack space. There can be VMs with deeply nested
    787784        // snapshots. The stack can be quite small, especially with XPCOM.
    788         llSettingsChildren.push_back(settings::g_SnapshotEmpty);
     785        llSettingsChildren.push_back(settings::Snapshot::Empty);
    789786        Snapshot *pSnap = *it;
    790787        rc = pSnap->i_saveSnapshotImpl(llSettingsChildren.back());
     
    11261123                                          const settings::Debugging *pDbg,
    11271124                                          const settings::Autostart *pAutostart,
    1128                                           const settings::Storage &storage,
    11291125                                          IN_GUID aSnapshotId,
    11301126                                          const Utf8Str &aStateFilePath)
     
    12031199    mBandwidthControl->init(this);
    12041200
    1205     /* load hardware and harddisk settings */
    1206 
    1207     HRESULT rc = i_loadHardware(hardware, pDbg, pAutostart);
    1208     if (SUCCEEDED(rc))
    1209         rc = i_loadStorageControllers(storage,
    1210                                       NULL, /* puuidRegistry */
    1211                                       &mSnapshotId);
     1201    /* load hardware and storage settings */
     1202    HRESULT rc = i_loadHardware(NULL, &mSnapshotId, hardware, pDbg, pAutostart);
    12121203
    12131204    if (SUCCEEDED(rc))
  • trunk/src/VBox/Main/src-server/VRDEServerImpl.cpp

    r60826 r61009  
    66
    77/*
    8  * Copyright (C) 2006-2015 Oracle Corporation
     8 * Copyright (C) 2006-2016 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8989
    9090    mData.allocate();
    91 
    92     mData->mAuthType             = AuthType_Null;
    93     mData->mAuthTimeout          = 5000;
    94     mData->mAuthLibrary.setNull();
    95     mData->mEnabled              = FALSE;
    96     mData->mAllowMultiConnection = FALSE;
    97     mData->mReuseSingleConnection = FALSE;
    98     mData->mVrdeExtPack.setNull();
    9991
    10092    /* Confirm a successful initialization */
     
    206198
    207199    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    208     mData->mEnabled = data.fEnabled;
    209     mData->mAuthType = data.authType;
    210     mData->mAuthTimeout = data.ulAuthTimeout;
    211     mData->mAuthLibrary = data.strAuthLibrary;
    212     mData->mAllowMultiConnection = data.fAllowMultiConnection;
    213     mData->mReuseSingleConnection = data.fReuseSingleConnection;
    214     mData->mVrdeExtPack = data.strVrdeExtPack;
    215     mData->mProperties = data.mapProperties;
     200    mData.assignCopy(&data);
    216201
    217202    return S_OK;
     
    231216
    232217    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    233 
    234     data.fEnabled = !!mData->mEnabled;
    235     data.authType = mData->mAuthType;
    236     data.strAuthLibrary = mData->mAuthLibrary;
    237     data.ulAuthTimeout = mData->mAuthTimeout;
    238     data.fAllowMultiConnection = !!mData->mAllowMultiConnection;
    239     data.fReuseSingleConnection = !!mData->mReuseSingleConnection;
    240     data.strVrdeExtPack = mData->mVrdeExtPack;
    241     data.mapProperties = mData->mProperties;
     218    data = *mData.data();
    242219
    243220    return S_OK;
     
    251228    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    252229
    253     *aEnabled = mData->mEnabled;
     230    *aEnabled = mData->fEnabled;
    254231
    255232    return S_OK;
     
    266243    HRESULT rc = S_OK;
    267244
    268     if (mData->mEnabled != aEnabled)
     245    if (mData->fEnabled != RT_BOOL(aEnabled))
    269246    {
    270247        mData.backup();
    271         mData->mEnabled = aEnabled;
     248        mData->fEnabled = RT_BOOL(aEnabled);
    272249
    273250        /* leave the lock before informing callbacks */
     
    390367            return E_INVALIDARG;
    391368
    392         if (strPorts != mData->mProperties["TCP/Ports"])
     369        if (strPorts != mData->mapProperties["TCP/Ports"])
    393370        {
    394371            /* Port value is not verified here because it is up to VRDP transport to
     
    397374             */
    398375            mData.backup();
    399             mData->mProperties["TCP/Ports"] = strPorts;
     376            mData->mapProperties["TCP/Ports"] = strPorts;
    400377
    401378            /* leave the lock before informing callbacks */
     
    419396        Utf8Str strOldValue;
    420397
    421         settings::StringsMap::const_iterator it = mData->mProperties.find(aKey);
    422         if (it != mData->mProperties.end())
     398        settings::StringsMap::const_iterator it = mData->mapProperties.find(aKey);
     399        if (it != mData->mapProperties.end())
    423400            strOldValue = it->second;
    424401
     
    426403        {
    427404            if (aValue.isEmpty())
    428                 mData->mProperties.erase(aKey);
     405                mData->mapProperties.erase(aKey);
    429406            else
    430                 mData->mProperties[aKey] = aValue;
     407                mData->mapProperties[aKey] = aValue;
    431408
    432409            /* leave the lock before informing callbacks */
     
    450427{
    451428    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    452     settings::StringsMap::const_iterator it = mData->mProperties.find(aKey);
    453     if (it != mData->mProperties.end())
     429    settings::StringsMap::const_iterator it = mData->mapProperties.find(aKey);
     430    if (it != mData->mapProperties.end())
    454431        aValue = it->second; // source is a Utf8Str
    455432    else if (aKey == "TCP/Ports")
     
    509486    aProperties.resize(0);
    510487    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    511     if (!mData->mEnabled)
     488    if (!mData->fEnabled)
    512489    {
    513490        return S_OK;
     
    595572    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    596573
    597     *aType = mData->mAuthType;
     574    *aType = mData->authType;
    598575
    599576    return S_OK;
     
    608585    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    609586
    610     if (mData->mAuthType != aType)
     587    if (mData->authType != aType)
    611588    {
    612589        mData.backup();
    613         mData->mAuthType = aType;
     590        mData->authType = aType;
    614591
    615592        /* leave the lock before informing callbacks */
     
    630607    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    631608
    632     *aTimeout = mData->mAuthTimeout;
     609    *aTimeout = mData->ulAuthTimeout;
    633610
    634611    return S_OK;
     
    644621    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    645622
    646     if (aTimeout != mData->mAuthTimeout)
     623    if (aTimeout != mData->ulAuthTimeout)
    647624    {
    648625        mData.backup();
    649         mData->mAuthTimeout = aTimeout;
     626        mData->ulAuthTimeout = aTimeout;
    650627
    651628        /* leave the lock before informing callbacks */
     
    669646{
    670647    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    671     aLibrary = mData->mAuthLibrary;
     648    aLibrary = mData->strAuthLibrary;
    672649    alock.release();
    673650
     
    701678    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    702679
    703     if (mData->mAuthLibrary != aLibrary)
     680    if (mData->strAuthLibrary != aLibrary)
    704681    {
    705682        mData.backup();
    706         mData->mAuthLibrary = aLibrary;
     683        mData->strAuthLibrary = aLibrary;
    707684
    708685        /* leave the lock before informing callbacks */
     
    724701    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    725702
    726     *aAllowMultiConnection = mData->mAllowMultiConnection;
     703    *aAllowMultiConnection = mData->fAllowMultiConnection;
    727704
    728705    return S_OK;
     
    738715    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    739716
    740     if (mData->mAllowMultiConnection != aAllowMultiConnection)
     717    if (mData->fAllowMultiConnection != RT_BOOL(aAllowMultiConnection))
    741718    {
    742719        mData.backup();
    743         mData->mAllowMultiConnection = aAllowMultiConnection;
     720        mData->fAllowMultiConnection = RT_BOOL(aAllowMultiConnection);
    744721
    745722        /* leave the lock before informing callbacks */
     
    760737    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    761738
    762     *aReuseSingleConnection = mData->mReuseSingleConnection;
     739    *aReuseSingleConnection = mData->fReuseSingleConnection;
    763740
    764741    return S_OK;
     
    773750    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    774751
    775     if (mData->mReuseSingleConnection != aReuseSingleConnection)
     752    if (mData->fReuseSingleConnection != RT_BOOL(aReuseSingleConnection))
    776753    {
    777754        mData.backup();
    778         mData->mReuseSingleConnection = aReuseSingleConnection;
     755        mData->fReuseSingleConnection = RT_BOOL(aReuseSingleConnection);
    779756
    780757        /* leave the lock before informing callbacks */
     
    794771{
    795772    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    796     Utf8Str strExtPack = mData->mVrdeExtPack;
     773    Utf8Str strExtPack = mData->strVrdeExtPack;
    797774    alock.release();
    798775    HRESULT hrc = S_OK;
     
    864841             */
    865842             AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    866              if (aExtPack != mData->mVrdeExtPack)
     843             if (aExtPack != mData->strVrdeExtPack)
    867844             {
    868845                 mData.backup();
    869                  mData->mVrdeExtPack = aExtPack;
     846                 mData->strVrdeExtPack = aExtPack;
    870847
    871848                /* leave the lock before informing callbacks */
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r60786 r61009  
    41314131            if (pMedium->i_isInRegistry(uuidRegistry))
    41324132            {
    4133                 llTarget.push_back(settings::g_MediumEmpty);
     4133                llTarget.push_back(settings::Medium::Empty);
    41344134                rc = pMedium->i_saveSettings(llTarget.back(), strMachineFolder);     // this recurses into child hard disks
    41354135                if (FAILED(rc))
  • trunk/src/VBox/Main/xml/Settings.cpp

    r60786 r61009  
    5252 *      version (stored in m->sv) is high enough. That is, for VirtualBox 4.0, write it
    5353 *      only if (m->sv >= SettingsVersion_v1_11).
     54 *
     55 *   5) You _must_ update xml/VirtalBox-settings.xsd to contain the new tags and attributes.
     56 *      Check that settings file from before and after your change are validating properly.
     57 *      Use "kmk testvalidsettings", it should not find any files which don't validate.
    5458 */
    5559
     
    7478#include <iprt/process.h>
    7579#include <iprt/ldr.h>
     80#include <iprt/base64.h>
    7681#include <iprt/cpp/lock.h>
    7782
     
    9297
    9398/** VirtualBox XML settings namespace */
    94 #define VBOX_XML_NAMESPACE      "http://www.innotek.de/VirtualBox-settings"
     99#define VBOX_XML_NAMESPACE      "http://www.virtualbox.org/"
     100
     101/** VirtualBox XML schema location (relative URI) */
     102#define VBOX_XML_SCHEMA "VirtualBox-settings.xsd"
    95103
    96104/** VirtualBox XML settings version number substring ("x.y")  */
     
    121129#define VBOX_XML_VERSION_FULL   VBOX_XML_VERSION "-" VBOX_XML_PLATFORM
    122130
    123 const struct Snapshot settings::g_SnapshotEmpty; /* default ctor is OK */
    124 const struct Medium settings::g_MediumEmpty; /* default ctor is OK */
    125 
    126131////////////////////////////////////////////////////////////////////////////////
    127132//
     
    212217    }
    213218};
    214 
    215 ////////////////////////////////////////////////////////////////////////////////
    216 //
    217 // MediaRegistry
    218 //
    219 ////////////////////////////////////////////////////////////////////////////////
    220 
    221 bool Medium::operator==(const Medium &m) const
    222 {
    223     return    (uuid == m.uuid)
    224            && (strLocation == m.strLocation)
    225            && (strDescription == m.strDescription)
    226            && (strFormat == m.strFormat)
    227            && (fAutoReset == m.fAutoReset)
    228            && (properties == m.properties)
    229            && (hdType == m.hdType)
    230            && (llChildren== m.llChildren);         // this is deep and recurses
    231 }
    232 
    233 bool MediaRegistry::operator==(const MediaRegistry &m) const
    234 {
    235     return    llHardDisks == m.llHardDisks
    236            && llDvdImages == m.llDvdImages
    237            && llFloppyImages == m.llFloppyImages;
    238 }
    239219
    240220////////////////////////////////////////////////////////////////////////////////
     
    337317                else if (ulMinor == 16)
    338318                    m->sv = SettingsVersion_v1_16;
    339                 else if (ulMinor > 15)
     319                else if (ulMinor > 16)
    340320                    m->sv = SettingsVersion_Future;
    341321            }
     
    488468
    489469/**
     470 * Helper function that parses a Base64 formatted string into a binary blob.
     471 * @param guid
     472 * @param strUUID
     473 */
     474void ConfigFileBase::parseBase64(IconBlob &binary,
     475                                 const Utf8Str &str) const
     476{
     477#define DECODE_STR_MAX _1M
     478    const char* psz = str.c_str();
     479    ssize_t cbOut = RTBase64DecodedSize(psz, NULL);
     480    if (cbOut > DECODE_STR_MAX)
     481        throw ConfigFileError(this, NULL, N_("Base64 encoded data too long. %d > %d"), cbOut, DECODE_STR_MAX);
     482    binary.resize(cbOut);
     483    int vrc = VINF_SUCCESS;
     484    if (cbOut)
     485        vrc = RTBase64Decode(psz, &binary.front(), cbOut, NULL, NULL);
     486    if (RT_FAILURE(vrc))
     487    {
     488        binary.resize(0);
     489        throw ConfigFileError(this, NULL, N_("Base64 encoded data could not be decoded (%Rrc)"), vrc);
     490    }
     491}
     492
     493/**
    490494 * Helper to create a string for a RTTIMESPEC for writing out ISO timestamps.
    491495 * @param stamp
     
    501505                      time.i32Year, time.u8Month, time.u8MonthDay,
    502506                      time.u8Hour, time.u8Minute, time.u8Second);
     507}
     508
     509/**
     510 * Helper to create a base64 encoded string out of a binary blob.
     511 * @param str
     512 * @param binary
     513 */
     514void ConfigFileBase::toBase64(com::Utf8Str &str, const IconBlob &binary) const
     515{
     516    ssize_t cb = binary.size();
     517    if (cb > 0)
     518    {
     519        ssize_t cchOut = RTBase64EncodedLength(cb);
     520        str.reserve(cchOut+1);
     521        int vrc = RTBase64Encode(&binary.front(), cb,
     522                                 str.mutableRaw(), str.capacity(),
     523                                 NULL);
     524        if (RT_FAILURE(vrc))
     525            throw ConfigFileError(this, NULL, N_("Failed to convert binary data to base64 format (%Rrc)"), vrc);
     526        str.jolt();
     527    }
    503528}
    504529
     
    800825        // XPCOM has very small stack, avoid big local variables and use the
    801826        // list element.
    802         llSettingsChildren.push_back(g_MediumEmpty);
     827        llSettingsChildren.push_back(Medium::Empty);
    803828        readMedium(t,
    804829                   depth + 1,
     
    843868                && (pelmMedium->nameEquals("HardDisk")))
    844869            {
    845                 mr.llHardDisks.push_back(g_MediumEmpty);
     870                mr.llHardDisks.push_back(Medium::Empty);
    846871                readMedium(t, 1, *pelmMedium, mr.llHardDisks.back());
    847872            }
     
    849874                     && (pelmMedium->nameEquals("Image")))
    850875            {
    851                 mr.llDvdImages.push_back(g_MediumEmpty);
     876                mr.llDvdImages.push_back(Medium::Empty);
    852877                readMedium(t, 1, *pelmMedium, mr.llDvdImages.back());
    853878            }
     
    855880                     && (pelmMedium->nameEquals("Image")))
    856881            {
    857                 mr.llFloppyImages.push_back(g_MediumEmpty);
     882                mr.llFloppyImages.push_back(Medium::Empty);
    858883                readMedium(t, 1, *pelmMedium, mr.llFloppyImages.back());
    859884            }
     
    973998                // but as it's an omission of someone who changed this file
    974999                // it's the only generic possibility.
    975                 pcszVersion = "1.15";
    976                 m->sv = SettingsVersion_v1_15;
     1000                pcszVersion = "1.16";
     1001                m->sv = SettingsVersion_v1_16;
    9771002            }
    9781003            break;
     
    10121037);
    10131038    m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE);
     1039    // Have the code for producing a proper schema reference. Not used by most
     1040    // tools, so don't bother doing it. The schema is not on the server anyway.
     1041#ifdef VBOX_WITH_SETTINGS_SCHEMA
     1042    m->pelmRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
     1043    m->pelmRoot->setAttribute("xsi:schemaLocation", VBOX_XML_NAMESPACE " " VBOX_XML_SCHEMA);
     1044#endif
    10141045
    10151046    // add settings version attribute to root element
     
    12311262                                        const MediaRegistry &mr)
    12321263{
     1264    if (mr.llHardDisks.size() == 0 && mr.llDvdImages.size() == 0 && mr.llFloppyImages.size() == 0)
     1265        return;
     1266
    12331267    xml::ElementNode *pelmMediaRegistry = elmParent.createChild("MediaRegistry");
    12341268
    1235     xml::ElementNode *pelmHardDisks = pelmMediaRegistry->createChild("HardDisks");
    1236     for (MediaList::const_iterator it = mr.llHardDisks.begin();
    1237          it != mr.llHardDisks.end();
    1238          ++it)
    1239     {
    1240         buildMedium(HardDisk, 1, *pelmHardDisks, *it);
    1241     }
    1242 
    1243     xml::ElementNode *pelmDVDImages = pelmMediaRegistry->createChild("DVDImages");
    1244     for (MediaList::const_iterator it = mr.llDvdImages.begin();
    1245          it != mr.llDvdImages.end();
    1246          ++it)
    1247     {
    1248         buildMedium(DVDImage, 1, *pelmDVDImages, *it);
    1249     }
    1250 
    1251     xml::ElementNode *pelmFloppyImages = pelmMediaRegistry->createChild("FloppyImages");
    1252     for (MediaList::const_iterator it = mr.llFloppyImages.begin();
    1253          it != mr.llFloppyImages.end();
    1254          ++it)
    1255     {
    1256         buildMedium(FloppyImage, 1, *pelmFloppyImages, *it);
     1269    if (mr.llHardDisks.size())
     1270    {
     1271        xml::ElementNode *pelmHardDisks = pelmMediaRegistry->createChild("HardDisks");
     1272        for (MediaList::const_iterator it = mr.llHardDisks.begin();
     1273             it != mr.llHardDisks.end();
     1274             ++it)
     1275        {
     1276            buildMedium(HardDisk, 1, *pelmHardDisks, *it);
     1277        }
     1278    }
     1279
     1280    if (mr.llDvdImages.size())
     1281    {
     1282        xml::ElementNode *pelmDVDImages = pelmMediaRegistry->createChild("DVDImages");
     1283        for (MediaList::const_iterator it = mr.llDvdImages.begin();
     1284             it != mr.llDvdImages.end();
     1285             ++it)
     1286        {
     1287            buildMedium(DVDImage, 1, *pelmDVDImages, *it);
     1288        }
     1289    }
     1290
     1291    if (mr.llFloppyImages.size())
     1292    {
     1293        xml::ElementNode *pelmFloppyImages = pelmMediaRegistry->createChild("FloppyImages");
     1294        for (MediaList::const_iterator it = mr.llFloppyImages.begin();
     1295             it != mr.llFloppyImages.end();
     1296             ++it)
     1297        {
     1298            buildMedium(FloppyImage, 1, *pelmFloppyImages, *it);
     1299        }
    12571300    }
    12581301}
     
    13351378////////////////////////////////////////////////////////////////////////////////
    13361379
     1380
     1381/**
     1382 * Constructor. Needs to set sane defaults which stand the test of time.
     1383 */
     1384USBDeviceFilter::USBDeviceFilter() :
     1385    fActive(false),
     1386    action(USBDeviceFilterAction_Null),
     1387    ulMaskedInterfaces(0)
     1388{
     1389}
     1390
    13371391/**
    13381392 * Comparison operator. This gets called from MachineConfigFile::operator==,
     
    13421396bool USBDeviceFilter::operator==(const USBDeviceFilter &u) const
    13431397{
    1344     return (    (this == &u)
    1345              || (    (strName           == u.strName)
    1346                   && (fActive           == u.fActive)
    1347                   && (strVendorId       == u.strVendorId)
    1348                   && (strProductId      == u.strProductId)
    1349                   && (strRevision       == u.strRevision)
    1350                   && (strManufacturer   == u.strManufacturer)
    1351                   && (strProduct        == u.strProduct)
    1352                   && (strSerialNumber   == u.strSerialNumber)
    1353                   && (strPort           == u.strPort)
    1354                   && (action            == u.action)
    1355                   && (strRemote         == u.strRemote)
    1356                   && (ulMaskedInterfaces == u.ulMaskedInterfaces)
    1357                 )
    1358            );
    1359 }
     1398    return (this == &u)
     1399        || (   strName           == u.strName
     1400            && fActive           == u.fActive
     1401            && strVendorId       == u.strVendorId
     1402            && strProductId      == u.strProductId
     1403            && strRevision       == u.strRevision
     1404            && strManufacturer   == u.strManufacturer
     1405            && strProduct        == u.strProduct
     1406            && strSerialNumber   == u.strSerialNumber
     1407            && strPort           == u.strPort
     1408            && action            == u.action
     1409            && strRemote         == u.strRemote
     1410            && ulMaskedInterfaces == u.ulMaskedInterfaces);
     1411}
     1412
     1413/**
     1414 * Constructor. Needs to set sane defaults which stand the test of time.
     1415 */
     1416Medium::Medium() :
     1417    fAutoReset(false),
     1418    hdType(MediumType_Normal)
     1419{
     1420}
     1421
     1422/**
     1423 * Comparison operator. This gets called from MachineConfigFile::operator==,
     1424 * which in turn gets called from Machine::saveSettings to figure out whether
     1425 * machine settings have really changed and thus need to be written out to disk.
     1426 */
     1427bool Medium::operator==(const Medium &m) const
     1428{
     1429    return (this == &m)
     1430        || (   uuid == m.uuid
     1431            && strLocation == m.strLocation
     1432            && strDescription == m.strDescription
     1433            && strFormat == m.strFormat
     1434            && fAutoReset == m.fAutoReset
     1435            && properties == m.properties
     1436            && hdType == m.hdType
     1437            && llChildren == m.llChildren);         // this is deep and recurses
     1438}
     1439
     1440const struct Medium Medium::Empty; /* default ctor is OK */
     1441
     1442/**
     1443 * Comparison operator. This gets called from MachineConfigFile::operator==,
     1444 * which in turn gets called from Machine::saveSettings to figure out whether
     1445 * machine settings have really changed and thus need to be written out to disk.
     1446 */
     1447bool MediaRegistry::operator==(const MediaRegistry &m) const
     1448{
     1449    return (this == &m)
     1450        || (   llHardDisks == m.llHardDisks
     1451            && llDvdImages == m.llDvdImages
     1452            && llFloppyImages == m.llFloppyImages);
     1453}
     1454
     1455/**
     1456 * Constructor. Needs to set sane defaults which stand the test of time.
     1457 */
     1458NATRule::NATRule() :
     1459    proto(NATProtocol_TCP),
     1460    u16HostPort(0),
     1461    u16GuestPort(0)
     1462{
     1463}
     1464
     1465/**
     1466 * Comparison operator. This gets called from MachineConfigFile::operator==,
     1467 * which in turn gets called from Machine::saveSettings to figure out whether
     1468 * machine settings have really changed and thus need to be written out to disk.
     1469 */
     1470bool NATRule::operator==(const NATRule &r) const
     1471{
     1472    return (this == &r)
     1473        || (   strName == r.strName
     1474            && proto == r.proto
     1475            && u16HostPort == r.u16HostPort
     1476            && strHostIP == r.strHostIP
     1477            && u16GuestPort == r.u16GuestPort
     1478            && strGuestIP == r.strGuestIP);
     1479}
     1480
     1481/**
     1482 * Constructor. Needs to set sane defaults which stand the test of time.
     1483 */
     1484NATHostLoopbackOffset::NATHostLoopbackOffset() :
     1485    u32Offset(0)
     1486{
     1487}
     1488
     1489/**
     1490 * Comparison operator. This gets called from MachineConfigFile::operator==,
     1491 * which in turn gets called from Machine::saveSettings to figure out whether
     1492 * machine settings have really changed and thus need to be written out to disk.
     1493 */
     1494bool NATHostLoopbackOffset::operator==(const NATHostLoopbackOffset &o) const
     1495{
     1496    return (this == &o)
     1497        || (   strLoopbackHostAddress == o.strLoopbackHostAddress
     1498            && u32Offset == o.u32Offset);
     1499}
     1500
     1501
     1502////////////////////////////////////////////////////////////////////////////////
     1503//
     1504// VirtualBox.xml structures
     1505//
     1506////////////////////////////////////////////////////////////////////////////////
     1507
     1508/**
     1509 * Constructor. Needs to set sane defaults which stand the test of time.
     1510 */
     1511SystemProperties::SystemProperties() :
     1512    ulLogHistoryCount(3),
     1513    fExclusiveHwVirt(true)
     1514{
     1515#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
     1516    fExclusiveHwVirt = false;
     1517#endif
     1518}
     1519
     1520/**
     1521 * Constructor. Needs to set sane defaults which stand the test of time.
     1522 */
     1523DhcpOptValue::DhcpOptValue() :
     1524    text(),
     1525    encoding(DhcpOptEncoding_Legacy)
     1526{
     1527}
     1528
     1529/**
     1530 * Non-standard constructor.
     1531 */
     1532DhcpOptValue::DhcpOptValue(const com::Utf8Str &aText, DhcpOptEncoding_T aEncoding) :
     1533    text(aText),
     1534    encoding(aEncoding)
     1535{
     1536}
     1537
     1538/**
     1539 * Non-standard constructor.
     1540 */
     1541VmNameSlotKey::VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot) :
     1542    VmName(aVmName),
     1543    Slot(aSlot)
     1544{
     1545}
     1546
     1547/**
     1548 * Non-standard comparison operator.
     1549 */
     1550bool VmNameSlotKey::operator< (const VmNameSlotKey& that) const
     1551{
     1552    if (VmName == that.VmName)
     1553        return Slot < that.Slot;
     1554    else
     1555        return VmName < that.VmName;
     1556}
     1557
     1558/**
     1559 * Constructor. Needs to set sane defaults which stand the test of time.
     1560 */
     1561DHCPServer::DHCPServer() :
     1562    fEnabled(false)
     1563{
     1564}
     1565
     1566/**
     1567 * Constructor. Needs to set sane defaults which stand the test of time.
     1568 */
     1569NATNetwork::NATNetwork() :
     1570    fEnabled(true),
     1571    fIPv6Enabled(false),
     1572    fAdvertiseDefaultIPv6Route(false),
     1573    fNeedDhcpServer(true),
     1574    u32HostLoopback6Offset(0)
     1575{
     1576}
     1577
     1578
    13601579
    13611580////////////////////////////////////////////////////////////////////////////////
     
    14471666        DhcpOpt_T OptName;
    14481667        com::Utf8Str OptText;
    1449         int32_t OptEnc = DhcpOptValue::LEGACY;
     1668        int32_t OptEnc = DhcpOptEncoding_Legacy;
    14501669
    14511670        opt->getAttributeValue("name", (uint32_t&)OptName);
     
    14571676        opt->getAttributeValue("encoding", OptEnc);
    14581677
    1459         map[OptName] = DhcpOptValue(OptText, (DhcpOptValue::Encoding)OptEnc);
     1678        map[OptName] = DhcpOptValue(OptText, (DhcpOptEncoding_T)OptEnc);
    14601679    } /* end of forall("Option") */
    14611680
     
    17671986                pelmOpt->setAttribute("name", itOpt->first);
    17681987                pelmOpt->setAttribute("value", itOpt->second.text);
    1769                 if (itOpt->second.encoding != DhcpOptValue::LEGACY)
     1988                if (itOpt->second.encoding != DhcpOptEncoding_Legacy)
    17701989                    pelmOpt->setAttribute("encoding", (int)itOpt->second.encoding);
    17711990            }
     
    17912010                    pelmOpt->setAttribute("name", itOpt1->first);
    17922011                    pelmOpt->setAttribute("value", itOpt1->second.text);
    1793                     if (itOpt1->second.encoding != DhcpOptValue::LEGACY)
     2012                    if (itOpt1->second.encoding != DhcpOptEncoding_Legacy)
    17942013                        pelmOpt->setAttribute("encoding", (int)itOpt1->second.encoding);
    17952014                }
     
    18822101
    18832102/**
     2103 * Constructor. Needs to set sane defaults which stand the test of time.
     2104 */
     2105VRDESettings::VRDESettings() :
     2106    fEnabled(false),
     2107    authType(AuthType_Null),
     2108    ulAuthTimeout(5000),
     2109    fAllowMultiConnection(false),
     2110    fReuseSingleConnection(false)
     2111{
     2112}
     2113
     2114/**
     2115 * Check if all settings have default values.
     2116 */
     2117bool VRDESettings::areDefaultSettings() const
     2118{
     2119    return !fEnabled
     2120        && authType == AuthType_Null
     2121        && (ulAuthTimeout == 5000 || ulAuthTimeout == 0)
     2122        && strAuthLibrary.isEmpty()
     2123        && !fAllowMultiConnection
     2124        && !fReuseSingleConnection
     2125        && strVrdeExtPack.isEmpty()
     2126        && mapProperties.size() == 0;
     2127}
     2128
     2129/**
    18842130 * Comparison operator. This gets called from MachineConfigFile::operator==,
    18852131 * which in turn gets called from Machine::saveSettings to figure out whether
     
    18882134bool VRDESettings::operator==(const VRDESettings& v) const
    18892135{
    1890     return (    (this == &v)
    1891              || (    (fEnabled                  == v.fEnabled)
    1892                   && (authType                  == v.authType)
    1893                   && (ulAuthTimeout             == v.ulAuthTimeout)
    1894                   && (strAuthLibrary            == v.strAuthLibrary)
    1895                   && (fAllowMultiConnection     == v.fAllowMultiConnection)
    1896                   && (fReuseSingleConnection    == v.fReuseSingleConnection)
    1897                   && (strVrdeExtPack            == v.strVrdeExtPack)
    1898                   && (mapProperties             == v.mapProperties)
    1899                 )
    1900            );
     2136    return (this == &v)
     2137        || (   fEnabled                  == v.fEnabled
     2138            && authType                  == v.authType
     2139            && ulAuthTimeout             == v.ulAuthTimeout
     2140            && strAuthLibrary            == v.strAuthLibrary
     2141            && fAllowMultiConnection     == v.fAllowMultiConnection
     2142            && fReuseSingleConnection    == v.fReuseSingleConnection
     2143            && strVrdeExtPack            == v.strVrdeExtPack
     2144            && mapProperties             == v.mapProperties);
     2145}
     2146
     2147/**
     2148 * Constructor. Needs to set sane defaults which stand the test of time.
     2149 */
     2150BIOSSettings::BIOSSettings() :
     2151    fACPIEnabled(true),
     2152    fIOAPICEnabled(false),
     2153    fLogoFadeIn(true),
     2154    fLogoFadeOut(true),
     2155    ulLogoDisplayTime(0),
     2156    biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
     2157    fPXEDebugEnabled(false),
     2158    llTimeOffset(0)
     2159{
     2160}
     2161
     2162/**
     2163 * Check if all settings have default values.
     2164 */
     2165bool BIOSSettings::areDefaultSettings() const
     2166{
     2167    return fACPIEnabled
     2168        && !fIOAPICEnabled
     2169        && fLogoFadeIn
     2170        && fLogoFadeOut
     2171        && ulLogoDisplayTime == 0
     2172        && biosBootMenuMode == BIOSBootMenuMode_MessageAndMenu
     2173        && !fPXEDebugEnabled
     2174        && llTimeOffset == 0;
    19012175}
    19022176
     
    19082182bool BIOSSettings::operator==(const BIOSSettings &d) const
    19092183{
    1910     return (    (this == &d)
    1911              || (    fACPIEnabled        == d.fACPIEnabled
    1912                   && fIOAPICEnabled      == d.fIOAPICEnabled
    1913                   && fLogoFadeIn         == d.fLogoFadeIn
    1914                   && fLogoFadeOut        == d.fLogoFadeOut
    1915                   && ulLogoDisplayTime   == d.ulLogoDisplayTime
    1916                   && strLogoImagePath    == d.strLogoImagePath
    1917                   && biosBootMenuMode    == d.biosBootMenuMode
    1918                   && fPXEDebugEnabled    == d.fPXEDebugEnabled
    1919                   && llTimeOffset        == d.llTimeOffset)
    1920            );
     2184    return (this == &d)
     2185        || (   fACPIEnabled        == d.fACPIEnabled
     2186            && fIOAPICEnabled      == d.fIOAPICEnabled
     2187            && fLogoFadeIn         == d.fLogoFadeIn
     2188            && fLogoFadeOut        == d.fLogoFadeOut
     2189            && ulLogoDisplayTime   == d.ulLogoDisplayTime
     2190            && strLogoImagePath    == d.strLogoImagePath
     2191            && biosBootMenuMode    == d.biosBootMenuMode
     2192            && fPXEDebugEnabled    == d.fPXEDebugEnabled
     2193            && llTimeOffset        == d.llTimeOffset);
     2194}
     2195
     2196/**
     2197 * Constructor. Needs to set sane defaults which stand the test of time.
     2198 */
     2199USBController::USBController() :
     2200    enmType(USBControllerType_Null)
     2201{
    19212202}
    19222203
     
    19282209bool USBController::operator==(const USBController &u) const
    19292210{
    1930     return (    (this == &u)
    1931                  || (    (strName == u.strName)
    1932                       && (enmType == u.enmType)
    1933                     )
    1934            );
     2211    return (this == &u)
     2212        || (   strName == u.strName
     2213            && enmType == u.enmType);
     2214}
     2215
     2216/**
     2217 * Constructor. Needs to set sane defaults which stand the test of time.
     2218 */
     2219USB::USB()
     2220{
    19352221}
    19362222
     
    19422228bool USB::operator==(const USB &u) const
    19432229{
    1944     return (    (this == &u)
    1945                  || (    (llUSBControllers == u.llUSBControllers)
    1946                       && (llDeviceFilters  == u.llDeviceFilters)
    1947                     )
    1948            );
     2230    return (this == &u)
     2231        || (   llUSBControllers == u.llUSBControllers
     2232            && llDeviceFilters  == u.llDeviceFilters);
     2233}
     2234
     2235/**
     2236 * Constructor. Needs to set sane defaults which stand the test of time.
     2237 */
     2238NAT::NAT() :
     2239    u32Mtu(0),
     2240    u32SockRcv(0),
     2241    u32SockSnd(0),
     2242    u32TcpRcv(0),
     2243    u32TcpSnd(0),
     2244    fDNSPassDomain(true), /* historically this value is true */
     2245    fDNSProxy(false),
     2246    fDNSUseHostResolver(false),
     2247    fAliasLog(false),
     2248    fAliasProxyOnly(false),
     2249    fAliasUseSamePorts(false)
     2250{
     2251}
     2252
     2253/**
     2254 * Check if all DNS settings have default values.
     2255 */
     2256bool NAT::areDNSDefaultSettings() const
     2257{
     2258    return fDNSPassDomain && !fDNSProxy && !fDNSUseHostResolver;
     2259}
     2260
     2261/**
     2262 * Check if all Alias settings have default values.
     2263 */
     2264bool NAT::areAliasDefaultSettings() const
     2265{
     2266    return !fAliasLog && !fAliasProxyOnly && !fAliasUseSamePorts;
     2267}
     2268
     2269/**
     2270 * Check if all TFTP settings have default values.
     2271 */
     2272bool NAT::areTFTPDefaultSettings() const
     2273{
     2274    return strTFTPPrefix.isEmpty()
     2275        && strTFTPBootFile.isEmpty()
     2276        && strTFTPNextServer.isEmpty();
     2277}
     2278
     2279/**
     2280 * Check if all settings have default values.
     2281 */
     2282bool NAT::areDefaultSettings() const
     2283{
     2284    return strNetwork.isEmpty()
     2285        && strBindIP.isEmpty()
     2286        && u32Mtu == 0
     2287        && u32SockRcv == 0
     2288        && u32SockSnd == 0
     2289        && u32TcpRcv == 0
     2290        && u32TcpSnd == 0
     2291        && areDNSDefaultSettings()
     2292        && areAliasDefaultSettings()
     2293        && areTFTPDefaultSettings()
     2294        && mapRules.size() == 0;
    19492295}
    19502296
     
    19542300 * machine settings have really changed and thus need to be written out to disk.
    19552301 */
    1956 bool NetworkAdapter::operator==(const NetworkAdapter &n) const
    1957 {
    1958     return (    (this == &n)
    1959              || (    (ulSlot                == n.ulSlot)
    1960                   && (type                  == n.type)
    1961                   && (fEnabled              == n.fEnabled)
    1962                   && (strMACAddress         == n.strMACAddress)
    1963                   && (fCableConnected       == n.fCableConnected)
    1964                   && (ulLineSpeed           == n.ulLineSpeed)
    1965                   && (enmPromiscModePolicy  == n.enmPromiscModePolicy)
    1966                   && (fTraceEnabled         == n.fTraceEnabled)
    1967                   && (strTraceFile          == n.strTraceFile)
    1968                   && (mode                  == n.mode)
    1969                   && (nat                   == n.nat)
    1970                   && (strBridgedName        == n.strBridgedName)
    1971                   && (strHostOnlyName       == n.strHostOnlyName)
    1972                   && (strInternalNetworkName == n.strInternalNetworkName)
    1973                   && (strGenericDriver      == n.strGenericDriver)
    1974                   && (genericProperties     == n.genericProperties)
    1975                   && (ulBootPriority        == n.ulBootPriority)
    1976                   && (strBandwidthGroup     == n.strBandwidthGroup)
    1977                 )
    1978            );
     2302bool NAT::operator==(const NAT &n) const
     2303{
     2304   return (this == &n)
     2305        || (   strNetwork           == n.strNetwork
     2306            && strBindIP           == n.strBindIP
     2307            && u32Mtu              == n.u32Mtu
     2308            && u32SockRcv          == n.u32SockRcv
     2309            && u32SockSnd          == n.u32SockSnd
     2310            && u32TcpSnd           == n.u32TcpSnd
     2311            && u32TcpRcv           == n.u32TcpRcv
     2312            && strTFTPPrefix       == n.strTFTPPrefix
     2313            && strTFTPBootFile     == n.strTFTPBootFile
     2314            && strTFTPNextServer   == n.strTFTPNextServer
     2315            && fDNSPassDomain      == n.fDNSPassDomain
     2316            && fDNSProxy           == n.fDNSProxy
     2317            && fDNSUseHostResolver == n.fDNSUseHostResolver
     2318            && fAliasLog           == n.fAliasLog
     2319            && fAliasProxyOnly     == n.fAliasProxyOnly
     2320            && fAliasUseSamePorts  == n.fAliasUseSamePorts
     2321            && mapRules            == n.mapRules);
     2322}
     2323
     2324/**
     2325 * Constructor. Needs to set sane defaults which stand the test of time.
     2326 */
     2327NetworkAdapter::NetworkAdapter() :
     2328    ulSlot(0),
     2329    type(NetworkAdapterType_Am79C973),
     2330    fEnabled(false),
     2331    fCableConnected(true),
     2332    ulLineSpeed(0),
     2333    enmPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
     2334    fTraceEnabled(false),
     2335    mode(NetworkAttachmentType_Null),
     2336    ulBootPriority(0)
     2337{
     2338}
     2339
     2340/**
     2341 * Check if all Generic Driver settings have default values.
     2342 */
     2343bool NetworkAdapter::areGenericDriverDefaultSettings() const
     2344{
     2345    return strGenericDriver.isEmpty()
     2346        && genericProperties.size() == 0;
     2347}
     2348
     2349/**
     2350 * Check if all settings have default values.
     2351 */
     2352bool NetworkAdapter::areDefaultSettings() const
     2353{
     2354    return !fEnabled
     2355        && strMACAddress.isEmpty()
     2356        && fCableConnected
     2357        && ulLineSpeed == 0
     2358        && enmPromiscModePolicy == NetworkAdapterPromiscModePolicy_Deny
     2359        && type == NetworkAdapterType_Am79C973
     2360        && mode == NetworkAttachmentType_Null
     2361        && nat.areDefaultSettings()
     2362        && strBridgedName.isEmpty()
     2363        && strInternalNetworkName.isEmpty()
     2364        && strHostOnlyName.isEmpty()
     2365        && areGenericDriverDefaultSettings()
     2366        && strNATNetworkName.isEmpty();
     2367}
     2368
     2369/**
     2370 * Special check if settings of the non-current attachment type have default values.
     2371 */
     2372bool NetworkAdapter::areDisabledDefaultSettings() const
     2373{
     2374    return (mode != NetworkAttachmentType_NAT ? nat.areDefaultSettings() : true)
     2375        && (mode != NetworkAttachmentType_Bridged ? strBridgedName.isEmpty() : true)
     2376        && (mode != NetworkAttachmentType_Internal ? strInternalNetworkName.isEmpty() : true)
     2377        && (mode != NetworkAttachmentType_HostOnly ? strHostOnlyName.isEmpty() : true)
     2378        && (mode != NetworkAttachmentType_Generic ? areGenericDriverDefaultSettings() : true)
     2379        && (mode != NetworkAttachmentType_NATNetwork ? strNATNetworkName.isEmpty() : true);
    19792380}
    19802381
     
    19842385 * machine settings have really changed and thus need to be written out to disk.
    19852386 */
    1986 bool SerialPort::operator==(const SerialPort &s) const
    1987 {
    1988     return (    (this == &s)
    1989              || (    (ulSlot            == s.ulSlot)
    1990                   && (fEnabled          == s.fEnabled)
    1991                   && (ulIOBase          == s.ulIOBase)
    1992                   && (ulIRQ             == s.ulIRQ)
    1993                   && (portMode          == s.portMode)
    1994                   && (strPath           == s.strPath)
    1995                   && (fServer           == s.fServer)
    1996                 )
    1997            );
     2387bool NetworkAdapter::operator==(const NetworkAdapter &n) const
     2388{
     2389    return (this == &n)
     2390        || (   ulSlot                == n.ulSlot
     2391            && type                  == n.type
     2392            && fEnabled              == n.fEnabled
     2393            && strMACAddress         == n.strMACAddress
     2394            && fCableConnected       == n.fCableConnected
     2395            && ulLineSpeed           == n.ulLineSpeed
     2396            && enmPromiscModePolicy  == n.enmPromiscModePolicy
     2397            && fTraceEnabled         == n.fTraceEnabled
     2398            && strTraceFile          == n.strTraceFile
     2399            && mode                  == n.mode
     2400            && nat                   == n.nat
     2401            && strBridgedName        == n.strBridgedName
     2402            && strHostOnlyName       == n.strHostOnlyName
     2403            && strInternalNetworkName == n.strInternalNetworkName
     2404            && strGenericDriver      == n.strGenericDriver
     2405            && genericProperties     == n.genericProperties
     2406            && ulBootPriority        == n.ulBootPriority
     2407            && strBandwidthGroup     == n.strBandwidthGroup);
     2408}
     2409
     2410/**
     2411 * Constructor. Needs to set sane defaults which stand the test of time.
     2412 */
     2413SerialPort::SerialPort() :
     2414    ulSlot(0),
     2415    fEnabled(false),
     2416    ulIOBase(0x3f8),
     2417    ulIRQ(4),
     2418    portMode(PortMode_Disconnected),
     2419    fServer(false)
     2420{
    19982421}
    19992422
     
    20032426 * machine settings have really changed and thus need to be written out to disk.
    20042427 */
    2005 bool ParallelPort::operator==(const ParallelPort &s) const
    2006 {
    2007     return (    (this == &s)
    2008              || (    (ulSlot            == s.ulSlot)
    2009                   && (fEnabled          == s.fEnabled)
    2010                   && (ulIOBase          == s.ulIOBase)
    2011                   && (ulIRQ             == s.ulIRQ)
    2012                   && (strPath           == s.strPath)
    2013                 )
    2014            );
     2428bool SerialPort::operator==(const SerialPort &s) const
     2429{
     2430    return (this == &s)
     2431        || (   ulSlot            == s.ulSlot
     2432            && fEnabled          == s.fEnabled
     2433            && ulIOBase          == s.ulIOBase
     2434            && ulIRQ             == s.ulIRQ
     2435            && portMode          == s.portMode
     2436            && strPath           == s.strPath
     2437            && fServer           == s.fServer);
     2438}
     2439
     2440/**
     2441 * Constructor. Needs to set sane defaults which stand the test of time.
     2442 */
     2443ParallelPort::ParallelPort() :
     2444    ulSlot(0),
     2445    fEnabled(false),
     2446    ulIOBase(0x378),
     2447    ulIRQ(7)
     2448{
    20152449}
    20162450
     
    20202454 * machine settings have really changed and thus need to be written out to disk.
    20212455 */
    2022 bool SharedFolder::operator==(const SharedFolder &g) const
    2023 {
    2024     return (    (this == &g)
    2025              || (    (strName       == g.strName)
    2026                   && (strHostPath   == g.strHostPath)
    2027                   && (fWritable     == g.fWritable)
    2028                   && (fAutoMount    == g.fAutoMount)
    2029                 )
    2030            );
     2456bool ParallelPort::operator==(const ParallelPort &s) const
     2457{
     2458    return (this == &s)
     2459        || (   ulSlot            == s.ulSlot
     2460            && fEnabled          == s.fEnabled
     2461            && ulIOBase          == s.ulIOBase
     2462            && ulIRQ             == s.ulIRQ
     2463            && strPath           == s.strPath);
     2464}
     2465
     2466/**
     2467 * Constructor. Needs to set sane defaults which stand the test of time.
     2468 */
     2469AudioAdapter::AudioAdapter() :
     2470    fEnabled(false),
     2471    controllerType(AudioControllerType_AC97),
     2472    codecType(AudioCodecType_STAC9700),
     2473    driverType(AudioDriverType_Null)
     2474{
     2475}
     2476
     2477/**
     2478 * Check if all settings have default values.
     2479 */
     2480bool AudioAdapter::areDefaultSettings() const
     2481{
     2482    return !fEnabled
     2483        && controllerType == AudioControllerType_AC97
     2484        && codecType == AudioCodecType_STAC9700
     2485        && driverType == MachineConfigFile::getHostDefaultAudioDriver()
     2486        && properties.size() == 0;
    20312487}
    20322488
     
    20362492 * machine settings have really changed and thus need to be written out to disk.
    20372493 */
     2494bool AudioAdapter::operator==(const AudioAdapter &a) const
     2495{
     2496    return (this == &a)
     2497        || (   fEnabled        == a.fEnabled
     2498            && controllerType  == a.controllerType
     2499            && codecType       == a.codecType
     2500            && driverType      == a.driverType
     2501            && properties      == a.properties);
     2502}
     2503
     2504/**
     2505 * Constructor. Needs to set sane defaults which stand the test of time.
     2506 */
     2507SharedFolder::SharedFolder() :
     2508    fWritable(false),
     2509    fAutoMount(false)
     2510{
     2511}
     2512
     2513/**
     2514 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2515 * which in turn gets called from Machine::saveSettings to figure out whether
     2516 * machine settings have really changed and thus need to be written out to disk.
     2517 */
     2518bool SharedFolder::operator==(const SharedFolder &g) const
     2519{
     2520    return (this == &g)
     2521        || (   strName       == g.strName
     2522            && strHostPath   == g.strHostPath
     2523            && fWritable     == g.fWritable
     2524            && fAutoMount    == g.fAutoMount);
     2525}
     2526
     2527/**
     2528 * Constructor. Needs to set sane defaults which stand the test of time.
     2529 */
     2530GuestProperty::GuestProperty() :
     2531    timestamp(0)
     2532{
     2533}
     2534
     2535/**
     2536 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2537 * which in turn gets called from Machine::saveSettings to figure out whether
     2538 * machine settings have really changed and thus need to be written out to disk.
     2539 */
    20382540bool GuestProperty::operator==(const GuestProperty &g) const
    20392541{
    2040     return (    (this == &g)
    2041              || (    (strName           == g.strName)
    2042                   && (strValue          == g.strValue)
    2043                   && (timestamp         == g.timestamp)
    2044                   && (strFlags          == g.strFlags)
    2045                 )
    2046            );
    2047 }
    2048 
    2049 Hardware::Hardware()
    2050         : strVersion("1"),
    2051           fHardwareVirt(true),
    2052           fNestedPaging(true),
    2053           fVPID(true),
    2054           fUnrestrictedExecution(true),
    2055           fHardwareVirtForce(false),
    2056           fTripleFaultReset(false),
    2057           fPAE(false),
    2058           enmLongMode(HC_ARCH_BITS == 64 ? Hardware::LongMode_Enabled : Hardware::LongMode_Disabled),
    2059           cCPUs(1),
    2060           fCpuHotPlug(false),
    2061           fHPETEnabled(false),
    2062           ulCpuExecutionCap(100),
    2063           uCpuIdPortabilityLevel(0),
    2064           strCpuProfile("host"),
    2065           ulMemorySizeMB((uint32_t)-1),
    2066           graphicsControllerType(GraphicsControllerType_VBoxVGA),
    2067           ulVRAMSizeMB(8),
    2068           cMonitors(1),
    2069           fAccelerate3D(false),
    2070           fAccelerate2DVideo(false),
    2071           ulVideoCaptureHorzRes(1024),
    2072           ulVideoCaptureVertRes(768),
    2073           ulVideoCaptureRate(512),
    2074           ulVideoCaptureFPS(25),
    2075           ulVideoCaptureMaxTime(0),
    2076           ulVideoCaptureMaxSize(0),
    2077           fVideoCaptureEnabled(false),
    2078           u64VideoCaptureScreens(UINT64_C(0xffffffffffffffff)),
    2079           strVideoCaptureFile(""),
    2080           firmwareType(FirmwareType_BIOS),
    2081           pointingHIDType(PointingHIDType_PS2Mouse),
    2082           keyboardHIDType(KeyboardHIDType_PS2Keyboard),
    2083           chipsetType(ChipsetType_PIIX3),
    2084           paravirtProvider(ParavirtProvider_Legacy),
    2085           strParavirtDebug(""),
    2086           fEmulatedUSBCardReader(false),
    2087           clipboardMode(ClipboardMode_Disabled),
    2088           dndMode(DnDMode_Disabled),
    2089           ulMemoryBalloonSize(0),
    2090           fPageFusionEnabled(false)
     2542    return (this == &g)
     2543        || (   strName           == g.strName
     2544            && strValue          == g.strValue
     2545            && timestamp         == g.timestamp
     2546            && strFlags          == g.strFlags);
     2547}
     2548
     2549/**
     2550 * Constructor. Needs to set sane defaults which stand the test of time.
     2551 */
     2552CpuIdLeaf::CpuIdLeaf() :
     2553    ulId(UINT32_MAX),
     2554    ulEax(0),
     2555    ulEbx(0),
     2556    ulEcx(0),
     2557    ulEdx(0)
     2558{
     2559}
     2560
     2561/**
     2562 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2563 * which in turn gets called from Machine::saveSettings to figure out whether
     2564 * machine settings have really changed and thus need to be written out to disk.
     2565 */
     2566bool CpuIdLeaf::operator==(const CpuIdLeaf &c) const
     2567{
     2568    return (this == &c)
     2569        || (   ulId      == c.ulId
     2570            && ulEax     == c.ulEax
     2571            && ulEbx     == c.ulEbx
     2572            && ulEcx     == c.ulEcx
     2573            && ulEdx     == c.ulEdx);
     2574}
     2575
     2576/**
     2577 * Constructor. Needs to set sane defaults which stand the test of time.
     2578 */
     2579Cpu::Cpu() :
     2580    ulId(UINT32_MAX)
     2581{
     2582}
     2583
     2584/**
     2585 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2586 * which in turn gets called from Machine::saveSettings to figure out whether
     2587 * machine settings have really changed and thus need to be written out to disk.
     2588 */
     2589bool Cpu::operator==(const Cpu &c) const
     2590{
     2591    return (this == &c)
     2592        || (ulId      == c.ulId);
     2593}
     2594
     2595/**
     2596 * Constructor. Needs to set sane defaults which stand the test of time.
     2597 */
     2598BandwidthGroup::BandwidthGroup() :
     2599    cMaxBytesPerSec(0),
     2600    enmType(BandwidthGroupType_Null)
     2601{
     2602}
     2603
     2604/**
     2605 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2606 * which in turn gets called from Machine::saveSettings to figure out whether
     2607 * machine settings have really changed and thus need to be written out to disk.
     2608 */
     2609bool BandwidthGroup::operator==(const BandwidthGroup &i) const
     2610{
     2611    return (this == &i)
     2612        || (   strName      == i.strName
     2613            && cMaxBytesPerSec == i.cMaxBytesPerSec
     2614            && enmType      == i.enmType);
     2615}
     2616
     2617/**
     2618 * IOSettings constructor.
     2619 */
     2620IOSettings::IOSettings() :
     2621    fIOCacheEnabled(true),
     2622    ulIOCacheSize(5)
     2623{
     2624}
     2625
     2626/**
     2627 * Check if all IO Cache settings have default values.
     2628 */
     2629bool IOSettings::areIOCacheDefaultSettings() const
     2630{
     2631    return fIOCacheEnabled
     2632        && ulIOCacheSize == 5;
     2633}
     2634
     2635/**
     2636 * Check if all settings have default values.
     2637 */
     2638bool IOSettings::areDefaultSettings() const
     2639{
     2640    return areIOCacheDefaultSettings()
     2641        && llBandwidthGroups.size() == 0;
     2642}
     2643
     2644/**
     2645 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2646 * which in turn gets called from Machine::saveSettings to figure out whether
     2647 * machine settings have really changed and thus need to be written out to disk.
     2648 */
     2649bool IOSettings::operator==(const IOSettings &i) const
     2650{
     2651    return (this == &i)
     2652        || (   fIOCacheEnabled   == i.fIOCacheEnabled
     2653            && ulIOCacheSize     == i.ulIOCacheSize
     2654            && llBandwidthGroups == i.llBandwidthGroups);
     2655}
     2656
     2657/**
     2658 * Constructor. Needs to set sane defaults which stand the test of time.
     2659 */
     2660HostPCIDeviceAttachment::HostPCIDeviceAttachment() :
     2661    uHostAddress(0),
     2662    uGuestAddress(0)
     2663{
     2664}
     2665
     2666/**
     2667 * Comparison operator. This gets called from MachineConfigFile::operator==,
     2668 * which in turn gets called from Machine::saveSettings to figure out whether
     2669 * machine settings have really changed and thus need to be written out to disk.
     2670 */
     2671bool HostPCIDeviceAttachment::operator==(const HostPCIDeviceAttachment &a) const
     2672{
     2673    return (this == &a)
     2674        || (   uHostAddress   == a.uHostAddress
     2675            && uGuestAddress  == a.uGuestAddress
     2676            && strDeviceName  == a.strDeviceName);
     2677}
     2678
     2679
     2680/**
     2681 * Constructor. Needs to set sane defaults which stand the test of time.
     2682 */
     2683Hardware::Hardware() :
     2684    strVersion("1"),
     2685    fHardwareVirt(true),
     2686    fNestedPaging(true),
     2687    fVPID(true),
     2688    fUnrestrictedExecution(true),
     2689    fHardwareVirtForce(false),
     2690    fTripleFaultReset(false),
     2691    fPAE(false),
     2692    enmLongMode(HC_ARCH_BITS == 64 ? Hardware::LongMode_Enabled : Hardware::LongMode_Disabled),
     2693    cCPUs(1),
     2694    fCpuHotPlug(false),
     2695    fHPETEnabled(false),
     2696    ulCpuExecutionCap(100),
     2697    uCpuIdPortabilityLevel(0),
     2698    strCpuProfile("host"),
     2699    ulMemorySizeMB((uint32_t)-1),
     2700    graphicsControllerType(GraphicsControllerType_VBoxVGA),
     2701    ulVRAMSizeMB(8),
     2702    cMonitors(1),
     2703    fAccelerate3D(false),
     2704    fAccelerate2DVideo(false),
     2705    ulVideoCaptureHorzRes(1024),
     2706    ulVideoCaptureVertRes(768),
     2707    ulVideoCaptureRate(512),
     2708    ulVideoCaptureFPS(25),
     2709    ulVideoCaptureMaxTime(0),
     2710    ulVideoCaptureMaxSize(0),
     2711    fVideoCaptureEnabled(false),
     2712    u64VideoCaptureScreens(UINT64_C(0xffffffffffffffff)),
     2713    strVideoCaptureFile(""),
     2714    firmwareType(FirmwareType_BIOS),
     2715    pointingHIDType(PointingHIDType_PS2Mouse),
     2716    keyboardHIDType(KeyboardHIDType_PS2Keyboard),
     2717    chipsetType(ChipsetType_PIIX3),
     2718    paravirtProvider(ParavirtProvider_Legacy), // default for old VMs, for new ones it's ParavirtProvider_Default
     2719    strParavirtDebug(""),
     2720    fEmulatedUSBCardReader(false),
     2721    clipboardMode(ClipboardMode_Disabled),
     2722    dndMode(DnDMode_Disabled),
     2723    ulMemoryBalloonSize(0),
     2724    fPageFusionEnabled(false)
    20912725{
    20922726    mapBootOrder[0] = DeviceType_Floppy;
     
    21152749
    21162750/**
     2751 * Check if all Paravirt settings have default values.
     2752 */
     2753bool Hardware::areParavirtDefaultSettings() const
     2754{
     2755    // Remember, this is the default for VMs created with 5.0, and older
     2756    // VMs will keep ParavirtProvider_Legacy which must be saved.
     2757    return paravirtProvider == ParavirtProvider_Default
     2758        && strParavirtDebug.isEmpty();
     2759}
     2760
     2761/**
     2762 * Check if all Boot Order settings have default values.
     2763 */
     2764bool Hardware::areBootOrderDefaultSettings() const
     2765{
     2766    BootOrderMap::const_iterator it0 = mapBootOrder.find(0);
     2767    BootOrderMap::const_iterator it1 = mapBootOrder.find(1);
     2768    BootOrderMap::const_iterator it2 = mapBootOrder.find(2);
     2769    BootOrderMap::const_iterator it3 = mapBootOrder.find(3);
     2770    return    (   mapBootOrder.size() == 3
     2771               || (   mapBootOrder.size() == 4
     2772                   && (it3 != mapBootOrder.end() && it3->second == DeviceType_Null)))
     2773           && (it0 != mapBootOrder.end() && it0->second == DeviceType_Floppy)
     2774           && (it1 != mapBootOrder.end() && it1->second == DeviceType_DVD)
     2775           && (it2 != mapBootOrder.end() && it2->second == DeviceType_HardDisk);
     2776}
     2777
     2778/**
     2779 * Check if all Display settings have default values.
     2780 */
     2781bool Hardware::areDisplayDefaultSettings() const
     2782{
     2783    return graphicsControllerType == GraphicsControllerType_VBoxVGA
     2784        && ulVRAMSizeMB == 8
     2785        && cMonitors <= 1
     2786        && !fAccelerate3D
     2787        && !fAccelerate2DVideo;
     2788}
     2789
     2790/**
     2791 * Check if all Video Capture settings have default values.
     2792 */
     2793bool Hardware::areVideoCaptureDefaultSettings() const
     2794{
     2795    return    !fVideoCaptureEnabled
     2796           && u64VideoCaptureScreens == UINT64_C(0xffffffffffffffff)
     2797           && strVideoCaptureFile.isEmpty()
     2798           && ulVideoCaptureHorzRes == 1024
     2799           && ulVideoCaptureVertRes == 768
     2800           && ulVideoCaptureRate == 512
     2801           && ulVideoCaptureFPS == 25
     2802           && ulVideoCaptureMaxTime == 0
     2803           && ulVideoCaptureMaxSize == 0;
     2804}
     2805
     2806/**
     2807 * Check if all Network Adapter settings have default values.
     2808 */
     2809bool Hardware::areAllNetworkAdaptersDefaultSettings() const
     2810{
     2811    for (NetworkAdaptersList::const_iterator it = llNetworkAdapters.begin();
     2812         it != llNetworkAdapters.end();
     2813         ++it)
     2814    {
     2815        if (!it->areDefaultSettings())
     2816            return false;
     2817    }
     2818    return true;
     2819}
     2820
     2821/**
    21172822 * Comparison operator. This gets called from MachineConfigFile::operator==,
    21182823 * which in turn gets called from Machine::saveSettings to figure out whether
     
    21212826bool Hardware::operator==(const Hardware& h) const
    21222827{
    2123     return (    (this == &h)
    2124              || (    (strVersion                == h.strVersion)
    2125                   && (uuid                      == h.uuid)
    2126                   && (fHardwareVirt             == h.fHardwareVirt)
    2127                   && (fNestedPaging             == h.fNestedPaging)
    2128                   && (fLargePages               == h.fLargePages)
    2129                   && (fVPID                     == h.fVPID)
    2130                   && (fUnrestrictedExecution    == h.fUnrestrictedExecution)
    2131                   && (fHardwareVirtForce        == h.fHardwareVirtForce)
    2132                   && (fPAE                      == h.fPAE)
    2133                   && (enmLongMode               == h.enmLongMode)
    2134                   && (fTripleFaultReset         == h.fTripleFaultReset)
    2135                   && (cCPUs                     == h.cCPUs)
    2136                   && (fCpuHotPlug               == h.fCpuHotPlug)
    2137                   && (ulCpuExecutionCap         == h.ulCpuExecutionCap)
    2138                   && (uCpuIdPortabilityLevel    == h.uCpuIdPortabilityLevel)
    2139                   && strCpuProfile              == h.strCpuProfile
    2140                   && (fHPETEnabled              == h.fHPETEnabled)
    2141                   && (llCpus                    == h.llCpus)
    2142                   && (llCpuIdLeafs              == h.llCpuIdLeafs)
    2143                   && (ulMemorySizeMB            == h.ulMemorySizeMB)
    2144                   && (mapBootOrder              == h.mapBootOrder)
    2145                   && (graphicsControllerType    == h.graphicsControllerType)
    2146                   && (ulVRAMSizeMB              == h.ulVRAMSizeMB)
    2147                   && (cMonitors                 == h.cMonitors)
    2148                   && (fAccelerate3D             == h.fAccelerate3D)
    2149                   && (fAccelerate2DVideo        == h.fAccelerate2DVideo)
    2150                   && (fVideoCaptureEnabled      == h.fVideoCaptureEnabled)
    2151                   && (u64VideoCaptureScreens    == h.u64VideoCaptureScreens)
    2152                   && (strVideoCaptureFile       == h.strVideoCaptureFile)
    2153                   && (ulVideoCaptureHorzRes     == h.ulVideoCaptureHorzRes)
    2154                   && (ulVideoCaptureVertRes     == h.ulVideoCaptureVertRes)
    2155                   && (ulVideoCaptureRate        == h.ulVideoCaptureRate)
    2156                   && (ulVideoCaptureFPS         == h.ulVideoCaptureFPS)
    2157                   && (ulVideoCaptureMaxTime     == h.ulVideoCaptureMaxTime)
    2158                   && (ulVideoCaptureMaxSize     == h.ulVideoCaptureMaxTime)
    2159                   && (firmwareType              == h.firmwareType)
    2160                   && (pointingHIDType           == h.pointingHIDType)
    2161                   && (keyboardHIDType           == h.keyboardHIDType)
    2162                   && (chipsetType               == h.chipsetType)
    2163                   && (paravirtProvider          == h.paravirtProvider)
    2164                   && (strParavirtDebug          == h.strParavirtDebug)
    2165                   && (fEmulatedUSBCardReader    == h.fEmulatedUSBCardReader)
    2166                   && (vrdeSettings              == h.vrdeSettings)
    2167                   && (biosSettings              == h.biosSettings)
    2168                   && (usbSettings               == h.usbSettings)
    2169                   && (llNetworkAdapters         == h.llNetworkAdapters)
    2170                   && (llSerialPorts             == h.llSerialPorts)
    2171                   && (llParallelPorts           == h.llParallelPorts)
    2172                   && (audioAdapter              == h.audioAdapter)
    2173                   && (llSharedFolders           == h.llSharedFolders)
    2174                   && (clipboardMode             == h.clipboardMode)
    2175                   && (dndMode                   == h.dndMode)
    2176                   && (ulMemoryBalloonSize       == h.ulMemoryBalloonSize)
    2177                   && (fPageFusionEnabled        == h.fPageFusionEnabled)
    2178                   && (llGuestProperties         == h.llGuestProperties)
    2179                   && (ioSettings                == h.ioSettings)
    2180                   && (pciAttachments            == h.pciAttachments)
    2181                   && (strDefaultFrontend        == h.strDefaultFrontend)
    2182                 )
    2183             );
     2828    return (this == &h)
     2829        || (   strVersion                == h.strVersion
     2830            && uuid                      == h.uuid
     2831            && fHardwareVirt             == h.fHardwareVirt
     2832            && fNestedPaging             == h.fNestedPaging
     2833            && fLargePages               == h.fLargePages
     2834            && fVPID                     == h.fVPID
     2835            && fUnrestrictedExecution    == h.fUnrestrictedExecution
     2836            && fHardwareVirtForce        == h.fHardwareVirtForce
     2837            && fPAE                      == h.fPAE
     2838            && enmLongMode               == h.enmLongMode
     2839            && fTripleFaultReset         == h.fTripleFaultReset
     2840            && cCPUs                     == h.cCPUs
     2841            && fCpuHotPlug               == h.fCpuHotPlug
     2842            && ulCpuExecutionCap         == h.ulCpuExecutionCap
     2843            && uCpuIdPortabilityLevel    == h.uCpuIdPortabilityLevel
     2844            && strCpuProfile             == h.strCpuProfile
     2845            && fHPETEnabled              == h.fHPETEnabled
     2846            && llCpus                    == h.llCpus
     2847            && llCpuIdLeafs              == h.llCpuIdLeafs
     2848            && ulMemorySizeMB            == h.ulMemorySizeMB
     2849            && mapBootOrder              == h.mapBootOrder
     2850            && graphicsControllerType    == h.graphicsControllerType
     2851            && ulVRAMSizeMB              == h.ulVRAMSizeMB
     2852            && cMonitors                 == h.cMonitors
     2853            && fAccelerate3D             == h.fAccelerate3D
     2854            && fAccelerate2DVideo        == h.fAccelerate2DVideo
     2855            && fVideoCaptureEnabled      == h.fVideoCaptureEnabled
     2856            && u64VideoCaptureScreens    == h.u64VideoCaptureScreens
     2857            && strVideoCaptureFile       == h.strVideoCaptureFile
     2858            && ulVideoCaptureHorzRes     == h.ulVideoCaptureHorzRes
     2859            && ulVideoCaptureVertRes     == h.ulVideoCaptureVertRes
     2860            && ulVideoCaptureRate        == h.ulVideoCaptureRate
     2861            && ulVideoCaptureFPS         == h.ulVideoCaptureFPS
     2862            && ulVideoCaptureMaxTime     == h.ulVideoCaptureMaxTime
     2863            && ulVideoCaptureMaxSize     == h.ulVideoCaptureMaxTime
     2864            && firmwareType              == h.firmwareType
     2865            && pointingHIDType           == h.pointingHIDType
     2866            && keyboardHIDType           == h.keyboardHIDType
     2867            && chipsetType               == h.chipsetType
     2868            && paravirtProvider          == h.paravirtProvider
     2869            && strParavirtDebug          == h.strParavirtDebug
     2870            && fEmulatedUSBCardReader    == h.fEmulatedUSBCardReader
     2871            && vrdeSettings              == h.vrdeSettings
     2872            && biosSettings              == h.biosSettings
     2873            && usbSettings               == h.usbSettings
     2874            && llNetworkAdapters         == h.llNetworkAdapters
     2875            && llSerialPorts             == h.llSerialPorts
     2876            && llParallelPorts           == h.llParallelPorts
     2877            && audioAdapter              == h.audioAdapter
     2878            && storage                   == h.storage
     2879            && llSharedFolders           == h.llSharedFolders
     2880            && clipboardMode             == h.clipboardMode
     2881            && dndMode                   == h.dndMode
     2882            && ulMemoryBalloonSize       == h.ulMemoryBalloonSize
     2883            && fPageFusionEnabled        == h.fPageFusionEnabled
     2884            && llGuestProperties         == h.llGuestProperties
     2885            && ioSettings                == h.ioSettings
     2886            && pciAttachments            == h.pciAttachments
     2887            && strDefaultFrontend        == h.strDefaultFrontend);
     2888}
     2889
     2890/**
     2891 * Constructor. Needs to set sane defaults which stand the test of time.
     2892 */
     2893AttachedDevice::AttachedDevice() :
     2894    deviceType(DeviceType_Null),
     2895    fPassThrough(false),
     2896    fTempEject(false),
     2897    fNonRotational(false),
     2898    fDiscard(false),
     2899    fHotPluggable(false),
     2900    lPort(0),
     2901    lDevice(0)
     2902{
    21842903}
    21852904
     
    21912910bool AttachedDevice::operator==(const AttachedDevice &a) const
    21922911{
    2193     return (    (this == &a)
    2194              || (    (deviceType                == a.deviceType)
    2195                   && (fPassThrough              == a.fPassThrough)
    2196                   && (fTempEject                == a.fTempEject)
    2197                   && (fNonRotational            == a.fNonRotational)
    2198                   && (fDiscard                  == a.fDiscard)
    2199                   && (fHotPluggable             == a.fHotPluggable)
    2200                   && (lPort                     == a.lPort)
    2201                   && (lDevice                   == a.lDevice)
    2202                   && (uuid                      == a.uuid)
    2203                   && (strHostDriveSrc           == a.strHostDriveSrc)
    2204                   && (strBwGroup                == a.strBwGroup)
    2205                 )
    2206            );
     2912    return (this == &a)
     2913        || (   deviceType                == a.deviceType
     2914            && fPassThrough              == a.fPassThrough
     2915            && fTempEject                == a.fTempEject
     2916            && fNonRotational            == a.fNonRotational
     2917            && fDiscard                  == a.fDiscard
     2918            && fHotPluggable             == a.fHotPluggable
     2919            && lPort                     == a.lPort
     2920            && lDevice                   == a.lDevice
     2921            && uuid                      == a.uuid
     2922            && strHostDriveSrc           == a.strHostDriveSrc
     2923            && strBwGroup                == a.strBwGroup);
     2924}
     2925
     2926/**
     2927 * Constructor. Needs to set sane defaults which stand the test of time.
     2928 */
     2929StorageController::StorageController() :
     2930    storageBus(StorageBus_IDE),
     2931    controllerType(StorageControllerType_PIIX3),
     2932    ulPortCount(2),
     2933    ulInstance(0),
     2934    fUseHostIOCache(true),
     2935    fBootable(true)
     2936{
    22072937}
    22082938
     
    22142944bool StorageController::operator==(const StorageController &s) const
    22152945{
    2216     return (    (this == &s)
    2217              || (    (strName                   == s.strName)
    2218                   && (storageBus                == s.storageBus)
    2219                   && (controllerType            == s.controllerType)
    2220                   && (ulPortCount               == s.ulPortCount)
    2221                   && (ulInstance                == s.ulInstance)
    2222                   && (fUseHostIOCache           == s.fUseHostIOCache)
    2223                   && (llAttachedDevices         == s.llAttachedDevices)
    2224                 )
    2225            );
     2946    return (this == &s)
     2947        || (   strName                   == s.strName
     2948            && storageBus                == s.storageBus
     2949            && controllerType            == s.controllerType
     2950            && ulPortCount               == s.ulPortCount
     2951            && ulInstance                == s.ulInstance
     2952            && fUseHostIOCache           == s.fUseHostIOCache
     2953            && llAttachedDevices         == s.llAttachedDevices);
    22262954}
    22272955
     
    22332961bool Storage::operator==(const Storage &s) const
    22342962{
    2235     return (    (this == &s)
    2236              || (llStorageControllers == s.llStorageControllers)            // deep compare
    2237            );
     2963    return (this == &s)
     2964        || (llStorageControllers == s.llStorageControllers);            // deep compare
     2965}
     2966
     2967/**
     2968 * Constructor. Needs to set sane defaults which stand the test of time.
     2969 */
     2970Debugging::Debugging() :
     2971    fTracingEnabled(false),
     2972    fAllowTracingToAccessVM(false),
     2973    strTracingConfig()
     2974{
     2975}
     2976
     2977/**
     2978 * Check if all settings have default values.
     2979 */
     2980bool Debugging::areDefaultSettings() const
     2981{
     2982    return !fTracingEnabled
     2983        && !fAllowTracingToAccessVM
     2984        && strTracingConfig.isEmpty();
    22382985}
    22392986
     
    22432990 * machine settings have really changed and thus need to be written out to disk.
    22442991 */
     2992bool Debugging::operator==(const Debugging &d) const
     2993{
     2994    return (this == &d)
     2995        || (   fTracingEnabled          == d.fTracingEnabled
     2996            && fAllowTracingToAccessVM  == d.fAllowTracingToAccessVM
     2997            && strTracingConfig         == d.strTracingConfig);
     2998}
     2999
     3000/**
     3001 * Constructor. Needs to set sane defaults which stand the test of time.
     3002 */
     3003Autostart::Autostart() :
     3004    fAutostartEnabled(false),
     3005    uAutostartDelay(0),
     3006    enmAutostopType(AutostopType_Disabled)
     3007{
     3008}
     3009
     3010/**
     3011 * Check if all settings have default values.
     3012 */
     3013bool Autostart::areDefaultSettings() const
     3014{
     3015    return !fAutostartEnabled
     3016        && !uAutostartDelay
     3017        && enmAutostopType == AutostopType_Disabled;
     3018}
     3019
     3020/**
     3021 * Comparison operator. This gets called from MachineConfigFile::operator==,
     3022 * which in turn gets called from Machine::saveSettings to figure out whether
     3023 * machine settings have really changed and thus need to be written out to disk.
     3024 */
     3025bool Autostart::operator==(const Autostart &a) const
     3026{
     3027    return (this == &a)
     3028        || (   fAutostartEnabled == a.fAutostartEnabled
     3029            && uAutostartDelay   == a.uAutostartDelay
     3030            && enmAutostopType   == a.enmAutostopType);
     3031}
     3032
     3033/**
     3034 * Constructor. Needs to set sane defaults which stand the test of time.
     3035 */
     3036Snapshot::Snapshot()
     3037{
     3038    RTTimeSpecSetNano(&timestamp, 0);
     3039}
     3040
     3041/**
     3042 * Comparison operator. This gets called from MachineConfigFile::operator==,
     3043 * which in turn gets called from Machine::saveSettings to figure out whether
     3044 * machine settings have really changed and thus need to be written out to disk.
     3045 */
    22453046bool Snapshot::operator==(const Snapshot &s) const
    22463047{
    2247     return (    (this == &s)
    2248              || (    (uuid                  == s.uuid)
    2249                   && (strName               == s.strName)
    2250                   && (strDescription        == s.strDescription)
    2251                   && (RTTimeSpecIsEqual(&timestamp, &s.timestamp))
    2252                   && (strStateFile          == s.strStateFile)
    2253                   && (hardware              == s.hardware)                  // deep compare
    2254                   && (storage               == s.storage)                   // deep compare
    2255                   && (llChildSnapshots      == s.llChildSnapshots)          // deep compare
    2256                   && debugging              == s.debugging
    2257                   && autostart              == s.autostart
    2258                 )
    2259            );
    2260 }
    2261 
    2262 /**
    2263  * IOSettings constructor.
    2264  */
    2265 IOSettings::IOSettings()
    2266 {
    2267     fIOCacheEnabled  = true;
    2268     ulIOCacheSize    = 5;
    2269 }
     3048    return (this == &s)
     3049        || (   uuid                  == s.uuid
     3050            && strName               == s.strName
     3051            && strDescription        == s.strDescription
     3052            && RTTimeSpecIsEqual(&timestamp, &s.timestamp)
     3053            && strStateFile          == s.strStateFile
     3054            && hardware              == s.hardware                  // deep compare
     3055            && llChildSnapshots      == s.llChildSnapshots          // deep compare
     3056            && debugging             == s.debugging
     3057            && autostart             == s.autostart);
     3058}
     3059
     3060const struct Snapshot settings::Snapshot::Empty; /* default ctor is OK */
     3061
     3062/**
     3063 * Constructor. Needs to set sane defaults which stand the test of time.
     3064 */
     3065MachineUserData::MachineUserData() :
     3066    fDirectoryIncludesUUID(false),
     3067    fNameSync(true),
     3068    fTeleporterEnabled(false),
     3069    uTeleporterPort(0),
     3070    enmFaultToleranceState(FaultToleranceState_Inactive),
     3071    uFaultTolerancePort(0),
     3072    uFaultToleranceInterval(0),
     3073    fRTCUseUTC(false),
     3074    strVMPriority("")
     3075{
     3076    llGroups.push_back("/");
     3077}
     3078
     3079/**
     3080 * Comparison operator. This gets called from MachineConfigFile::operator==,
     3081 * which in turn gets called from Machine::saveSettings to figure out whether
     3082 * machine settings have really changed and thus need to be written out to disk.
     3083 */
     3084bool MachineUserData::operator==(const MachineUserData &c) const
     3085{
     3086    return (this == &c)
     3087        || (   strName                    == c.strName
     3088            && fDirectoryIncludesUUID     == c.fDirectoryIncludesUUID
     3089            && fNameSync                  == c.fNameSync
     3090            && strDescription             == c.strDescription
     3091            && llGroups                   == c.llGroups
     3092            && strOsType                  == c.strOsType
     3093            && strSnapshotFolder          == c.strSnapshotFolder
     3094            && fTeleporterEnabled         == c.fTeleporterEnabled
     3095            && uTeleporterPort            == c.uTeleporterPort
     3096            && strTeleporterAddress       == c.strTeleporterAddress
     3097            && strTeleporterPassword      == c.strTeleporterPassword
     3098            && enmFaultToleranceState     == c.enmFaultToleranceState
     3099            && uFaultTolerancePort        == c.uFaultTolerancePort
     3100            && uFaultToleranceInterval    == c.uFaultToleranceInterval
     3101            && strFaultToleranceAddress   == c.strFaultToleranceAddress
     3102            && strFaultTolerancePassword  == c.strFaultTolerancePassword
     3103            && fRTCUseUTC                 == c.fRTCUseUTC
     3104            && ovIcon                     == c.ovIcon
     3105            && strVMPriority              == c.strVMPriority);
     3106}
     3107
    22703108
    22713109////////////////////////////////////////////////////////////////////////////////
     
    23553193bool MachineConfigFile::operator==(const MachineConfigFile &c) const
    23563194{
    2357     return (    (this == &c)
    2358             || (    (uuid                       == c.uuid)
    2359                  && (machineUserData            == c.machineUserData)
    2360                  && (strStateFile               == c.strStateFile)
    2361                  && (uuidCurrentSnapshot        == c.uuidCurrentSnapshot)
    2362                  // skip fCurrentStateModified!
    2363                  && (RTTimeSpecIsEqual(&timeLastStateChange, &c.timeLastStateChange))
    2364                  && (fAborted                   == c.fAborted)
    2365                  && (hardwareMachine            == c.hardwareMachine)       // this one's deep
    2366                  && (storageMachine             == c.storageMachine)        // this one's deep
    2367                  && (mediaRegistry              == c.mediaRegistry)         // this one's deep
    2368                  // skip mapExtraDataItems! there is no old state available as it's always forced
    2369                  && (llFirstSnapshot            == c.llFirstSnapshot)       // this one's deep
    2370                )
    2371            );
     3195    return (this == &c)
     3196        || (   uuid                       == c.uuid
     3197            && machineUserData            == c.machineUserData
     3198            && strStateFile               == c.strStateFile
     3199            && uuidCurrentSnapshot        == c.uuidCurrentSnapshot
     3200            // skip fCurrentStateModified!
     3201            && RTTimeSpecIsEqual(&timeLastStateChange, &c.timeLastStateChange)
     3202            && fAborted                   == c.fAborted
     3203            && hardwareMachine            == c.hardwareMachine      // this one's deep
     3204            && mediaRegistry              == c.mediaRegistry        // this one's deep
     3205            // skip mapExtraDataItems! there is no old state available as it's always forced
     3206            && llFirstSnapshot            == c.llFirstSnapshot);    // this one's deep
    23723207}
    23733208
     
    27133548                                         AudioAdapter &aa)
    27143549{
    2715 
    27163550    if (m->sv >= SettingsVersion_v1_15)
    27173551    {
     
    27313565    }
    27323566
     3567    // Special default handling: tag presence hints it should be enabled
     3568    aa.fEnabled = true;
    27333569    elmAudioAdapter.getAttributeValue("enabled", aa.fEnabled);
    27343570
     
    28583694 */
    28593695void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware,
    2860                                      Hardware &hw,
    2861                                      Storage &strg)
    2862 {
     3696                                     Hardware &hw)
     3697{
     3698    if (m->sv >= SettingsVersion_v1_15)
     3699        hw.paravirtProvider = ParavirtProvider_Default;
    28633700    if (!elmHardware.getAttributeValue("version", hw.strVersion))
    28643701    {
     
    30603897            }
    30613898
    3062             Utf8Str strDebug;
    3063             if (pelmHwChild->getAttributeValue("debug", strDebug))
    3064                 hw.strParavirtDebug = strDebug;
     3899            pelmHwChild->getAttributeValue("debug", hw.strParavirtDebug);
    30653900        }
    30663901        else if (pelmHwChild->nameEquals("HPET"))
     
    32824117                }
    32834118                sctl.ulPortCount = 2;
    3284                 strg.llStorageControllers.push_back(sctl);
     4119                hw.storage.llStorageControllers.push_back(sctl);
    32854120            }
    32864121        }
     
    33644199                readStorageControllerAttributes(*pelmHwChild, sctl);
    33654200
    3366                 strg.llStorageControllers.push_back(sctl);
     4201                hw.storage.llStorageControllers.push_back(sctl);
    33674202            }
    33684203        }
     
    35264361            }
    35274362        }
     4363        else if (pelmHwChild->nameEquals("StorageControllers"))
     4364            readStorageControllers(*pelmHwChild, hw.storage);
    35284365    }
    35294366
     
    39964833    if (!(pelmHardware = elmSnapshot.findChildElement("Hardware")))
    39974834        throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@Hardware element is missing"));
    3998     readHardware(*pelmHardware, snap.hardware, snap.storage);
     4835    readHardware(*pelmHardware, snap.hardware);
    39994836
    40004837    xml::NodesLoop nlSnapshotChildren(elmSnapshot);
     
    40064843        else if (   m->sv < SettingsVersion_v1_7
    40074844                 && pelmSnapshotChild->nameEquals("HardDiskAttachments"))
    4008             readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.storage);
     4845            readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.hardware.storage);
    40094846        else if (   m->sv >= SettingsVersion_v1_7
    40104847                 && pelmSnapshotChild->nameEquals("StorageControllers"))
    4011             readStorageControllers(*pelmSnapshotChild, snap.storage);
     4848            readStorageControllers(*pelmSnapshotChild, snap.hardware.storage);
    40124849        else if (pelmSnapshotChild->nameEquals("Snapshots"))
    40134850        {
     
    40214858                    // end of the list. XPCOM has very small stack, avoid
    40224859                    // big local variables and use the list element.
    4023                     snap.llChildSnapshots.push_back(g_SnapshotEmpty);
     4860                    snap.llChildSnapshots.push_back(Snapshot::Empty);
    40244861                    bool found = readSnapshot(curSnapshotUuid, depth + 1, *pelmChildSnapshot, snap.llChildSnapshots.back());
    40254862                    foundCurrentSnapshot = foundCurrentSnapshot || found;
     
    40324869        // go through Hardware once more to repair the settings controller structures
    40334870        // with data from old DVDDrive and FloppyDrive elements
    4034         readDVDAndFloppies_pre1_9(*pelmHardware, snap.storage);
     4871        readDVDAndFloppies_pre1_9(*pelmHardware, snap.hardware.storage);
    40354872
    40364873    readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging);
     
    41364973        elmMachine.getAttributeValue("processPriority", machineUserData.strVMPriority);
    41374974
    4138         elmMachine.getAttributeValue("icon", machineUserData.ovIcon);
     4975        elmMachine.getAttributeValue("icon", str);
     4976        parseBase64(machineUserData.ovIcon, str);
    41394977
    41404978        // parse Hardware before the other elements because other things depend on it
     
    41424980        if (!(pelmHardware = elmMachine.findChildElement("Hardware")))
    41434981            throw ConfigFileError(this, &elmMachine, N_("Required Machine/Hardware element is missing"));
    4144         readHardware(*pelmHardware, hardwareMachine, storageMachine);
     4982        readHardware(*pelmHardware, hardwareMachine);
    41454983
    41464984        xml::NodesLoop nlRootChildren(elmMachine);
     
    41544992                      && (pelmMachineChild->nameEquals("HardDiskAttachments"))
    41554993                    )
    4156                 readHardDiskAttachments_pre1_7(*pelmMachineChild, storageMachine);
     4994                readHardDiskAttachments_pre1_7(*pelmMachineChild, hardwareMachine.storage);
    41574995            else if (    (m->sv >= SettingsVersion_v1_7)
    41584996                      && (pelmMachineChild->nameEquals("StorageControllers"))
    41594997                    )
    4160                 readStorageControllers(*pelmMachineChild, storageMachine);
     4998                readStorageControllers(*pelmMachineChild, hardwareMachine.storage);
    41614999            else if (pelmMachineChild->nameEquals("Snapshot"))
    41625000            {
     
    42065044            // go through Hardware once more to repair the settings controller structures
    42075045            // with data from old DVDDrive and FloppyDrive elements
    4208             readDVDAndFloppies_pre1_9(*pelmHardware, storageMachine);
     5046            readDVDAndFloppies_pre1_9(*pelmHardware, hardwareMachine.storage);
    42095047    }
    42105048    else
     
    42165054 * keys under that. Called for both the \<Machine\> node and for snapshots.
    42175055 * @param elmParent
    4218  * @param st
     5056 * @param hw
     5057 * @param fl
     5058 * @param pllElementsWithUuidAttributes
    42195059 */
    42205060void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent,
    42215061                                         const Hardware &hw,
    4222                                          const Storage &strg)
     5062                                         uint32_t fl,
     5063                                         std::list<xml::ElementNode*> *pllElementsWithUuidAttributes)
    42235064{
    42245065    xml::ElementNode *pelmHardware = elmParent.createChild("Hardware");
    42255066
    4226     if (m->sv >= SettingsVersion_v1_4)
     5067    if (   m->sv >= SettingsVersion_v1_4
     5068        && (m->sv < SettingsVersion_v1_7 ? hw.strVersion != "1" : hw.strVersion != "2"))
    42275069        pelmHardware->setAttribute("version", hw.strVersion);
    42285070
     
    42355077    xml::ElementNode *pelmCPU      = pelmHardware->createChild("CPU");
    42365078
    4237     xml::ElementNode *pelmHwVirtEx = pelmCPU->createChild("HardwareVirtEx");
    4238     pelmHwVirtEx->setAttribute("enabled", hw.fHardwareVirt);
    4239 
    4240     pelmCPU->createChild("HardwareVirtExNestedPaging")->setAttribute("enabled", hw.fNestedPaging);
    4241     pelmCPU->createChild("HardwareVirtExVPID")->setAttribute("enabled", hw.fVPID);
    4242     pelmCPU->createChild("HardwareVirtExUX")->setAttribute("enabled", hw.fUnrestrictedExecution);
     5079    if (!hw.fHardwareVirt)
     5080        pelmCPU->createChild("HardwareVirtEx")->setAttribute("enabled", hw.fHardwareVirt);
     5081    if (!hw.fNestedPaging)
     5082        pelmCPU->createChild("HardwareVirtExNestedPaging")->setAttribute("enabled", hw.fNestedPaging);
     5083    if (!hw.fVPID)
     5084        pelmCPU->createChild("HardwareVirtExVPID")->setAttribute("enabled", hw.fVPID);
     5085    if (!hw.fUnrestrictedExecution)
     5086        pelmCPU->createChild("HardwareVirtExUX")->setAttribute("enabled", hw.fUnrestrictedExecution);
     5087    // PAE has too crazy default handling, must always save this setting.
    42435088    pelmCPU->createChild("PAE")->setAttribute("enabled", hw.fPAE);
    42445089    if (m->sv >= SettingsVersion_v1_14 && hw.enmLongMode != Hardware::LongMode_Legacy)
     5090    {
     5091        // LongMode has too crazy default handling, must always save this setting.
    42455092        pelmCPU->createChild("LongMode")->setAttribute("enabled", hw.enmLongMode == Hardware::LongMode_Enabled);
     5093    }
    42465094
    42475095    if (hw.fTripleFaultReset)
    42485096        pelmCPU->createChild("TripleFaultReset")->setAttribute("enabled", hw.fTripleFaultReset);
    4249     pelmCPU->setAttribute("count", hw.cCPUs);
     5097    if (hw.cCPUs > 1)
     5098        pelmCPU->setAttribute("count", hw.cCPUs);
    42505099    if (hw.ulCpuExecutionCap != 100)
    42515100        pelmCPU->setAttribute("executionCap", hw.ulCpuExecutionCap);
     
    42555104        pelmCPU->setAttribute("CpuProfile", hw.strCpuProfile);
    42565105
    4257     /* Always save this setting as we have changed the default in 4.0 (on for large memory 64-bit systems). */
     5106    // HardwareVirtExLargePages has too crazy default handling, must always save this setting.
    42585107    pelmCPU->createChild("HardwareVirtExLargePages")->setAttribute("enabled", hw.fLargePages);
    42595108
    42605109    if (m->sv >= SettingsVersion_v1_9)
    4261         pelmCPU->createChild("HardwareVirtForce")->setAttribute("enabled", hw.fHardwareVirtForce);
     5110    {
     5111        if (hw.fHardwareVirtForce)
     5112            pelmCPU->createChild("HardwareVirtForce")->setAttribute("enabled", hw.fHardwareVirtForce);
     5113    }
    42625114
    42635115    if (m->sv >= SettingsVersion_v1_10)
    42645116    {
    4265         pelmCPU->setAttribute("hotplug", hw.fCpuHotPlug);
     5117        if (hw.fCpuHotPlug)
     5118            pelmCPU->setAttribute("hotplug", hw.fCpuHotPlug);
    42665119
    42675120        xml::ElementNode *pelmCpuTree = NULL;
     
    43025155    if (m->sv >= SettingsVersion_v1_10)
    43035156    {
    4304         pelmMemory->setAttribute("PageFusion", hw.fPageFusionEnabled);
     5157        if (hw.fPageFusionEnabled)
     5158            pelmMemory->setAttribute("PageFusion", hw.fPageFusionEnabled);
    43055159    }
    43065160
     
    43095163       )
    43105164    {
    4311          xml::ElementNode *pelmFirmware = pelmHardware->createChild("Firmware");
    4312          const char *pcszFirmware;
    4313 
    4314          switch (hw.firmwareType)
    4315          {
     5165        xml::ElementNode *pelmFirmware = pelmHardware->createChild("Firmware");
     5166        const char *pcszFirmware;
     5167
     5168        switch (hw.firmwareType)
     5169        {
    43165170            case FirmwareType_EFI:      pcszFirmware = "EFI";     break;
    43175171            case FirmwareType_EFI32:    pcszFirmware = "EFI32";   break;
     
    43195173            case FirmwareType_EFIDUAL:  pcszFirmware = "EFIDUAL"; break;
    43205174            default:                    pcszFirmware = "None";    break;
    4321          }
    4322          pelmFirmware->setAttribute("type", pcszFirmware);
     5175        }
     5176        pelmFirmware->setAttribute("type", pcszFirmware);
     5177    }
     5178
     5179    if (   m->sv >= SettingsVersion_v1_10
     5180        && (   hw.pointingHIDType != PointingHIDType_PS2Mouse
     5181            || hw.keyboardHIDType != KeyboardHIDType_PS2Keyboard))
     5182    {
     5183        xml::ElementNode *pelmHID = pelmHardware->createChild("HID");
     5184        const char *pcszHID;
     5185
     5186        if (hw.pointingHIDType != PointingHIDType_PS2Mouse)
     5187        {
     5188            switch (hw.pointingHIDType)
     5189            {
     5190                case PointingHIDType_USBMouse:      pcszHID = "USBMouse";     break;
     5191                case PointingHIDType_USBTablet:     pcszHID = "USBTablet";    break;
     5192                case PointingHIDType_PS2Mouse:      pcszHID = "PS2Mouse";     break;
     5193                case PointingHIDType_ComboMouse:    pcszHID = "ComboMouse";   break;
     5194                case PointingHIDType_USBMultiTouch: pcszHID = "USBMultiTouch";break;
     5195                case PointingHIDType_None:          pcszHID = "None";         break;
     5196                default:            Assert(false);  pcszHID = "PS2Mouse";     break;
     5197            }
     5198            pelmHID->setAttribute("Pointing", pcszHID);
     5199        }
     5200
     5201        if (hw.keyboardHIDType != KeyboardHIDType_PS2Keyboard)
     5202        {
     5203            switch (hw.keyboardHIDType)
     5204            {
     5205                case KeyboardHIDType_USBKeyboard:   pcszHID = "USBKeyboard";   break;
     5206                case KeyboardHIDType_PS2Keyboard:   pcszHID = "PS2Keyboard";   break;
     5207                case KeyboardHIDType_ComboKeyboard: pcszHID = "ComboKeyboard"; break;
     5208                case KeyboardHIDType_None:          pcszHID = "None";          break;
     5209                default:            Assert(false);  pcszHID = "PS2Keyboard";   break;
     5210            }
     5211            pelmHID->setAttribute("Keyboard", pcszHID);
     5212        }
    43235213    }
    43245214
    43255215    if (    (m->sv >= SettingsVersion_v1_10)
     5216        &&  hw.fHPETEnabled
    43265217       )
    43275218    {
    4328          xml::ElementNode *pelmHID = pelmHardware->createChild("HID");
    4329          const char *pcszHID;
    4330 
    4331          switch (hw.pointingHIDType)
    4332          {
    4333             case PointingHIDType_USBMouse:      pcszHID = "USBMouse";     break;
    4334             case PointingHIDType_USBTablet:     pcszHID = "USBTablet";    break;
    4335             case PointingHIDType_PS2Mouse:      pcszHID = "PS2Mouse";     break;
    4336             case PointingHIDType_ComboMouse:    pcszHID = "ComboMouse";   break;
    4337             case PointingHIDType_USBMultiTouch: pcszHID = "USBMultiTouch";break;
    4338             case PointingHIDType_None:          pcszHID = "None";         break;
    4339             default:            Assert(false);  pcszHID = "PS2Mouse";     break;
    4340          }
    4341          pelmHID->setAttribute("Pointing", pcszHID);
    4342 
    4343          switch (hw.keyboardHIDType)
    4344          {
    4345             case KeyboardHIDType_USBKeyboard:   pcszHID = "USBKeyboard";   break;
    4346             case KeyboardHIDType_PS2Keyboard:   pcszHID = "PS2Keyboard";   break;
    4347             case KeyboardHIDType_ComboKeyboard: pcszHID = "ComboKeyboard"; break;
    4348             case KeyboardHIDType_None:          pcszHID = "None";          break;
    4349             default:            Assert(false);  pcszHID = "PS2Keyboard";   break;
    4350          }
    4351          pelmHID->setAttribute("Keyboard", pcszHID);
    4352     }
    4353 
    4354     if (    (m->sv >= SettingsVersion_v1_10)
    4355        )
    4356     {
    4357          xml::ElementNode *pelmHPET = pelmHardware->createChild("HPET");
    4358          pelmHPET->setAttribute("enabled", hw.fHPETEnabled);
     5219        xml::ElementNode *pelmHPET = pelmHardware->createChild("HPET");
     5220        pelmHPET->setAttribute("enabled", hw.fHPETEnabled);
    43595221    }
    43605222
     
    43625224       )
    43635225    {
    4364          xml::ElementNode *pelmChipset = pelmHardware->createChild("Chipset");
    4365          const char *pcszChipset;
    4366 
    4367          switch (hw.chipsetType)
    4368          {
    4369             case ChipsetType_PIIX3:             pcszChipset = "PIIX3";   break;
    4370             case ChipsetType_ICH9:              pcszChipset = "ICH9";    break;
    4371             default:            Assert(false);  pcszChipset = "PIIX3";   break;
    4372          }
    4373          pelmChipset->setAttribute("type", pcszChipset);
     5226        if (hw.chipsetType != ChipsetType_PIIX3)
     5227        {
     5228            xml::ElementNode *pelmChipset = pelmHardware->createChild("Chipset");
     5229            const char *pcszChipset;
     5230
     5231            switch (hw.chipsetType)
     5232            {
     5233                case ChipsetType_PIIX3:             pcszChipset = "PIIX3";   break;
     5234                case ChipsetType_ICH9:              pcszChipset = "ICH9";    break;
     5235                default:            Assert(false);  pcszChipset = "PIIX3";   break;
     5236            }
     5237            pelmChipset->setAttribute("type", pcszChipset);
     5238        }
    43745239    }
    43755240
     
    43985263    }
    43995264
    4400     xml::ElementNode *pelmBoot = pelmHardware->createChild("Boot");
    4401     for (BootOrderMap::const_iterator it = hw.mapBootOrder.begin();
    4402          it != hw.mapBootOrder.end();
    4403          ++it)
    4404     {
    4405         uint32_t i = it->first;
    4406         DeviceType_T type = it->second;
    4407         const char *pcszDevice;
    4408 
    4409         switch (type)
    4410         {
    4411             case DeviceType_Floppy:     pcszDevice = "Floppy"; break;
    4412             case DeviceType_DVD:        pcszDevice = "DVD"; break;
    4413             case DeviceType_HardDisk:   pcszDevice = "HardDisk"; break;
    4414             case DeviceType_Network:    pcszDevice = "Network"; break;
    4415             default: /*case DeviceType_Null:*/      pcszDevice = "None"; break;
    4416         }
    4417 
    4418         xml::ElementNode *pelmOrder = pelmBoot->createChild("Order");
    4419         pelmOrder->setAttribute("position",
    4420                                 i + 1);   // XML is 1-based but internal data is 0-based
    4421         pelmOrder->setAttribute("device", pcszDevice);
    4422     }
    4423 
    4424     xml::ElementNode *pelmDisplay = pelmHardware->createChild("Display");
    4425     if (hw.graphicsControllerType != GraphicsControllerType_VBoxVGA)
    4426     {
    4427         const char *pcszGraphics;
    4428         switch (hw.graphicsControllerType)
    4429         {
    4430             case GraphicsControllerType_VBoxVGA:            pcszGraphics = "VBoxVGA"; break;
    4431             case GraphicsControllerType_VMSVGA:             pcszGraphics = "VMSVGA"; break;
    4432             default: /*case GraphicsControllerType_Null:*/  pcszGraphics = "None"; break;
    4433         }
    4434         pelmDisplay->setAttribute("controller", pcszGraphics);
    4435     }
    4436     pelmDisplay->setAttribute("VRAMSize", hw.ulVRAMSizeMB);
    4437     pelmDisplay->setAttribute("monitorCount", hw.cMonitors);
    4438     pelmDisplay->setAttribute("accelerate3D", hw.fAccelerate3D);
    4439 
    4440     if (m->sv >= SettingsVersion_v1_8)
    4441         pelmDisplay->setAttribute("accelerate2DVideo", hw.fAccelerate2DVideo);
    4442     xml::ElementNode *pelmVideoCapture = pelmHardware->createChild("VideoCapture");
    4443 
    4444     if (m->sv >= SettingsVersion_v1_14)
    4445     {
    4446         pelmVideoCapture->setAttribute("enabled",   hw.fVideoCaptureEnabled);
    4447         pelmVideoCapture->setAttribute("screens",   hw.u64VideoCaptureScreens);
     5265    if (!hw.areBootOrderDefaultSettings())
     5266    {
     5267        xml::ElementNode *pelmBoot = pelmHardware->createChild("Boot");
     5268        for (BootOrderMap::const_iterator it = hw.mapBootOrder.begin();
     5269             it != hw.mapBootOrder.end();
     5270             ++it)
     5271        {
     5272            uint32_t i = it->first;
     5273            DeviceType_T type = it->second;
     5274            const char *pcszDevice;
     5275
     5276            switch (type)
     5277            {
     5278                case DeviceType_Floppy:     pcszDevice = "Floppy"; break;
     5279                case DeviceType_DVD:        pcszDevice = "DVD"; break;
     5280                case DeviceType_HardDisk:   pcszDevice = "HardDisk"; break;
     5281                case DeviceType_Network:    pcszDevice = "Network"; break;
     5282                default: /*case DeviceType_Null:*/      pcszDevice = "None"; break;
     5283            }
     5284
     5285            xml::ElementNode *pelmOrder = pelmBoot->createChild("Order");
     5286            pelmOrder->setAttribute("position",
     5287                                    i + 1);   // XML is 1-based but internal data is 0-based
     5288            pelmOrder->setAttribute("device", pcszDevice);
     5289        }
     5290    }
     5291
     5292    if (!hw.areDisplayDefaultSettings())
     5293    {
     5294        xml::ElementNode *pelmDisplay = pelmHardware->createChild("Display");
     5295        if (hw.graphicsControllerType != GraphicsControllerType_VBoxVGA)
     5296        {
     5297            const char *pcszGraphics;
     5298            switch (hw.graphicsControllerType)
     5299            {
     5300                case GraphicsControllerType_VBoxVGA:            pcszGraphics = "VBoxVGA"; break;
     5301                case GraphicsControllerType_VMSVGA:             pcszGraphics = "VMSVGA"; break;
     5302                default: /*case GraphicsControllerType_Null:*/  pcszGraphics = "None"; break;
     5303            }
     5304            pelmDisplay->setAttribute("controller", pcszGraphics);
     5305        }
     5306        if (hw.ulVRAMSizeMB != 8)
     5307            pelmDisplay->setAttribute("VRAMSize", hw.ulVRAMSizeMB);
     5308        if (hw.cMonitors > 1)
     5309            pelmDisplay->setAttribute("monitorCount", hw.cMonitors);
     5310        if (hw.fAccelerate3D)
     5311            pelmDisplay->setAttribute("accelerate3D", hw.fAccelerate3D);
     5312
     5313        if (m->sv >= SettingsVersion_v1_8)
     5314        {
     5315            if (hw.fAccelerate2DVideo)
     5316                pelmDisplay->setAttribute("accelerate2DVideo", hw.fAccelerate2DVideo);
     5317        }
     5318    }
     5319
     5320    if (m->sv >= SettingsVersion_v1_14 && !hw.areVideoCaptureDefaultSettings())
     5321    {
     5322        xml::ElementNode *pelmVideoCapture = pelmHardware->createChild("VideoCapture");
     5323        if (hw.fVideoCaptureEnabled)
     5324            pelmVideoCapture->setAttribute("enabled",   hw.fVideoCaptureEnabled);
     5325        if (hw.u64VideoCaptureScreens != UINT64_C(0xffffffffffffffff))
     5326            pelmVideoCapture->setAttribute("screens",   hw.u64VideoCaptureScreens);
    44485327        if (!hw.strVideoCaptureFile.isEmpty())
    44495328            pelmVideoCapture->setAttributePath("file",  hw.strVideoCaptureFile);
    4450         pelmVideoCapture->setAttribute("horzRes",   hw.ulVideoCaptureHorzRes);
    4451         pelmVideoCapture->setAttribute("vertRes",   hw.ulVideoCaptureVertRes);
    4452         pelmVideoCapture->setAttribute("rate",      hw.ulVideoCaptureRate);
    4453         pelmVideoCapture->setAttribute("fps",       hw.ulVideoCaptureFPS);
    4454         pelmVideoCapture->setAttribute("maxTime",   hw.ulVideoCaptureMaxTime);
    4455         pelmVideoCapture->setAttribute("maxSize",   hw.ulVideoCaptureMaxSize);
    4456     }
    4457 
    4458     xml::ElementNode *pelmVRDE = pelmHardware->createChild("RemoteDisplay");
    4459     pelmVRDE->setAttribute("enabled", hw.vrdeSettings.fEnabled);
    4460     if (m->sv < SettingsVersion_v1_11)
    4461     {
    4462         /* In VBox 4.0 these attributes are replaced with "Properties". */
    4463         Utf8Str strPort;
    4464         StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.find("TCP/Ports");
    4465         if (it != hw.vrdeSettings.mapProperties.end())
    4466             strPort = it->second;
    4467         if (!strPort.length())
    4468             strPort = "3389";
    4469         pelmVRDE->setAttribute("port", strPort);
    4470 
    4471         Utf8Str strAddress;
    4472         it = hw.vrdeSettings.mapProperties.find("TCP/Address");
    4473         if (it != hw.vrdeSettings.mapProperties.end())
    4474             strAddress = it->second;
    4475         if (strAddress.length())
    4476             pelmVRDE->setAttribute("netAddress", strAddress);
    4477     }
    4478     const char *pcszAuthType;
    4479     switch (hw.vrdeSettings.authType)
    4480     {
    4481         case AuthType_Guest:    pcszAuthType = "Guest";    break;
    4482         case AuthType_External: pcszAuthType = "External"; break;
    4483         default: /*case AuthType_Null:*/ pcszAuthType = "Null"; break;
    4484     }
    4485     pelmVRDE->setAttribute("authType", pcszAuthType);
    4486 
    4487     if (hw.vrdeSettings.ulAuthTimeout != 0)
    4488         pelmVRDE->setAttribute("authTimeout", hw.vrdeSettings.ulAuthTimeout);
    4489     if (hw.vrdeSettings.fAllowMultiConnection)
    4490         pelmVRDE->setAttribute("allowMultiConnection", hw.vrdeSettings.fAllowMultiConnection);
    4491     if (hw.vrdeSettings.fReuseSingleConnection)
    4492         pelmVRDE->setAttribute("reuseSingleConnection", hw.vrdeSettings.fReuseSingleConnection);
    4493 
    4494     if (m->sv == SettingsVersion_v1_10)
    4495     {
    4496         xml::ElementNode *pelmVideoChannel = pelmVRDE->createChild("VideoChannel");
    4497 
    4498         /* In 4.0 videochannel settings were replaced with properties, so look at properties. */
    4499         Utf8Str str;
    4500         StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.find("VideoChannel/Enabled");
    4501         if (it != hw.vrdeSettings.mapProperties.end())
    4502             str = it->second;
    4503         bool fVideoChannel =    RTStrICmp(str.c_str(), "true") == 0
    4504                              || RTStrCmp(str.c_str(), "1") == 0;
    4505         pelmVideoChannel->setAttribute("enabled", fVideoChannel);
    4506 
    4507         it = hw.vrdeSettings.mapProperties.find("VideoChannel/Quality");
    4508         if (it != hw.vrdeSettings.mapProperties.end())
    4509             str = it->second;
    4510         uint32_t ulVideoChannelQuality = RTStrToUInt32(str.c_str()); /* This returns 0 on invalid string which is ok. */
    4511         if (ulVideoChannelQuality == 0)
    4512             ulVideoChannelQuality = 75;
    4513         else
    4514             ulVideoChannelQuality = RT_CLAMP(ulVideoChannelQuality, 10, 100);
    4515         pelmVideoChannel->setAttribute("quality", ulVideoChannelQuality);
    4516     }
    4517     if (m->sv >= SettingsVersion_v1_11)
    4518     {
    4519         if (hw.vrdeSettings.strAuthLibrary.length())
    4520             pelmVRDE->setAttribute("authLibrary", hw.vrdeSettings.strAuthLibrary);
    4521         if (hw.vrdeSettings.strVrdeExtPack.isNotEmpty())
    4522             pelmVRDE->setAttribute("VRDEExtPack", hw.vrdeSettings.strVrdeExtPack);
    4523         if (hw.vrdeSettings.mapProperties.size() > 0)
    4524         {
    4525             xml::ElementNode *pelmProperties = pelmVRDE->createChild("VRDEProperties");
    4526             for (StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.begin();
    4527                  it != hw.vrdeSettings.mapProperties.end();
    4528                  ++it)
    4529             {
    4530                 const Utf8Str &strName = it->first;
    4531                 const Utf8Str &strValue = it->second;
    4532                 xml::ElementNode *pelm = pelmProperties->createChild("Property");
    4533                 pelm->setAttribute("name", strName);
    4534                 pelm->setAttribute("value", strValue);
    4535             }
    4536         }
    4537     }
    4538 
    4539     xml::ElementNode *pelmBIOS = pelmHardware->createChild("BIOS");
    4540     pelmBIOS->createChild("ACPI")->setAttribute("enabled", hw.biosSettings.fACPIEnabled);
    4541     pelmBIOS->createChild("IOAPIC")->setAttribute("enabled", hw.biosSettings.fIOAPICEnabled);
    4542 
    4543     xml::ElementNode *pelmLogo = pelmBIOS->createChild("Logo");
    4544     pelmLogo->setAttribute("fadeIn", hw.biosSettings.fLogoFadeIn);
    4545     pelmLogo->setAttribute("fadeOut", hw.biosSettings.fLogoFadeOut);
    4546     pelmLogo->setAttribute("displayTime", hw.biosSettings.ulLogoDisplayTime);
    4547     if (hw.biosSettings.strLogoImagePath.length())
    4548         pelmLogo->setAttribute("imagePath", hw.biosSettings.strLogoImagePath);
    4549 
    4550     const char *pcszBootMenu;
    4551     switch (hw.biosSettings.biosBootMenuMode)
    4552     {
    4553         case BIOSBootMenuMode_Disabled: pcszBootMenu = "Disabled"; break;
    4554         case BIOSBootMenuMode_MenuOnly: pcszBootMenu = "MenuOnly"; break;
    4555         default: /*BIOSBootMenuMode_MessageAndMenu*/ pcszBootMenu = "MessageAndMenu"; break;
    4556     }
    4557     pelmBIOS->createChild("BootMenu")->setAttribute("mode", pcszBootMenu);
    4558     pelmBIOS->createChild("TimeOffset")->setAttribute("value", hw.biosSettings.llTimeOffset);
    4559     pelmBIOS->createChild("PXEDebug")->setAttribute("enabled", hw.biosSettings.fPXEDebugEnabled);
     5329        if (hw.ulVideoCaptureHorzRes != 1024 || hw.ulVideoCaptureVertRes != 768)
     5330        {
     5331            pelmVideoCapture->setAttribute("horzRes",   hw.ulVideoCaptureHorzRes);
     5332            pelmVideoCapture->setAttribute("vertRes",   hw.ulVideoCaptureVertRes);
     5333        }
     5334        if (hw.ulVideoCaptureRate != 512)
     5335            pelmVideoCapture->setAttribute("rate",      hw.ulVideoCaptureRate);
     5336        if (hw.ulVideoCaptureFPS)
     5337            pelmVideoCapture->setAttribute("fps",       hw.ulVideoCaptureFPS);
     5338        if (hw.ulVideoCaptureMaxTime)
     5339            pelmVideoCapture->setAttribute("maxTime",   hw.ulVideoCaptureMaxTime);
     5340        if (hw.ulVideoCaptureMaxSize)
     5341            pelmVideoCapture->setAttribute("maxSize",   hw.ulVideoCaptureMaxSize);
     5342    }
     5343
     5344    if (!hw.vrdeSettings.areDefaultSettings())
     5345    {
     5346        xml::ElementNode *pelmVRDE = pelmHardware->createChild("RemoteDisplay");
     5347        if (hw.vrdeSettings.fEnabled)
     5348            pelmVRDE->setAttribute("enabled", hw.vrdeSettings.fEnabled);
     5349        if (m->sv < SettingsVersion_v1_11)
     5350        {
     5351            /* In VBox 4.0 these attributes are replaced with "Properties". */
     5352            Utf8Str strPort;
     5353            StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.find("TCP/Ports");
     5354            if (it != hw.vrdeSettings.mapProperties.end())
     5355                strPort = it->second;
     5356            if (!strPort.length())
     5357                strPort = "3389";
     5358            pelmVRDE->setAttribute("port", strPort);
     5359
     5360            Utf8Str strAddress;
     5361            it = hw.vrdeSettings.mapProperties.find("TCP/Address");
     5362            if (it != hw.vrdeSettings.mapProperties.end())
     5363                strAddress = it->second;
     5364            if (strAddress.length())
     5365                pelmVRDE->setAttribute("netAddress", strAddress);
     5366        }
     5367        if (hw.vrdeSettings.authType != AuthType_Null)
     5368        {
     5369            const char *pcszAuthType;
     5370            switch (hw.vrdeSettings.authType)
     5371            {
     5372                case AuthType_Guest:    pcszAuthType = "Guest";    break;
     5373                case AuthType_External: pcszAuthType = "External"; break;
     5374                default: /*case AuthType_Null:*/ pcszAuthType = "Null"; break;
     5375            }
     5376            pelmVRDE->setAttribute("authType", pcszAuthType);
     5377        }
     5378
     5379        if (hw.vrdeSettings.ulAuthTimeout != 0 && hw.vrdeSettings.ulAuthTimeout != 5000)
     5380            pelmVRDE->setAttribute("authTimeout", hw.vrdeSettings.ulAuthTimeout);
     5381        if (hw.vrdeSettings.fAllowMultiConnection)
     5382            pelmVRDE->setAttribute("allowMultiConnection", hw.vrdeSettings.fAllowMultiConnection);
     5383        if (hw.vrdeSettings.fReuseSingleConnection)
     5384            pelmVRDE->setAttribute("reuseSingleConnection", hw.vrdeSettings.fReuseSingleConnection);
     5385
     5386        if (m->sv == SettingsVersion_v1_10)
     5387        {
     5388            xml::ElementNode *pelmVideoChannel = pelmVRDE->createChild("VideoChannel");
     5389
     5390            /* In 4.0 videochannel settings were replaced with properties, so look at properties. */
     5391            Utf8Str str;
     5392            StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.find("VideoChannel/Enabled");
     5393            if (it != hw.vrdeSettings.mapProperties.end())
     5394                str = it->second;
     5395            bool fVideoChannel =    RTStrICmp(str.c_str(), "true") == 0
     5396                                 || RTStrCmp(str.c_str(), "1") == 0;
     5397            pelmVideoChannel->setAttribute("enabled", fVideoChannel);
     5398
     5399            it = hw.vrdeSettings.mapProperties.find("VideoChannel/Quality");
     5400            if (it != hw.vrdeSettings.mapProperties.end())
     5401                str = it->second;
     5402            uint32_t ulVideoChannelQuality = RTStrToUInt32(str.c_str()); /* This returns 0 on invalid string which is ok. */
     5403            if (ulVideoChannelQuality == 0)
     5404                ulVideoChannelQuality = 75;
     5405            else
     5406                ulVideoChannelQuality = RT_CLAMP(ulVideoChannelQuality, 10, 100);
     5407            pelmVideoChannel->setAttribute("quality", ulVideoChannelQuality);
     5408        }
     5409        if (m->sv >= SettingsVersion_v1_11)
     5410        {
     5411            if (hw.vrdeSettings.strAuthLibrary.length())
     5412                pelmVRDE->setAttribute("authLibrary", hw.vrdeSettings.strAuthLibrary);
     5413            if (hw.vrdeSettings.strVrdeExtPack.isNotEmpty())
     5414                pelmVRDE->setAttribute("VRDEExtPack", hw.vrdeSettings.strVrdeExtPack);
     5415            if (hw.vrdeSettings.mapProperties.size() > 0)
     5416            {
     5417                xml::ElementNode *pelmProperties = pelmVRDE->createChild("VRDEProperties");
     5418                for (StringsMap::const_iterator it = hw.vrdeSettings.mapProperties.begin();
     5419                     it != hw.vrdeSettings.mapProperties.end();
     5420                     ++it)
     5421                {
     5422                    const Utf8Str &strName = it->first;
     5423                    const Utf8Str &strValue = it->second;
     5424                    xml::ElementNode *pelm = pelmProperties->createChild("Property");
     5425                    pelm->setAttribute("name", strName);
     5426                    pelm->setAttribute("value", strValue);
     5427                }
     5428            }
     5429        }
     5430    }
     5431
     5432    if (!hw.biosSettings.areDefaultSettings())
     5433    {
     5434        xml::ElementNode *pelmBIOS = pelmHardware->createChild("BIOS");
     5435        if (!hw.biosSettings.fACPIEnabled)
     5436            pelmBIOS->createChild("ACPI")->setAttribute("enabled", hw.biosSettings.fACPIEnabled);
     5437        if (hw.biosSettings.fIOAPICEnabled)
     5438            pelmBIOS->createChild("IOAPIC")->setAttribute("enabled", hw.biosSettings.fIOAPICEnabled);
     5439
     5440        if (   !hw.biosSettings.fLogoFadeIn
     5441            || !hw.biosSettings.fLogoFadeOut
     5442            || hw.biosSettings.ulLogoDisplayTime
     5443            || !hw.biosSettings.strLogoImagePath.isEmpty())
     5444        {
     5445            xml::ElementNode *pelmLogo = pelmBIOS->createChild("Logo");
     5446            pelmLogo->setAttribute("fadeIn", hw.biosSettings.fLogoFadeIn);
     5447            pelmLogo->setAttribute("fadeOut", hw.biosSettings.fLogoFadeOut);
     5448            pelmLogo->setAttribute("displayTime", hw.biosSettings.ulLogoDisplayTime);
     5449            if (!hw.biosSettings.strLogoImagePath.isEmpty())
     5450                pelmLogo->setAttribute("imagePath", hw.biosSettings.strLogoImagePath);
     5451        }
     5452
     5453        if (hw.biosSettings.biosBootMenuMode != BIOSBootMenuMode_MessageAndMenu)
     5454        {
     5455            const char *pcszBootMenu;
     5456            switch (hw.biosSettings.biosBootMenuMode)
     5457            {
     5458                case BIOSBootMenuMode_Disabled: pcszBootMenu = "Disabled"; break;
     5459                case BIOSBootMenuMode_MenuOnly: pcszBootMenu = "MenuOnly"; break;
     5460                default: /*BIOSBootMenuMode_MessageAndMenu*/ pcszBootMenu = "MessageAndMenu"; break;
     5461            }
     5462            pelmBIOS->createChild("BootMenu")->setAttribute("mode", pcszBootMenu);
     5463        }
     5464        if (hw.biosSettings.llTimeOffset)
     5465            pelmBIOS->createChild("TimeOffset")->setAttribute("value", hw.biosSettings.llTimeOffset);
     5466        if (hw.biosSettings.fPXEDebugEnabled)
     5467            pelmBIOS->createChild("PXEDebug")->setAttribute("enabled", hw.biosSettings.fPXEDebugEnabled);
     5468    }
    45605469
    45615470    if (m->sv < SettingsVersion_v1_9)
     
    45695478        xml::ElementNode *pelmFloppy = pelmHardware->createChild("FloppyDrive");
    45705479
    4571         for (StorageControllersList::const_iterator it = strg.llStorageControllers.begin();
    4572              it != strg.llStorageControllers.end();
     5480        for (StorageControllersList::const_iterator it = hw.storage.llStorageControllers.begin();
     5481             it != hw.storage.llStorageControllers.end();
    45735482             ++it)
    45745483        {
     
    46585567    else
    46595568    {
    4660         xml::ElementNode *pelmUSB = pelmHardware->createChild("USB");
    4661         xml::ElementNode *pelmCtrls = pelmUSB->createChild("Controllers");
    4662 
    4663         for (USBControllerList::const_iterator it = hardwareMachine.usbSettings.llUSBControllers.begin();
    4664              it != hardwareMachine.usbSettings.llUSBControllers.end();
     5569        if (   hardwareMachine.usbSettings.llUSBControllers.size()
     5570            || hardwareMachine.usbSettings.llDeviceFilters.size())
     5571        {
     5572            xml::ElementNode *pelmUSB = pelmHardware->createChild("USB");
     5573            if (hardwareMachine.usbSettings.llUSBControllers.size())
     5574            {
     5575                xml::ElementNode *pelmCtrls = pelmUSB->createChild("Controllers");
     5576
     5577                for (USBControllerList::const_iterator it = hardwareMachine.usbSettings.llUSBControllers.begin();
     5578                     it != hardwareMachine.usbSettings.llUSBControllers.end();
     5579                     ++it)
     5580                {
     5581                    const USBController &ctrl = *it;
     5582                    com::Utf8Str strType;
     5583                    xml::ElementNode *pelmCtrl = pelmCtrls->createChild("Controller");
     5584
     5585                    switch (ctrl.enmType)
     5586                    {
     5587                        case USBControllerType_OHCI:
     5588                            strType = "OHCI";
     5589                            break;
     5590                        case USBControllerType_EHCI:
     5591                            strType = "EHCI";
     5592                            break;
     5593                        case USBControllerType_XHCI:
     5594                            strType = "XHCI";
     5595                            break;
     5596                        default:
     5597                            AssertMsgFailed(("Unknown USB controller type %d\n", ctrl.enmType));
     5598                    }
     5599
     5600                    pelmCtrl->setAttribute("name", ctrl.strName);
     5601                    pelmCtrl->setAttribute("type", strType);
     5602                }
     5603            }
     5604
     5605            if (hardwareMachine.usbSettings.llDeviceFilters.size())
     5606            {
     5607                xml::ElementNode *pelmFilters = pelmUSB->createChild("DeviceFilters");
     5608                buildUSBDeviceFilters(*pelmFilters, hw.usbSettings.llDeviceFilters, false /* fHostMode */);
     5609            }
     5610        }
     5611    }
     5612
     5613    if (   hw.llNetworkAdapters.size()
     5614        && !hw.areAllNetworkAdaptersDefaultSettings())
     5615    {
     5616        xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network");
     5617        for (NetworkAdaptersList::const_iterator it = hw.llNetworkAdapters.begin();
     5618             it != hw.llNetworkAdapters.end();
    46655619             ++it)
    46665620        {
    4667             const USBController &ctrl = *it;
    4668             com::Utf8Str strType;
    4669             xml::ElementNode *pelmCtrl = pelmCtrls->createChild("Controller");
    4670 
    4671             switch (ctrl.enmType)
    4672             {
    4673                 case USBControllerType_OHCI:
    4674                     strType = "OHCI";
     5621            const NetworkAdapter &nic = *it;
     5622
     5623            if (!nic.areDefaultSettings())
     5624            {
     5625                xml::ElementNode *pelmAdapter = pelmNetwork->createChild("Adapter");
     5626                pelmAdapter->setAttribute("slot", nic.ulSlot);
     5627                if (nic.fEnabled)
     5628                    pelmAdapter->setAttribute("enabled", nic.fEnabled);
     5629                if (!nic.strMACAddress.isEmpty())
     5630                    pelmAdapter->setAttribute("MACAddress", nic.strMACAddress);
     5631                if (!nic.fCableConnected)
     5632                    pelmAdapter->setAttribute("cable", nic.fCableConnected);
     5633                if (nic.ulLineSpeed)
     5634                    pelmAdapter->setAttribute("speed", nic.ulLineSpeed);
     5635                if (nic.ulBootPriority != 0)
     5636                    pelmAdapter->setAttribute("bootPriority", nic.ulBootPriority);
     5637                if (nic.fTraceEnabled)
     5638                {
     5639                    pelmAdapter->setAttribute("trace", nic.fTraceEnabled);
     5640                    pelmAdapter->setAttribute("tracefile", nic.strTraceFile);
     5641                }
     5642                if (nic.strBandwidthGroup.isNotEmpty())
     5643                    pelmAdapter->setAttribute("bandwidthGroup", nic.strBandwidthGroup);
     5644
     5645                const char *pszPolicy;
     5646                switch (nic.enmPromiscModePolicy)
     5647                {
     5648                    case NetworkAdapterPromiscModePolicy_Deny:          pszPolicy = NULL; break;
     5649                    case NetworkAdapterPromiscModePolicy_AllowNetwork:  pszPolicy = "AllowNetwork"; break;
     5650                    case NetworkAdapterPromiscModePolicy_AllowAll:      pszPolicy = "AllowAll"; break;
     5651                    default:                                            pszPolicy = NULL; AssertFailed(); break;
     5652                }
     5653                if (pszPolicy)
     5654                    pelmAdapter->setAttribute("promiscuousModePolicy", pszPolicy);
     5655
     5656                if (nic.type != NetworkAdapterType_Am79C973)
     5657                {
     5658                    const char *pcszType;
     5659                    switch (nic.type)
     5660                    {
     5661                        case NetworkAdapterType_Am79C973:   pcszType = "Am79C973"; break;
     5662                        case NetworkAdapterType_I82540EM:   pcszType = "82540EM"; break;
     5663                        case NetworkAdapterType_I82543GC:   pcszType = "82543GC"; break;
     5664                        case NetworkAdapterType_I82545EM:   pcszType = "82545EM"; break;
     5665                        case NetworkAdapterType_Virtio:     pcszType = "virtio"; break;
     5666                        default: /*case NetworkAdapterType_Am79C970A:*/  pcszType = "Am79C970A"; break;
     5667                    }
     5668                    pelmAdapter->setAttribute("type", pcszType);
     5669                }
     5670
     5671                xml::ElementNode *pelmNAT;
     5672                if (m->sv < SettingsVersion_v1_10)
     5673                {
     5674                    switch (nic.mode)
     5675                    {
     5676                        case NetworkAttachmentType_NAT:
     5677                            pelmNAT = pelmAdapter->createChild("NAT");
     5678                            if (nic.nat.strNetwork.length())
     5679                                pelmNAT->setAttribute("network", nic.nat.strNetwork);
     5680                            break;
     5681
     5682                        case NetworkAttachmentType_Bridged:
     5683                            pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);
     5684                            break;
     5685
     5686                        case NetworkAttachmentType_Internal:
     5687                            pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);
     5688                            break;
     5689
     5690                        case NetworkAttachmentType_HostOnly:
     5691                            pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);
     5692                            break;
     5693
     5694                        default: /*case NetworkAttachmentType_Null:*/
     5695                            break;
     5696                    }
     5697                }
     5698                else
     5699                {
     5700                    /* m->sv >= SettingsVersion_v1_10 */
     5701                    if (!nic.areDisabledDefaultSettings())
     5702                    {
     5703                        xml::ElementNode *pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
     5704                        if (nic.mode != NetworkAttachmentType_NAT)
     5705                            buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, nic);
     5706                        if (nic.mode != NetworkAttachmentType_Bridged)
     5707                            buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, nic);
     5708                        if (nic.mode != NetworkAttachmentType_Internal)
     5709                            buildNetworkXML(NetworkAttachmentType_Internal, *pelmDisabledNode, nic);
     5710                        if (nic.mode != NetworkAttachmentType_HostOnly)
     5711                            buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, nic);
     5712                        if (nic.mode != NetworkAttachmentType_Generic)
     5713                            buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, nic);
     5714                        if (nic.mode != NetworkAttachmentType_NATNetwork)
     5715                            buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, nic);
     5716                    }
     5717                    buildNetworkXML(nic.mode, *pelmAdapter, nic);
     5718                }
     5719            }
     5720        }
     5721    }
     5722
     5723    if (hw.llSerialPorts.size())
     5724    {
     5725        xml::ElementNode *pelmPorts = pelmHardware->createChild("UART");
     5726        for (SerialPortsList::const_iterator it = hw.llSerialPorts.begin();
     5727             it != hw.llSerialPorts.end();
     5728             ++it)
     5729        {
     5730            const SerialPort &port = *it;
     5731            xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
     5732            pelmPort->setAttribute("slot", port.ulSlot);
     5733            pelmPort->setAttribute("enabled", port.fEnabled);
     5734            pelmPort->setAttributeHex("IOBase", port.ulIOBase);
     5735            pelmPort->setAttribute("IRQ", port.ulIRQ);
     5736
     5737            const char *pcszHostMode;
     5738            switch (port.portMode)
     5739            {
     5740                case PortMode_HostPipe: pcszHostMode = "HostPipe"; break;
     5741                case PortMode_HostDevice: pcszHostMode = "HostDevice"; break;
     5742                case PortMode_TCP: pcszHostMode = "TCP"; break;
     5743                case PortMode_RawFile: pcszHostMode = "RawFile"; break;
     5744                default: /*case PortMode_Disconnected:*/ pcszHostMode = "Disconnected"; break;
     5745            }
     5746            switch (port.portMode)
     5747            {
     5748                case PortMode_TCP:
     5749                case PortMode_HostPipe:
     5750                    pelmPort->setAttribute("server", port.fServer);
     5751                    /* no break */
     5752                case PortMode_HostDevice:
     5753                case PortMode_RawFile:
     5754                    pelmPort->setAttribute("path", port.strPath);
    46755755                    break;
    4676                 case USBControllerType_EHCI:
    4677                     strType = "EHCI";
     5756
     5757                default:
    46785758                    break;
    4679                 case USBControllerType_XHCI:
    4680                     strType = "XHCI";
     5759            }
     5760            pelmPort->setAttribute("hostMode", pcszHostMode);
     5761        }
     5762    }
     5763
     5764    if (hw.llParallelPorts.size())
     5765    {
     5766        xml::ElementNode *pelmPorts = pelmHardware->createChild("LPT");
     5767        for (ParallelPortsList::const_iterator it = hw.llParallelPorts.begin();
     5768             it != hw.llParallelPorts.end();
     5769             ++it)
     5770        {
     5771            const ParallelPort &port = *it;
     5772            xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
     5773            pelmPort->setAttribute("slot", port.ulSlot);
     5774            pelmPort->setAttribute("enabled", port.fEnabled);
     5775            pelmPort->setAttributeHex("IOBase", port.ulIOBase);
     5776            pelmPort->setAttribute("IRQ", port.ulIRQ);
     5777            if (port.strPath.length())
     5778                pelmPort->setAttribute("path", port.strPath);
     5779        }
     5780    }
     5781
     5782    if (!hw.audioAdapter.areDefaultSettings())
     5783    {
     5784        xml::ElementNode *pelmAudio = pelmHardware->createChild("AudioAdapter");
     5785        if (hw.audioAdapter.controllerType != AudioControllerType_AC97)
     5786        {
     5787            const char *pcszController;
     5788            switch (hw.audioAdapter.controllerType)
     5789            {
     5790                case AudioControllerType_SB16:
     5791                    pcszController = "SB16";
    46815792                    break;
     5793                case AudioControllerType_HDA:
     5794                    if (m->sv >= SettingsVersion_v1_11)
     5795                    {
     5796                        pcszController = "HDA";
     5797                        break;
     5798                    }
     5799                    /* fall through */
     5800                case AudioControllerType_AC97:
    46825801                default:
    4683                     AssertMsgFailed(("Unknown USB controller type %d\n", ctrl.enmType));
    4684             }
    4685 
    4686             pelmCtrl->setAttribute("name", ctrl.strName);
    4687             pelmCtrl->setAttribute("type", strType);
    4688         }
    4689 
    4690         xml::ElementNode *pelmFilters = pelmUSB->createChild("DeviceFilters");
    4691         buildUSBDeviceFilters(*pelmFilters, hw.usbSettings.llDeviceFilters, false /* fHostMode */);
    4692     }
    4693 
    4694     xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network");
    4695     for (NetworkAdaptersList::const_iterator it = hw.llNetworkAdapters.begin();
    4696          it != hw.llNetworkAdapters.end();
    4697          ++it)
    4698     {
    4699         const NetworkAdapter &nic = *it;
    4700 
    4701         xml::ElementNode *pelmAdapter = pelmNetwork->createChild("Adapter");
    4702         pelmAdapter->setAttribute("slot", nic.ulSlot);
    4703         pelmAdapter->setAttribute("enabled", nic.fEnabled);
    4704         pelmAdapter->setAttribute("MACAddress", nic.strMACAddress);
    4705         pelmAdapter->setAttribute("cable", nic.fCableConnected);
    4706         pelmAdapter->setAttribute("speed", nic.ulLineSpeed);
    4707         if (nic.ulBootPriority != 0)
    4708         {
    4709             pelmAdapter->setAttribute("bootPriority", nic.ulBootPriority);
    4710         }
    4711         if (nic.fTraceEnabled)
    4712         {
    4713             pelmAdapter->setAttribute("trace", nic.fTraceEnabled);
    4714             pelmAdapter->setAttribute("tracefile", nic.strTraceFile);
    4715         }
    4716         if (nic.strBandwidthGroup.isNotEmpty())
    4717             pelmAdapter->setAttribute("bandwidthGroup", nic.strBandwidthGroup);
    4718 
    4719         const char *pszPolicy;
    4720         switch (nic.enmPromiscModePolicy)
    4721         {
    4722             case NetworkAdapterPromiscModePolicy_Deny:          pszPolicy = NULL; break;
    4723             case NetworkAdapterPromiscModePolicy_AllowNetwork:  pszPolicy = "AllowNetwork"; break;
    4724             case NetworkAdapterPromiscModePolicy_AllowAll:      pszPolicy = "AllowAll"; break;
    4725             default:                                            pszPolicy = NULL; AssertFailed(); break;
    4726         }
    4727         if (pszPolicy)
    4728             pelmAdapter->setAttribute("promiscuousModePolicy", pszPolicy);
    4729 
    4730         const char *pcszType;
    4731         switch (nic.type)
    4732         {
    4733             case NetworkAdapterType_Am79C973:   pcszType = "Am79C973"; break;
    4734             case NetworkAdapterType_I82540EM:   pcszType = "82540EM"; break;
    4735             case NetworkAdapterType_I82543GC:   pcszType = "82543GC"; break;
    4736             case NetworkAdapterType_I82545EM:   pcszType = "82545EM"; break;
    4737             case NetworkAdapterType_Virtio:     pcszType = "virtio"; break;
    4738             default: /*case NetworkAdapterType_Am79C970A:*/  pcszType = "Am79C970A"; break;
    4739         }
    4740         pelmAdapter->setAttribute("type", pcszType);
    4741 
    4742         xml::ElementNode *pelmNAT;
    4743         if (m->sv < SettingsVersion_v1_10)
    4744         {
    4745             switch (nic.mode)
    4746             {
    4747                 case NetworkAttachmentType_NAT:
    4748                     pelmNAT = pelmAdapter->createChild("NAT");
    4749                     if (nic.nat.strNetwork.length())
    4750                         pelmNAT->setAttribute("network", nic.nat.strNetwork);
     5802                    pcszController = "AC97";
    47515803                    break;
    4752 
    4753                 case NetworkAttachmentType_Bridged:
    4754                     pelmAdapter->createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);
    4755                     break;
    4756 
    4757                 case NetworkAttachmentType_Internal:
    4758                     pelmAdapter->createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);
    4759                     break;
    4760 
    4761                 case NetworkAttachmentType_HostOnly:
    4762                     pelmAdapter->createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);
    4763                     break;
    4764 
    4765                 default: /*case NetworkAttachmentType_Null:*/
    4766                     break;
    4767             }
    4768         }
    4769         else
    4770         {
    4771             /* m->sv >= SettingsVersion_v1_10 */
    4772             xml::ElementNode *pelmDisabledNode = NULL;
    4773             pelmDisabledNode = pelmAdapter->createChild("DisabledModes");
    4774             if (nic.mode != NetworkAttachmentType_NAT)
    4775                 buildNetworkXML(NetworkAttachmentType_NAT, *pelmDisabledNode, false, nic);
    4776             if (nic.mode != NetworkAttachmentType_Bridged)
    4777                 buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, false, nic);
    4778             if (nic.mode != NetworkAttachmentType_Internal)
    4779                 buildNetworkXML(NetworkAttachmentType_Internal, *pelmDisabledNode, false, nic);
    4780             if (nic.mode != NetworkAttachmentType_HostOnly)
    4781                 buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, false, nic);
    4782             if (nic.mode != NetworkAttachmentType_Generic)
    4783                 buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, false, nic);
    4784             if (nic.mode != NetworkAttachmentType_NATNetwork)
    4785                 buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, false, nic);
    4786             buildNetworkXML(nic.mode, *pelmAdapter, true, nic);
    4787         }
    4788     }
    4789 
    4790     xml::ElementNode *pelmPorts = pelmHardware->createChild("UART");
    4791     for (SerialPortsList::const_iterator it = hw.llSerialPorts.begin();
    4792          it != hw.llSerialPorts.end();
    4793          ++it)
    4794     {
    4795         const SerialPort &port = *it;
    4796         xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
    4797         pelmPort->setAttribute("slot", port.ulSlot);
    4798         pelmPort->setAttribute("enabled", port.fEnabled);
    4799         pelmPort->setAttributeHex("IOBase", port.ulIOBase);
    4800         pelmPort->setAttribute("IRQ", port.ulIRQ);
    4801 
    4802         const char *pcszHostMode;
    4803         switch (port.portMode)
    4804         {
    4805             case PortMode_HostPipe: pcszHostMode = "HostPipe"; break;
    4806             case PortMode_HostDevice: pcszHostMode = "HostDevice"; break;
    4807             case PortMode_TCP: pcszHostMode = "TCP"; break;
    4808             case PortMode_RawFile: pcszHostMode = "RawFile"; break;
    4809             default: /*case PortMode_Disconnected:*/ pcszHostMode = "Disconnected"; break;
    4810         }
    4811         switch (port.portMode)
    4812         {
    4813             case PortMode_TCP:
    4814             case PortMode_HostPipe:
    4815                 pelmPort->setAttribute("server", port.fServer);
    4816                 /* no break */
    4817             case PortMode_HostDevice:
    4818             case PortMode_RawFile:
    4819                 pelmPort->setAttribute("path", port.strPath);
     5804            }
     5805            pelmAudio->setAttribute("controller", pcszController);
     5806        }
     5807
     5808        const char *pcszCodec;
     5809        switch (hw.audioAdapter.codecType)
     5810        {
     5811            /* Only write out the setting for non-default AC'97 codec
     5812             * and leave the rest alone.
     5813             */
     5814    #if 0
     5815            case AudioCodecType_SB16:
     5816                pcszCodec = "SB16";
    48205817                break;
    4821 
     5818            case AudioCodecType_STAC9221:
     5819                pcszCodec = "STAC9221";
     5820                break;
     5821            case AudioCodecType_STAC9700:
     5822                pcszCodec = "STAC9700";
     5823                break;
     5824    #endif
     5825            case AudioCodecType_AD1980:
     5826                pcszCodec = "AD1980";
     5827                break;
    48225828            default:
    4823                 break;
    4824         }
    4825         pelmPort->setAttribute("hostMode", pcszHostMode);
    4826     }
    4827 
    4828     pelmPorts = pelmHardware->createChild("LPT");
    4829     for (ParallelPortsList::const_iterator it = hw.llParallelPorts.begin();
    4830          it != hw.llParallelPorts.end();
    4831          ++it)
    4832     {
    4833         const ParallelPort &port = *it;
    4834         xml::ElementNode *pelmPort = pelmPorts->createChild("Port");
    4835         pelmPort->setAttribute("slot", port.ulSlot);
    4836         pelmPort->setAttribute("enabled", port.fEnabled);
    4837         pelmPort->setAttributeHex("IOBase", port.ulIOBase);
    4838         pelmPort->setAttribute("IRQ", port.ulIRQ);
    4839         if (port.strPath.length())
    4840             pelmPort->setAttribute("path", port.strPath);
    4841     }
    4842 
    4843     xml::ElementNode *pelmAudio = pelmHardware->createChild("AudioAdapter");
    4844     const char *pcszController;
    4845     switch (hw.audioAdapter.controllerType)
    4846     {
    4847         case AudioControllerType_SB16:
    4848             pcszController = "SB16";
    4849             break;
    4850         case AudioControllerType_HDA:
    4851             if (m->sv >= SettingsVersion_v1_11)
    4852             {
    4853                 pcszController = "HDA";
    4854                 break;
    4855             }
    4856             /* fall through */
    4857         case AudioControllerType_AC97:
    4858         default:
    4859             pcszController = "AC97";
    4860             break;
    4861     }
    4862     pelmAudio->setAttribute("controller", pcszController);
    4863 
    4864     const char *pcszCodec;
    4865     switch (hw.audioAdapter.codecType)
    4866     {
    4867         /* Only write out the setting for non-default AC'97 codec
    4868          * and leave the rest alone.
    4869          */
    4870 #if 0
    4871         case AudioCodecType_SB16:
    4872             pcszCodec = "SB16";
    4873             break;
    4874         case AudioCodecType_STAC9221:
    4875             pcszCodec = "STAC9221";
    4876             break;
    4877         case AudioCodecType_STAC9700:
    4878             pcszCodec = "STAC9700";
    4879             break;
    4880 #endif
    4881         case AudioCodecType_AD1980:
    4882             pcszCodec = "AD1980";
    4883             break;
    4884         default:
    4885             /* Don't write out anything if unknown. */
    4886             pcszCodec = NULL;
    4887     }
    4888     if (pcszCodec)
    4889         pelmAudio->setAttribute("codec", pcszCodec);
    4890 
    4891     if (m->sv >= SettingsVersion_v1_10)
     5829                /* Don't write out anything if unknown. */
     5830                pcszCodec = NULL;
     5831        }
     5832        if (pcszCodec)
     5833            pelmAudio->setAttribute("codec", pcszCodec);
     5834
     5835        const char *pcszDriver;
     5836        switch (hw.audioAdapter.driverType)
     5837        {
     5838            case AudioDriverType_WinMM: pcszDriver = "WinMM"; break;
     5839            case AudioDriverType_DirectSound: pcszDriver = "DirectSound"; break;
     5840            case AudioDriverType_SolAudio: pcszDriver = "SolAudio"; break;
     5841            case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
     5842            case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
     5843            case AudioDriverType_OSS: pcszDriver = "OSS"; break;
     5844            case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
     5845            case AudioDriverType_MMPM: pcszDriver = "MMPM"; break;
     5846            default: /*case AudioDriverType_Null:*/ pcszDriver = "Null"; break;
     5847        }
     5848        pelmAudio->setAttribute("driver", pcszDriver);
     5849
     5850        if (hw.audioAdapter.fEnabled)
     5851            pelmAudio->setAttribute("enabled", hw.audioAdapter.fEnabled);
     5852
     5853        if (m->sv >= SettingsVersion_v1_15 && hw.audioAdapter.properties.size() > 0)
     5854        {
     5855            for (StringsMap::const_iterator it = hw.audioAdapter.properties.begin();
     5856                 it != hw.audioAdapter.properties.end();
     5857                 ++it)
     5858            {
     5859                const Utf8Str &strName = it->first;
     5860                const Utf8Str &strValue = it->second;
     5861                xml::ElementNode *pelm = pelmAudio->createChild("Property");
     5862                pelm->setAttribute("name", strName);
     5863                pelm->setAttribute("value", strValue);
     5864            }
     5865        }
     5866    }
     5867
     5868    if (m->sv >= SettingsVersion_v1_10 && machineUserData.fRTCUseUTC)
    48925869    {
    48935870        xml::ElementNode *pelmRTC = pelmHardware->createChild("RTC");
     
    48955872    }
    48965873
    4897     const char *pcszDriver;
    4898     switch (hw.audioAdapter.driverType)
    4899     {
    4900         case AudioDriverType_WinMM: pcszDriver = "WinMM"; break;
    4901         case AudioDriverType_DirectSound: pcszDriver = "DirectSound"; break;
    4902         case AudioDriverType_SolAudio: pcszDriver = "SolAudio"; break;
    4903         case AudioDriverType_ALSA: pcszDriver = "ALSA"; break;
    4904         case AudioDriverType_Pulse: pcszDriver = "Pulse"; break;
    4905         case AudioDriverType_OSS: pcszDriver = "OSS"; break;
    4906         case AudioDriverType_CoreAudio: pcszDriver = "CoreAudio"; break;
    4907         case AudioDriverType_MMPM: pcszDriver = "MMPM"; break;
    4908         default: /*case AudioDriverType_Null:*/ pcszDriver = "Null"; break;
    4909     }
    4910     pelmAudio->setAttribute("driver", pcszDriver);
    4911 
    4912     pelmAudio->setAttribute("enabled", hw.audioAdapter.fEnabled);
    4913 
    4914     if (m->sv >= SettingsVersion_v1_15 && hw.audioAdapter.properties.size() > 0)
    4915     {
    4916         for (StringsMap::const_iterator it = hw.audioAdapter.properties.begin();
    4917              it != hw.audioAdapter.properties.end();
     5874    if (hw.llSharedFolders.size())
     5875    {
     5876        xml::ElementNode *pelmSharedFolders = pelmHardware->createChild("SharedFolders");
     5877        for (SharedFoldersList::const_iterator it = hw.llSharedFolders.begin();
     5878             it != hw.llSharedFolders.end();
    49185879             ++it)
    49195880        {
    4920             const Utf8Str &strName = it->first;
    4921             const Utf8Str &strValue = it->second;
    4922             xml::ElementNode *pelm = pelmAudio->createChild("Property");
    4923             pelm->setAttribute("name", strName);
    4924             pelm->setAttribute("value", strValue);
    4925         }
    4926     }
    4927 
    4928     xml::ElementNode *pelmSharedFolders = pelmHardware->createChild("SharedFolders");
    4929     for (SharedFoldersList::const_iterator it = hw.llSharedFolders.begin();
    4930          it != hw.llSharedFolders.end();
    4931          ++it)
    4932     {
    4933         const SharedFolder &sf = *it;
    4934         xml::ElementNode *pelmThis = pelmSharedFolders->createChild("SharedFolder");
    4935         pelmThis->setAttribute("name", sf.strName);
    4936         pelmThis->setAttribute("hostPath", sf.strHostPath);
    4937         pelmThis->setAttribute("writable", sf.fWritable);
    4938         pelmThis->setAttribute("autoMount", sf.fAutoMount);
    4939     }
    4940 
    4941     xml::ElementNode *pelmClip = pelmHardware->createChild("Clipboard");
    4942     const char *pcszClip;
    4943     switch (hw.clipboardMode)
    4944     {
    4945         default: /*case ClipboardMode_Disabled:*/ pcszClip = "Disabled"; break;
    4946         case ClipboardMode_HostToGuest: pcszClip = "HostToGuest"; break;
    4947         case ClipboardMode_GuestToHost: pcszClip = "GuestToHost"; break;
    4948         case ClipboardMode_Bidirectional: pcszClip = "Bidirectional"; break;
    4949     }
    4950     pelmClip->setAttribute("mode", pcszClip);
    4951 
    4952     xml::ElementNode *pelmDragAndDrop = pelmHardware->createChild("DragAndDrop");
    4953     const char *pcszDragAndDrop;
    4954     switch (hw.dndMode)
    4955     {
    4956         default: /*case DnDMode_Disabled:*/ pcszDragAndDrop = "Disabled"; break;
    4957         case DnDMode_HostToGuest: pcszDragAndDrop = "HostToGuest"; break;
    4958         case DnDMode_GuestToHost: pcszDragAndDrop = "GuestToHost"; break;
    4959         case DnDMode_Bidirectional: pcszDragAndDrop = "Bidirectional"; break;
    4960     }
    4961     pelmDragAndDrop->setAttribute("mode", pcszDragAndDrop);
    4962 
    4963     if (m->sv >= SettingsVersion_v1_10)
     5881            const SharedFolder &sf = *it;
     5882            xml::ElementNode *pelmThis = pelmSharedFolders->createChild("SharedFolder");
     5883            pelmThis->setAttribute("name", sf.strName);
     5884            pelmThis->setAttribute("hostPath", sf.strHostPath);
     5885            pelmThis->setAttribute("writable", sf.fWritable);
     5886            pelmThis->setAttribute("autoMount", sf.fAutoMount);
     5887        }
     5888    }
     5889
     5890    if (hw.clipboardMode != ClipboardMode_Disabled)
     5891    {
     5892        xml::ElementNode *pelmClip = pelmHardware->createChild("Clipboard");
     5893        const char *pcszClip;
     5894        switch (hw.clipboardMode)
     5895        {
     5896            default: /*case ClipboardMode_Disabled:*/ pcszClip = "Disabled"; break;
     5897            case ClipboardMode_HostToGuest: pcszClip = "HostToGuest"; break;
     5898            case ClipboardMode_GuestToHost: pcszClip = "GuestToHost"; break;
     5899            case ClipboardMode_Bidirectional: pcszClip = "Bidirectional"; break;
     5900        }
     5901        pelmClip->setAttribute("mode", pcszClip);
     5902    }
     5903
     5904    if (hw.dndMode != DnDMode_Disabled)
     5905    {
     5906        xml::ElementNode *pelmDragAndDrop = pelmHardware->createChild("DragAndDrop");
     5907        const char *pcszDragAndDrop;
     5908        switch (hw.dndMode)
     5909        {
     5910            default: /*case DnDMode_Disabled:*/ pcszDragAndDrop = "Disabled"; break;
     5911            case DnDMode_HostToGuest: pcszDragAndDrop = "HostToGuest"; break;
     5912            case DnDMode_GuestToHost: pcszDragAndDrop = "GuestToHost"; break;
     5913            case DnDMode_Bidirectional: pcszDragAndDrop = "Bidirectional"; break;
     5914        }
     5915        pelmDragAndDrop->setAttribute("mode", pcszDragAndDrop);
     5916    }
     5917
     5918    if (   m->sv >= SettingsVersion_v1_10
     5919        && !hw.ioSettings.areDefaultSettings())
    49645920    {
    49655921        xml::ElementNode *pelmIO = pelmHardware->createChild("IO");
    49665922        xml::ElementNode *pelmIOCache;
    49675923
    4968         pelmIOCache = pelmIO->createChild("IoCache");
    4969         pelmIOCache->setAttribute("enabled", hw.ioSettings.fIOCacheEnabled);
    4970         pelmIOCache->setAttribute("size", hw.ioSettings.ulIOCacheSize);
    4971 
    4972         if (m->sv >= SettingsVersion_v1_11)
     5924        if (!hw.ioSettings.areDefaultSettings())
     5925        {
     5926            pelmIOCache = pelmIO->createChild("IoCache");
     5927            if (!hw.ioSettings.fIOCacheEnabled)
     5928                pelmIOCache->setAttribute("enabled", hw.ioSettings.fIOCacheEnabled);
     5929            if (hw.ioSettings.ulIOCacheSize != 5)
     5930                pelmIOCache->setAttribute("size", hw.ioSettings.ulIOCacheSize);
     5931        }
     5932
     5933        if (   m->sv >= SettingsVersion_v1_11
     5934            && hw.ioSettings.llBandwidthGroups.size())
    49735935        {
    49745936            xml::ElementNode *pelmBandwidthGroups = pelmIO->createChild("BandwidthGroups");
     
    49955957    }
    49965958
    4997     if (m->sv >= SettingsVersion_v1_12)
     5959    if (   m->sv >= SettingsVersion_v1_12
     5960        && hw.pciAttachments.size())
    49985961    {
    49995962        xml::ElementNode *pelmPCI = pelmHardware->createChild("HostPci");
     
    50145977    }
    50155978
    5016     if (m->sv >= SettingsVersion_v1_12)
     5979    if (   m->sv >= SettingsVersion_v1_12
     5980        && hw.fEmulatedUSBCardReader)
    50175981    {
    50185982        xml::ElementNode *pelmEmulatedUSB = pelmHardware->createChild("EmulatedUSB");
     
    50305994    }
    50315995
    5032     xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest");
    5033     pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize);
    5034 
    5035     xml::ElementNode *pelmGuestProps = pelmHardware->createChild("GuestProperties");
    5036     for (GuestPropertiesList::const_iterator it = hw.llGuestProperties.begin();
    5037          it != hw.llGuestProperties.end();
    5038          ++it)
    5039     {
    5040         const GuestProperty &prop = *it;
    5041         xml::ElementNode *pelmProp = pelmGuestProps->createChild("GuestProperty");
    5042         pelmProp->setAttribute("name", prop.strName);
    5043         pelmProp->setAttribute("value", prop.strValue);
    5044         pelmProp->setAttribute("timestamp", prop.timestamp);
    5045         pelmProp->setAttribute("flags", prop.strFlags);
    5046     }
     5996    if (hw.ulMemoryBalloonSize)
     5997    {
     5998        xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest");
     5999        pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize);
     6000    }
     6001
     6002    if (hw.llGuestProperties.size())
     6003    {
     6004        xml::ElementNode *pelmGuestProps = pelmHardware->createChild("GuestProperties");
     6005        for (GuestPropertiesList::const_iterator it = hw.llGuestProperties.begin();
     6006             it != hw.llGuestProperties.end();
     6007             ++it)
     6008        {
     6009            const GuestProperty &prop = *it;
     6010            xml::ElementNode *pelmProp = pelmGuestProps->createChild("GuestProperty");
     6011            pelmProp->setAttribute("name", prop.strName);
     6012            pelmProp->setAttribute("value", prop.strValue);
     6013            pelmProp->setAttribute("timestamp", prop.timestamp);
     6014            pelmProp->setAttribute("flags", prop.strFlags);
     6015        }
     6016    }
     6017
     6018    /** @todo In the future (6.0?) place the storage controllers under <Hardware>, because
     6019     * this is where it always should've been. What else than hardware are they? */
     6020    xml::ElementNode &elmStorageParent = (m->sv > SettingsVersion_Future) ? *pelmHardware : elmParent;
     6021    buildStorageControllersXML(elmStorageParent,
     6022                               hardwareMachine.storage,
     6023                               !!(fl & BuildMachineXML_SkipRemovableMedia),
     6024                               pllElementsWithUuidAttributes);
    50476025}
    50486026
     
    50566034void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode,
    50576035                                        xml::ElementNode &elmParent,
    5058                                         bool fEnabled,
    50596036                                        const NetworkAdapter &nic)
    50606037{
     
    50626039    {
    50636040        case NetworkAttachmentType_NAT:
    5064             xml::ElementNode *pelmNAT;
    5065             pelmNAT = elmParent.createChild("NAT");
    5066 
    5067             if (nic.nat.strNetwork.length())
    5068                 pelmNAT->setAttribute("network", nic.nat.strNetwork);
    5069             if (nic.nat.strBindIP.length())
    5070                 pelmNAT->setAttribute("hostip", nic.nat.strBindIP);
    5071             if (nic.nat.u32Mtu)
    5072                 pelmNAT->setAttribute("mtu", nic.nat.u32Mtu);
    5073             if (nic.nat.u32SockRcv)
    5074                 pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv);
    5075             if (nic.nat.u32SockSnd)
    5076                 pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd);
    5077             if (nic.nat.u32TcpRcv)
    5078                 pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv);
    5079             if (nic.nat.u32TcpSnd)
    5080                 pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd);
    5081             xml::ElementNode *pelmDNS;
    5082             pelmDNS = pelmNAT->createChild("DNS");
    5083             pelmDNS->setAttribute("pass-domain", nic.nat.fDNSPassDomain);
    5084             pelmDNS->setAttribute("use-proxy", nic.nat.fDNSProxy);
    5085             pelmDNS->setAttribute("use-host-resolver", nic.nat.fDNSUseHostResolver);
    5086 
    5087             xml::ElementNode *pelmAlias;
    5088             pelmAlias = pelmNAT->createChild("Alias");
    5089             pelmAlias->setAttribute("logging", nic.nat.fAliasLog);
    5090             pelmAlias->setAttribute("proxy-only", nic.nat.fAliasProxyOnly);
    5091             pelmAlias->setAttribute("use-same-ports", nic.nat.fAliasUseSamePorts);
    5092 
    5093             if (   nic.nat.strTFTPPrefix.length()
    5094                 || nic.nat.strTFTPBootFile.length()
    5095                 || nic.nat.strTFTPNextServer.length())
    5096             {
    5097                 xml::ElementNode *pelmTFTP;
    5098                 pelmTFTP = pelmNAT->createChild("TFTP");
    5099                 if (nic.nat.strTFTPPrefix.length())
    5100                     pelmTFTP->setAttribute("prefix", nic.nat.strTFTPPrefix);
    5101                 if (nic.nat.strTFTPBootFile.length())
    5102                     pelmTFTP->setAttribute("boot-file", nic.nat.strTFTPBootFile);
    5103                 if (nic.nat.strTFTPNextServer.length())
    5104                     pelmTFTP->setAttribute("next-server", nic.nat.strTFTPNextServer);
    5105             }
    5106             buildNATForwardRulesMap(*pelmNAT, nic.nat.mapRules);
     6041            if (!nic.nat.areDefaultSettings())
     6042            {
     6043                xml::ElementNode *pelmNAT = elmParent.createChild("NAT");
     6044
     6045                if (nic.nat.strNetwork.length())
     6046                    pelmNAT->setAttribute("network", nic.nat.strNetwork);
     6047                if (nic.nat.strBindIP.length())
     6048                    pelmNAT->setAttribute("hostip", nic.nat.strBindIP);
     6049                if (nic.nat.u32Mtu)
     6050                    pelmNAT->setAttribute("mtu", nic.nat.u32Mtu);
     6051                if (nic.nat.u32SockRcv)
     6052                    pelmNAT->setAttribute("sockrcv", nic.nat.u32SockRcv);
     6053                if (nic.nat.u32SockSnd)
     6054                    pelmNAT->setAttribute("socksnd", nic.nat.u32SockSnd);
     6055                if (nic.nat.u32TcpRcv)
     6056                    pelmNAT->setAttribute("tcprcv", nic.nat.u32TcpRcv);
     6057                if (nic.nat.u32TcpSnd)
     6058                    pelmNAT->setAttribute("tcpsnd", nic.nat.u32TcpSnd);
     6059                if (!nic.nat.areDNSDefaultSettings())
     6060                {
     6061                    xml::ElementNode *pelmDNS = pelmNAT->createChild("DNS");
     6062                    if (!nic.nat.fDNSPassDomain)
     6063                        pelmDNS->setAttribute("pass-domain", nic.nat.fDNSPassDomain);
     6064                    if (nic.nat.fDNSProxy)
     6065                        pelmDNS->setAttribute("use-proxy", nic.nat.fDNSProxy);
     6066                    if (nic.nat.fDNSUseHostResolver)
     6067                        pelmDNS->setAttribute("use-host-resolver", nic.nat.fDNSUseHostResolver);
     6068                }
     6069
     6070                if (!nic.nat.areAliasDefaultSettings())
     6071                {
     6072                    xml::ElementNode *pelmAlias = pelmNAT->createChild("Alias");
     6073                    if (nic.nat.fAliasLog)
     6074                        pelmAlias->setAttribute("logging", nic.nat.fAliasLog);
     6075                    if (nic.nat.fAliasProxyOnly)
     6076                        pelmAlias->setAttribute("proxy-only", nic.nat.fAliasProxyOnly);
     6077                    if (nic.nat.fAliasUseSamePorts)
     6078                        pelmAlias->setAttribute("use-same-ports", nic.nat.fAliasUseSamePorts);
     6079                }
     6080
     6081                if (!nic.nat.areTFTPDefaultSettings())
     6082                {
     6083                    xml::ElementNode *pelmTFTP;
     6084                    pelmTFTP = pelmNAT->createChild("TFTP");
     6085                    if (nic.nat.strTFTPPrefix.length())
     6086                        pelmTFTP->setAttribute("prefix", nic.nat.strTFTPPrefix);
     6087                    if (nic.nat.strTFTPBootFile.length())
     6088                        pelmTFTP->setAttribute("boot-file", nic.nat.strTFTPBootFile);
     6089                    if (nic.nat.strTFTPNextServer.length())
     6090                        pelmTFTP->setAttribute("next-server", nic.nat.strTFTPNextServer);
     6091                }
     6092                buildNATForwardRulesMap(*pelmNAT, nic.nat.mapRules);
     6093            }
    51076094            break;
    51086095
    51096096        case NetworkAttachmentType_Bridged:
    5110             if (fEnabled || !nic.strBridgedName.isEmpty())
     6097            if (!nic.strBridgedName.isEmpty())
    51116098                elmParent.createChild("BridgedInterface")->setAttribute("name", nic.strBridgedName);
    51126099            break;
    51136100
    51146101        case NetworkAttachmentType_Internal:
    5115             if (fEnabled || !nic.strInternalNetworkName.isEmpty())
     6102            if (!nic.strInternalNetworkName.isEmpty())
    51166103                elmParent.createChild("InternalNetwork")->setAttribute("name", nic.strInternalNetworkName);
    51176104            break;
    51186105
    51196106        case NetworkAttachmentType_HostOnly:
    5120             if (fEnabled || !nic.strHostOnlyName.isEmpty())
     6107            if (!nic.strHostOnlyName.isEmpty())
    51216108                elmParent.createChild("HostOnlyInterface")->setAttribute("name", nic.strHostOnlyName);
    51226109            break;
    51236110
    51246111        case NetworkAttachmentType_Generic:
    5125             if (fEnabled || !nic.strGenericDriver.isEmpty() || nic.genericProperties.size())
     6112            if (!nic.areGenericDriverDefaultSettings())
    51266113            {
    51276114                xml::ElementNode *pelmMode = elmParent.createChild("GenericInterface");
     
    51396126
    51406127        case NetworkAttachmentType_NATNetwork:
    5141             if (fEnabled || !nic.strNATNetworkName.isEmpty())
     6128            if (!nic.strNATNetworkName.isEmpty())
    51426129                elmParent.createChild("NATNetwork")->setAttribute("name", nic.strNATNetworkName);
    51436130            break;
     
    51676154                                                   std::list<xml::ElementNode*> *pllElementsWithUuidAttributes)
    51686155{
     6156    if (!st.llStorageControllers.size())
     6157        return;
    51696158    xml::ElementNode *pelmStorageControllers = elmParent.createChild("StorageControllers");
    51706159
     
    54076396        pelmSnapshot->createChild("Description")->addContent(snap.strDescription);
    54086397
    5409     buildHardwareXML(*pelmSnapshot, snap.hardware, snap.storage);
    5410     buildStorageControllersXML(*pelmSnapshot,
    5411                                snap.storage,
    5412                                false /* fSkipRemovableMedia */,
    5413                                NULL); /* pllElementsWithUuidAttributes */
    5414                                     // we only skip removable media for OVF, but we never get here for OVF
    5415                                     // since snapshots never get written then
     6398    // We only skip removable media for OVF, but OVF never includes snapshots.
     6399    buildHardwareXML(*pelmSnapshot, snap.hardware, 0 /* fl */, NULL /* pllElementsWithUuidAttributes */);
    54166400    buildDebuggingXML(pelmSnapshot, &snap.debugging);
    54176401    buildAutostartXML(pelmSnapshot, &snap.autostart);
     
    55136497    // Please keep the icon last so that one doesn't have to check if there
    55146498    // is anything in the line after this very long attribute in the XML.
    5515     if (machineUserData.ovIcon.length())
    5516         elmMachine.setAttribute("icon", machineUserData.ovIcon);
     6499    if (machineUserData.ovIcon.size())
     6500    {
     6501        Utf8Str strIcon;
     6502        toBase64(strIcon, machineUserData.ovIcon);
     6503        elmMachine.setAttribute("icon", strIcon);
     6504    }
    55176505    if (    m->sv >= SettingsVersion_v1_9
    55186506        &&  (   machineUserData.fTeleporterEnabled
     
    55696557        buildSnapshotXML(1, elmMachine, llFirstSnapshot.front());
    55706558
    5571     buildHardwareXML(elmMachine, hardwareMachine, storageMachine);
    5572     buildStorageControllersXML(elmMachine,
    5573                                storageMachine,
    5574                                !!(fl & BuildMachineXML_SkipRemovableMedia),
    5575                                pllElementsWithUuidAttributes);
     6559    buildHardwareXML(elmMachine, hardwareMachine, fl, pllElementsWithUuidAttributes);
    55766560    buildDebuggingXML(&elmMachine, &debugging);
    55776561    buildAutostartXML(&elmMachine, &autostart);
     
    57046688        }
    57056689
    5706         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    5707              it != storageMachine.llStorageControllers.end();
     6690        for (StorageControllersList::const_iterator it = hardwareMachine.storage.llStorageControllers.begin();
     6691             it != hardwareMachine.storage.llStorageControllers.end();
    57086692             ++it)
    57096693        {
     
    57416725         * Also check if there are USB storage controllers.
    57426726         */
    5743         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    5744              it != storageMachine.llStorageControllers.end();
     6727        for (StorageControllersList::const_iterator it = hardwareMachine.storage.llStorageControllers.begin();
     6728             it != hardwareMachine.storage.llStorageControllers.end();
    57456729             ++it)
    57466730        {
     
    58086792            || hardwareMachine.graphicsControllerType != GraphicsControllerType_VBoxVGA
    58096793            || hardwareMachine.enmLongMode != Hardware::LongMode_Legacy
    5810             || machineUserData.ovIcon.length() > 0
     6794            || machineUserData.ovIcon.size() > 0
    58116795            || hardwareMachine.fVideoCaptureEnabled)
    58126796        {
     
    59126896            if (   netit->enmPromiscModePolicy != NetworkAdapterPromiscModePolicy_Deny
    59136897                || netit->mode == NetworkAttachmentType_Generic
    5914                 || !netit->strGenericDriver.isEmpty()
    5915                 || netit->genericProperties.size()
     6898                || !netit->areGenericDriverDefaultSettings()
    59166899               )
    59176900            {
     
    60106993
    60116994        // need to run thru all the storage controllers and attached devices to figure this out
    6012         for (StorageControllersList::const_iterator it = storageMachine.llStorageControllers.begin();
    6013              it != storageMachine.llStorageControllers.end();
     6995        for (StorageControllersList::const_iterator it = hardwareMachine.storage.llStorageControllers.begin();
     6996             it != hardwareMachine.storage.llStorageControllers.end();
    60146997             ++it)
    60156998        {
  • trunk/src/VBox/Main/xml/VirtualBox-settings.xsd

    r59927 r61009  
    2020<xsd:schema
    2121  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    22   xmlns="http://www.innotek.de/VirtualBox-settings"
    23   xmlns:vb="http://www.innotek.de/VirtualBox-settings"
    24   targetNamespace="http://www.innotek.de/VirtualBox-settings"
     22  xmlns="http://www.virtualbox.org/"
     23  xmlns:vb="http://www.virtualbox.org/"
     24  targetNamespace="http://www.virtualbox.org/"
    2525  elementFormDefault="qualified"
    2626>
     
    2929  <xsd:documentation xml:lang="en">
    3030    Oracle VM VirtualBox Settings Schema (common definitions).
    31     Copyright (c) 2004-2013 Oracle Corporation
     31    Copyright (c) 2004-2016 Oracle Corporation
    3232  </xsd:documentation>
    3333</xsd:annotation>
     
    251251-->
    252252<xsd:complexType name="TDHCPServer">
     253  <xsd:sequence>
     254    <xsd:element name="Options" minOccurs="0">
     255      <xsd:complexType>
     256        <xsd:sequence>
     257          <xsd:element name="Option" type="TDHCPOption" minOccurs="0" maxOccurs="unbounded"/>
     258        </xsd:sequence>
     259      </xsd:complexType>
     260    </xsd:element>
     261  </xsd:sequence>
    253262  <xsd:attribute name="networkName" type="xsd:string"  use="required"/>
    254263  <xsd:attribute name="lowerIP"     type="xsd:string"  use="required"/>
     
    257266  <xsd:attribute name="networkMask" type="xsd:string"  use="required"/>
    258267  <xsd:attribute name="enabled"     type="xsd:boolean" use="required"/>
     268</xsd:complexType>
     269
     270<xsd:complexType name="TDHCPOption">
     271  <xsd:attribute name="name" type="xsd:string" use="required"/>
     272  <xsd:attribute name="value" type="xsd:string" use="required"/>
     273  <xsd:attribute name="encoding" type="xsd:integer" default="0"/>
     274</xsd:complexType>
     275
     276<xsd:complexType name="TNATNetwork">
     277  <xsd:sequence>
     278    <xsd:element name="PortForwarding4" minOccurs="0">
     279      <xsd:complexType>
     280        <xsd:sequence>
     281          <xsd:element name="Forwarding" type="TNATPortForwarding" minOccurs="0" maxOccurs="unbounded"/>
     282        </xsd:sequence>
     283      </xsd:complexType>
     284    </xsd:element>
     285    <xsd:element name="PortForwarding6" minOccurs="0">
     286      <xsd:complexType>
     287        <xsd:sequence>
     288          <xsd:element name="Forwarding" type="TNATPortForwarding" minOccurs="0" maxOccurs="unbounded"/>
     289        </xsd:sequence>
     290      </xsd:complexType>
     291    </xsd:element>
     292    <xsd:element name="Mappings" minOccurs="0">
     293      <xsd:complexType>
     294        <xsd:sequence>
     295          <xsd:element name="Loopback4" type="TNATLoopback4" minOccurs="0" maxOccurs="unbounded"/>
     296        </xsd:sequence>
     297      </xsd:complexType>
     298    </xsd:element>
     299  </xsd:sequence>
     300  <xsd:attribute name="networkName" type="xsd:string"  use="required"/>
     301  <xsd:attribute name="enabled"     type="xsd:boolean" use="required"/>
     302  <xsd:attribute name="network"     type="xsd:string"  use="required"/>
     303  <xsd:attribute name="ipv6"        type="xsd:boolean" use="required"/>
     304  <xsd:attribute name="ipv6prefix"  type="xsd:string"  use="required"/>
     305  <xsd:attribute name="advertiseDefaultIPv6Route" type="xsd:boolean" use="required"/>
     306  <xsd:attribute name="needDhcp"    type="xsd:boolean" use="required"/>
     307  <xsd:attribute name="loopback6"   type="xsd:integer" default="0"/>
     308</xsd:complexType>
     309
     310<xsd:complexType name="TNATLoopback4">
     311  <xsd:attribute name="address" type="xsd:string" use="required"/>
     312  <xsd:attribute name="offset" type="xsd:integer" use="required"/>
     313</xsd:complexType>
     314
     315<xsd:complexType name="TNATPortForwarding">
     316  <xsd:attribute name="name" type="xsd:string" use="required"/>
     317  <xsd:attribute name="proto" type="xsd:integer" use="required"/>
     318  <xsd:attribute name="hostip" type="xsd:string" default=""/>
     319  <xsd:attribute name="hostport" type="xsd:integer" use="required"/>
     320  <xsd:attribute name="guestip" type="xsd:string" use="required"/>
     321  <xsd:attribute name="guestport" type="xsd:integer" use="required"/>
    259322</xsd:complexType>
    260323
     
    400463      </xsd:complexType>
    401464    </xsd:element>
    402     <xsd:element name="MediaRegistry" type="TMediaRegistry"/>
    403     <xsd:element name="NetserviceRegistry" minOccurs="0" maxOccurs="1">
     465    <xsd:element name="MediaRegistry" type="TMediaRegistry" minOccurs="0"/>
     466    <xsd:element name="NetserviceRegistry" minOccurs="0">
    404467      <xsd:complexType>
    405468        <xsd:all>
     
    408471              <xsd:sequence>
    409472                <xsd:element name="DHCPServer" type="TDHCPServer" minOccurs="0" maxOccurs="unbounded"/>
     473              </xsd:sequence>
     474            </xsd:complexType>
     475          </xsd:element>
     476          <xsd:element name="NATNetworks" minOccurs="0">
     477            <xsd:complexType>
     478              <xsd:sequence>
     479                <xsd:element name="NATNetwork" type="TNATNetwork" minOccurs="0" maxOccurs="unbounded"/>
    410480              </xsd:sequence>
    411481            </xsd:complexType>
     
    527597
    528598<xsd:complexType name="TDisplay">
    529   <xsd:attribute name="VRAMSize" use="required">
     599  <xsd:attribute name="VRAMSize" default="8">
    530600    <xsd:simpleType>
    531601      <xsd:restriction base="xsd:unsignedInt">
    532         <xsd:minInclusive value="1"/>
     602        <xsd:minInclusive value="0"/>
    533603        <xsd:maxInclusive value="256"/>
    534604      </xsd:restriction>
     
    602672<xsd:complexType name="TBIOS">
    603673  <xsd:all>
    604     <xsd:element name="ACPI">
     674    <xsd:element name="ACPI" minOccurs="0">
    605675      <xsd:complexType>
    606676        <xsd:attribute name="enabled" type="xsd:boolean" use="required"/>
     
    795865
    796866<xsd:complexType name="TAudioAdapter">
    797   <xsd:attribute name="enabled" type="xsd:boolean" use="required"/>
     867  <xsd:attribute name="enabled" type="xsd:boolean" default="false"/>
    798868  <xsd:attribute name="controller" default="AC97">
    799869    <xsd:simpleType>
     
    919989  <xsd:complexContent>
    920990    <xsd:extension base="TNetworkConfig">
    921       <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C970A"/>
     991      <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C973"/>
    922992      <xsd:attribute name="slot" type="xsd:unsignedInt" use="required"/>
    923       <xsd:attribute name="enabled" type="xsd:boolean" use="required"/>
     993      <xsd:attribute name="enabled" type="xsd:boolean" default="false"/>
    924994      <xsd:attribute name="MACAddress">
    925995        <xsd:simpleType>
     
    929999        </xsd:simpleType>
    9301000      </xsd:attribute>
    931       <xsd:attribute name="cable" type="xsd:boolean" use="required"/>
     1001      <xsd:attribute name="cable" type="xsd:boolean" default="true"/>
    9321002      <xsd:attribute name="speed" type="xsd:unsignedInt" default="1000000"/>
    9331003      <xsd:attribute name="bootPriority" type="xsd:unsignedInt"/>
     
    12531323    <xsd:element name="Chipset" type="TChipset" minOccurs="0"/>
    12541324    <xsd:element name="Paravirt" type="TParavirt" minOccurs="0"/>
    1255     <xsd:element name="Boot" type="TBoot">
     1325    <xsd:element name="Boot" type="TBoot" minOccurs="0">
    12561326      <xsd:unique name="THardware-Boot-Order">
    12571327        <xsd:selector xpath="vb:Order"/>
     
    12591329      </xsd:unique>
    12601330    </xsd:element>
    1261     <xsd:element name="Display" type="TDisplay"/>
     1331    <xsd:element name="Display" type="TDisplay" minOccurs="0"/>
    12621332    <xsd:element name="VideoRecording" type="TVideoRecording" minOccurs="0"/>
    12631333    <xsd:element name="VideoCapture" type="TVideoCapture" minOccurs="0"/>
    12641334    <xsd:element name="RemoteDisplay" type="TRemoteDisplay" minOccurs="0"/>
    1265     <xsd:element name="BIOS" type="TBIOS"/>
     1335    <xsd:element name="BIOS" type="TBIOS" minOccurs="0"/>
    12661336    <xsd:element name="DVDDrive" type="TDVDDrive" minOccurs="0"/>
    12671337    <xsd:element name="FloppyDrive" type="TFloppyDrive" minOccurs="0"/>
     
    12691339    <xsd:element name="USB" type="TUSB" minOccurs="0"/>
    12701340    <xsd:element name="SATAController" type="TSATAController" minOccurs="0"/> <!-- deprecated -->
    1271     <xsd:element name="Network" type="TNetwork">
     1341    <xsd:element name="Network" type="TNetwork" minOccurs="0">
    12721342      <xsd:unique name="THardware-Network-Adapter">
    12731343        <xsd:selector xpath="vb:Adapter"/>
     
    12991369      </xsd:unique>
    13001370    </xsd:element>
    1301     <xsd:element name="AudioAdapter" type="TAudioAdapter"/>
     1371    <xsd:element name="AudioAdapter" type="TAudioAdapter" minOccurs="0"/>
    13021372    <xsd:element name="RTC" type="TRTC" minOccurs="0"/>
    1303     <xsd:element name="SharedFolders" type="TSharedFolders">
     1373    <xsd:element name="SharedFolders" type="TSharedFolders" minOccurs="0">
    13041374      <xsd:unique name="THardware-SharedFolders-SharedFolder">
    13051375        <xsd:selector xpath="vb:SharedFolder"/>
     
    13071377      </xsd:unique>
    13081378    </xsd:element>
    1309     <xsd:element name="Clipboard" type="TClipboard"/>
     1379    <xsd:element name="Clipboard" type="TClipboard" minOccurs="0"/>
    13101380    <xsd:element name="DragAndDrop" type="TDragAndDrop" minOccurs="0"/>
    13111381    <xsd:element name="IO" type="TIO" minOccurs="0"/>
    13121382    <xsd:element name="HostPci" type="THostPci" minOccurs="0"/>
    13131383    <xsd:element name="EmulatedUSB" type="TEmulatedUSB" minOccurs="0"/>
    1314     <xsd:element name="Guest" type="TGuest"/>
     1384    <xsd:element name="Guest" type="TGuest" minOccurs="0"/>
    13151385    <xsd:element name="GuestProperties" type="TGuestProperties" minOccurs="0">
    13161386      <xsd:unique name="THardware-GuestProperties-GuestProperty">
     
    13191389      </xsd:unique>
    13201390    </xsd:element>
     1391    <xsd:element name="StorageControllers" type="TStorageControllers" minOccurs="0"/>
    13211392  </xsd:all>
    13221393  <xsd:attribute name="version" type="xsd:string" default="2"/>
     
    13631434    <xsd:element name="Description" type="xsd:string" minOccurs="0"/>
    13641435    <xsd:element name="Hardware" type="THardware"/>
    1365     <xsd:element name="StorageControllers" type="TStorageControllers"/>
     1436    <xsd:element name="StorageControllers" type="TStorageControllers" minOccurs="0"/>
    13661437    <xsd:element name="Snapshots" minOccurs="0">
    13671438      <xsd:complexType>
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette