VirtualBox

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

Last change on this file since 62855 was 62602, checked in by vboxsync, 8 years ago

Main/xml/Settings.cpp: parse the version of the VirtualBox settings embedded in the OVF file, to get the defaults right

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 38.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-2016 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_settings_h
41#define ___VBox_settings_h
42
43#include <iprt/time.h>
44
45#include "VBox/com/VirtualBox.h"
46
47#include <VBox/com/Guid.h>
48#include <VBox/com/string.h>
49
50#include <list>
51#include <map>
52#include <vector>
53
54/**
55 * Maximum depth of a medium tree, to prevent stack overflows.
56 * XPCOM has a relatively low stack size for its workers, and we have
57 * to avoid crashes due to exceeding the limit both on reading and
58 * writing config files.
59 */
60#define SETTINGS_MEDIUM_DEPTH_MAX 300
61
62/**
63 * Maximum depth of the snapshot tree, to prevent stack overflows.
64 * XPCOM has a relatively low stack size for its workers, and we have
65 * to avoid crashes due to exceeding the limit both on reading and
66 * writing config files. The bottleneck is reading config files with
67 * deep snapshot nesting, as libxml2 needs quite some stack space,
68 * so with the current stack size the margin isn't big.
69 */
70#define SETTINGS_SNAPSHOT_DEPTH_MAX 250
71
72namespace xml
73{
74 class ElementNode;
75}
76
77namespace settings
78{
79
80class ConfigFileError;
81
82////////////////////////////////////////////////////////////////////////////////
83//
84// Structures shared between Machine XML and VirtualBox.xml
85//
86////////////////////////////////////////////////////////////////////////////////
87
88typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
89typedef std::list<com::Utf8Str> StringsList;
90
91/**
92 * USB device filter definition. This struct is used both in MainConfigFile
93 * (for global USB filters) and MachineConfigFile (for machine filters).
94 *
95 * NOTE: If you add any fields in here, you must update a) the constructor and b)
96 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
97 * your settings might never get saved.
98 */
99struct USBDeviceFilter
100{
101 USBDeviceFilter();
102
103 bool operator==(const USBDeviceFilter&u) const;
104
105 com::Utf8Str strName;
106 bool fActive;
107 com::Utf8Str strVendorId,
108 strProductId,
109 strRevision,
110 strManufacturer,
111 strProduct,
112 strSerialNumber,
113 strPort;
114 USBDeviceFilterAction_T action; // only used with host USB filters
115 com::Utf8Str strRemote; // irrelevant for host USB objects
116 uint32_t ulMaskedInterfaces; // irrelevant for host USB objects
117};
118
119typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
120
121struct Medium;
122typedef std::list<Medium> MediaList;
123
124/**
125 * NOTE: If you add any fields in here, you must update a) the constructor and b)
126 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
127 * your settings might never get saved.
128 */
129struct Medium
130{
131 Medium();
132
133 bool operator==(const Medium &m) const;
134
135 com::Guid uuid;
136 com::Utf8Str strLocation;
137 com::Utf8Str strDescription;
138
139 // the following are for hard disks only:
140 com::Utf8Str strFormat;
141 bool fAutoReset; // optional, only for diffs, default is false
142 StringsMap properties;
143 MediumType_T hdType;
144
145 MediaList llChildren; // only used with hard disks
146
147 static const struct Medium Empty;
148};
149
150/**
151 * A media registry. Starting with VirtualBox 3.3, this can appear in both the
152 * VirtualBox.xml file as well as machine XML files with settings version 1.11
153 * or higher, so these lists are now in ConfigFileBase.
154 *
155 * NOTE: If you add any fields in here, you must update a) the constructor and b)
156 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
157 * your settings might never get saved.
158 */
159struct MediaRegistry
160{
161 bool operator==(const MediaRegistry &m) const;
162
163 MediaList llHardDisks,
164 llDvdImages,
165 llFloppyImages;
166};
167
168/**
169 * NOTE: If you add any fields in here, you must update a) the constructor and b)
170 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
171 * your settings might never get saved.
172 */
173struct NATRule
174{
175 NATRule();
176
177 bool operator==(const NATRule &r) const;
178
179 com::Utf8Str strName;
180 NATProtocol_T proto;
181 uint16_t u16HostPort;
182 com::Utf8Str strHostIP;
183 uint16_t u16GuestPort;
184 com::Utf8Str strGuestIP;
185};
186typedef std::map<com::Utf8Str, NATRule> NATRulesMap;
187
188struct NATHostLoopbackOffset
189{
190 NATHostLoopbackOffset();
191
192 bool operator==(const NATHostLoopbackOffset &o) const;
193
194 bool operator==(const com::Utf8Str& strAddr)
195 {
196 return strLoopbackHostAddress == strAddr;
197 }
198
199 bool operator==(uint32_t off)
200 {
201 return u32Offset == off;
202 }
203
204 /** Note: 128/8 is only acceptable */
205 com::Utf8Str strLoopbackHostAddress;
206 uint32_t u32Offset;
207};
208
209typedef std::list<NATHostLoopbackOffset> NATLoopbackOffsetList;
210
211typedef std::vector<uint8_t> IconBlob;
212
213/**
214 * Common base class for both MainConfigFile and MachineConfigFile
215 * which contains some common logic for both.
216 */
217class ConfigFileBase
218{
219public:
220 bool fileExists();
221
222 void copyBaseFrom(const ConfigFileBase &b);
223
224protected:
225 ConfigFileBase(const com::Utf8Str *pstrFilename);
226 /* Note: this copy constructor doesn't create a full copy of other, cause
227 * the file based stuff (xml doc) could not be copied. */
228 ConfigFileBase(const ConfigFileBase &other);
229
230 ~ConfigFileBase();
231
232 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
233
234 static const char *stringifyMediaType(MediaType t);
235 SettingsVersion_T parseVersion(const com::Utf8Str &strVersion);
236 void parseUUID(com::Guid &guid,
237 const com::Utf8Str &strUUID) const;
238 void parseTimestamp(RTTIMESPEC &timestamp,
239 const com::Utf8Str &str) const;
240 void parseBase64(IconBlob &binary,
241 const com::Utf8Str &str) const;
242 com::Utf8Str stringifyTimestamp(const RTTIMESPEC &tm) const;
243 void toBase64(com::Utf8Str &str,
244 const IconBlob &binary) const;
245
246 void readExtraData(const xml::ElementNode &elmExtraData,
247 StringsMap &map);
248 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
249 USBDeviceFiltersList &ll);
250 void readMediumOne(MediaType t, const xml::ElementNode &elmMedium, Medium &med);
251 void readMedium(MediaType t, uint32_t depth, const xml::ElementNode &elmMedium, Medium &med);
252 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr);
253 void readNATForwardRulesMap(const xml::ElementNode &elmParent, NATRulesMap &mapRules);
254 void readNATLoopbacks(const xml::ElementNode &elmParent, NATLoopbackOffsetList &llLoopBacks);
255
256 void setVersionAttribute(xml::ElementNode &elm);
257 void createStubDocument();
258
259 void buildExtraData(xml::ElementNode &elmParent, const StringsMap &me);
260 void buildUSBDeviceFilters(xml::ElementNode &elmParent,
261 const USBDeviceFiltersList &ll,
262 bool fHostMode);
263 void buildMedium(MediaType t,
264 uint32_t depth,
265 xml::ElementNode &elmMedium,
266 const Medium &mdm);
267 void buildMediaRegistry(xml::ElementNode &elmParent,
268 const MediaRegistry &mr);
269 void buildNATForwardRulesMap(xml::ElementNode &elmParent, const NATRulesMap &mapRules);
270 void buildNATLoopbacks(xml::ElementNode &elmParent, const NATLoopbackOffsetList &natLoopbackList);
271 void clearDocument();
272
273 struct Data;
274 Data *m;
275
276 friend class ConfigFileError;
277};
278
279////////////////////////////////////////////////////////////////////////////////
280//
281// VirtualBox.xml structures
282//
283////////////////////////////////////////////////////////////////////////////////
284
285struct USBDeviceSource
286{
287 com::Utf8Str strName;
288 com::Utf8Str strBackend;
289 com::Utf8Str strAddress;
290 StringsMap properties;
291};
292
293typedef std::list<USBDeviceSource> USBDeviceSourcesList;
294
295struct Host
296{
297 USBDeviceFiltersList llUSBDeviceFilters;
298 USBDeviceSourcesList llUSBDeviceSources;
299};
300
301struct SystemProperties
302{
303 SystemProperties();
304
305 com::Utf8Str strDefaultMachineFolder;
306 com::Utf8Str strDefaultHardDiskFolder;
307 com::Utf8Str strDefaultHardDiskFormat;
308 com::Utf8Str strVRDEAuthLibrary;
309 com::Utf8Str strWebServiceAuthLibrary;
310 com::Utf8Str strDefaultVRDEExtPack;
311 com::Utf8Str strAutostartDatabasePath;
312 com::Utf8Str strDefaultAdditionsISO;
313 com::Utf8Str strDefaultFrontend;
314 com::Utf8Str strLoggingLevel;
315 uint32_t ulLogHistoryCount;
316 bool fExclusiveHwVirt;
317};
318
319struct MachineRegistryEntry
320{
321 com::Guid uuid;
322 com::Utf8Str strSettingsFile;
323};
324
325typedef std::list<MachineRegistryEntry> MachinesRegistry;
326
327struct DhcpOptValue
328{
329 DhcpOptValue();
330 DhcpOptValue(const com::Utf8Str &aText, DhcpOptEncoding_T aEncoding = DhcpOptEncoding_Legacy);
331
332 com::Utf8Str text;
333 DhcpOptEncoding_T encoding;
334};
335
336typedef std::map<DhcpOpt_T, DhcpOptValue> DhcpOptionMap;
337typedef DhcpOptionMap::value_type DhcpOptValuePair;
338typedef DhcpOptionMap::iterator DhcpOptIterator;
339typedef DhcpOptionMap::const_iterator DhcpOptConstIterator;
340
341typedef struct VmNameSlotKey
342{
343 VmNameSlotKey(const com::Utf8Str& aVmName, LONG aSlot);
344
345 bool operator<(const VmNameSlotKey& that) const;
346
347 const com::Utf8Str VmName;
348 LONG Slot;
349} VmNameSlotKey;
350
351typedef std::map<VmNameSlotKey, DhcpOptionMap> VmSlot2OptionsMap;
352typedef VmSlot2OptionsMap::value_type VmSlot2OptionsPair;
353typedef VmSlot2OptionsMap::iterator VmSlot2OptionsIterator;
354typedef VmSlot2OptionsMap::const_iterator VmSlot2OptionsConstIterator;
355
356struct DHCPServer
357{
358 DHCPServer();
359
360 com::Utf8Str strNetworkName,
361 strIPAddress,
362 strIPLower,
363 strIPUpper;
364 bool fEnabled;
365 DhcpOptionMap GlobalDhcpOptions;
366 VmSlot2OptionsMap VmSlot2OptionsM;
367};
368
369typedef std::list<DHCPServer> DHCPServersList;
370
371
372/**
373 * NAT Networking settings (NAT service).
374 */
375struct NATNetwork
376{
377 NATNetwork();
378
379 com::Utf8Str strNetworkName;
380 com::Utf8Str strIPv4NetworkCidr;
381 com::Utf8Str strIPv6Prefix;
382 bool fEnabled;
383 bool fIPv6Enabled;
384 bool fAdvertiseDefaultIPv6Route;
385 bool fNeedDhcpServer;
386 uint32_t u32HostLoopback6Offset;
387 NATLoopbackOffsetList llHostLoopbackOffsetList;
388 NATRulesMap mapPortForwardRules4;
389 NATRulesMap mapPortForwardRules6;
390};
391
392typedef std::list<NATNetwork> NATNetworksList;
393
394
395class MainConfigFile : public ConfigFileBase
396{
397public:
398 MainConfigFile(const com::Utf8Str *pstrFilename);
399
400 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry);
401 void readDHCPServers(const xml::ElementNode &elmDHCPServers);
402 void readDhcpOptions(DhcpOptionMap& map, const xml::ElementNode& options);
403 void readNATNetworks(const xml::ElementNode &elmNATNetworks);
404
405 void write(const com::Utf8Str strFilename);
406
407 Host host;
408 SystemProperties systemProperties;
409 MediaRegistry mediaRegistry;
410 MachinesRegistry llMachines;
411 DHCPServersList llDhcpServers;
412 NATNetworksList llNATNetworks;
413 StringsMap mapExtraDataItems;
414
415private:
416 void bumpSettingsVersionIfNeeded();
417 void buildUSBDeviceSources(xml::ElementNode &elmParent, const USBDeviceSourcesList &ll);
418 void readUSBDeviceSources(const xml::ElementNode &elmDeviceSources, USBDeviceSourcesList &ll);
419};
420
421////////////////////////////////////////////////////////////////////////////////
422//
423// Machine XML structures
424//
425////////////////////////////////////////////////////////////////////////////////
426
427/**
428 * NOTE: If you add any fields in here, you must update a) the constructor and b)
429 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
430 * your settings might never get saved.
431 */
432struct VRDESettings
433{
434 VRDESettings();
435
436 bool areDefaultSettings(SettingsVersion_T sv) const;
437
438 bool operator==(const VRDESettings& v) const;
439
440 bool fEnabled;
441 AuthType_T authType;
442 uint32_t ulAuthTimeout;
443 com::Utf8Str strAuthLibrary;
444 bool fAllowMultiConnection,
445 fReuseSingleConnection;
446 com::Utf8Str strVrdeExtPack;
447 StringsMap mapProperties;
448};
449
450/**
451 * NOTE: If you add any fields in here, you must update a) the constructor and b)
452 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
453 * your settings might never get saved.
454 */
455struct BIOSSettings
456{
457 BIOSSettings();
458
459 bool areDefaultSettings() const;
460
461 bool operator==(const BIOSSettings &d) const;
462
463 bool fACPIEnabled,
464 fIOAPICEnabled,
465 fLogoFadeIn,
466 fLogoFadeOut,
467 fPXEDebugEnabled;
468 uint32_t ulLogoDisplayTime;
469 BIOSBootMenuMode_T biosBootMenuMode;
470 APICMode_T apicMode; // requires settings version 1.16 (VirtualBox 5.1)
471 int64_t llTimeOffset;
472 com::Utf8Str strLogoImagePath;
473};
474
475/**
476 * NOTE: If you add any fields in here, you must update a) the constructor and b)
477 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
478 * your settings might never get saved.
479 */
480struct USBController
481{
482 USBController();
483
484 bool operator==(const USBController &u) const;
485
486 com::Utf8Str strName;
487 USBControllerType_T enmType;
488};
489
490typedef std::list<USBController> USBControllerList;
491
492struct USB
493{
494 USB();
495
496 bool operator==(const USB &u) const;
497
498 /** List of USB controllers present. */
499 USBControllerList llUSBControllers;
500 /** List of USB device filters. */
501 USBDeviceFiltersList llDeviceFilters;
502};
503
504struct NAT
505{
506 NAT();
507
508 bool areDNSDefaultSettings() const;
509 bool areAliasDefaultSettings() const;
510 bool areTFTPDefaultSettings() const;
511 bool areDefaultSettings() const;
512
513 bool operator==(const NAT &n) const;
514
515 com::Utf8Str strNetwork;
516 com::Utf8Str strBindIP;
517 uint32_t u32Mtu;
518 uint32_t u32SockRcv;
519 uint32_t u32SockSnd;
520 uint32_t u32TcpRcv;
521 uint32_t u32TcpSnd;
522 com::Utf8Str strTFTPPrefix;
523 com::Utf8Str strTFTPBootFile;
524 com::Utf8Str strTFTPNextServer;
525 bool fDNSPassDomain;
526 bool fDNSProxy;
527 bool fDNSUseHostResolver;
528 bool fAliasLog;
529 bool fAliasProxyOnly;
530 bool fAliasUseSamePorts;
531 NATRulesMap mapRules;
532};
533
534/**
535 * NOTE: If you add any fields in here, you must update a) the constructor and b)
536 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
537 * your settings might never get saved.
538 */
539struct NetworkAdapter
540{
541 NetworkAdapter();
542
543 bool areGenericDriverDefaultSettings() const;
544 bool areDefaultSettings(SettingsVersion_T sv) const;
545 bool areDisabledDefaultSettings() const;
546
547 bool operator==(const NetworkAdapter &n) const;
548
549 uint32_t ulSlot;
550
551 NetworkAdapterType_T type;
552 bool fEnabled;
553 com::Utf8Str strMACAddress;
554 bool fCableConnected;
555 uint32_t ulLineSpeed;
556 NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
557 bool fTraceEnabled;
558 com::Utf8Str strTraceFile;
559
560 NetworkAttachmentType_T mode;
561 NAT nat;
562 com::Utf8Str strBridgedName;
563 com::Utf8Str strHostOnlyName;
564 com::Utf8Str strInternalNetworkName;
565 com::Utf8Str strGenericDriver;
566 StringsMap genericProperties;
567 com::Utf8Str strNATNetworkName;
568 uint32_t ulBootPriority;
569 com::Utf8Str strBandwidthGroup; // requires settings version 1.13 (VirtualBox 4.2)
570};
571
572typedef std::list<NetworkAdapter> NetworkAdaptersList;
573
574/**
575 * NOTE: If you add any fields in here, you must update a) the constructor and b)
576 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
577 * your settings might never get saved.
578 */
579struct SerialPort
580{
581 SerialPort();
582
583 bool operator==(const SerialPort &n) const;
584
585 uint32_t ulSlot;
586
587 bool fEnabled;
588 uint32_t ulIOBase;
589 uint32_t ulIRQ;
590 PortMode_T portMode;
591 com::Utf8Str strPath;
592 bool fServer;
593};
594
595typedef std::list<SerialPort> SerialPortsList;
596
597/**
598 * NOTE: If you add any fields in here, you must update a) the constructor and b)
599 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
600 * your settings might never get saved.
601 */
602struct ParallelPort
603{
604 ParallelPort();
605
606 bool operator==(const ParallelPort &d) const;
607
608 uint32_t ulSlot;
609
610 bool fEnabled;
611 uint32_t ulIOBase;
612 uint32_t ulIRQ;
613 com::Utf8Str strPath;
614};
615
616typedef std::list<ParallelPort> ParallelPortsList;
617
618/**
619 * NOTE: If you add any fields in here, you must update a) the constructor and b)
620 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
621 * your settings might never get saved.
622 */
623struct AudioAdapter
624{
625 AudioAdapter();
626
627 bool areDefaultSettings(SettingsVersion_T sv) const;
628
629 bool operator==(const AudioAdapter &a) const;
630
631 bool fEnabled;
632 AudioControllerType_T controllerType;
633 AudioCodecType_T codecType;
634 AudioDriverType_T driverType;
635 settings::StringsMap properties;
636};
637
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 SharedFolder
644{
645 SharedFolder();
646
647 bool operator==(const SharedFolder &a) const;
648
649 com::Utf8Str strName,
650 strHostPath;
651 bool fWritable;
652 bool fAutoMount;
653};
654
655typedef std::list<SharedFolder> SharedFoldersList;
656
657/**
658 * NOTE: If you add any fields in here, you must update a) the constructor and b)
659 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
660 * your settings might never get saved.
661 */
662struct GuestProperty
663{
664 GuestProperty();
665
666 bool operator==(const GuestProperty &g) const;
667
668 com::Utf8Str strName,
669 strValue;
670 uint64_t timestamp;
671 com::Utf8Str strFlags;
672};
673
674typedef std::list<GuestProperty> GuestPropertiesList;
675
676typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
677
678/**
679 * NOTE: If you add any fields in here, you must update a) the constructor and b)
680 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
681 * your settings might never get saved.
682 */
683struct CpuIdLeaf
684{
685 CpuIdLeaf();
686
687 bool operator==(const CpuIdLeaf &c) const;
688
689 uint32_t ulId;
690 uint32_t ulEax;
691 uint32_t ulEbx;
692 uint32_t ulEcx;
693 uint32_t ulEdx;
694};
695
696typedef std::list<CpuIdLeaf> CpuIdLeafsList;
697
698/**
699 * NOTE: If you add any fields in here, you must update a) the constructor and b)
700 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
701 * your settings might never get saved.
702 */
703struct Cpu
704{
705 Cpu();
706
707 bool operator==(const Cpu &c) const;
708
709 uint32_t ulId;
710};
711
712typedef std::list<Cpu> CpuList;
713
714/**
715 * NOTE: If you add any fields in here, you must update a) the constructor and b)
716 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
717 * your settings might never get saved.
718 */
719struct BandwidthGroup
720{
721 BandwidthGroup();
722
723 bool operator==(const BandwidthGroup &i) const;
724
725 com::Utf8Str strName;
726 uint64_t cMaxBytesPerSec;
727 BandwidthGroupType_T enmType;
728};
729
730typedef std::list<BandwidthGroup> BandwidthGroupList;
731
732/**
733 * NOTE: If you add any fields in here, you must update a) the constructor and b)
734 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
735 * your settings might never get saved.
736 */
737struct IOSettings
738{
739 IOSettings();
740
741 bool areIOCacheDefaultSettings() const;
742 bool areDefaultSettings() const;
743
744 bool operator==(const IOSettings &i) const;
745
746 bool fIOCacheEnabled;
747 uint32_t ulIOCacheSize;
748 BandwidthGroupList llBandwidthGroups;
749};
750
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 HostPCIDeviceAttachment
757{
758 HostPCIDeviceAttachment();
759
760 bool operator==(const HostPCIDeviceAttachment &a) const;
761
762 com::Utf8Str strDeviceName;
763 uint32_t uHostAddress;
764 uint32_t uGuestAddress;
765};
766
767typedef std::list<HostPCIDeviceAttachment> HostPCIDeviceAttachmentList;
768
769/**
770 * A device attached to a storage controller. This can either be a
771 * hard disk or a DVD drive or a floppy drive and also specifies
772 * which medium is "in" the drive; as a result, this is a combination
773 * of the Main IMedium and IMediumAttachment interfaces.
774 *
775 * NOTE: If you add any fields in here, you must update a) the constructor and b)
776 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
777 * your settings might never get saved.
778 */
779struct AttachedDevice
780{
781 AttachedDevice();
782
783 bool operator==(const AttachedDevice &a) const;
784
785 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
786
787 // DVDs can be in pass-through mode:
788 bool fPassThrough;
789
790 // Whether guest-triggered eject of DVDs will keep the medium in the
791 // VM config or not:
792 bool fTempEject;
793
794 // Whether the medium is non-rotational:
795 bool fNonRotational;
796
797 // Whether the medium supports discarding unused blocks:
798 bool fDiscard;
799
800 // Whether the medium is hot-pluggable:
801 bool fHotPluggable;
802
803 int32_t lPort;
804 int32_t lDevice;
805
806 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
807 // this is its UUID; it depends on deviceType which media registry this then needs to
808 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
809 com::Guid uuid;
810
811 // for DVDs and floppies, the attachment can also be a host device:
812 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
813
814 // Bandwidth group the device is attached to.
815 com::Utf8Str strBwGroup;
816};
817
818typedef std::list<AttachedDevice> AttachedDevicesList;
819
820/**
821 * NOTE: If you add any fields in here, you must update a) the constructor and b)
822 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
823 * your settings might never get saved.
824 */
825struct StorageController
826{
827 StorageController();
828
829 bool operator==(const StorageController &s) const;
830
831 com::Utf8Str strName;
832 StorageBus_T storageBus; // _SATA, _SCSI, _IDE, _SAS
833 StorageControllerType_T controllerType;
834 uint32_t ulPortCount;
835 uint32_t ulInstance;
836 bool fUseHostIOCache;
837 bool fBootable;
838
839 // only for when controllerType == StorageControllerType_IntelAhci:
840 int32_t lIDE0MasterEmulationPort,
841 lIDE0SlaveEmulationPort,
842 lIDE1MasterEmulationPort,
843 lIDE1SlaveEmulationPort;
844
845 AttachedDevicesList llAttachedDevices;
846};
847
848typedef std::list<StorageController> StorageControllersList;
849
850/**
851 * We wrap the storage controllers list into an extra struct so we can
852 * use an undefined struct without needing std::list<> in all the headers.
853 *
854 * NOTE: If you add any fields in here, you must update a) the constructor and b)
855 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
856 * your settings might never get saved.
857 */
858struct Storage
859{
860 bool operator==(const Storage &s) const;
861
862 StorageControllersList llStorageControllers;
863};
864
865/**
866 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
867 * field.
868 *
869 * NOTE: If you add any fields in here, you must update a) the constructor and b)
870 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
871 * your settings might never get saved.
872 */
873struct Hardware
874{
875 Hardware();
876
877 bool areParavirtDefaultSettings(SettingsVersion_T sv) const;
878 bool areBootOrderDefaultSettings() const;
879 bool areDisplayDefaultSettings() const;
880 bool areVideoCaptureDefaultSettings() const;
881 bool areAllNetworkAdaptersDefaultSettings(SettingsVersion_T sv) const;
882
883 bool operator==(const Hardware&) const;
884
885 com::Utf8Str strVersion; // hardware version, optional
886 com::Guid uuid; // hardware uuid, optional (null).
887
888 bool fHardwareVirt,
889 fNestedPaging,
890 fLargePages,
891 fVPID,
892 fUnrestrictedExecution,
893 fHardwareVirtForce,
894 fSyntheticCpu,
895 fTripleFaultReset,
896 fPAE,
897 fAPIC, // requires settings version 1.16 (VirtualBox 5.1)
898 fX2APIC; // requires settings version 1.16 (VirtualBox 5.1)
899 typedef enum LongModeType { LongMode_Enabled, LongMode_Disabled, LongMode_Legacy } LongModeType;
900 LongModeType enmLongMode;
901 uint32_t cCPUs;
902 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
903 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
904 bool fHPETEnabled; // requires settings version 1.10 (VirtualBox 3.2)
905 uint32_t ulCpuExecutionCap; // requires settings version 1.11 (VirtualBox 3.3)
906 uint32_t uCpuIdPortabilityLevel; // requires settings version 1.15 (VirtualBox 5.0)
907 com::Utf8Str strCpuProfile; // requires settings version 1.16 (VirtualBox 5.1)
908
909 CpuIdLeafsList llCpuIdLeafs;
910
911 uint32_t ulMemorySizeMB;
912
913 BootOrderMap mapBootOrder; // item 0 has highest priority
914
915 GraphicsControllerType_T graphicsControllerType;
916 uint32_t ulVRAMSizeMB;
917 uint32_t cMonitors;
918 bool fAccelerate3D,
919 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
920
921 uint32_t ulVideoCaptureHorzRes; // requires settings version 1.14 (VirtualBox 4.3)
922 uint32_t ulVideoCaptureVertRes; // requires settings version 1.14 (VirtualBox 4.3)
923 uint32_t ulVideoCaptureRate; // requires settings version 1.14 (VirtualBox 4.3)
924 uint32_t ulVideoCaptureFPS; // requires settings version 1.14 (VirtualBox 4.3)
925 uint32_t ulVideoCaptureMaxTime; // requires settings version 1.14 (VirtualBox 4.3)
926 uint32_t ulVideoCaptureMaxSize; // requires settings version 1.14 (VirtualBox 4.3)
927 bool fVideoCaptureEnabled; // requires settings version 1.14 (VirtualBox 4.3)
928 uint64_t u64VideoCaptureScreens; // requires settings version 1.14 (VirtualBox 4.3)
929 com::Utf8Str strVideoCaptureFile; // requires settings version 1.14 (VirtualBox 4.3)
930
931 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
932
933 PointingHIDType_T pointingHIDType; // requires settings version 1.10 (VirtualBox 3.2)
934 KeyboardHIDType_T keyboardHIDType; // requires settings version 1.10 (VirtualBox 3.2)
935
936 ChipsetType_T chipsetType; // requires settings version 1.11 (VirtualBox 4.0)
937 ParavirtProvider_T paravirtProvider; // requires settings version 1.15 (VirtualBox 4.4)
938 com::Utf8Str strParavirtDebug; // requires settings version 1.16 (VirtualBox 5.1)
939
940 bool fEmulatedUSBCardReader; // 1.12 (VirtualBox 4.1)
941
942 VRDESettings vrdeSettings;
943
944 BIOSSettings biosSettings;
945 USB usbSettings;
946 NetworkAdaptersList llNetworkAdapters;
947 SerialPortsList llSerialPorts;
948 ParallelPortsList llParallelPorts;
949 AudioAdapter audioAdapter;
950 Storage storage;
951
952 // technically these two have no business in the hardware section, but for some
953 // clever reason <Hardware> is where they are in the XML....
954 SharedFoldersList llSharedFolders;
955 ClipboardMode_T clipboardMode;
956 DnDMode_T dndMode;
957
958 uint32_t ulMemoryBalloonSize;
959 bool fPageFusionEnabled;
960
961 GuestPropertiesList llGuestProperties;
962
963 IOSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
964 HostPCIDeviceAttachmentList pciAttachments; // requires settings version 1.12 (VirtualBox 4.1)
965
966 com::Utf8Str strDefaultFrontend; // requires settings version 1.14 (VirtualBox 4.3)
967};
968
969/**
970 * Settings that has to do with debugging.
971 */
972struct Debugging
973{
974 Debugging();
975
976 bool areDefaultSettings() const;
977
978 bool operator==(const Debugging &rOther) const;
979
980 bool fTracingEnabled;
981 bool fAllowTracingToAccessVM;
982 com::Utf8Str strTracingConfig;
983};
984
985/**
986 * Settings that has to do with autostart.
987 */
988struct Autostart
989{
990 Autostart();
991
992 bool areDefaultSettings() const;
993
994 bool operator==(const Autostart &rOther) const;
995
996 bool fAutostartEnabled;
997 uint32_t uAutostartDelay;
998 AutostopType_T enmAutostopType;
999};
1000
1001struct Snapshot;
1002typedef std::list<Snapshot> SnapshotsList;
1003
1004/**
1005 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1006 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1007 * your settings might never get saved.
1008 */
1009struct Snapshot
1010{
1011 Snapshot();
1012
1013 bool operator==(const Snapshot &s) const;
1014
1015 com::Guid uuid;
1016 com::Utf8Str strName,
1017 strDescription; // optional
1018 RTTIMESPEC timestamp;
1019
1020 com::Utf8Str strStateFile; // for online snapshots only
1021
1022 Hardware hardware;
1023
1024 Debugging debugging;
1025 Autostart autostart;
1026
1027 SnapshotsList llChildSnapshots;
1028
1029 static const struct Snapshot Empty;
1030};
1031
1032/**
1033 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1034 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
1035 * your settings might never get saved.
1036 */
1037struct MachineUserData
1038{
1039 MachineUserData();
1040
1041 bool operator==(const MachineUserData &c) const;
1042
1043 com::Utf8Str strName;
1044 bool fDirectoryIncludesUUID;
1045 bool fNameSync;
1046 com::Utf8Str strDescription;
1047 StringsList llGroups;
1048 com::Utf8Str strOsType;
1049 com::Utf8Str strSnapshotFolder;
1050 bool fTeleporterEnabled;
1051 uint32_t uTeleporterPort;
1052 com::Utf8Str strTeleporterAddress;
1053 com::Utf8Str strTeleporterPassword;
1054 FaultToleranceState_T enmFaultToleranceState;
1055 uint32_t uFaultTolerancePort;
1056 com::Utf8Str strFaultToleranceAddress;
1057 com::Utf8Str strFaultTolerancePassword;
1058 uint32_t uFaultToleranceInterval;
1059 bool fRTCUseUTC;
1060 IconBlob ovIcon;
1061 com::Utf8Str strVMPriority;
1062};
1063
1064
1065/**
1066 * MachineConfigFile represents an XML machine configuration. All the machine settings
1067 * that go out to the XML (or are read from it) are in here.
1068 *
1069 * NOTE: If you add any fields in here, you must update a) the constructor and b)
1070 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
1071 * might never get saved.
1072 */
1073class MachineConfigFile : public ConfigFileBase
1074{
1075public:
1076 com::Guid uuid;
1077
1078 MachineUserData machineUserData;
1079
1080 com::Utf8Str strStateFile;
1081 bool fCurrentStateModified; // optional, default is true
1082 RTTIMESPEC timeLastStateChange; // optional, defaults to now
1083 bool fAborted; // optional, default is false
1084
1085 com::Guid uuidCurrentSnapshot;
1086
1087 Hardware hardwareMachine;
1088 MediaRegistry mediaRegistry;
1089 Debugging debugging;
1090 Autostart autostart;
1091
1092 StringsMap mapExtraDataItems;
1093
1094 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
1095
1096 MachineConfigFile(const com::Utf8Str *pstrFilename);
1097
1098 bool operator==(const MachineConfigFile &m) const;
1099
1100 bool canHaveOwnMediaRegistry() const;
1101
1102 void importMachineXML(const xml::ElementNode &elmMachine);
1103
1104 void write(const com::Utf8Str &strFilename);
1105
1106 enum
1107 {
1108 BuildMachineXML_IncludeSnapshots = 0x01,
1109 BuildMachineXML_WriteVBoxVersionAttribute = 0x02,
1110 BuildMachineXML_SkipRemovableMedia = 0x04,
1111 BuildMachineXML_MediaRegistry = 0x08,
1112 BuildMachineXML_SuppressSavedState = 0x10
1113 };
1114 void buildMachineXML(xml::ElementNode &elmMachine,
1115 uint32_t fl,
1116 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1117
1118 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T drv);
1119 static AudioDriverType_T getHostDefaultAudioDriver();
1120
1121private:
1122 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
1123 void readAttachedNetworkMode(const xml::ElementNode &pelmMode, bool fEnabled, NetworkAdapter &nic);
1124 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
1125 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
1126 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
1127 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
1128 void readAudioAdapter(const xml::ElementNode &elmAudioAdapter, AudioAdapter &aa);
1129 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
1130 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
1131 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw);
1132 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
1133 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
1134 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
1135 void readTeleporter(const xml::ElementNode *pElmTeleporter, MachineUserData *pUserData);
1136 void readDebugging(const xml::ElementNode *pElmDbg, Debugging *pDbg);
1137 void readAutostart(const xml::ElementNode *pElmAutostart, Autostart *pAutostart);
1138 void readGroups(const xml::ElementNode *elmGroups, StringsList *pllGroups);
1139 bool readSnapshot(const com::Guid &curSnapshotUuid, uint32_t depth, const xml::ElementNode &elmSnapshot, Snapshot &snap);
1140 void convertOldOSType_pre1_5(com::Utf8Str &str);
1141 void readMachine(const xml::ElementNode &elmMachine);
1142
1143 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, uint32_t fl, std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1144 void buildNetworkXML(NetworkAttachmentType_T mode, bool fEnabled, xml::ElementNode &elmParent, const NetworkAdapter &nic);
1145 void buildStorageControllersXML(xml::ElementNode &elmParent,
1146 const Storage &st,
1147 bool fSkipRemovableMedia,
1148 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1149 void buildDebuggingXML(xml::ElementNode *pElmParent, const Debugging *pDbg);
1150 void buildAutostartXML(xml::ElementNode *pElmParent, const Autostart *pAutostart);
1151 void buildGroupsXML(xml::ElementNode *pElmParent, const StringsList *pllGroups);
1152 void buildSnapshotXML(uint32_t depth, xml::ElementNode &elmParent, const Snapshot &snap);
1153
1154 void bumpSettingsVersionIfNeeded();
1155};
1156
1157} // namespace settings
1158
1159
1160#endif /* ___VBox_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