VirtualBox

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

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

Missing update

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