VirtualBox

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

Last change on this file since 44399 was 44191, checked in by vboxsync, 12 years ago

include,ExtPacks\Puel\UsbWebcam,Main,VRDP,VBoxManage: emulated USB webcam.

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