VirtualBox

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

Last change on this file since 74431 was 74431, checked in by vboxsync, 6 years ago

Main,GUI,VBoxManage: Provide API for proxy settings that picks up the current GUI settings and converts it to SystemProperties XML attributes. Adjusted GUI to use it. Updated VBoxMangage system properties handling accordingly. bugref:9249

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

© 2023 Oracle
ContactPrivacy policyTerms of Use