VirtualBox

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

Last change on this file since 46228 was 46123, checked in by vboxsync, 12 years ago

Main/VPX, VBoxManage: added IMachine::VideoCaptureScreens and IDisplay::{enableVideoCapture,disableVideoCapture}

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette