VirtualBox

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

Last change on this file since 34373 was 34244, checked in by vboxsync, 14 years ago

Main,Config.kmk,VBoxManage,ExtPacks: Moved the VRDE bits from IVirtualBox to the extension packs; changed ISystemProperties and IVRDEServer to talk about VRDE extension packs instead of VRDE libraries.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 32.9 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 fVideoChannel(false),
287 ulVideoChannelQuality(75)
288 {}
289
290 bool operator==(const VRDESettings& v) const;
291
292 bool fEnabled;
293 AuthType_T authType;
294 uint32_t ulAuthTimeout;
295 bool fAllowMultiConnection,
296 fReuseSingleConnection,
297 fVideoChannel;
298 uint32_t ulVideoChannelQuality;
299 com::Utf8Str strVrdeExtPack;
300 StringsMap mapProperties;
301};
302
303/**
304 * NOTE: If you add any fields in here, you must update a) the constructor and b)
305 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
306 * your settings might never get saved.
307 */
308struct BIOSSettings
309{
310 BIOSSettings()
311 : fACPIEnabled(true),
312 fIOAPICEnabled(false),
313 fLogoFadeIn(true),
314 fLogoFadeOut(true),
315 ulLogoDisplayTime(0),
316 biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
317 fPXEDebugEnabled(false),
318 llTimeOffset(0)
319 {}
320
321 bool operator==(const BIOSSettings &d) const;
322
323 bool fACPIEnabled,
324 fIOAPICEnabled,
325 fLogoFadeIn,
326 fLogoFadeOut;
327 uint32_t ulLogoDisplayTime;
328 com::Utf8Str strLogoImagePath;
329 BIOSBootMenuMode_T biosBootMenuMode;
330 bool fPXEDebugEnabled;
331 int64_t llTimeOffset;
332};
333
334/**
335 * NOTE: If you add any fields in here, you must update a) the constructor and b)
336 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
337 * your settings might never get saved.
338 */
339struct USBController
340{
341 USBController()
342 : fEnabled(false),
343 fEnabledEHCI(false)
344 {}
345
346 bool operator==(const USBController &u) const;
347
348 bool fEnabled;
349 bool fEnabledEHCI;
350 USBDeviceFiltersList llDeviceFilters;
351};
352
353 struct NATRule
354 {
355 NATRule(): proto(NATProtocol_TCP),
356 u16HostPort(0),
357 u16GuestPort(0){}
358 com::Utf8Str strName;
359 NATProtocol_T proto;
360 uint16_t u16HostPort;
361 com::Utf8Str strHostIP;
362 uint16_t u16GuestPort;
363 com::Utf8Str strGuestIP;
364 bool operator==(const NATRule &r) const
365 {
366 return strName == r.strName
367 && proto == r.proto
368 && u16HostPort == r.u16HostPort
369 && strHostIP == r.strHostIP
370 && u16GuestPort == r.u16GuestPort
371 && strGuestIP == r.strGuestIP;
372 }
373 };
374 typedef std::list<NATRule> NATRuleList;
375
376 struct NAT
377 {
378 NAT() : u32Mtu(0),
379 u32SockRcv(0),
380 u32SockSnd(0),
381 u32TcpRcv(0),
382 u32TcpSnd(0),
383 fDnsPassDomain(true), /* historically this value is true */
384 fDnsProxy(false),
385 fDnsUseHostResolver(false),
386 fAliasLog(false),
387 fAliasProxyOnly(false),
388 fAliasUseSamePorts(false) {}
389 com::Utf8Str strNetwork;
390 com::Utf8Str strBindIP;
391 uint32_t u32Mtu;
392 uint32_t u32SockRcv;
393 uint32_t u32SockSnd;
394 uint32_t u32TcpRcv;
395 uint32_t u32TcpSnd;
396 com::Utf8Str strTftpPrefix;
397 com::Utf8Str strTftpBootFile;
398 com::Utf8Str strTftpNextServer;
399 bool fDnsPassDomain;
400 bool fDnsProxy;
401 bool fDnsUseHostResolver;
402 bool fAliasLog;
403 bool fAliasProxyOnly;
404 bool fAliasUseSamePorts;
405 NATRuleList llRules;
406 bool operator==(const NAT &n) const
407 {
408 return strNetwork == n.strNetwork
409 && strBindIP == n.strBindIP
410 && u32Mtu == n.u32Mtu
411 && u32SockRcv == n.u32SockRcv
412 && u32SockSnd == n.u32SockSnd
413 && u32TcpSnd == n.u32TcpSnd
414 && u32TcpRcv == n.u32TcpRcv
415 && strTftpPrefix == n.strTftpPrefix
416 && strTftpBootFile == n.strTftpBootFile
417 && strTftpNextServer == n.strTftpNextServer
418 && fDnsPassDomain == n.fDnsPassDomain
419 && fDnsProxy == n.fDnsProxy
420 && fDnsUseHostResolver == n.fDnsUseHostResolver
421 && fAliasLog == n.fAliasLog
422 && fAliasProxyOnly == n.fAliasProxyOnly
423 && fAliasUseSamePorts == n.fAliasUseSamePorts
424 && llRules == n.llRules;
425 }
426 };
427/**
428 * NOTE: If you add any fields in here, you must update a) the constructor and b)
429 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
430 * your settings might never get saved.
431 */
432struct NetworkAdapter
433{
434 NetworkAdapter()
435 : ulSlot(0),
436 type(NetworkAdapterType_Am79C970A),
437 fEnabled(false),
438 fCableConnected(false),
439 ulLineSpeed(0),
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 bool fTraceEnabled;
457 com::Utf8Str strTraceFile;
458
459 NetworkAttachmentType_T mode;
460 NAT nat;
461 com::Utf8Str strName; // NAT has own attribute
462 // with bridged: host interface or empty;
463 // otherwise: network name (required)
464 uint32_t ulBootPriority;
465 bool fHasDisabledNAT;
466 uint32_t ulBandwidthLimit;
467};
468typedef std::list<NetworkAdapter> NetworkAdaptersList;
469
470/**
471 * NOTE: If you add any fields in here, you must update a) the constructor and b)
472 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
473 * your settings might never get saved.
474 */
475struct SerialPort
476{
477 SerialPort()
478 : ulSlot(0),
479 fEnabled(false),
480 ulIOBase(0x3f8),
481 ulIRQ(4),
482 portMode(PortMode_Disconnected),
483 fServer(false)
484 {}
485
486 bool operator==(const SerialPort &n) const;
487
488 uint32_t ulSlot;
489
490 bool fEnabled;
491 uint32_t ulIOBase;
492 uint32_t ulIRQ;
493 PortMode_T portMode;
494 com::Utf8Str strPath;
495 bool fServer;
496};
497typedef std::list<SerialPort> SerialPortsList;
498
499/**
500 * NOTE: If you add any fields in here, you must update a) the constructor and b)
501 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
502 * your settings might never get saved.
503 */
504struct ParallelPort
505{
506 ParallelPort()
507 : ulSlot(0),
508 fEnabled(false),
509 ulIOBase(0x378),
510 ulIRQ(4)
511 {}
512
513 bool operator==(const ParallelPort &d) const;
514
515 uint32_t ulSlot;
516
517 bool fEnabled;
518 uint32_t ulIOBase;
519 uint32_t ulIRQ;
520 com::Utf8Str strPath;
521};
522typedef std::list<ParallelPort> ParallelPortsList;
523
524/**
525 * NOTE: If you add any fields in here, you must update a) the constructor and b)
526 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
527 * your settings might never get saved.
528 */
529struct AudioAdapter
530{
531 AudioAdapter()
532 : fEnabled(true),
533 controllerType(AudioControllerType_AC97),
534 driverType(AudioDriverType_Null)
535 {}
536
537 bool operator==(const AudioAdapter &a) const
538 {
539 return (this == &a)
540 || ( (fEnabled == a.fEnabled)
541 && (controllerType == a.controllerType)
542 && (driverType == a.driverType)
543 );
544 }
545
546 bool fEnabled;
547 AudioControllerType_T controllerType;
548 AudioDriverType_T driverType;
549};
550
551/**
552 * NOTE: If you add any fields in here, you must update a) the constructor and b)
553 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
554 * your settings might never get saved.
555 */
556struct SharedFolder
557{
558 SharedFolder()
559 : fWritable(false)
560 , fAutoMount(false)
561 {}
562
563 bool operator==(const SharedFolder &a) const;
564
565 com::Utf8Str strName,
566 strHostPath;
567 bool fWritable;
568 bool fAutoMount;
569};
570typedef std::list<SharedFolder> SharedFoldersList;
571
572/**
573 * NOTE: If you add any fields in here, you must update a) the constructor and b)
574 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
575 * your settings might never get saved.
576 */
577struct GuestProperty
578{
579 GuestProperty()
580 : timestamp(0)
581 {};
582
583 bool operator==(const GuestProperty &g) const;
584
585 com::Utf8Str strName,
586 strValue;
587 uint64_t timestamp;
588 com::Utf8Str strFlags;
589};
590typedef std::list<GuestProperty> GuestPropertiesList;
591
592typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
593
594/**
595 * NOTE: If you add any fields in here, you must update a) the constructor and b)
596 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
597 * your settings might never get saved.
598 */
599struct CpuIdLeaf
600{
601 CpuIdLeaf()
602 : ulId(UINT32_MAX),
603 ulEax(0),
604 ulEbx(0),
605 ulEcx(0),
606 ulEdx(0)
607 {}
608
609 bool operator==(const CpuIdLeaf &c) const
610 {
611 return ( (this == &c)
612 || ( (ulId == c.ulId)
613 && (ulEax == c.ulEax)
614 && (ulEbx == c.ulEbx)
615 && (ulEcx == c.ulEcx)
616 && (ulEdx == c.ulEdx)
617 )
618 );
619 }
620
621 uint32_t ulId;
622 uint32_t ulEax;
623 uint32_t ulEbx;
624 uint32_t ulEcx;
625 uint32_t ulEdx;
626};
627typedef std::list<CpuIdLeaf> CpuIdLeafsList;
628
629/**
630 * NOTE: If you add any fields in here, you must update a) the constructor and b)
631 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
632 * your settings might never get saved.
633 */
634struct Cpu
635{
636 Cpu()
637 : ulId(UINT32_MAX)
638 {}
639
640 bool operator==(const Cpu &c) const
641 {
642 return (ulId == c.ulId);
643 }
644
645 uint32_t ulId;
646};
647typedef std::list<Cpu> CpuList;
648
649/**
650 * NOTE: If you add any fields in here, you must update a) the constructor and b)
651 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
652 * your settings might never get saved.
653 */
654struct IoSettings
655{
656 IoSettings();
657
658 bool operator==(const IoSettings &i) const
659 {
660 return ( (fIoCacheEnabled == i.fIoCacheEnabled)
661 && (ulIoCacheSize == i.ulIoCacheSize));
662 }
663
664 bool fIoCacheEnabled;
665 uint32_t ulIoCacheSize;
666};
667
668/**
669 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
670 * field.
671 *
672 * NOTE: If you add any fields in here, you must update a) the constructor and b)
673 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
674 * your settings might never get saved.
675 */
676struct Hardware
677{
678 Hardware();
679
680 bool operator==(const Hardware&) const;
681
682 com::Utf8Str strVersion; // hardware version, optional
683 com::Guid uuid; // hardware uuid, optional (null).
684
685 bool fHardwareVirt,
686 fHardwareVirtExclusive,
687 fNestedPaging,
688 fLargePages,
689 fVPID,
690 fHardwareVirtForce,
691 fSyntheticCpu,
692 fPAE;
693 uint32_t cCPUs;
694 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
695 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
696 bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
697 uint32_t ulCpuExecutionCap; // requires settings version 1.11 (VirtualBox 3.3)
698
699 CpuIdLeafsList llCpuIdLeafs;
700
701 uint32_t ulMemorySizeMB;
702
703 BootOrderMap mapBootOrder; // item 0 has highest priority
704
705 uint32_t ulVRAMSizeMB;
706 uint32_t cMonitors;
707 bool fAccelerate3D,
708 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
709 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
710
711 PointingHidType_T pointingHidType; // requires settings version 1.10 (VirtualBox 3.2)
712 KeyboardHidType_T keyboardHidType; // requires settings version 1.10 (VirtualBox 3.2)
713
714 ChipsetType_T chipsetType; // requires settings version 1.11 (VirtualBox 4.0)
715
716 VRDESettings vrdeSettings;
717
718 BIOSSettings biosSettings;
719 USBController usbController;
720 NetworkAdaptersList llNetworkAdapters;
721 SerialPortsList llSerialPorts;
722 ParallelPortsList llParallelPorts;
723 AudioAdapter audioAdapter;
724
725 // technically these two have no business in the hardware section, but for some
726 // clever reason <Hardware> is where they are in the XML....
727 SharedFoldersList llSharedFolders;
728 ClipboardMode_T clipboardMode;
729
730 uint32_t ulMemoryBalloonSize;
731 bool fPageFusionEnabled;
732
733 GuestPropertiesList llGuestProperties;
734 com::Utf8Str strNotificationPatterns;
735
736 IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
737};
738
739/**
740 * A device attached to a storage controller. This can either be a
741 * hard disk or a DVD drive or a floppy drive and also specifies
742 * which medium is "in" the drive; as a result, this is a combination
743 * of the Main IMedium and IMediumAttachment interfaces.
744 *
745 * NOTE: If you add any fields in here, you must update a) the constructor and b)
746 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
747 * your settings might never get saved.
748 */
749struct AttachedDevice
750{
751 AttachedDevice()
752 : deviceType(DeviceType_Null),
753 fPassThrough(false),
754 lPort(0),
755 lDevice(0),
756 ulBandwidthLimit(0)
757 {}
758
759 bool operator==(const AttachedDevice &a) const;
760
761 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
762
763 // DVDs can be in pass-through mode:
764 bool fPassThrough;
765
766 int32_t lPort;
767 int32_t lDevice;
768
769 uint32_t ulBandwidthLimit;
770
771 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
772 // this is its UUID; it depends on deviceType which media registry this then needs to
773 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
774 com::Guid uuid;
775
776 // for DVDs and floppies, the attachment can also be a host device:
777 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
778};
779typedef std::list<AttachedDevice> AttachedDevicesList;
780
781/**
782 * NOTE: If you add any fields in here, you must update a) the constructor and b)
783 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
784 * your settings might never get saved.
785 */
786struct StorageController
787{
788 StorageController()
789 : storageBus(StorageBus_IDE),
790 controllerType(StorageControllerType_PIIX3),
791 ulPortCount(2),
792 ulInstance(0),
793 fUseHostIOCache(true),
794 fBootable(true),
795 lIDE0MasterEmulationPort(0),
796 lIDE0SlaveEmulationPort(0),
797 lIDE1MasterEmulationPort(0),
798 lIDE1SlaveEmulationPort(0)
799 {}
800
801 bool operator==(const StorageController &s) const;
802
803 com::Utf8Str strName;
804 StorageBus_T storageBus; // _SATA, _SCSI, _IDE, _SAS
805 StorageControllerType_T controllerType;
806 uint32_t ulPortCount;
807 uint32_t ulInstance;
808 bool fUseHostIOCache;
809 bool fBootable;
810
811 // only for when controllerType == StorageControllerType_IntelAhci:
812 int32_t lIDE0MasterEmulationPort,
813 lIDE0SlaveEmulationPort,
814 lIDE1MasterEmulationPort,
815 lIDE1SlaveEmulationPort;
816
817 AttachedDevicesList llAttachedDevices;
818};
819typedef std::list<StorageController> StorageControllersList;
820
821/**
822 * We wrap the storage controllers list into an extra struct so we can
823 * use an undefined struct without needing std::list<> in all the headers.
824 *
825 * NOTE: If you add any fields in here, you must update a) the constructor and b)
826 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
827 * your settings might never get saved.
828 */
829struct Storage
830{
831 bool operator==(const Storage &s) const;
832
833 StorageControllersList llStorageControllers;
834};
835
836struct Snapshot;
837typedef std::list<Snapshot> SnapshotsList;
838
839/**
840 * NOTE: If you add any fields in here, you must update a) the constructor and b)
841 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
842 * your settings might never get saved.
843 */
844struct Snapshot
845{
846 bool operator==(const Snapshot &s) const;
847
848 com::Guid uuid;
849 com::Utf8Str strName,
850 strDescription; // optional
851 RTTIMESPEC timestamp;
852
853 com::Utf8Str strStateFile; // for online snapshots only
854
855 Hardware hardware;
856 Storage storage;
857
858 SnapshotsList llChildSnapshots;
859};
860
861struct MachineUserData
862{
863 MachineUserData()
864 : fNameSync(true),
865 fTeleporterEnabled(false),
866 uTeleporterPort(0),
867 enmFaultToleranceState(FaultToleranceState_Inactive),
868 uFaultTolerancePort(0),
869 uFaultToleranceInterval(0),
870 fRTCUseUTC(false)
871 { }
872
873 bool operator==(const MachineUserData &c) const
874 {
875 return (strName == c.strName)
876 && (fNameSync == c.fNameSync)
877 && (strDescription == c.strDescription)
878 && (strOsType == c.strOsType)
879 && (strSnapshotFolder == c.strSnapshotFolder)
880 && (fTeleporterEnabled == c.fTeleporterEnabled)
881 && (uTeleporterPort == c.uTeleporterPort)
882 && (strTeleporterAddress == c.strTeleporterAddress)
883 && (strTeleporterPassword == c.strTeleporterPassword)
884 && (enmFaultToleranceState == c.enmFaultToleranceState)
885 && (uFaultTolerancePort == c.uFaultTolerancePort)
886 && (uFaultToleranceInterval == c.uFaultToleranceInterval)
887 && (strFaultToleranceAddress == c.strFaultToleranceAddress)
888 && (strFaultTolerancePassword == c.strFaultTolerancePassword)
889 && (fRTCUseUTC == c.fRTCUseUTC);
890 }
891
892 com::Utf8Str strName;
893 bool fNameSync;
894 com::Utf8Str strDescription;
895 com::Utf8Str strOsType;
896 com::Utf8Str strSnapshotFolder;
897 bool fTeleporterEnabled;
898 uint32_t uTeleporterPort;
899 com::Utf8Str strTeleporterAddress;
900 com::Utf8Str strTeleporterPassword;
901 FaultToleranceState_T enmFaultToleranceState;
902 uint32_t uFaultTolerancePort;
903 com::Utf8Str strFaultToleranceAddress;
904 com::Utf8Str strFaultTolerancePassword;
905 uint32_t uFaultToleranceInterval;
906 bool fRTCUseUTC;
907};
908
909/**
910 * MachineConfigFile represents an XML machine configuration. All the machine settings
911 * that go out to the XML (or are read from it) are in here.
912 *
913 * NOTE: If you add any fields in here, you must update a) the constructor and b)
914 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
915 * might never get saved.
916 */
917class MachineConfigFile : public ConfigFileBase
918{
919public:
920 com::Guid uuid;
921
922 MachineUserData machineUserData;
923
924 com::Utf8Str strStateFile;
925 bool fCurrentStateModified; // optional, default is true
926 RTTIMESPEC timeLastStateChange; // optional, defaults to now
927 bool fAborted; // optional, default is false
928
929 com::Guid uuidCurrentSnapshot;
930
931 Hardware hardwareMachine;
932 Storage storageMachine;
933 MediaRegistry mediaRegistry;
934
935 StringsMap mapExtraDataItems;
936
937 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
938
939 MachineConfigFile(const com::Utf8Str *pstrFilename);
940
941 bool operator==(const MachineConfigFile &m) const;
942
943 bool canHaveOwnMediaRegistry() const;
944
945 void importMachineXML(const xml::ElementNode &elmMachine);
946
947 void write(const com::Utf8Str &strFilename);
948
949 enum
950 {
951 BuildMachineXML_IncludeSnapshots = 0x01,
952 BuildMachineXML_WriteVboxVersionAttribute = 0x02,
953 BuildMachineXML_SkipRemovableMedia = 0x04,
954 BuildMachineXML_MediaRegistry = 0x08,
955 BuildMachineXML_SuppressSavedState = 0x10
956 };
957 void buildMachineXML(xml::ElementNode &elmMachine,
958 uint32_t fl,
959 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
960
961 static bool isAudioDriverAllowedOnThisHost(AudioDriverType_T drv);
962 static AudioDriverType_T getHostDefaultAudioDriver();
963
964private:
965 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
966 void readAttachedNetworkMode(const xml::ElementNode &pelmMode, bool fEnabled, NetworkAdapter &nic);
967 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
968 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
969 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
970 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
971 void readAudioAdapter(const xml::ElementNode &elmAudioAdapter, AudioAdapter &aa);
972 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
973 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
974 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
975 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
976 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
977 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
978 void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
979 void convertOldOSType_pre1_5(com::Utf8Str &str);
980 void readMachine(const xml::ElementNode &elmMachine);
981
982 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
983 void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, const NetworkAdapter &nic);
984 void buildStorageControllersXML(xml::ElementNode &elmParent,
985 const Storage &st,
986 bool fSkipRemovableMedia,
987 std::list<xml::ElementNode*> *pllElementsWithUuidAttributes);
988 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
989
990 void bumpSettingsVersionIfNeeded();
991};
992
993} // namespace settings
994
995
996#endif /* ___VBox_settings_h */
Note: See TracBrowser for help on using the repository browser.

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