VirtualBox

source: vbox/trunk/include/VBox/settings.h@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 52.0 KB
Line 
1/** @file
2 * Settings file data structures.
3 *
4 * These structures are created by the settings file loader and filled with values
5 * copied from the raw XML data. This was all new with VirtualBox 3.1 and allows us
6 * to finally make the XML reader version-independent and read VirtualBox XML files
7 * from earlier and even newer (future) versions without requiring complicated,
8 * tedious and error-prone XSLT conversions.
9 *
10 * It is this file that defines all structures that map VirtualBox global and
11 * machine settings to XML files. These structures are used by the rest of Main,
12 * even though this header file does not require anything else in Main.
13 *
14 * Note: Headers in Main code have been tweaked to only declare the structures
15 * defined here so that this header need only be included from code files that
16 * actually use these structures.
17 */
18
19/*
20 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
21 *
22 * This file is part of VirtualBox base platform packages, as
23 * available from https://www.virtualbox.org.
24 *
25 * This program is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU General Public License
27 * as published by the Free Software Foundation, in version 3 of the
28 * License.
29 *
30 * This program is distributed in the hope that it will be useful, but
31 * WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * General Public License for more details.
34 *
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, see <https://www.gnu.org/licenses>.
37 *
38 * The contents of this file may alternatively be used under the terms
39 * of the Common Development and Distribution License Version 1.0
40 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
41 * in the VirtualBox distribution, in which case the provisions of the
42 * CDDL are applicable instead of those of the GPL.
43 *
44 * You may elect to license modified versions of this file under the
45 * terms and conditions of either the GPL or the CDDL or both.
46 *
47 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
48 */
49
50#ifndef VBOX_INCLUDED_settings_h
51#define VBOX_INCLUDED_settings_h
52#ifndef RT_WITHOUT_PRAGMA_ONCE
53# pragma once
54#endif
55
56#include <iprt/time.h>
57
58#include "VBox/com/VirtualBox.h"
59
60#include <VBox/com/Guid.h>
61#include <VBox/com/string.h>
62#include <VBox/VBoxCryptoIf.h>
63
64#include <list>
65#include <map>
66#include <vector>
67
68/**
69 * Maximum depth of a medium tree, to prevent stack overflows.
70 * XPCOM has a relatively low stack size for its workers, and we have
71 * to avoid crashes due to exceeding the limit both on reading and
72 * writing config files. The bottleneck is in libxml2.
73 * Data point: a release and asan build could both handle 3800 on Debian 10.
74 */
75#define SETTINGS_MEDIUM_DEPTH_MAX 300
76
77/**
78 * Maximum depth of the snapshot tree, to prevent stack overflows.
79 * XPCOM has a relatively low stack size for its workers, and we have
80 * to avoid crashes due to exceeding the limit both on reading and
81 * writing config files. The bottleneck is reading config files with
82 * deep snapshot nesting, as libxml2 needs quite some stack space.
83 * Data point: a release and asan build could both handle 1300 on Debian 10.
84 */
85#define SETTINGS_SNAPSHOT_DEPTH_MAX 250
86
87namespace xml
88{
89 class ElementNode;
90}
91
92namespace settings
93{
94
95class ConfigFileError;
96
97////////////////////////////////////////////////////////////////////////////////
98//
99// Structures shared between Machine XML and VirtualBox.xml
100//
101////////////////////////////////////////////////////////////////////////////////
102
103typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
104typedef std::list<com::Utf8Str> StringsList;
105
106/**
107 * USB device filter definition. This struct is used both in MainConfigFile
108 * (for global USB filters) and MachineConfigFile (for machine filters).
109 *
110 * NOTE: If you add any fields in here, you must update a) the constructor and b)
111 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
112 * your settings might never get saved.
113 */
114struct USBDeviceFilter
115{
116 USBDeviceFilter();
117
118 bool operator==(const USBDeviceFilter&u) const;
119
120 com::Utf8Str strName;
121 bool fActive;
122 com::Utf8Str strVendorId,
123 strProductId,
124 strRevision,
125 strManufacturer,
126 strProduct,
127 strSerialNumber,
128 strPort;
129 USBDeviceFilterAction_T action; // only used with host USB filters
130 com::Utf8Str strRemote; // irrelevant for host USB objects
131 uint32_t ulMaskedInterfaces; // irrelevant for host USB objects
132};
133
134typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
135
136struct Medium;
137typedef std::list<Medium> MediaList;
138
139/**
140 * NOTE: If you add any fields in here, you must update a) the constructor and b)
141 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
142 * your settings might never get saved.
143 */
144struct Medium
145{
146 Medium();
147
148 bool operator==(const Medium &m) const;
149
150 com::Guid uuid;
151 com::Utf8Str strLocation;
152 com::Utf8Str strDescription;
153
154 // the following are for hard disks only:
155 com::Utf8Str strFormat;
156 bool fAutoReset; // optional, only for diffs, default is false
157 StringsMap properties;
158 MediumType_T hdType;
159
160 MediaList llChildren; // only used with hard disks
161
162 static const struct Medium Empty;
163};
164
165/**
166 * A media registry. Starting with VirtualBox 3.3, this can appear in both the
167 * VirtualBox.xml file as well as machine XML files with settings version 1.11
168 * or higher, so these lists are now in ConfigFileBase.
169 *
170 * NOTE: If you add any fields in here, you must update a) the constructor and b)
171 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
172 * your settings might never get saved.
173 */
174struct MediaRegistry
175{
176 bool operator==(const MediaRegistry &m) const;
177
178 MediaList llHardDisks,
179 llDvdImages,
180 llFloppyImages;
181};
182
183/**
184 * NOTE: If you add any fields in here, you must update a) the constructor and b)
185 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
186 * your settings might never get saved.
187 */
188struct NATRule
189{
190 NATRule();
191
192 bool operator==(const NATRule &r) const;
193
194 com::Utf8Str strName;
195 NATProtocol_T proto;
196 uint16_t u16HostPort;
197 com::Utf8Str strHostIP;
198 uint16_t u16GuestPort;
199 com::Utf8Str strGuestIP;
200};
201typedef std::map<com::Utf8Str, NATRule> NATRulesMap;
202
203struct NATHostLoopbackOffset
204{
205 NATHostLoopbackOffset();
206
207 bool operator==(const NATHostLoopbackOffset &o) const;
208
209 bool operator==(const com::Utf8Str& strAddr)
210 {
211 return strLoopbackHostAddress == strAddr;
212 }
213
214 bool operator==(uint32_t off)
215 {
216 return u32Offset == off;
217 }
218
219 /** Note: 128/8 is only acceptable */
220 com::Utf8Str strLoopbackHostAddress;
221 uint32_t u32Offset;
222};
223
224typedef std::list<NATHostLoopbackOffset> NATLoopbackOffsetList;
225
226typedef std::vector<uint8_t> IconBlob;
227
228/**
229 * Common base class for both MainConfigFile and MachineConfigFile
230 * which contains some common logic for both.
231 */
232class ConfigFileBase
233{
234public:
235 bool fileExists();
236 SettingsVersion_T getSettingsVersion();
237
238 void copyBaseFrom(const ConfigFileBase &b);
239
240protected:
241 ConfigFileBase(const com::Utf8Str *pstrFilename);
242 /* Note: this copy constructor doesn't create a full copy of other, cause
243 * the file based stuff (xml doc) could not be copied. */
244 ConfigFileBase(const ConfigFileBase &other);
245
246 ~ConfigFileBase();
247
248 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
249
250 static const char *stringifyMediaType(MediaType t);
251 SettingsVersion_T parseVersion(const com::Utf8Str &strVersion,
252 const xml::ElementNode *pElm);
253 void parseUUID(com::Guid &guid,
254 const com::Utf8Str &strUUID,
255 const xml::ElementNode *pElm) const;
256 void parseTimestamp(RTTIMESPEC &timestamp,
257 const com::Utf8Str &str,
258 const xml::ElementNode *pElm) const;
259 void parseBase64(IconBlob &binary,
260 const com::Utf8Str &str,
261 const xml::ElementNode *pElm) const;
262 com::Utf8Str stringifyTimestamp(const RTTIMESPEC &tm) const;
263 void toBase64(com::Utf8Str &str,
264 const IconBlob &binary) const;
265
266 void readExtraData(const xml::ElementNode &elmExtraData,
267 StringsMap &map);
268 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
269 USBDeviceFiltersList &ll);
270 void readMediumOne(MediaType t, const xml::ElementNode &elmMedium, Medium &med);
271 void readMedium(MediaType t, const xml::ElementNode &elmMedium, Medium &med);
272 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr);
273 void readNATForwardRulesMap(const xml::ElementNode &elmParent, NATRulesMap &mapRules);
274 void readNATLoopbacks(const xml::ElementNode &elmParent, NATLoopbackOffsetList &llLoopBacks);
275
276 void setVersionAttribute(xml::ElementNode &elm);
277 void specialBackupIfFirstBump();
278 void createStubDocument();
279
280 void buildExtraData(xml::ElementNode &elmParent, const StringsMap &me);
281 void buildUSBDeviceFilters(xml::ElementNode &elmParent,
282 const USBDeviceFiltersList &ll,
283 bool fHostMode);
284 void buildMedium(MediaType t,
285 xml::ElementNode &elmMedium,
286 const Medium &med);
287 void buildMediaRegistry(xml::ElementNode &elmParent,
288 const MediaRegistry &mr);
289 void buildNATForwardRulesMap(xml::ElementNode &elmParent, const NATRulesMap &mapRules);
290 void buildNATLoopbacks(xml::ElementNode &elmParent, const NATLoopbackOffsetList &natLoopbackList);
291 void clearDocument();
292
293 struct Data;
294 Data *m;
295
296 friend class ConfigFileError;
297};
298
299////////////////////////////////////////////////////////////////////////////////
300//
301// VirtualBox.xml structures
302//
303////////////////////////////////////////////////////////////////////////////////
304
305struct USBDeviceSource
306{
307 com::Utf8Str strName;
308 com::Utf8Str strBackend;
309 com::Utf8Str strAddress;
310 StringsMap properties;
311};
312
313typedef std::list<USBDeviceSource> USBDeviceSourcesList;
314
315#ifdef VBOX_WITH_UPDATE_AGENT
316struct UpdateAgent
317{
318 UpdateAgent();
319
320 bool fEnabled;
321 UpdateChannel_T enmChannel;
322 uint32_t uCheckFreqSeconds;
323 com::Utf8Str strRepoUrl;
324 com::Utf8Str strLastCheckDate;
325 uint32_t uCheckCount;
326};
327#endif /* VBOX_WITH_UPDATE_AGENT */
328
329struct Host
330{
331 USBDeviceFiltersList llUSBDeviceFilters;
332 USBDeviceSourcesList llUSBDeviceSources;
333#ifdef VBOX_WITH_UPDATE_AGENT
334 UpdateAgent updateHost;
335 /** @todo Add handling for ExtPack and Guest Additions updates here later. See @bugref{7983}. */
336#endif /* VBOX_WITH_UPDATE_AGENT */
337};
338
339struct SystemProperties
340{
341 SystemProperties();
342
343 com::Utf8Str strDefaultMachineFolder;
344 com::Utf8Str strDefaultHardDiskFolder;
345 com::Utf8Str strDefaultHardDiskFormat;
346 com::Utf8Str strVRDEAuthLibrary;
347 com::Utf8Str strWebServiceAuthLibrary;
348 com::Utf8Str strDefaultVRDEExtPack;
349 com::Utf8Str strDefaultCryptoExtPack;
350 com::Utf8Str strAutostartDatabasePath;
351 com::Utf8Str strDefaultAdditionsISO;
352 com::Utf8Str strDefaultFrontend;
353 com::Utf8Str strLoggingLevel;
354 com::Utf8Str strProxyUrl;
355 uint32_t uProxyMode; /**< ProxyMode_T */
356 uint32_t uLogHistoryCount;
357 bool fExclusiveHwVirt;
358 com::Utf8Str strLanguageId;
359};
360
361struct MachineRegistryEntry
362{
363 com::Guid uuid;
364 com::Utf8Str strSettingsFile;
365};
366
367typedef std::list<MachineRegistryEntry> MachinesRegistry;
368
369struct DhcpOptValue
370{
371 DhcpOptValue();
372 DhcpOptValue(const com::Utf8Str &aText, DHCPOptionEncoding_T aEncoding = DHCPOptionEncoding_Normal);
373
374 com::Utf8Str strValue;
375 DHCPOptionEncoding_T enmEncoding;
376};
377
378typedef std::map<DHCPOption_T, DhcpOptValue> DhcpOptionMap;
379typedef DhcpOptionMap::value_type DhcpOptValuePair;
380typedef DhcpOptionMap::iterator DhcpOptIterator;
381typedef DhcpOptionMap::const_iterator DhcpOptConstIterator;
382
383struct DHCPGroupCondition
384{
385 DHCPGroupCondition();
386
387 bool fInclusive;
388 DHCPGroupConditionType_T enmType;
389 com::Utf8Str strValue;
390};
391typedef std::vector<DHCPGroupCondition> DHCPGroupConditionVec;
392
393
394struct DHCPConfig
395{
396 DHCPConfig();
397
398 DhcpOptionMap mapOptions;
399 uint32_t secMinLeaseTime;
400 uint32_t secDefaultLeaseTime;
401 uint32_t secMaxLeaseTime;
402 com::Utf8Str strForcedOptions;
403 com::Utf8Str strSuppressedOptions;
404};
405
406struct DHCPGroupConfig : DHCPConfig
407{
408 DHCPGroupConfig();
409
410 com::Utf8Str strName;
411 DHCPGroupConditionVec vecConditions;
412};
413typedef std::vector<DHCPGroupConfig> DHCPGroupConfigVec;
414
415struct DHCPIndividualConfig : DHCPConfig
416{
417 DHCPIndividualConfig();
418
419 com::Utf8Str strMACAddress;
420 com::Utf8Str strVMName;
421 uint32_t uSlot;
422 com::Utf8Str strFixedAddress;
423};
424typedef std::map<com::Utf8Str, DHCPIndividualConfig> DHCPIndividualConfigMap;
425
426struct DHCPServer
427{
428 DHCPServer();
429
430 com::Utf8Str strNetworkName;
431 com::Utf8Str strIPAddress;
432 com::Utf8Str strIPLower;
433 com::Utf8Str strIPUpper;
434 bool fEnabled;
435 DHCPConfig globalConfig;
436 DHCPGroupConfigVec vecGroupConfigs;
437 DHCPIndividualConfigMap mapIndividualConfigs;
438};
439typedef std::list<DHCPServer> DHCPServersList;
440
441
442/**
443 * NAT Networking settings (NAT service).
444 */
445struct NATNetwork
446{
447 NATNetwork();
448
449 com::Utf8Str strNetworkName;
450 com::Utf8Str strIPv4NetworkCidr;
451 com::Utf8Str strIPv6Prefix;
452 bool fEnabled;
453 bool fIPv6Enabled;
454 bool fAdvertiseDefaultIPv6Route;
455 bool fNeedDhcpServer;
456 uint32_t u32HostLoopback6Offset;
457 NATLoopbackOffsetList llHostLoopbackOffsetList;
458 NATRulesMap mapPortForwardRules4;
459 NATRulesMap mapPortForwardRules6;
460};
461
462typedef std::list<NATNetwork> NATNetworksList;
463
464#ifdef VBOX_WITH_VMNET
465/**
466 * HostOnly Networking settings.
467 */
468struct HostOnlyNetwork
469{
470 HostOnlyNetwork();
471
472 com::Guid uuid;
473 com::Utf8Str strNetworkName;
474 com::Utf8Str strNetworkMask;
475 com::Utf8Str strIPLower;
476 com::Utf8Str strIPUpper;
477 bool fEnabled;
478};
479
480typedef std::list<HostOnlyNetwork> HostOnlyNetworksList;
481#endif /* VBOX_WITH_VMNET */
482
483#ifdef VBOX_WITH_CLOUD_NET
484/**
485 * Cloud Networking settings.
486 */
487struct CloudNetwork
488{
489 CloudNetwork();
490
491 com::Utf8Str strNetworkName;
492 com::Utf8Str strProviderShortName;
493 com::Utf8Str strProfileName;
494 com::Utf8Str strNetworkId;
495 bool fEnabled;
496};
497
498typedef std::list<CloudNetwork> CloudNetworksList;
499#endif /* VBOX_WITH_CLOUD_NET */
500
501
502class MainConfigFile : public ConfigFileBase
503{
504public:
505 MainConfigFile(const com::Utf8Str *pstrFilename);
506
507 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry);
508 void readNATNetworks(const xml::ElementNode &elmNATNetworks);
509#ifdef VBOX_WITH_VMNET
510 void readHostOnlyNetworks(const xml::ElementNode &elmHostOnlyNetworks);
511#endif /* VBOX_WITH_VMNET */
512#ifdef VBOX_WITH_CLOUD_NET
513 void readCloudNetworks(const xml::ElementNode &elmCloudNetworks);
514#endif /* VBOX_WITH_CLOUD_NET */
515
516 void write(const com::Utf8Str strFilename);
517
518 Host host;
519 SystemProperties systemProperties;
520 MediaRegistry mediaRegistry;
521 MachinesRegistry llMachines;
522 DHCPServersList llDhcpServers;
523 NATNetworksList llNATNetworks;
524#ifdef VBOX_WITH_VMNET
525 HostOnlyNetworksList llHostOnlyNetworks;
526#endif /* VBOX_WITH_VMNET */
527#ifdef VBOX_WITH_CLOUD_NET
528 CloudNetworksList llCloudNetworks;
529#endif /* VBOX_WITH_CLOUD_NET */
530 StringsMap mapExtraDataItems;
531
532private:
533 void bumpSettingsVersionIfNeeded();
534 void buildUSBDeviceSources(xml::ElementNode &elmParent, const USBDeviceSourcesList &ll);
535 void readUSBDeviceSources(const xml::ElementNode &elmDeviceSources, USBDeviceSourcesList &ll);
536 void buildDHCPServers(xml::ElementNode &elmDHCPServers, DHCPServersList const &ll);
537 void buildDHCPOptions(xml::ElementNode &elmOptions, DHCPConfig const &rConfig, bool fIgnoreSubnetMask);
538 void readDHCPServers(const xml::ElementNode &elmDHCPServers);
539 void readDHCPOptions(DHCPConfig &rConfig, const xml::ElementNode &elmOptions, bool fIgnoreSubnetMask);
540 bool convertGuiProxySettings(const com::Utf8Str &strUIProxySettings);
541};
542
543////////////////////////////////////////////////////////////////////////////////
544//
545// Machine XML structures
546//
547////////////////////////////////////////////////////////////////////////////////
548
549/**
550 * NOTE: If you add any fields in here, you must update a) the constructor and b)
551 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
552 * your settings might never get saved.
553 */
554struct VRDESettings
555{
556 VRDESettings();
557
558 bool areDefaultSettings(SettingsVersion_T sv) const;
559
560 bool operator==(const VRDESettings& v) const;
561
562 bool fEnabled;
563 AuthType_T authType;
564 uint32_t ulAuthTimeout;
565 com::Utf8Str strAuthLibrary;
566 bool fAllowMultiConnection,
567 fReuseSingleConnection;
568 com::Utf8Str strVrdeExtPack;
569 StringsMap mapProperties;
570};
571
572/**
573 * NOTE: If you add any fields in here, you must update a) the constructor and b)
574 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
575 * your settings might never get saved.
576 */
577struct BIOSSettings
578{
579 BIOSSettings();
580
581 bool areDefaultSettings() const;
582
583 bool operator==(const BIOSSettings &d) const;
584
585 bool fACPIEnabled,
586 fIOAPICEnabled,
587 fLogoFadeIn,
588 fLogoFadeOut,
589 fPXEDebugEnabled,
590 fSmbiosUuidLittleEndian;
591 uint32_t ulLogoDisplayTime;
592 BIOSBootMenuMode_T biosBootMenuMode;
593 APICMode_T apicMode; // requires settings version 1.16 (VirtualBox 5.1)
594 int64_t llTimeOffset;
595 com::Utf8Str strLogoImagePath;
596};
597
598/**
599 * NOTE: If you add any fields in here, you must update a) the constructor and b)
600 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
601 * your settings might never get saved.
602 */
603struct TpmSettings
604{
605 TpmSettings();
606
607 bool areDefaultSettings() const;
608
609 bool operator==(const TpmSettings &d) const;
610
611 TpmType_T tpmType;
612 com::Utf8Str strLocation;
613};
614
615/**
616 * NOTE: If you add any fields in here, you must update a) the constructor and b)
617 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
618 * your settings might never get saved.
619 */
620struct NvramSettings
621{
622 NvramSettings();
623
624 bool areDefaultSettings() const;
625
626 bool operator==(const NvramSettings &d) const;
627
628 com::Utf8Str strNvramPath;
629 com::Utf8Str strKeyId;
630 com::Utf8Str strKeyStore;
631};
632
633/** List for keeping a recording feature list. */
634typedef std::map<RecordingFeature_T, bool> RecordingFeatureMap;
635
636/**
637 * Recording settings for a single screen (e.g. virtual monitor).
638 *
639 * NOTE: If you add any fields in here, you must update a) the constructor and b)
640 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
641 * your settings might never get saved.
642 */
643struct RecordingScreenSettings
644{
645 RecordingScreenSettings(uint32_t idScreen = UINT32_MAX);
646
647 virtual ~RecordingScreenSettings();
648
649 void applyDefaults(void);
650
651 bool areDefaultSettings(void) const;
652
653 bool isFeatureEnabled(RecordingFeature_T enmFeature) const;
654
655 static const char *getDefaultOptions(void);
656
657 static int featuresFromString(const com::Utf8Str &strFeatures, RecordingFeatureMap &featureMap);
658
659 static void featuresToString(const RecordingFeatureMap &featureMap, com::Utf8Str &strFeatures);
660
661 static int audioCodecFromString(const com::Utf8Str &strCodec, RecordingAudioCodec_T &enmCodec);
662
663 static void audioCodecToString(const RecordingAudioCodec_T &enmCodec, com::Utf8Str &strCodec);
664
665 static int videoCodecFromString(const com::Utf8Str &strCodec, RecordingVideoCodec_T &enmCodec);
666
667 static void videoCodecToString(const RecordingVideoCodec_T &enmCodec, com::Utf8Str &strCodec);
668
669 bool operator==(const RecordingScreenSettings &d) const;
670
671 /** Screen ID.
672 * UINT32_MAX if not set. */
673 uint32_t idScreen;
674 /** Whether to record this screen or not. */
675 bool fEnabled; // requires settings version 1.14 (VirtualBox 4.3)
676 /** Destination to record to. */
677 RecordingDestination_T enmDest;
678 /** Which features are enable or not. */
679 RecordingFeatureMap featureMap; // requires settings version 1.19 (VirtualBox 7.0)
680 /** Maximum time (in s) to record. If set to 0, no time limit is set. */
681 uint32_t ulMaxTimeS; // requires settings version 1.14 (VirtualBox 4.3)
682 /** Options string for hidden / advanced / experimental features.
683 * Use RecordingScreenSettings::getDefaultOptions(). */
684 com::Utf8Str strOptions; // new since VirtualBox 5.2.
685
686 /**
687 * Structure holding settings for audio recording.
688 */
689 struct Audio
690 {
691 /** The audio codec type to use. */
692 RecordingAudioCodec_T enmCodec; // requires settings version 1.19 (VirtualBox 7.0)
693 /** Codec deadline to use. */
694 RecordingCodecDeadline_T enmDeadline; // requires settings version 1.19 (VirtualBox 7.0)
695 /** Rate control mode to use. */
696 RecordingRateControlMode_T
697 enmRateCtlMode;// requires settings version 1.19 (VirtualBox 7.0)
698 /** Hz rate. */
699 uint16_t uHz; // requires settings version 1.19 (VirtualBox 7.0)
700 /** Bits per sample. */
701 uint8_t cBits; // requires settings version 1.19 (VirtualBox 7.0)
702 /** Number of audio channels. */
703 uint8_t cChannels; // requires settings version 1.19 (VirtualBox 7.0)
704 } Audio;
705
706 /**
707 * Structure holding settings for video recording.
708 */
709 struct Video
710 {
711 /** The codec to use. */
712 RecordingVideoCodec_T enmCodec; // requires settings version 1.19 (VirtualBox 7.0)
713 /** Codec deadline to use. */
714 RecordingCodecDeadline_T enmDeadline; // requires settings version 1.19 (VirtualBox 7.0)
715 /** Rate control mode to use. */
716 RecordingRateControlMode_T
717 enmRateCtlMode; // requires settings version 1.19 (VirtualBox 7.0)
718 /** Rate control mode to use. */
719 RecordingVideoScalingMode_T
720 enmScalingMode; // requires settings version 1.19 (VirtualBox 7.0)
721 /** Target frame width in pixels (X). */
722 uint32_t ulWidth; // requires settings version 1.14 (VirtualBox 4.3)
723 /** Target frame height in pixels (Y). */
724 uint32_t ulHeight; // requires settings version 1.14 (VirtualBox 4.3)
725 /** Encoding rate. */
726 uint32_t ulRate; // requires settings version 1.14 (VirtualBox 4.3)
727 /** Frames per second (FPS). */
728 uint32_t ulFPS; // requires settings version 1.14 (VirtualBox 4.3)
729 } Video;
730
731 /**
732 * Structure holding settings if the destination is a file.
733 */
734 struct File
735 {
736 /** Maximum size (in MB) the file is allowed to have.
737 * When reaching the limit, recording will stop. 0 means no limit. */
738 uint32_t ulMaxSizeMB; // requires settings version 1.14 (VirtualBox 4.3)
739 /** Absolute file name path to use for recording.
740 * When empty, this is considered as being the default setting. */
741 com::Utf8Str strName; // requires settings version 1.14 (VirtualBox 4.3)
742 } File;
743};
744
745/** Map for keeping settings per virtual screen.
746 * The key specifies the screen ID. */
747typedef std::map<uint32_t, RecordingScreenSettings> RecordingScreenSettingsMap;
748
749/**
750 * Common recording settings, shared among all per-screen recording settings.
751 *
752 * NOTE: If you add any fields in here, you must update a) the constructor and b)
753 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
754 * your settings might never get saved.
755 */
756struct RecordingCommonSettings
757{
758 RecordingCommonSettings();
759
760 void applyDefaults(void);
761
762 bool areDefaultSettings(void) const;
763
764 bool operator==(const RecordingCommonSettings &d) const;
765
766 /** Whether recording as a whole is enabled or disabled. */
767 bool fEnabled; // requires settings version 1.14 (VirtualBox 4.3)
768};
769
770/**
771 * NOTE: If you add any fields in here, you must update a) the constructor and b)
772 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
773 * your settings might never get saved.
774 */
775struct RecordingSettings
776{
777 RecordingSettings();
778
779 void applyDefaults(void);
780
781 bool areDefaultSettings(void) const;
782
783 bool operator==(const RecordingSettings &that) const;
784
785 /** Common settings for all per-screen recording settings. */
786 RecordingCommonSettings common;
787 /** Map of handled recording screen settings.
788 * The key specifies the screen ID. */
789 RecordingScreenSettingsMap mapScreens;
790};
791
792/**
793 * NOTE: If you add any fields in here, you must update a) the constructor and b)
794 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
795 * your settings might never get saved.
796 */
797struct GraphicsAdapter
798{
799 GraphicsAdapter();
800
801 bool areDefaultSettings() const;
802
803 bool operator==(const GraphicsAdapter &g) const;
804
805 GraphicsControllerType_T graphicsControllerType;
806 uint32_t ulVRAMSizeMB;
807 uint32_t cMonitors;
808 bool fAccelerate3D,
809 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
810};
811
812/**
813 * NOTE: If you add any fields in here, you must update a) the constructor and b)
814 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
815 * your settings might never get saved.
816 */
817struct USBController
818{
819 USBController();
820
821 bool operator==(const USBController &u) const;
822
823 com::Utf8Str strName;
824 USBControllerType_T enmType;
825};
826
827typedef std::list<USBController> USBControllerList;
828
829struct USB
830{
831 USB();
832
833 bool operator==(const USB &u) const;
834
835 /** List of USB controllers present. */
836 USBControllerList llUSBControllers;
837 /** List of USB device filters. */
838 USBDeviceFiltersList llDeviceFilters;
839};
840
841struct NAT
842{
843 NAT();
844
845 bool areDNSDefaultSettings() const;
846 bool areAliasDefaultSettings() const;
847 bool areTFTPDefaultSettings() const;
848 bool areLocalhostReachableDefaultSettings(SettingsVersion_T sv) const;
849 bool areDefaultSettings(SettingsVersion_T sv) const;
850
851 bool operator==(const NAT &n) const;
852
853 com::Utf8Str strNetwork;
854 com::Utf8Str strBindIP;
855 uint32_t u32Mtu;
856 uint32_t u32SockRcv;
857 uint32_t u32SockSnd;
858 uint32_t u32TcpRcv;
859 uint32_t u32TcpSnd;
860 com::Utf8Str strTFTPPrefix;
861 com::Utf8Str strTFTPBootFile;
862 com::Utf8Str strTFTPNextServer;
863 bool fDNSPassDomain;
864 bool fDNSProxy;
865 bool fDNSUseHostResolver;
866 bool fAliasLog;
867 bool fAliasProxyOnly;
868 bool fAliasUseSamePorts;
869 bool fLocalhostReachable;
870 NATRulesMap mapRules;
871};
872
873/**
874 * NOTE: If you add any fields in here, you must update a) the constructor and b)
875 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
876 * your settings might never get saved.
877 */
878struct NetworkAdapter
879{
880 NetworkAdapter();
881
882 bool areGenericDriverDefaultSettings() const;
883 bool areDefaultSettings(SettingsVersion_T sv) const;
884 bool areDisabledDefaultSettings(SettingsVersion_T sv) const;
885
886 bool operator==(const NetworkAdapter &n) const;
887
888 uint32_t ulSlot;
889
890 NetworkAdapterType_T type;
891 bool fEnabled;
892 com::Utf8Str strMACAddress;
893 bool fCableConnected;
894 uint32_t ulLineSpeed;
895 NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
896 bool fTraceEnabled;
897 com::Utf8Str strTraceFile;
898
899 NetworkAttachmentType_T mode;
900 NAT nat;
901 com::Utf8Str strBridgedName;
902 com::Utf8Str strHostOnlyName;
903#ifdef VBOX_WITH_VMNET
904 com::Utf8Str strHostOnlyNetworkName;
905#endif /* VBOX_WITH_VMNET */
906 com::Utf8Str strInternalNetworkName;
907 com::Utf8Str strGenericDriver;
908 StringsMap genericProperties;
909 com::Utf8Str strNATNetworkName;
910#ifdef VBOX_WITH_CLOUD_NET
911 com::Utf8Str strCloudNetworkName;
912#endif /* VBOX_WITH_CLOUD_NET */
913 uint32_t ulBootPriority;
914 com::Utf8Str strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2)
915};
916
917typedef std::list<NetworkAdapter> NetworkAdaptersList;
918
919/**
920 * NOTE: If you add any fields in here, you must update a) the constructor and b)
921 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
922 * your settings might never get saved.
923 */
924struct SerialPort
925{
926 SerialPort();
927
928 bool operator==(const SerialPort &n) const;
929
930 uint32_t ulSlot;
931
932 bool fEnabled;
933 uint32_t ulIOBase;
934 uint32_t ulIRQ;
935 PortMode_T portMode;
936 com::Utf8Str strPath;
937 bool fServer;
938 UartType_T uartType;
939};
940
941typedef std::list<SerialPort> SerialPortsList;
942
943/**
944 * NOTE: If you add any fields in here, you must update a) the constructor and b)
945 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
946 * your settings might never get saved.
947 */
948struct ParallelPort
949{
950 ParallelPort();
951
952 bool operator==(const ParallelPort &d) const;
953
954 uint32_t ulSlot;
955
956 bool fEnabled;
957 uint32_t ulIOBase;
958 uint32_t ulIRQ;
959 com::Utf8Str strPath;
960};
961
962typedef std::list<ParallelPort> ParallelPortsList;
963
964/**
965 * NOTE: If you add any fields in here, you must update a) the constructor and b)
966 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
967 * your settings might never get saved.
968 */
969struct AudioAdapter
970{
971 AudioAdapter();
972
973 bool areDefaultSettings(SettingsVersion_T sv) const;
974
975 bool operator==(const AudioAdapter &a) const;
976
977 bool fEnabled;
978 bool fEnabledIn;
979 bool fEnabledOut;
980 AudioControllerType_T controllerType;
981 AudioCodecType_T codecType;
982 AudioDriverType_T driverType;
983 settings::StringsMap properties;
984};
985
986/**
987 * NOTE: If you add any fields in here, you must update a) the constructor and b)
988 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
989 * your settings might never get saved.
990 */
991struct SharedFolder
992{
993 SharedFolder();
994
995 bool operator==(const SharedFolder &a) const;
996
997 com::Utf8Str strName,
998 strHostPath;
999 bool fWritable;
1000 bool fAutoMount;
1001 com::Utf8Str strAutoMountPoint;
1002};
1003
1004typedef std::list<SharedFolder> SharedFoldersList;
1005
1006/**
1007 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1008 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1009 * your settings might never get saved.
1010 */
1011struct GuestProperty
1012{
1013 GuestProperty();
1014
1015 bool operator==(const GuestProperty &g) const;
1016
1017 com::Utf8Str strName,
1018 strValue;
1019 uint64_t timestamp;
1020 com::Utf8Str strFlags;
1021};
1022
1023typedef std::list<GuestProperty> GuestPropertiesList;
1024
1025typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
1026
1027/**
1028 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1029 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1030 * your settings might never get saved.
1031 */
1032struct CpuIdLeaf
1033{
1034 CpuIdLeaf();
1035
1036 bool operator==(const CpuIdLeaf &c) const;
1037
1038 uint32_t idx;
1039 uint32_t idxSub;
1040 uint32_t uEax;
1041 uint32_t uEbx;
1042 uint32_t uEcx;
1043 uint32_t uEdx;
1044};
1045
1046typedef std::list<CpuIdLeaf> CpuIdLeafsList;
1047
1048/**
1049 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1050 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1051 * your settings might never get saved.
1052 */
1053struct Cpu
1054{
1055 Cpu();
1056
1057 bool operator==(const Cpu &c) const;
1058
1059 uint32_t ulId;
1060};
1061
1062typedef std::list<Cpu> CpuList;
1063
1064/**
1065 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1066 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1067 * your settings might never get saved.
1068 */
1069struct BandwidthGroup
1070{
1071 BandwidthGroup();
1072
1073 bool operator==(const BandwidthGroup &i) const;
1074
1075 com::Utf8Str strName;
1076 uint64_t cMaxBytesPerSec;
1077 BandwidthGroupType_T enmType;
1078};
1079
1080typedef std::list<BandwidthGroup> BandwidthGroupList;
1081
1082/**
1083 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1084 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1085 * your settings might never get saved.
1086 */
1087struct IOSettings
1088{
1089 IOSettings();
1090
1091 bool areIOCacheDefaultSettings() const;
1092 bool areDefaultSettings() const;
1093
1094 bool operator==(const IOSettings &i) const;
1095
1096 bool fIOCacheEnabled;
1097 uint32_t ulIOCacheSize;
1098 BandwidthGroupList llBandwidthGroups;
1099};
1100
1101/**
1102 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1103 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1104 * your settings might never get saved.
1105 */
1106struct HostPCIDeviceAttachment
1107{
1108 HostPCIDeviceAttachment();
1109
1110 bool operator==(const HostPCIDeviceAttachment &a) const;
1111
1112 com::Utf8Str strDeviceName;
1113 uint32_t uHostAddress;
1114 uint32_t uGuestAddress;
1115};
1116
1117typedef std::list<HostPCIDeviceAttachment> HostPCIDeviceAttachmentList;
1118
1119/**
1120 * A device attached to a storage controller. This can either be a
1121 * hard disk or a DVD drive or a floppy drive and also specifies
1122 * which medium is "in" the drive; as a result, this is a combination
1123 * of the Main IMedium and IMediumAttachment interfaces.
1124 *
1125 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1126 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1127 * your settings might never get saved.
1128 */
1129struct AttachedDevice
1130{
1131 AttachedDevice();
1132
1133 bool operator==(const AttachedDevice &a) const;
1134
1135 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
1136
1137 // DVDs can be in pass-through mode:
1138 bool fPassThrough;
1139
1140 // Whether guest-triggered eject of DVDs will keep the medium in the
1141 // VM config or not:
1142 bool fTempEject;
1143
1144 // Whether the medium is non-rotational:
1145 bool fNonRotational;
1146
1147 // Whether the medium supports discarding unused blocks:
1148 bool fDiscard;
1149
1150 // Whether the medium is hot-pluggable:
1151 bool fHotPluggable;
1152
1153 int32_t lPort;
1154 int32_t lDevice;
1155
1156 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
1157 // this is its UUID; it depends on deviceType which media registry this then needs to
1158 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
1159 com::Guid uuid;
1160
1161 // for DVDs and floppies, the attachment can also be a host device:
1162 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
1163
1164 // Bandwidth group the device is attached to.
1165 com::Utf8Str strBwGroup;
1166};
1167
1168typedef std::list<AttachedDevice> AttachedDevicesList;
1169
1170/**
1171 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1172 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1173 * your settings might never get saved.
1174 */
1175struct StorageController
1176{
1177 StorageController();
1178
1179 bool operator==(const StorageController &s) const;
1180
1181 com::Utf8Str strName;
1182 StorageBus_T storageBus; // _SATA, _SCSI, _IDE, _SAS
1183 StorageControllerType_T controllerType;
1184 uint32_t ulPortCount;
1185 uint32_t ulInstance;
1186 bool fUseHostIOCache;
1187 bool fBootable;
1188
1189 // only for when controllerType == StorageControllerType_IntelAhci:
1190 int32_t lIDE0MasterEmulationPort,
1191 lIDE0SlaveEmulationPort,
1192 lIDE1MasterEmulationPort,
1193 lIDE1SlaveEmulationPort;
1194
1195 AttachedDevicesList llAttachedDevices;
1196};
1197
1198typedef std::list<StorageController> StorageControllersList;
1199
1200/**
1201 * We wrap the storage controllers list into an extra struct so we can
1202 * use an undefined struct without needing std::list<> in all the headers.
1203 *
1204 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1205 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1206 * your settings might never get saved.
1207 */
1208struct Storage
1209{
1210 bool operator==(const Storage &s) const;
1211
1212 StorageControllersList llStorageControllers;
1213};
1214
1215/**
1216 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
1217 * field.
1218 *
1219 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1220 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1221 * your settings might never get saved.
1222 */
1223struct Hardware
1224{
1225 Hardware();
1226
1227 bool areParavirtDefaultSettings(SettingsVersion_T sv) const;
1228 bool areBootOrderDefaultSettings() const;
1229 bool areDisplayDefaultSettings() const;
1230 bool areAllNetworkAdaptersDefaultSettings(SettingsVersion_T sv) const;
1231
1232 bool operator==(const Hardware&) const;
1233
1234 com::Utf8Str strVersion; // hardware version, optional
1235 com::Guid uuid; // hardware uuid, optional (null).
1236
1237 bool fHardwareVirt,
1238 fNestedPaging,
1239 fLargePages,
1240 fVPID,
1241 fUnrestrictedExecution,
1242 fHardwareVirtForce,
1243 fUseNativeApi,
1244 fSyntheticCpu,
1245 fTripleFaultReset,
1246 fPAE,
1247 fAPIC, // requires settings version 1.16 (VirtualBox 5.1)
1248 fX2APIC; // requires settings version 1.16 (VirtualBox 5.1)
1249 bool fIBPBOnVMExit; //< added out of cycle, after 1.16 was out.
1250 bool fIBPBOnVMEntry; //< added out of cycle, after 1.16 was out.
1251 bool fSpecCtrl; //< added out of cycle, after 1.16 was out.
1252 bool fSpecCtrlByHost; //< added out of cycle, after 1.16 was out.
1253 bool fL1DFlushOnSched ; //< added out of cycle, after 1.16 was out.
1254 bool fL1DFlushOnVMEntry ; //< added out of cycle, after 1.16 was out.
1255 bool fMDSClearOnSched; //< added out of cycle, after 1.16 was out.
1256 bool fMDSClearOnVMEntry; //< added out of cycle, after 1.16 was out.
1257 bool fNestedHWVirt; //< requires settings version 1.17 (VirtualBox 6.0)
1258 bool fVirtVmsaveVmload; //< requires settings version 1.18 (VirtualBox 6.1)
1259 typedef enum LongModeType { LongMode_Enabled, LongMode_Disabled, LongMode_Legacy } LongModeType;
1260 LongModeType enmLongMode;
1261 uint32_t cCPUs;
1262 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
1263 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
1264 bool fHPETEnabled; // requires settings version 1.10 (VirtualBox 3.2)
1265 uint32_t ulCpuExecutionCap; // requires settings version 1.11 (VirtualBox 3.3)
1266 uint32_t uCpuIdPortabilityLevel; // requires settings version 1.15 (VirtualBox 5.0)
1267 com::Utf8Str strCpuProfile; // requires settings version 1.16 (VirtualBox 5.1)
1268
1269 CpuIdLeafsList llCpuIdLeafs;
1270
1271 uint32_t ulMemorySizeMB;
1272
1273 BootOrderMap mapBootOrder; // item 0 has highest priority
1274
1275 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
1276
1277 PointingHIDType_T pointingHIDType; // requires settings version 1.10 (VirtualBox 3.2)
1278 KeyboardHIDType_T keyboardHIDType; // requires settings version 1.10 (VirtualBox 3.2)
1279
1280 ChipsetType_T chipsetType; // requires settings version 1.11 (VirtualBox 4.0)
1281 IommuType_T iommuType; // requires settings version 1.19 (VirtualBox 6.2)
1282 ParavirtProvider_T paravirtProvider; // requires settings version 1.15 (VirtualBox 4.4)
1283 com::Utf8Str strParavirtDebug; // requires settings version 1.16 (VirtualBox 5.1)
1284
1285 bool fEmulatedUSBCardReader; // 1.12 (VirtualBox 4.1)
1286
1287 VRDESettings vrdeSettings;
1288
1289 BIOSSettings biosSettings;
1290 NvramSettings nvramSettings;
1291 GraphicsAdapter graphicsAdapter;
1292 USB usbSettings;
1293 TpmSettings tpmSettings; // requires settings version 1.19 (VirtualBox 6.2)
1294 NetworkAdaptersList llNetworkAdapters;
1295 SerialPortsList llSerialPorts;
1296 ParallelPortsList llParallelPorts;
1297 AudioAdapter audioAdapter;
1298 Storage storage;
1299
1300 // technically these two have no business in the hardware section, but for some
1301 // clever reason <Hardware> is where they are in the XML....
1302 SharedFoldersList llSharedFolders;
1303
1304 ClipboardMode_T clipboardMode;
1305 bool fClipboardFileTransfersEnabled;
1306
1307 DnDMode_T dndMode;
1308
1309 uint32_t ulMemoryBalloonSize;
1310 bool fPageFusionEnabled;
1311
1312 GuestPropertiesList llGuestProperties;
1313
1314 IOSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
1315 HostPCIDeviceAttachmentList pciAttachments; // requires settings version 1.12 (VirtualBox 4.1)
1316
1317 com::Utf8Str strDefaultFrontend; // requires settings version 1.14 (VirtualBox 4.3)
1318};
1319
1320/**
1321 * Settings that has to do with debugging.
1322 */
1323struct Debugging
1324{
1325 Debugging();
1326
1327 bool areDefaultSettings() const;
1328
1329 bool operator==(const Debugging &rOther) const;
1330
1331 bool fTracingEnabled;
1332 bool fAllowTracingToAccessVM;
1333 com::Utf8Str strTracingConfig;
1334 GuestDebugProvider_T enmDbgProvider;
1335 GuestDebugIoProvider_T enmIoProvider;
1336 com::Utf8Str strAddress;
1337 uint32_t ulPort;
1338};
1339
1340/**
1341 * Settings that has to do with autostart.
1342 */
1343struct Autostart
1344{
1345 Autostart();
1346
1347 bool areDefaultSettings() const;
1348
1349 bool operator==(const Autostart &rOther) const;
1350
1351 bool fAutostartEnabled;
1352 uint32_t uAutostartDelay;
1353 AutostopType_T enmAutostopType;
1354};
1355
1356struct Snapshot;
1357typedef std::list<Snapshot> SnapshotsList;
1358
1359/**
1360 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1361 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1362 * your settings might never get saved.
1363 */
1364struct Snapshot
1365{
1366 Snapshot();
1367
1368 bool operator==(const Snapshot &s) const;
1369
1370 com::Guid uuid;
1371 com::Utf8Str strName,
1372 strDescription; // optional
1373 RTTIMESPEC timestamp;
1374
1375 com::Utf8Str strStateFile; // for online snapshots only
1376
1377 Hardware hardware;
1378
1379 Debugging debugging;
1380 Autostart autostart;
1381 RecordingSettings recordingSettings;
1382
1383 SnapshotsList llChildSnapshots;
1384
1385 static const struct Snapshot Empty;
1386};
1387
1388/**
1389 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1390 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1391 * your settings might never get saved.
1392 */
1393struct MachineUserData
1394{
1395 MachineUserData();
1396
1397 bool operator==(const MachineUserData &c) const;
1398
1399 com::Utf8Str strName;
1400 bool fDirectoryIncludesUUID;
1401 bool fNameSync;
1402 com::Utf8Str strDescription;
1403 StringsList llGroups;
1404 com::Utf8Str strOsType;
1405 com::Utf8Str strSnapshotFolder;
1406 bool fTeleporterEnabled;
1407 uint32_t uTeleporterPort;
1408 com::Utf8Str strTeleporterAddress;
1409 com::Utf8Str strTeleporterPassword;
1410 bool fRTCUseUTC;
1411 IconBlob ovIcon;
1412 VMProcPriority_T enmVMPriority;
1413};
1414
1415
1416/**
1417 * MachineConfigFile represents an XML machine configuration. All the machine settings
1418 * that go out to the XML (or are read from it) are in here.
1419 *
1420 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1421 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
1422 * might never get saved.
1423 */
1424class MachineConfigFile : public ConfigFileBase
1425{
1426public:
1427 com::Guid uuid;
1428
1429 enum
1430 {
1431 ParseState_NotParsed,
1432 ParseState_PasswordError,
1433 ParseState_Parsed
1434 } enmParseState;
1435
1436 MachineUserData machineUserData;
1437
1438 com::Utf8Str strStateKeyId;
1439 com::Utf8Str strStateKeyStore;
1440 com::Utf8Str strStateFile;
1441 bool fCurrentStateModified; // optional, default is true
1442 RTTIMESPEC timeLastStateChange; // optional, defaults to now
1443 bool fAborted; // optional, default is false
1444
1445 com::Guid uuidCurrentSnapshot;
1446
1447 Hardware hardwareMachine;
1448 MediaRegistry mediaRegistry;
1449 Debugging debugging;
1450 Autostart autostart;
1451 RecordingSettings recordingSettings;
1452
1453 StringsMap mapExtraDataItems;
1454
1455 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
1456
1457 com::Utf8Str strKeyId;
1458 com::Utf8Str strKeyStore; // if not empty, the encryption is used
1459 com::Utf8Str strLogKeyId;
1460 com::Utf8Str strLogKeyStore;
1461
1462 MachineConfigFile(const com::Utf8Str *pstrFilename,
1463 PCVBOXCRYPTOIF pCryptoIf = NULL,
1464 const char *pszPassword = NULL);
1465
1466 bool operator==(const MachineConfigFile &m) const;
1467
1468 bool canHaveOwnMediaRegistry() const;
1469
1470 void importMachineXML(const xml::ElementNode &elmMachine);
1471
1472 void write(const com::Utf8Str &strFilename, PCVBOXCRYPTOIF pCryptoIf = NULL, const char *pszPassword = NULL);
1473
1474 enum
1475 {
1476 BuildMachineXML_IncludeSnapshots = 0x01,
1477 BuildMachineXML_WriteVBoxVersionAttribute = 0x02,
1478 BuildMachineXML_SkipRemovableMedia = 0x04,
1479 BuildMachineXML_MediaRegistry = 0x08,
1480 BuildMachineXML_SuppressSavedState = 0x10
1481 };
1482
1483 void copyEncryptionSettingsFrom(const MachineConfigFile &other);
1484 void buildMachineXML(xml::ElementNode &elmMachine,
1485 uint32_t fl,
1486 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1487
1488 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T enmDrvType);
1489 static AudioDriverType_T getHostDefaultAudioDriver();
1490
1491private:
1492 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
1493 void readAttachedNetworkMode(const xml::ElementNode &pelmMode, bool fEnabled, NetworkAdapter &nic);
1494 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
1495 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
1496 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
1497 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
1498 void readAudioAdapter(const xml::ElementNode &elmAudioAdapter, AudioAdapter &aa);
1499 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
1500 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
1501 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw);
1502 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
1503 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
1504 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
1505 void readTeleporter(const xml::ElementNode &elmTeleporter, MachineUserData &userData);
1506 void readDebugging(const xml::ElementNode &elmDbg, Debugging &dbg);
1507 void readAutostart(const xml::ElementNode &elmAutostart, Autostart &autostrt);
1508 void readRecordingSettings(const xml::ElementNode &elmRecording, uint32_t cMonitors, RecordingSettings &recording);
1509 void readGroups(const xml::ElementNode &elmGroups, StringsList &llGroups);
1510 bool readSnapshot(const com::Guid &curSnapshotUuid, const xml::ElementNode &elmSnapshot, Snapshot &snap);
1511 void convertOldOSType_pre1_5(com::Utf8Str &str);
1512 void readMachine(const xml::ElementNode &elmMachine);
1513 void readMachineEncrypted(const xml::ElementNode &elmMachine, PCVBOXCRYPTOIF pCryptoIf, const char *pszPassword);
1514
1515 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, uint32_t fl, std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1516 void buildNetworkXML(NetworkAttachmentType_T mode, bool fEnabled, xml::ElementNode &elmParent, const NetworkAdapter &nic);
1517 void buildStorageControllersXML(xml::ElementNode &elmParent,
1518 const Storage &st,
1519 bool fSkipRemovableMedia,
1520 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1521 void buildDebuggingXML(xml::ElementNode &elmParent, const Debugging &dbg);
1522 void buildAutostartXML(xml::ElementNode &elmParent, const Autostart &autostrt);
1523 void buildRecordingXML(xml::ElementNode &elmParent, const RecordingSettings &recording);
1524 void buildGroupsXML(xml::ElementNode &elmParent, const StringsList &llGroups);
1525 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
1526
1527 void buildMachineEncryptedXML(xml::ElementNode &elmMachine,
1528 uint32_t fl,
1529 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes,
1530 PCVBOXCRYPTOIF pCryptoIf,
1531 const char *pszPassword);
1532
1533 void bumpSettingsVersionIfNeeded();
1534};
1535
1536} // namespace settings
1537
1538
1539#endif /* !VBOX_INCLUDED_settings_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use