VirtualBox

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

Last change on this file since 41737 was 41371, checked in by vboxsync, 13 years ago

Main,include,VBoxManage: smartcard support: IMachine::EmulatedUSBCardReaderEnabled.

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