VirtualBox

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

Last change on this file since 28331 was 28295, checked in by vboxsync, 15 years ago

Main: saving NAT Engine states while network switches.

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