VirtualBox

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

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

Added a promiscModePolicy attribute to INetworkAdapter, three values: deny (default), allow-network (i.e. VMs), allow-all (i.e. include unrelated host traffic).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 34.7 KB
Line 
1/** @file
2 * Settings file data structures.
3 *
4 * These structures are created by the settings file loader and filled with values
5 * copied from the raw XML data. This was all new with VirtualBox 3.1 and allows us
6 * to finally make the XML reader version-independent and read VirtualBox XML files
7 * from earlier and even newer (future) versions without requiring complicated,
8 * tedious and error-prone XSLT conversions.
9 *
10 * It is this file that defines all structures that map VirtualBox global and
11 * machine settings to XML files. These structures are used by the rest of Main,
12 * even though this header file does not require anything else in Main.
13 *
14 * Note: Headers in Main code have been tweaked to only declare the structures
15 * defined here so that this header need only be included from code files that
16 * actually use these structures.
17 */
18
19/*
20 * Copyright (C) 2007-2010 Oracle Corporation
21 *
22 * This file is part of VirtualBox Open Source Edition (OSE), as
23 * available from http://www.virtualbox.org. This file is free software;
24 * you can redistribute it and/or modify it under the terms of the GNU
25 * General Public License (GPL) as published by the Free Software
26 * Foundation, in version 2 as it comes in the "COPYING" file of the
27 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
28 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
29 *
30 * The contents of this file may alternatively be used under the terms
31 * of the Common Development and Distribution License Version 1.0
32 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
33 * VirtualBox OSE distribution, in which case the provisions of the
34 * CDDL are applicable instead of those of the GPL.
35 *
36 * You may elect to license modified versions of this file under the
37 * terms and conditions of either the GPL or the CDDL or both.
38 */
39
40#ifndef ___VBox_settings_h
41#define ___VBox_settings_h
42
43#include <iprt/time.h>
44
45#include "VBox/com/VirtualBox.h"
46
47#include <VBox/com/Guid.h>
48#include <VBox/com/string.h>
49
50#include <list>
51#include <map>
52
53namespace xml
54{
55 class ElementNode;
56}
57
58namespace settings
59{
60
61class ConfigFileError;
62
63////////////////////////////////////////////////////////////////////////////////
64//
65// Structures shared between Machine XML and VirtualBox.xml
66//
67////////////////////////////////////////////////////////////////////////////////
68
69/**
70 * USB device filter definition. This struct is used both in MainConfigFile
71 * (for global USB filters) and MachineConfigFile (for machine filters).
72 *
73 * NOTE: If you add any fields in here, you must update a) the constructor and b)
74 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
75 * your settings might never get saved.
76 */
77struct USBDeviceFilter
78{
79 USBDeviceFilter()
80 : fActive(false),
81 action(USBDeviceFilterAction_Null),
82 ulMaskedInterfaces(0)
83 {}
84
85 bool operator==(const USBDeviceFilter&u) const;
86
87 com::Utf8Str strName;
88 bool fActive;
89 com::Utf8Str strVendorId,
90 strProductId,
91 strRevision,
92 strManufacturer,
93 strProduct,
94 strSerialNumber,
95 strPort;
96 USBDeviceFilterAction_T action; // only used with host USB filters
97 com::Utf8Str strRemote; // irrelevant for host USB objects
98 uint32_t ulMaskedInterfaces; // irrelevant for host USB objects
99};
100
101typedef std::map<com::Utf8Str, com::Utf8Str> StringsMap;
102
103// ExtraDataItem (used by both VirtualBox.xml and machines XML)
104struct USBDeviceFilter;
105typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
106
107struct Medium;
108typedef std::list<Medium> MediaList;
109
110/**
111 * NOTE: If you add any fields in here, you must update a) the constructor and b)
112 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
113 * your settings might never get saved.
114 */
115struct Medium
116{
117 com::Guid uuid;
118 com::Utf8Str strLocation;
119 com::Utf8Str strDescription;
120
121 // the following are for hard disks only:
122 com::Utf8Str strFormat;
123 bool fAutoReset; // optional, only for diffs, default is false
124 StringsMap properties;
125 MediumType_T hdType;
126
127 MediaList llChildren; // only used with hard disks
128
129 bool operator==(const Medium &m) const;
130};
131
132/**
133 * A media registry. Starting with VirtualBox 3.3, this can appear in both the
134 * VirtualBox.xml file as well as machine XML files with settings version 1.11
135 * or higher, so these lists are now in ConfigFileBase.
136 *
137 * NOTE: If you add any fields in here, you must update a) the constructor and b)
138 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
139 * your settings might never get saved.
140 */
141struct MediaRegistry
142{
143 MediaList llHardDisks,
144 llDvdImages,
145 llFloppyImages;
146
147 bool operator==(const MediaRegistry &m) const;
148};
149
150/**
151 * Common base class for both MainConfigFile and MachineConfigFile
152 * which contains some common logic for both.
153 */
154class ConfigFileBase
155{
156public:
157 bool fileExists();
158
159 void copyBaseFrom(const ConfigFileBase &b);
160
161protected:
162 ConfigFileBase(const com::Utf8Str *pstrFilename);
163 ~ConfigFileBase();
164
165 void parseUUID(com::Guid &guid,
166 const com::Utf8Str &strUUID) const;
167 void parseTimestamp(RTTIMESPEC &timestamp,
168 const com::Utf8Str &str) const;
169
170 com::Utf8Str makeString(const RTTIMESPEC &tm);
171
172 void readExtraData(const xml::ElementNode &elmExtraData,
173 StringsMap &map);
174 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
175 USBDeviceFiltersList &ll);
176 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
177 void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia);
178 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr);
179
180 void setVersionAttribute(xml::ElementNode &elm);
181 void createStubDocument();
182
183 void buildExtraData(xml::ElementNode &elmParent, const StringsMap &me);
184 void buildUSBDeviceFilters(xml::ElementNode &elmParent,
185 const USBDeviceFiltersList &ll,
186 bool fHostMode);
187 void buildMedium(xml::ElementNode &elmMedium,
188 DeviceType_T devType,
189 const Medium &m,
190 uint32_t level);
191 void buildMediaRegistry(xml::ElementNode &elmParent,
192 const MediaRegistry &mr);
193 void clearDocument();
194
195 struct Data;
196 Data *m;
197
198private:
199 // prohibit copying (Data contains pointers to XML which cannot be copied)
200 ConfigFileBase(const ConfigFileBase&);
201
202 friend class ConfigFileError;
203};
204
205////////////////////////////////////////////////////////////////////////////////
206//
207// VirtualBox.xml structures
208//
209////////////////////////////////////////////////////////////////////////////////
210
211struct Host
212{
213 USBDeviceFiltersList llUSBDeviceFilters;
214};
215
216struct SystemProperties
217{
218 SystemProperties()
219 : ulLogHistoryCount(3)
220 {}
221
222 com::Utf8Str strDefaultMachineFolder;
223 com::Utf8Str strDefaultHardDiskFolder;
224 com::Utf8Str strDefaultHardDiskFormat;
225 com::Utf8Str strVRDEAuthLibrary;
226 com::Utf8Str strWebServiceAuthLibrary;
227 com::Utf8Str strDefaultVRDEExtPack;
228 uint32_t ulLogHistoryCount;
229};
230
231struct MachineRegistryEntry
232{
233 com::Guid uuid;
234 com::Utf8Str strSettingsFile;
235};
236typedef std::list<MachineRegistryEntry> MachinesRegistry;
237
238struct DHCPServer
239{
240 com::Utf8Str strNetworkName,
241 strIPAddress,
242 strIPNetworkMask,
243 strIPLower,
244 strIPUpper;
245 bool fEnabled;
246};
247typedef std::list<DHCPServer> DHCPServersList;
248
249class MainConfigFile : public ConfigFileBase
250{
251public:
252 MainConfigFile(const com::Utf8Str *pstrFilename);
253
254 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry);
255 void readDHCPServers(const xml::ElementNode &elmDHCPServers);
256
257 void write(const com::Utf8Str strFilename);
258
259 Host host;
260 SystemProperties systemProperties;
261 MediaRegistry mediaRegistry;
262 MachinesRegistry llMachines;
263 DHCPServersList llDhcpServers;
264 StringsMap mapExtraDataItems;
265};
266
267////////////////////////////////////////////////////////////////////////////////
268//
269// Machine XML structures
270//
271////////////////////////////////////////////////////////////////////////////////
272
273/**
274 * NOTE: If you add any fields in here, you must update a) the constructor and b)
275 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
276 * your settings might never get saved.
277 */
278struct VRDESettings
279{
280 VRDESettings()
281 : fEnabled(true),
282 authType(AuthType_Null),
283 ulAuthTimeout(5000),
284 fAllowMultiConnection(false),
285 fReuseSingleConnection(false)
286 {}
287
288 bool operator==(const VRDESettings& v) const;
289
290 bool fEnabled;
291 AuthType_T authType;
292 uint32_t ulAuthTimeout;
293 com::Utf8Str strAuthLibrary;
294 bool fAllowMultiConnection,
295 fReuseSingleConnection;
296 com::Utf8Str strVrdeExtPack;
297 StringsMap mapProperties;
298};
299
300/**
301 * NOTE: If you add any fields in here, you must update a) the constructor and b)
302 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
303 * your settings might never get saved.
304 */
305struct BIOSSettings
306{
307 BIOSSettings()
308 : fACPIEnabled(true),
309 fIOAPICEnabled(false),
310 fLogoFadeIn(true),
311 fLogoFadeOut(true),
312 ulLogoDisplayTime(0),
313 biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
314 fPXEDebugEnabled(false),
315 llTimeOffset(0)
316 {}
317
318 bool operator==(const BIOSSettings &d) const;
319
320 bool fACPIEnabled,
321 fIOAPICEnabled,
322 fLogoFadeIn,
323 fLogoFadeOut;
324 uint32_t ulLogoDisplayTime;
325 com::Utf8Str strLogoImagePath;
326 BIOSBootMenuMode_T biosBootMenuMode;
327 bool fPXEDebugEnabled;
328 int64_t llTimeOffset;
329};
330
331/**
332 * NOTE: If you add any fields in here, you must update a) the constructor and b)
333 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
334 * your settings might never get saved.
335 */
336struct USBController
337{
338 USBController()
339 : fEnabled(false),
340 fEnabledEHCI(false)
341 {}
342
343 bool operator==(const USBController &u) const;
344
345 bool fEnabled;
346 bool fEnabledEHCI;
347 USBDeviceFiltersList llDeviceFilters;
348};
349
350 struct NATRule
351 {
352 NATRule(): proto(NATProtocol_TCP),
353 u16HostPort(0),
354 u16GuestPort(0){}
355 com::Utf8Str strName;
356 NATProtocol_T proto;
357 uint16_t u16HostPort;
358 com::Utf8Str strHostIP;
359 uint16_t u16GuestPort;
360 com::Utf8Str strGuestIP;
361 bool operator==(const NATRule &r) const
362 {
363 return strName == r.strName
364 && proto == r.proto
365 && u16HostPort == r.u16HostPort
366 && strHostIP == r.strHostIP
367 && u16GuestPort == r.u16GuestPort
368 && strGuestIP == r.strGuestIP;
369 }
370 };
371 typedef std::list<NATRule> NATRuleList;
372
373 struct NAT
374 {
375 NAT() : u32Mtu(0),
376 u32SockRcv(0),
377 u32SockSnd(0),
378 u32TcpRcv(0),
379 u32TcpSnd(0),
380 fDnsPassDomain(true), /* historically this value is true */
381 fDnsProxy(false),
382 fDnsUseHostResolver(false),
383 fAliasLog(false),
384 fAliasProxyOnly(false),
385 fAliasUseSamePorts(false)
386 {}
387
388 com::Utf8Str strNetwork;
389 com::Utf8Str strBindIP;
390 uint32_t u32Mtu;
391 uint32_t u32SockRcv;
392 uint32_t u32SockSnd;
393 uint32_t u32TcpRcv;
394 uint32_t u32TcpSnd;
395 com::Utf8Str strTftpPrefix;
396 com::Utf8Str strTftpBootFile;
397 com::Utf8Str strTftpNextServer;
398 bool fDnsPassDomain;
399 bool fDnsProxy;
400 bool fDnsUseHostResolver;
401 bool fAliasLog;
402 bool fAliasProxyOnly;
403 bool fAliasUseSamePorts;
404 NATRuleList llRules;
405 bool operator==(const NAT &n) const
406 {
407 return strNetwork == n.strNetwork
408 && strBindIP == n.strBindIP
409 && u32Mtu == n.u32Mtu
410 && u32SockRcv == n.u32SockRcv
411 && u32SockSnd == n.u32SockSnd
412 && u32TcpSnd == n.u32TcpSnd
413 && u32TcpRcv == n.u32TcpRcv
414 && strTftpPrefix == n.strTftpPrefix
415 && strTftpBootFile == n.strTftpBootFile
416 && strTftpNextServer == n.strTftpNextServer
417 && fDnsPassDomain == n.fDnsPassDomain
418 && fDnsProxy == n.fDnsProxy
419 && fDnsUseHostResolver == n.fDnsUseHostResolver
420 && fAliasLog == n.fAliasLog
421 && fAliasProxyOnly == n.fAliasProxyOnly
422 && fAliasUseSamePorts == n.fAliasUseSamePorts
423 && llRules == n.llRules;
424 }
425 };
426/**
427 * NOTE: If you add any fields in here, you must update a) the constructor and b)
428 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
429 * your settings might never get saved.
430 */
431struct NetworkAdapter
432{
433 NetworkAdapter()
434 : ulSlot(0),
435 type(NetworkAdapterType_Am79C970A),
436 fEnabled(false),
437 fCableConnected(false),
438 ulLineSpeed(0),
439 enmPromiscModePolicy(NetworkAdapterPromiscModePolicy_Deny),
440 fTraceEnabled(false),
441 mode(NetworkAttachmentType_Null),
442 ulBootPriority(0),
443 fHasDisabledNAT(false),
444 ulBandwidthLimit(0)
445 {}
446
447 bool operator==(const NetworkAdapter &n) const;
448
449 uint32_t ulSlot;
450
451 NetworkAdapterType_T type;
452 bool fEnabled;
453 com::Utf8Str strMACAddress;
454 bool fCableConnected;
455 uint32_t ulLineSpeed;
456 NetworkAdapterPromiscModePolicy_T enmPromiscModePolicy;
457 bool fTraceEnabled;
458 com::Utf8Str strTraceFile;
459
460 NetworkAttachmentType_T mode;
461 NAT nat;
462 /**
463 * @remarks NAT has own attribute with bridged: host interface or empty;
464 * otherwise: network name (required) */
465 com::Utf8Str strName;
466 uint32_t ulBootPriority;
467 bool fHasDisabledNAT;
468 uint32_t ulBandwidthLimit;
469};
470typedef std::list<NetworkAdapter> NetworkAdaptersList;
471
472/**
473 * NOTE: If you add any fields in here, you must update a) the constructor and b)
474 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
475 * your settings might never get saved.
476 */
477struct SerialPort
478{
479 SerialPort()
480 : ulSlot(0),
481 fEnabled(false),
482 ulIOBase(0x3f8),
483 ulIRQ(4),
484 portMode(PortMode_Disconnected),
485 fServer(false)
486 {}
487
488 bool operator==(const SerialPort &n) const;
489
490 uint32_t ulSlot;
491
492 bool fEnabled;
493 uint32_t ulIOBase;
494 uint32_t ulIRQ;
495 PortMode_T portMode;
496 com::Utf8Str strPath;
497 bool fServer;
498};
499typedef std::list<SerialPort> SerialPortsList;
500
501/**
502 * NOTE: If you add any fields in here, you must update a) the constructor and b)
503 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
504 * your settings might never get saved.
505 */
506struct ParallelPort
507{
508 ParallelPort()
509 : ulSlot(0),
510 fEnabled(false),
511 ulIOBase(0x378),
512 ulIRQ(4)
513 {}
514
515 bool operator==(const ParallelPort &d) const;
516
517 uint32_t ulSlot;
518
519 bool fEnabled;
520 uint32_t ulIOBase;
521 uint32_t ulIRQ;
522 com::Utf8Str strPath;
523};
524typedef std::list<ParallelPort> ParallelPortsList;
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 AudioAdapter
532{
533 AudioAdapter()
534 : fEnabled(true),
535 controllerType(AudioControllerType_AC97),
536 driverType(AudioDriverType_Null)
537 {}
538
539 bool operator==(const AudioAdapter &a) const
540 {
541 return (this == &a)
542 || ( (fEnabled == a.fEnabled)
543 && (controllerType == a.controllerType)
544 && (driverType == a.driverType)
545 );
546 }
547
548 bool fEnabled;
549 AudioControllerType_T controllerType;
550 AudioDriverType_T driverType;
551};
552
553/**
554 * NOTE: If you add any fields in here, you must update a) the constructor and b)
555 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
556 * your settings might never get saved.
557 */
558struct SharedFolder
559{
560 SharedFolder()
561 : fWritable(false)
562 , fAutoMount(false)
563 {}
564
565 bool operator==(const SharedFolder &a) const;
566
567 com::Utf8Str strName,
568 strHostPath;
569 bool fWritable;
570 bool fAutoMount;
571};
572typedef std::list<SharedFolder> SharedFoldersList;
573
574/**
575 * NOTE: If you add any fields in here, you must update a) the constructor and b)
576 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
577 * your settings might never get saved.
578 */
579struct GuestProperty
580{
581 GuestProperty()
582 : timestamp(0)
583 {};
584
585 bool operator==(const GuestProperty &g) const;
586
587 com::Utf8Str strName,
588 strValue;
589 uint64_t timestamp;
590 com::Utf8Str strFlags;
591};
592typedef std::list<GuestProperty> GuestPropertiesList;
593
594typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
595
596/**
597 * NOTE: If you add any fields in here, you must update a) the constructor and b)
598 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
599 * your settings might never get saved.
600 */
601struct CpuIdLeaf
602{
603 CpuIdLeaf()
604 : ulId(UINT32_MAX),
605 ulEax(0),
606 ulEbx(0),
607 ulEcx(0),
608 ulEdx(0)
609 {}
610
611 bool operator==(const CpuIdLeaf &c) const
612 {
613 return ( (this == &c)
614 || ( (ulId == c.ulId)
615 && (ulEax == c.ulEax)
616 && (ulEbx == c.ulEbx)
617 && (ulEcx == c.ulEcx)
618 && (ulEdx == c.ulEdx)
619 )
620 );
621 }
622
623 uint32_t ulId;
624 uint32_t ulEax;
625 uint32_t ulEbx;
626 uint32_t ulEcx;
627 uint32_t ulEdx;
628};
629typedef std::list<CpuIdLeaf> CpuIdLeafsList;
630
631/**
632 * NOTE: If you add any fields in here, you must update a) the constructor and b)
633 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
634 * your settings might never get saved.
635 */
636struct Cpu
637{
638 Cpu()
639 : ulId(UINT32_MAX)
640 {}
641
642 bool operator==(const Cpu &c) const
643 {
644 return (ulId == c.ulId);
645 }
646
647 uint32_t ulId;
648};
649typedef std::list<Cpu> CpuList;
650
651/**
652 * NOTE: If you add any fields in here, you must update a) the constructor and b)
653 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
654 * your settings might never get saved.
655 */
656struct BandwidthGroup
657{
658 BandwidthGroup()
659 : cMaxMbPerSec(0),
660 enmType(BandwidthGroupType_Null)
661 {}
662
663 bool operator==(const BandwidthGroup &i) const
664 {
665 return ( (strName == i.strName)
666 && (cMaxMbPerSec == i.cMaxMbPerSec)
667 && (enmType == i.enmType));
668 }
669
670 com::Utf8Str strName;
671 uint32_t cMaxMbPerSec;
672 BandwidthGroupType_T enmType;
673};
674typedef std::list<BandwidthGroup> BandwidthGroupList;
675
676/**
677 * NOTE: If you add any fields in here, you must update a) the constructor and b)
678 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
679 * your settings might never get saved.
680 */
681struct IoSettings
682{
683 IoSettings();
684
685 bool operator==(const IoSettings &i) const
686 {
687 return ( (fIoCacheEnabled == i.fIoCacheEnabled)
688 && (ulIoCacheSize == i.ulIoCacheSize)
689 && (llBandwidthGroups == i.llBandwidthGroups));
690 }
691
692 bool fIoCacheEnabled;
693 uint32_t ulIoCacheSize;
694 BandwidthGroupList llBandwidthGroups;
695};
696
697/**
698 * NOTE: If you add any fields in here, you must update a) the constructor and b)
699 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
700 * your settings might never get saved.
701 */
702struct HostPciDeviceAttachment
703{
704 HostPciDeviceAttachment()
705 : uHostAddress(0),
706 uGuestAddress(0)
707 {}
708
709 bool operator==(const HostPciDeviceAttachment &a) const
710 {
711 return ( (uHostAddress == a.uHostAddress)
712 && (uGuestAddress == a.uGuestAddress)
713 && (strDeviceName == a.strDeviceName)
714 );
715 }
716
717 com::Utf8Str strDeviceName;
718 uint32_t uHostAddress;
719 uint32_t uGuestAddress;
720};
721typedef std::list<HostPciDeviceAttachment> HostPciDeviceAttachmentList;
722
723/**
724 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
725 * field.
726 *
727 * NOTE: If you add any fields in here, you must update a) the constructor and b)
728 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
729 * your settings might never get saved.
730 */
731struct Hardware
732{
733 Hardware();
734
735 bool operator==(const Hardware&) const;
736
737 com::Utf8Str strVersion; // hardware version, optional
738 com::Guid uuid; // hardware uuid, optional (null).
739
740 bool fHardwareVirt,
741 fHardwareVirtExclusive,
742 fNestedPaging,
743 fLargePages,
744 fVPID,
745 fHardwareVirtForce,
746 fSyntheticCpu,
747 fPAE;
748 uint32_t cCPUs;
749 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
750 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
751 bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
752 uint32_t ulCpuExecutionCap; // requires settings version 1.11 (VirtualBox 3.3)
753
754 CpuIdLeafsList llCpuIdLeafs;
755
756 uint32_t ulMemorySizeMB;
757
758 BootOrderMap mapBootOrder; // item 0 has highest priority
759
760 uint32_t ulVRAMSizeMB;
761 uint32_t cMonitors;
762 bool fAccelerate3D,
763 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
764 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
765
766 PointingHidType_T pointingHidType; // requires settings version 1.10 (VirtualBox 3.2)
767 KeyboardHidType_T keyboardHidType; // requires settings version 1.10 (VirtualBox 3.2)
768
769 ChipsetType_T chipsetType; // requires settings version 1.11 (VirtualBox 4.0)
770
771 VRDESettings vrdeSettings;
772
773 BIOSSettings biosSettings;
774 USBController usbController;
775 NetworkAdaptersList llNetworkAdapters;
776 SerialPortsList llSerialPorts;
777 ParallelPortsList llParallelPorts;
778 AudioAdapter audioAdapter;
779
780 // technically these two have no business in the hardware section, but for some
781 // clever reason <Hardware> is where they are in the XML....
782 SharedFoldersList llSharedFolders;
783 ClipboardMode_T clipboardMode;
784
785 uint32_t ulMemoryBalloonSize;
786 bool fPageFusionEnabled;
787
788 GuestPropertiesList llGuestProperties;
789 com::Utf8Str strNotificationPatterns;
790
791 IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
792 HostPciDeviceAttachmentList pciAttachments; // requires settings version 1.12 (VirtualBox 4.1)
793};
794
795/**
796 * A device attached to a storage controller. This can either be a
797 * hard disk or a DVD drive or a floppy drive and also specifies
798 * which medium is "in" the drive; as a result, this is a combination
799 * of the Main IMedium and IMediumAttachment interfaces.
800 *
801 * NOTE: If you add any fields in here, you must update a) the constructor and b)
802 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
803 * your settings might never get saved.
804 */
805struct AttachedDevice
806{
807 AttachedDevice()
808 : deviceType(DeviceType_Null),
809 fPassThrough(false),
810 lPort(0),
811 lDevice(0)
812 {}
813
814 bool operator==(const AttachedDevice &a) const;
815
816 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
817
818 // DVDs can be in pass-through mode:
819 bool fPassThrough;
820
821 int32_t lPort;
822 int32_t lDevice;
823
824 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
825 // this is its UUID; it depends on deviceType which media registry this then needs to
826 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
827 com::Guid uuid;
828
829 // for DVDs and floppies, the attachment can also be a host device:
830 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
831
832 // Bandwidth group the device is attached to.
833 com::Utf8Str strBwGroup;
834};
835typedef std::list<AttachedDevice> AttachedDevicesList;
836
837/**
838 * NOTE: If you add any fields in here, you must update a) the constructor and b)
839 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
840 * your settings might never get saved.
841 */
842struct StorageController
843{
844 StorageController()
845 : storageBus(StorageBus_IDE),
846 controllerType(StorageControllerType_PIIX3),
847 ulPortCount(2),
848 ulInstance(0),
849 fUseHostIOCache(true),
850 fBootable(true),
851 lIDE0MasterEmulationPort(0),
852 lIDE0SlaveEmulationPort(0),
853 lIDE1MasterEmulationPort(0),
854 lIDE1SlaveEmulationPort(0)
855 {}
856
857 bool operator==(const StorageController &s) const;
858
859 com::Utf8Str strName;
860 StorageBus_T storageBus; // _SATA, _SCSI, _IDE, _SAS
861 StorageControllerType_T controllerType;
862 uint32_t ulPortCount;
863 uint32_t ulInstance;
864 bool fUseHostIOCache;
865 bool fBootable;
866
867 // only for when controllerType == StorageControllerType_IntelAhci:
868 int32_t lIDE0MasterEmulationPort,
869 lIDE0SlaveEmulationPort,
870 lIDE1MasterEmulationPort,
871 lIDE1SlaveEmulationPort;
872
873 AttachedDevicesList llAttachedDevices;
874};
875typedef std::list<StorageController> StorageControllersList;
876
877/**
878 * We wrap the storage controllers list into an extra struct so we can
879 * use an undefined struct without needing std::list<> in all the headers.
880 *
881 * NOTE: If you add any fields in here, you must update a) the constructor and b)
882 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
883 * your settings might never get saved.
884 */
885struct Storage
886{
887 bool operator==(const Storage &s) const;
888
889 StorageControllersList llStorageControllers;
890};
891
892struct Snapshot;
893typedef std::list<Snapshot> SnapshotsList;
894
895/**
896 * NOTE: If you add any fields in here, you must update a) the constructor and b)
897 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
898 * your settings might never get saved.
899 */
900struct Snapshot
901{
902 bool operator==(const Snapshot &s) const;
903
904 com::Guid uuid;
905 com::Utf8Str strName,
906 strDescription; // optional
907 RTTIMESPEC timestamp;
908
909 com::Utf8Str strStateFile; // for online snapshots only
910
911 Hardware hardware;
912 Storage storage;
913
914 SnapshotsList llChildSnapshots;
915};
916
917struct MachineUserData
918{
919 MachineUserData()
920 : fNameSync(true),
921 fTeleporterEnabled(false),
922 uTeleporterPort(0),
923 enmFaultToleranceState(FaultToleranceState_Inactive),
924 uFaultTolerancePort(0),
925 uFaultToleranceInterval(0),
926 fRTCUseUTC(false)
927 { }
928
929 bool operator==(const MachineUserData &c) const
930 {
931 return (strName == c.strName)
932 && (fNameSync == c.fNameSync)
933 && (strDescription == c.strDescription)
934 && (strOsType == c.strOsType)
935 && (strSnapshotFolder == c.strSnapshotFolder)
936 && (fTeleporterEnabled == c.fTeleporterEnabled)
937 && (uTeleporterPort == c.uTeleporterPort)
938 && (strTeleporterAddress == c.strTeleporterAddress)
939 && (strTeleporterPassword == c.strTeleporterPassword)
940 && (enmFaultToleranceState == c.enmFaultToleranceState)
941 && (uFaultTolerancePort == c.uFaultTolerancePort)
942 && (uFaultToleranceInterval == c.uFaultToleranceInterval)
943 && (strFaultToleranceAddress == c.strFaultToleranceAddress)
944 && (strFaultTolerancePassword == c.strFaultTolerancePassword)
945 && (fRTCUseUTC == c.fRTCUseUTC);
946 }
947
948 com::Utf8Str strName;
949 bool fNameSync;
950 com::Utf8Str strDescription;
951 com::Utf8Str strOsType;
952 com::Utf8Str strSnapshotFolder;
953 bool fTeleporterEnabled;
954 uint32_t uTeleporterPort;
955 com::Utf8Str strTeleporterAddress;
956 com::Utf8Str strTeleporterPassword;
957 FaultToleranceState_T enmFaultToleranceState;
958 uint32_t uFaultTolerancePort;
959 com::Utf8Str strFaultToleranceAddress;
960 com::Utf8Str strFaultTolerancePassword;
961 uint32_t uFaultToleranceInterval;
962 bool fRTCUseUTC;
963};
964
965/**
966 * MachineConfigFile represents an XML machine configuration. All the machine settings
967 * that go out to the XML (or are read from it) are in here.
968 *
969 * NOTE: If you add any fields in here, you must update a) the constructor and b)
970 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
971 * might never get saved.
972 */
973class MachineConfigFile : public ConfigFileBase
974{
975public:
976 com::Guid uuid;
977
978 MachineUserData machineUserData;
979
980 com::Utf8Str strStateFile;
981 bool fCurrentStateModified; // optional, default is true
982 RTTIMESPEC timeLastStateChange; // optional, defaults to now
983 bool fAborted; // optional, default is false
984
985 com::Guid uuidCurrentSnapshot;
986
987 Hardware hardwareMachine;
988 Storage storageMachine;
989 MediaRegistry mediaRegistry;
990
991 StringsMap mapExtraDataItems;
992
993 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
994
995 MachineConfigFile(const com::Utf8Str *pstrFilename);
996
997 bool operator==(const MachineConfigFile &m) const;
998
999 bool canHaveOwnMediaRegistry() const;
1000
1001 void importMachineXML(const xml::ElementNode &elmMachine);
1002
1003 void write(const com::Utf8Str &strFilename);
1004
1005 enum
1006 {
1007 BuildMachineXML_IncludeSnapshots = 0x01,
1008 BuildMachineXML_WriteVboxVersionAttribute = 0x02,
1009 BuildMachineXML_SkipRemovableMedia = 0x04,
1010 BuildMachineXML_MediaRegistry = 0x08,
1011 BuildMachineXML_SuppressSavedState = 0x10
1012 };
1013 void buildMachineXML(xml::ElementNode &elmMachine,
1014 uint32_t fl,
1015 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1016
1017 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T drv);
1018 static AudioDriverType_T getHostDefaultAudioDriver();
1019
1020private:
1021 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
1022 void readAttachedNetworkMode(const xml::ElementNode &pelmMode, bool fEnabled, NetworkAdapter &nic);
1023 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
1024 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
1025 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
1026 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
1027 void readAudioAdapter(const xml::ElementNode &elmAudioAdapter, AudioAdapter &aa);
1028 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
1029 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
1030 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
1031 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
1032 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
1033 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
1034 void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
1035 void convertOldOSType_pre1_5(com::Utf8Str &str);
1036 void readMachine(const xml::ElementNode &elmMachine);
1037
1038 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
1039 void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, const NetworkAdapter &nic);
1040 void buildStorageControllersXML(xml::ElementNode &elmParent,
1041 const Storage &st,
1042 bool fSkipRemovableMedia,
1043 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
1044 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
1045
1046 void bumpSettingsVersionIfNeeded();
1047};
1048
1049} // namespace settings
1050
1051
1052#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