VirtualBox

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

Last change on this file since 42177 was 42176, checked in by vboxsync, 13 years ago

Main+Frontends/VBoxManage: implement saving the settings, and add the matching VBoxManage support

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