VirtualBox

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

Last change on this file since 42192 was 42179, checked in by vboxsync, 13 years ago

Missing changes

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