VirtualBox

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

Last change on this file since 45786 was 45660, checked in by vboxsync, 12 years ago

Main/Machine+Console+Settings: add graphics controller type setting, preparing for the fututure, plus some whitespace cleanup

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