VirtualBox

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

Last change on this file since 95840 was 95840, checked in by vboxsync, 3 years ago

Recording/Main: Fixed a regression when loading settings < 1.19: There we use a bitmap instead of a count, so make sure to iterate by the number of configured monitors and use the bitmap for the monitor recording enabled status instead [build fix]. bugref:9286

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

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