VirtualBox

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

Last change on this file since 27965 was 27918, checked in by vboxsync, 15 years ago

Main/OVF: import vbox:Machine XML within OVF, first batch (XML is parsed and machine config created, but COM Machine can't handle it yet)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 28.3 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 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
40 * Clara, CA 95054 USA or visit http://www.sun.com if you need
41 * additional information or have any questions.
42 */
43
44#ifndef ___VBox_settings_h
45#define ___VBox_settings_h
46
47#include <iprt/time.h>
48
49#include "VBox/com/VirtualBox.h"
50
51#include <VBox/com/Guid.h>
52#include <VBox/com/string.h>
53
54#include <list>
55#include <map>
56
57namespace xml
58{
59 class ElementNode;
60}
61
62namespace settings
63{
64
65class ConfigFileError;
66
67////////////////////////////////////////////////////////////////////////////////
68//
69// Helper classes
70//
71////////////////////////////////////////////////////////////////////////////////
72
73// ExtraDataItem (used by both VirtualBox.xml and machines XML)
74typedef std::map<com::Utf8Str, com::Utf8Str> ExtraDataItemsMap;
75struct USBDeviceFilter;
76typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
77
78/**
79 * Common base class for both MainConfigFile and MachineConfigFile
80 * which contains some common logic for both.
81 */
82class ConfigFileBase
83{
84public:
85 bool fileExists();
86
87 void copyBaseFrom(const ConfigFileBase &b);
88
89protected:
90 ConfigFileBase(const com::Utf8Str *pstrFilename);
91 ~ConfigFileBase();
92
93 void parseUUID(com::Guid &guid,
94 const com::Utf8Str &strUUID) const;
95 void parseTimestamp(RTTIMESPEC &timestamp,
96 const com::Utf8Str &str) const;
97
98 com::Utf8Str makeString(const RTTIMESPEC &tm);
99 com::Utf8Str makeString(const com::Guid &guid);
100
101 void readExtraData(const xml::ElementNode &elmExtraData,
102 ExtraDataItemsMap &map);
103 void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
104 USBDeviceFiltersList &ll);
105
106 void createStubDocument();
107
108 void writeExtraData(xml::ElementNode &elmParent, const ExtraDataItemsMap &me);
109 void writeUSBDeviceFilters(xml::ElementNode &elmParent,
110 const USBDeviceFiltersList &ll,
111 bool fHostMode);
112
113 void clearDocument();
114
115 struct Data;
116 Data *m;
117
118 friend class ConfigFileError;
119};
120
121////////////////////////////////////////////////////////////////////////////////
122//
123// Structures shared between Machine XML and VirtualBox.xml
124//
125////////////////////////////////////////////////////////////////////////////////
126
127/**
128 * USB device filter definition. This struct is used both in MainConfigFile
129 * (for global USB filters) and MachineConfigFile (for machine filters).
130 *
131 * NOTE: If you add any fields in here, you must update a) the constructor and b)
132 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
133 * your settings might never get saved.
134 */
135struct USBDeviceFilter
136{
137 USBDeviceFilter()
138 : fActive(false),
139 action(USBDeviceFilterAction_Null),
140 ulMaskedInterfaces(0)
141 {}
142
143 bool operator==(const USBDeviceFilter&u) const;
144
145 com::Utf8Str strName;
146 bool fActive;
147 com::Utf8Str strVendorId,
148 strProductId,
149 strRevision,
150 strManufacturer,
151 strProduct,
152 strSerialNumber,
153 strPort;
154 USBDeviceFilterAction_T action; // only used with host USB filters
155 com::Utf8Str strRemote; // irrelevant for host USB objects
156 uint32_t ulMaskedInterfaces; // irrelevant for host USB objects
157};
158
159////////////////////////////////////////////////////////////////////////////////
160//
161// VirtualBox.xml structures
162//
163////////////////////////////////////////////////////////////////////////////////
164
165struct Host
166{
167 USBDeviceFiltersList llUSBDeviceFilters;
168};
169
170struct SystemProperties
171{
172 SystemProperties()
173 : ulLogHistoryCount(3)
174 {}
175
176 com::Utf8Str strDefaultMachineFolder;
177 com::Utf8Str strDefaultHardDiskFolder;
178 com::Utf8Str strDefaultHardDiskFormat;
179 com::Utf8Str strRemoteDisplayAuthLibrary;
180 com::Utf8Str strWebServiceAuthLibrary;
181 uint32_t ulLogHistoryCount;
182};
183
184typedef std::map<com::Utf8Str, com::Utf8Str> PropertiesMap;
185
186struct Medium;
187typedef std::list<Medium> MediaList;
188
189struct Medium
190{
191 com::Guid uuid;
192 com::Utf8Str strLocation;
193 com::Utf8Str strDescription;
194
195 // the following are for hard disks only:
196 com::Utf8Str strFormat;
197 bool fAutoReset; // optional, only for diffs, default is false
198 PropertiesMap properties;
199 MediumType_T hdType;
200
201 MediaList llChildren; // only used with hard disks
202};
203
204struct MachineRegistryEntry
205{
206 com::Guid uuid;
207 com::Utf8Str strSettingsFile;
208};
209typedef std::list<MachineRegistryEntry> MachinesRegistry;
210
211struct DHCPServer
212{
213 com::Utf8Str strNetworkName,
214 strIPAddress,
215 strIPNetworkMask,
216 strIPLower,
217 strIPUpper;
218 bool fEnabled;
219};
220typedef std::list<DHCPServer> DHCPServersList;
221
222class MainConfigFile : public ConfigFileBase
223{
224public:
225 MainConfigFile(const com::Utf8Str *pstrFilename);
226
227 typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
228 void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia);
229 void readMediaRegistry(const xml::ElementNode &elmMediaRegistry);
230 void readMachineRegistry(const xml::ElementNode &elmMachineRegistry);
231 void readDHCPServers(const xml::ElementNode &elmDHCPServers);
232
233 void writeHardDisk(xml::ElementNode &elmMedium,
234 const Medium &m,
235 uint32_t level);
236 void write(const com::Utf8Str strFilename);
237
238 Host host;
239 SystemProperties systemProperties;
240 MediaList llHardDisks,
241 llDvdImages,
242 llFloppyImages;
243 MachinesRegistry llMachines;
244 DHCPServersList llDhcpServers;
245 ExtraDataItemsMap mapExtraDataItems;
246};
247
248////////////////////////////////////////////////////////////////////////////////
249//
250// Machine XML structures
251//
252////////////////////////////////////////////////////////////////////////////////
253
254/**
255 * NOTE: If you add any fields in here, you must update a) the constructor and b)
256 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
257 * your settings might never get saved.
258 */
259struct VRDPSettings
260{
261 VRDPSettings()
262 : fEnabled(true),
263 authType(VRDPAuthType_Null),
264 ulAuthTimeout(5000),
265 fAllowMultiConnection(false),
266 fReuseSingleConnection(false)
267 {}
268
269 bool operator==(const VRDPSettings& v) const;
270
271 bool fEnabled;
272 com::Utf8Str strPort;
273 com::Utf8Str strNetAddress;
274 VRDPAuthType_T authType;
275 uint32_t ulAuthTimeout;
276 bool fAllowMultiConnection,
277 fReuseSingleConnection;
278};
279
280/**
281 * NOTE: If you add any fields in here, you must update a) the constructor and b)
282 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
283 * your settings might never get saved.
284 */
285struct BIOSSettings
286{
287 BIOSSettings()
288 : fACPIEnabled(true),
289 fIOAPICEnabled(false),
290 fLogoFadeIn(true),
291 fLogoFadeOut(true),
292 ulLogoDisplayTime(0),
293 biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
294 fPXEDebugEnabled(false),
295 llTimeOffset(0)
296 {}
297
298 bool operator==(const BIOSSettings &d) const;
299
300 bool fACPIEnabled,
301 fIOAPICEnabled,
302 fLogoFadeIn,
303 fLogoFadeOut;
304 uint32_t ulLogoDisplayTime;
305 com::Utf8Str strLogoImagePath;
306 BIOSBootMenuMode_T biosBootMenuMode;
307 bool fPXEDebugEnabled;
308 int64_t llTimeOffset;
309};
310
311/**
312 * NOTE: If you add any fields in here, you must update a) the constructor and b)
313 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
314 * your settings might never get saved.
315 */
316struct USBController
317{
318 USBController()
319 : fEnabled(false),
320 fEnabledEHCI(false)
321 {}
322
323 bool operator==(const USBController &u) const;
324
325 bool fEnabled;
326 bool fEnabledEHCI;
327 USBDeviceFiltersList llDeviceFilters;
328};
329
330 struct NATRule
331 {
332 NATRule(): u32Proto(0),
333 u16HostPort(0),
334 u16GuestPort(0){}
335 com::Utf8Str strName;
336 uint32_t u32Proto;
337 uint16_t u16HostPort;
338 com::Utf8Str strHostIP;
339 uint16_t u16GuestPort;
340 com::Utf8Str strGuestIP;
341 bool operator==(const NATRule &r) const
342 {
343 return strName == r.strName
344 && u32Proto == r.u32Proto
345 && u16HostPort == r.u16HostPort
346 && strHostIP == r.strHostIP
347 && u16GuestPort == r.u16GuestPort
348 && strGuestIP == r.strGuestIP;
349 }
350 };
351 typedef std::list<NATRule> NATRuleList;
352
353 struct NAT
354 {
355 NAT(): u32Mtu(0),
356 u32SockRcv(0),
357 u32SockSnd(0),
358 u32TcpRcv(0),
359 u32TcpSnd(0),
360 fDnsPassDomain(true), /* historically this value is true */
361 fDnsProxy(false),
362 fDnsUseHostResolver(false){}
363 com::Utf8Str strNetwork;
364 com::Utf8Str strBindIP;
365 uint32_t u32Mtu;
366 uint32_t u32SockRcv;
367 uint32_t u32SockSnd;
368 uint32_t u32TcpRcv;
369 uint32_t u32TcpSnd;
370 com::Utf8Str strTftpPrefix;
371 com::Utf8Str strTftpBootFile;
372 com::Utf8Str strTftpNextServer;
373 bool fDnsPassDomain;
374 bool fDnsProxy;
375 bool fDnsUseHostResolver;
376 NATRuleList llRules;
377 bool operator==(const NAT &n) const
378 {
379 return strNetwork == n.strNetwork
380 && strBindIP == n.strBindIP
381 && u32Mtu == n.u32Mtu
382 && u32SockRcv == n.u32SockRcv
383 && u32SockSnd == n.u32SockSnd
384 && u32TcpSnd == n.u32TcpSnd
385 && u32TcpRcv == n.u32TcpRcv
386 && strTftpPrefix == n.strTftpPrefix
387 && strTftpBootFile == n.strTftpBootFile
388 && strTftpNextServer == n.strTftpNextServer
389 && fDnsPassDomain == n.fDnsPassDomain
390 && fDnsProxy == n.fDnsProxy
391 && fDnsUseHostResolver == n.fDnsUseHostResolver
392 && llRules == n.llRules;
393 }
394 };
395/**
396 * NOTE: If you add any fields in here, you must update a) the constructor and b)
397 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
398 * your settings might never get saved.
399 */
400struct NetworkAdapter
401{
402 NetworkAdapter()
403 : ulSlot(0),
404 type(NetworkAdapterType_Am79C970A),
405 fEnabled(false),
406 fCableConnected(false),
407 ulLineSpeed(0),
408 fTraceEnabled(false),
409 mode(NetworkAttachmentType_Null)
410 {}
411
412 bool operator==(const NetworkAdapter &n) const;
413
414 uint32_t ulSlot;
415
416 NetworkAdapterType_T type;
417 bool fEnabled;
418 com::Utf8Str strMACAddress;
419 bool fCableConnected;
420 uint32_t ulLineSpeed;
421 bool fTraceEnabled;
422 com::Utf8Str strTraceFile;
423
424 NetworkAttachmentType_T mode;
425 NAT nat;
426 com::Utf8Str strName; // NAT has own attribute
427 // with bridged: host interface or empty;
428 // otherwise: network name (required)
429};
430typedef std::list<NetworkAdapter> NetworkAdaptersList;
431
432/**
433 * NOTE: If you add any fields in here, you must update a) the constructor and b)
434 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
435 * your settings might never get saved.
436 */
437struct SerialPort
438{
439 SerialPort()
440 : ulSlot(0),
441 fEnabled(false),
442 ulIOBase(0x3f8),
443 ulIRQ(4),
444 portMode(PortMode_Disconnected),
445 fServer(false)
446 {}
447
448 bool operator==(const SerialPort &n) const;
449
450 uint32_t ulSlot;
451
452 bool fEnabled;
453 uint32_t ulIOBase;
454 uint32_t ulIRQ;
455 PortMode_T portMode;
456 com::Utf8Str strPath;
457 bool fServer;
458};
459typedef std::list<SerialPort> SerialPortsList;
460
461/**
462 * NOTE: If you add any fields in here, you must update a) the constructor and b)
463 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
464 * your settings might never get saved.
465 */
466struct ParallelPort
467{
468 ParallelPort()
469 : ulSlot(0),
470 fEnabled(false),
471 ulIOBase(0x378),
472 ulIRQ(4)
473 {}
474
475 bool operator==(const ParallelPort &d) const;
476
477 uint32_t ulSlot;
478
479 bool fEnabled;
480 uint32_t ulIOBase;
481 uint32_t ulIRQ;
482 com::Utf8Str strPath;
483};
484typedef std::list<ParallelPort> ParallelPortsList;
485
486/**
487 * NOTE: If you add any fields in here, you must update a) the constructor and b)
488 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
489 * your settings might never get saved.
490 */
491struct AudioAdapter
492{
493 AudioAdapter()
494 : fEnabled(true),
495 controllerType(AudioControllerType_AC97),
496 driverType(AudioDriverType_Null)
497 {}
498
499 bool operator==(const AudioAdapter &a) const
500 {
501 return (this == &a)
502 || ( (fEnabled == a.fEnabled)
503 && (controllerType == a.controllerType)
504 && (driverType == a.driverType)
505 );
506 }
507
508 bool fEnabled;
509 AudioControllerType_T controllerType;
510 AudioDriverType_T driverType;
511};
512
513/**
514 * NOTE: If you add any fields in here, you must update a) the constructor and b)
515 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
516 * your settings might never get saved.
517 */
518struct SharedFolder
519{
520 SharedFolder()
521 : fWritable(false)
522 {}
523
524 bool operator==(const SharedFolder &a) const;
525
526 com::Utf8Str strName,
527 strHostPath;
528 bool fWritable;
529};
530typedef std::list<SharedFolder> SharedFoldersList;
531
532/**
533 * NOTE: If you add any fields in here, you must update a) the constructor and b)
534 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
535 * your settings might never get saved.
536 */
537struct GuestProperty
538{
539 GuestProperty()
540 : timestamp(0)
541 {};
542
543 bool operator==(const GuestProperty &g) const;
544
545 com::Utf8Str strName,
546 strValue;
547 uint64_t timestamp;
548 com::Utf8Str strFlags;
549};
550typedef std::list<GuestProperty> GuestPropertiesList;
551
552typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
553
554/**
555 * NOTE: If you add any fields in here, you must update a) the constructor and b)
556 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
557 * your settings might never get saved.
558 */
559struct CpuIdLeaf
560{
561 CpuIdLeaf()
562 : ulId(UINT32_MAX),
563 ulEax(0),
564 ulEbx(0),
565 ulEcx(0),
566 ulEdx(0)
567 {}
568
569 bool operator==(const CpuIdLeaf &c) const
570 {
571 return ( (this == &c)
572 || ( (ulId == c.ulId)
573 && (ulEax == c.ulEax)
574 && (ulEbx == c.ulEbx)
575 && (ulEcx == c.ulEcx)
576 && (ulEdx == c.ulEdx)
577 )
578 );
579 }
580
581 uint32_t ulId;
582 uint32_t ulEax;
583 uint32_t ulEbx;
584 uint32_t ulEcx;
585 uint32_t ulEdx;
586};
587typedef std::list<CpuIdLeaf> CpuIdLeafsList;
588
589/**
590 * NOTE: If you add any fields in here, you must update a) the constructor and b)
591 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
592 * your settings might never get saved.
593 */
594struct Cpu
595{
596 Cpu()
597 : ulId(UINT32_MAX)
598 {}
599
600 bool operator==(const Cpu &c) const
601 {
602 return (ulId == c.ulId);
603 }
604
605 uint32_t ulId;
606};
607typedef std::list<Cpu> CpuList;
608
609/**
610 * NOTE: If you add any fields in here, you must update a) the constructor and b)
611 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
612 * your settings might never get saved.
613 */
614struct IoSettings
615{
616 IoSettings();
617
618 bool operator==(const IoSettings &i) const
619 {
620 return ( (ioMgrType == i.ioMgrType)
621 && (ioBackendType == i.ioBackendType)
622 && (fIoCacheEnabled == i.fIoCacheEnabled)
623 && (ulIoCacheSize == i.ulIoCacheSize)
624 && (ulIoBandwidthMax == i.ulIoBandwidthMax));
625 }
626
627 IoMgrType_T ioMgrType;
628 IoBackendType_T ioBackendType;
629 bool fIoCacheEnabled;
630 uint32_t ulIoCacheSize;
631 uint32_t ulIoBandwidthMax;
632};
633
634/**
635 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
636 * field.
637 *
638 * NOTE: If you add any fields in here, you must update a) the constructor and b)
639 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
640 * your settings might never get saved.
641 */
642struct Hardware
643{
644 Hardware();
645
646 bool operator==(const Hardware&) const;
647
648 com::Utf8Str strVersion; // hardware version, optional
649 com::Guid uuid; // hardware uuid, optional (null).
650
651 bool fHardwareVirt,
652 fHardwareVirtExclusive,
653 fNestedPaging,
654 fLargePages,
655 fVPID,
656 fSyntheticCpu,
657 fPAE;
658 uint32_t cCPUs;
659 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
660 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
661 bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
662
663 CpuIdLeafsList llCpuIdLeafs;
664
665 uint32_t ulMemorySizeMB;
666
667 BootOrderMap mapBootOrder; // item 0 has highest priority
668
669 uint32_t ulVRAMSizeMB;
670 uint32_t cMonitors;
671 bool fAccelerate3D,
672 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
673 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
674
675 PointingHidType_T pointingHidType; // requires settings version 1.10 (VirtualBox 3.2)
676 KeyboardHidType_T keyboardHidType; // requires settings version 1.10 (VirtualBox 3.2)
677
678 VRDPSettings vrdpSettings;
679
680 BIOSSettings biosSettings;
681 USBController usbController;
682 NetworkAdaptersList llNetworkAdapters;
683 SerialPortsList llSerialPorts;
684 ParallelPortsList llParallelPorts;
685 AudioAdapter audioAdapter;
686
687 // technically these two have no business in the hardware section, but for some
688 // clever reason <Hardware> is where they are in the XML....
689 SharedFoldersList llSharedFolders;
690 ClipboardMode_T clipboardMode;
691
692 uint32_t ulMemoryBalloonSize;
693
694 GuestPropertiesList llGuestProperties;
695 com::Utf8Str strNotificationPatterns;
696
697 IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
698};
699
700/**
701 * A device attached to a storage controller. This can either be a
702 * hard disk or a DVD drive or a floppy drive and also specifies
703 * which medium is "in" the drive; as a result, this is a combination
704 * of the Main IMedium and IMediumAttachment interfaces.
705 *
706 * NOTE: If you add any fields in here, you must update a) the constructor and b)
707 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
708 * your settings might never get saved.
709 */
710struct AttachedDevice
711{
712 AttachedDevice()
713 : deviceType(DeviceType_Null),
714 fPassThrough(false),
715 lPort(0),
716 lDevice(0)
717 {}
718
719 bool operator==(const AttachedDevice &a) const;
720
721 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
722
723 // DVDs can be in pass-through mode:
724 bool fPassThrough;
725
726 int32_t lPort;
727 int32_t lDevice;
728
729 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
730 // this is its UUID; it depends on deviceType which media registry this then needs to
731 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
732 com::Guid uuid;
733
734 // for DVDs and floppies, the attachment can also be a host device:
735 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
736};
737typedef std::list<AttachedDevice> AttachedDevicesList;
738
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 StorageController
745{
746 StorageController()
747 : storageBus(StorageBus_IDE),
748 controllerType(StorageControllerType_PIIX3),
749 ulPortCount(2),
750 ulInstance(0),
751 lIDE0MasterEmulationPort(0),
752 lIDE0SlaveEmulationPort(0),
753 lIDE1MasterEmulationPort(0),
754 lIDE1SlaveEmulationPort(0)
755 {}
756
757 bool operator==(const StorageController &s) const;
758
759 com::Utf8Str strName;
760 StorageBus_T storageBus; // _SATA, _SCSI, _IDE
761 StorageControllerType_T controllerType;
762 uint32_t ulPortCount;
763 uint32_t ulInstance;
764
765 // only for when controllerType == StorageControllerType_IntelAhci:
766 int32_t lIDE0MasterEmulationPort,
767 lIDE0SlaveEmulationPort,
768 lIDE1MasterEmulationPort,
769 lIDE1SlaveEmulationPort;
770
771 AttachedDevicesList llAttachedDevices;
772};
773typedef std::list<StorageController> StorageControllersList;
774
775/**
776 * We wrap the storage controllers list into an extra struct so we can
777 * use an undefined struct without needing std::list<> in all the headers.
778 *
779 * NOTE: If you add any fields in here, you must update a) the constructor and b)
780 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
781 * your settings might never get saved.
782 */
783struct Storage
784{
785 bool operator==(const Storage &s) const;
786
787 StorageControllersList llStorageControllers;
788};
789
790struct Snapshot;
791typedef std::list<Snapshot> SnapshotsList;
792
793/**
794 * NOTE: If you add any fields in here, you must update a) the constructor and b)
795 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
796 * your settings might never get saved.
797 */
798struct Snapshot
799{
800 bool operator==(const Snapshot &s) const;
801
802 com::Guid uuid;
803 com::Utf8Str strName,
804 strDescription; // optional
805 RTTIMESPEC timestamp;
806
807 com::Utf8Str strStateFile; // for online snapshots only
808
809 Hardware hardware;
810 Storage storage;
811
812 SnapshotsList llChildSnapshots;
813};
814
815/**
816 * MachineConfigFile represents an XML machine configuration. All the machine settings
817 * that go out to the XML (or are read from it) are in here.
818 *
819 * NOTE: If you add any fields in here, you must update a) the constructor and b)
820 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
821 * might never get saved.
822 */
823class MachineConfigFile : public ConfigFileBase
824{
825public:
826 com::Guid uuid;
827 com::Utf8Str strName;
828 bool fNameSync;
829 com::Utf8Str strDescription;
830 com::Utf8Str strOsType;
831 com::Utf8Str strStateFile;
832 com::Guid uuidCurrentSnapshot;
833 com::Utf8Str strSnapshotFolder;
834 bool fTeleporterEnabled;
835 uint32_t uTeleporterPort;
836 com::Utf8Str strTeleporterAddress;
837 com::Utf8Str strTeleporterPassword;
838 bool fRTCUseUTC;
839
840 bool fCurrentStateModified; // optional, default is true
841 RTTIMESPEC timeLastStateChange; // optional, defaults to now
842 bool fAborted; // optional, default is false
843
844 Hardware hardwareMachine;
845 Storage storageMachine;
846
847 ExtraDataItemsMap mapExtraDataItems;
848
849 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
850
851 MachineConfigFile(const com::Utf8Str *pstrFilename);
852
853 bool operator==(const MachineConfigFile &m) const;
854
855 void importMachineXML(const xml::ElementNode &elmMachine);
856
857 void write(const com::Utf8Str &strFilename);
858 void buildMachineXML(xml::ElementNode &elmMachine);
859
860private:
861 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
862 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
863 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
864 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
865 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
866 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
867 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
868 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
869 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
870 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
871 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
872 void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
873 void convertOldOSType_pre1_5(com::Utf8Str &str);
874 void readMachine(const xml::ElementNode &elmMachine);
875
876 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
877 void buildStorageControllersXML(xml::ElementNode &elmParent, const Storage &st);
878 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
879
880 void bumpSettingsVersionIfNeeded();
881};
882
883} // namespace settings
884
885
886#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