VirtualBox

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

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

Main: Implemenation of per-machine media registries; VirtualBox::openMedium() no longer adds media to the global registry, instead a media are stored in a machine XML registry after Machine::AttachDevice() has been called; Machine::AttachDevice() now takes an IMedium object instead of a UUID; also make Machine::Unregister() work again for inaccessible machines

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