VirtualBox

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

Last change on this file since 35184 was 35146, checked in by vboxsync, 14 years ago

VRDE: use VRDE properties for video redirection settings.

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