VirtualBox

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

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

potentially uninitialized variable

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