VirtualBox

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

最後變更 在這個檔案從28228是 28195,由 vboxsync 提交於 15 年 前

Main/OVF: add vbox settings version to vbox:Machine element

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Date Revision Author Id
檔案大小: 28.7 KB
 
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.alldomusa.eu.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};
437typedef std::list<NetworkAdapter> NetworkAdaptersList;
438
439/**
440 * NOTE: If you add any fields in here, you must update a) the constructor and b)
441 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
442 * your settings might never get saved.
443 */
444struct SerialPort
445{
446 SerialPort()
447 : ulSlot(0),
448 fEnabled(false),
449 ulIOBase(0x3f8),
450 ulIRQ(4),
451 portMode(PortMode_Disconnected),
452 fServer(false)
453 {}
454
455 bool operator==(const SerialPort &n) const;
456
457 uint32_t ulSlot;
458
459 bool fEnabled;
460 uint32_t ulIOBase;
461 uint32_t ulIRQ;
462 PortMode_T portMode;
463 com::Utf8Str strPath;
464 bool fServer;
465};
466typedef std::list<SerialPort> SerialPortsList;
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 ParallelPort
474{
475 ParallelPort()
476 : ulSlot(0),
477 fEnabled(false),
478 ulIOBase(0x378),
479 ulIRQ(4)
480 {}
481
482 bool operator==(const ParallelPort &d) const;
483
484 uint32_t ulSlot;
485
486 bool fEnabled;
487 uint32_t ulIOBase;
488 uint32_t ulIRQ;
489 com::Utf8Str strPath;
490};
491typedef std::list<ParallelPort> ParallelPortsList;
492
493/**
494 * NOTE: If you add any fields in here, you must update a) the constructor and b)
495 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
496 * your settings might never get saved.
497 */
498struct AudioAdapter
499{
500 AudioAdapter()
501 : fEnabled(true),
502 controllerType(AudioControllerType_AC97),
503 driverType(AudioDriverType_Null)
504 {}
505
506 bool operator==(const AudioAdapter &a) const
507 {
508 return (this == &a)
509 || ( (fEnabled == a.fEnabled)
510 && (controllerType == a.controllerType)
511 && (driverType == a.driverType)
512 );
513 }
514
515 bool fEnabled;
516 AudioControllerType_T controllerType;
517 AudioDriverType_T driverType;
518};
519
520/**
521 * NOTE: If you add any fields in here, you must update a) the constructor and b)
522 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
523 * your settings might never get saved.
524 */
525struct SharedFolder
526{
527 SharedFolder()
528 : fWritable(false)
529 {}
530
531 bool operator==(const SharedFolder &a) const;
532
533 com::Utf8Str strName,
534 strHostPath;
535 bool fWritable;
536};
537typedef std::list<SharedFolder> SharedFoldersList;
538
539/**
540 * NOTE: If you add any fields in here, you must update a) the constructor and b)
541 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
542 * your settings might never get saved.
543 */
544struct GuestProperty
545{
546 GuestProperty()
547 : timestamp(0)
548 {};
549
550 bool operator==(const GuestProperty &g) const;
551
552 com::Utf8Str strName,
553 strValue;
554 uint64_t timestamp;
555 com::Utf8Str strFlags;
556};
557typedef std::list<GuestProperty> GuestPropertiesList;
558
559typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
560
561/**
562 * NOTE: If you add any fields in here, you must update a) the constructor and b)
563 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
564 * your settings might never get saved.
565 */
566struct CpuIdLeaf
567{
568 CpuIdLeaf()
569 : ulId(UINT32_MAX),
570 ulEax(0),
571 ulEbx(0),
572 ulEcx(0),
573 ulEdx(0)
574 {}
575
576 bool operator==(const CpuIdLeaf &c) const
577 {
578 return ( (this == &c)
579 || ( (ulId == c.ulId)
580 && (ulEax == c.ulEax)
581 && (ulEbx == c.ulEbx)
582 && (ulEcx == c.ulEcx)
583 && (ulEdx == c.ulEdx)
584 )
585 );
586 }
587
588 uint32_t ulId;
589 uint32_t ulEax;
590 uint32_t ulEbx;
591 uint32_t ulEcx;
592 uint32_t ulEdx;
593};
594typedef std::list<CpuIdLeaf> CpuIdLeafsList;
595
596/**
597 * NOTE: If you add any fields in here, you must update a) the constructor and b)
598 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
599 * your settings might never get saved.
600 */
601struct Cpu
602{
603 Cpu()
604 : ulId(UINT32_MAX)
605 {}
606
607 bool operator==(const Cpu &c) const
608 {
609 return (ulId == c.ulId);
610 }
611
612 uint32_t ulId;
613};
614typedef std::list<Cpu> CpuList;
615
616/**
617 * NOTE: If you add any fields in here, you must update a) the constructor and b)
618 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
619 * your settings might never get saved.
620 */
621struct IoSettings
622{
623 IoSettings();
624
625 bool operator==(const IoSettings &i) const
626 {
627 return ( (ioMgrType == i.ioMgrType)
628 && (ioBackendType == i.ioBackendType)
629 && (fIoCacheEnabled == i.fIoCacheEnabled)
630 && (ulIoCacheSize == i.ulIoCacheSize)
631 && (ulIoBandwidthMax == i.ulIoBandwidthMax));
632 }
633
634 IoMgrType_T ioMgrType;
635 IoBackendType_T ioBackendType;
636 bool fIoCacheEnabled;
637 uint32_t ulIoCacheSize;
638 uint32_t ulIoBandwidthMax;
639};
640
641/**
642 * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
643 * field.
644 *
645 * NOTE: If you add any fields in here, you must update a) the constructor and b)
646 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
647 * your settings might never get saved.
648 */
649struct Hardware
650{
651 Hardware();
652
653 bool operator==(const Hardware&) const;
654
655 com::Utf8Str strVersion; // hardware version, optional
656 com::Guid uuid; // hardware uuid, optional (null).
657
658 bool fHardwareVirt,
659 fHardwareVirtExclusive,
660 fNestedPaging,
661 fLargePages,
662 fVPID,
663 fSyntheticCpu,
664 fPAE;
665 uint32_t cCPUs;
666 bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
667 CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
668 bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
669
670 CpuIdLeafsList llCpuIdLeafs;
671
672 uint32_t ulMemorySizeMB;
673
674 BootOrderMap mapBootOrder; // item 0 has highest priority
675
676 uint32_t ulVRAMSizeMB;
677 uint32_t cMonitors;
678 bool fAccelerate3D,
679 fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
680 FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
681
682 PointingHidType_T pointingHidType; // requires settings version 1.10 (VirtualBox 3.2)
683 KeyboardHidType_T keyboardHidType; // requires settings version 1.10 (VirtualBox 3.2)
684
685 VRDPSettings vrdpSettings;
686
687 BIOSSettings biosSettings;
688 USBController usbController;
689 NetworkAdaptersList llNetworkAdapters;
690 SerialPortsList llSerialPorts;
691 ParallelPortsList llParallelPorts;
692 AudioAdapter audioAdapter;
693
694 // technically these two have no business in the hardware section, but for some
695 // clever reason <Hardware> is where they are in the XML....
696 SharedFoldersList llSharedFolders;
697 ClipboardMode_T clipboardMode;
698
699 uint32_t ulMemoryBalloonSize;
700
701 GuestPropertiesList llGuestProperties;
702 com::Utf8Str strNotificationPatterns;
703
704 IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
705};
706
707/**
708 * A device attached to a storage controller. This can either be a
709 * hard disk or a DVD drive or a floppy drive and also specifies
710 * which medium is "in" the drive; as a result, this is a combination
711 * of the Main IMedium and IMediumAttachment interfaces.
712 *
713 * NOTE: If you add any fields in here, you must update a) the constructor and b)
714 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
715 * your settings might never get saved.
716 */
717struct AttachedDevice
718{
719 AttachedDevice()
720 : deviceType(DeviceType_Null),
721 fPassThrough(false),
722 lPort(0),
723 lDevice(0)
724 {}
725
726 bool operator==(const AttachedDevice &a) const;
727
728 DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
729
730 // DVDs can be in pass-through mode:
731 bool fPassThrough;
732
733 int32_t lPort;
734 int32_t lDevice;
735
736 // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
737 // this is its UUID; it depends on deviceType which media registry this then needs to
738 // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
739 com::Guid uuid;
740
741 // for DVDs and floppies, the attachment can also be a host device:
742 com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
743};
744typedef std::list<AttachedDevice> AttachedDevicesList;
745
746/**
747 * NOTE: If you add any fields in here, you must update a) the constructor and b)
748 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
749 * your settings might never get saved.
750 */
751struct StorageController
752{
753 StorageController()
754 : storageBus(StorageBus_IDE),
755 controllerType(StorageControllerType_PIIX3),
756 ulPortCount(2),
757 ulInstance(0),
758 lIDE0MasterEmulationPort(0),
759 lIDE0SlaveEmulationPort(0),
760 lIDE1MasterEmulationPort(0),
761 lIDE1SlaveEmulationPort(0)
762 {}
763
764 bool operator==(const StorageController &s) const;
765
766 com::Utf8Str strName;
767 StorageBus_T storageBus; // _SATA, _SCSI, _IDE
768 StorageControllerType_T controllerType;
769 uint32_t ulPortCount;
770 uint32_t ulInstance;
771
772 // only for when controllerType == StorageControllerType_IntelAhci:
773 int32_t lIDE0MasterEmulationPort,
774 lIDE0SlaveEmulationPort,
775 lIDE1MasterEmulationPort,
776 lIDE1SlaveEmulationPort;
777
778 AttachedDevicesList llAttachedDevices;
779};
780typedef std::list<StorageController> StorageControllersList;
781
782/**
783 * We wrap the storage controllers list into an extra struct so we can
784 * use an undefined struct without needing std::list<> in all the headers.
785 *
786 * NOTE: If you add any fields in here, you must update a) the constructor and b)
787 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
788 * your settings might never get saved.
789 */
790struct Storage
791{
792 bool operator==(const Storage &s) const;
793
794 StorageControllersList llStorageControllers;
795};
796
797struct Snapshot;
798typedef std::list<Snapshot> SnapshotsList;
799
800/**
801 * NOTE: If you add any fields in here, you must update a) the constructor and b)
802 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
803 * your settings might never get saved.
804 */
805struct Snapshot
806{
807 bool operator==(const Snapshot &s) const;
808
809 com::Guid uuid;
810 com::Utf8Str strName,
811 strDescription; // optional
812 RTTIMESPEC timestamp;
813
814 com::Utf8Str strStateFile; // for online snapshots only
815
816 Hardware hardware;
817 Storage storage;
818
819 SnapshotsList llChildSnapshots;
820};
821
822/**
823 * MachineConfigFile represents an XML machine configuration. All the machine settings
824 * that go out to the XML (or are read from it) are in here.
825 *
826 * NOTE: If you add any fields in here, you must update a) the constructor and b)
827 * the operator== which is used by Machine::saveSettings(), or otherwise your settings
828 * might never get saved.
829 */
830class MachineConfigFile : public ConfigFileBase
831{
832public:
833 com::Guid uuid;
834 com::Utf8Str strName;
835 bool fNameSync;
836 com::Utf8Str strDescription;
837 com::Utf8Str strOsType;
838 com::Utf8Str strStateFile;
839 com::Guid uuidCurrentSnapshot;
840 com::Utf8Str strSnapshotFolder;
841 bool fTeleporterEnabled;
842 uint32_t uTeleporterPort;
843 com::Utf8Str strTeleporterAddress;
844 com::Utf8Str strTeleporterPassword;
845 bool fRTCUseUTC;
846
847 bool fCurrentStateModified; // optional, default is true
848 RTTIMESPEC timeLastStateChange; // optional, defaults to now
849 bool fAborted; // optional, default is false
850
851 Hardware hardwareMachine;
852 Storage storageMachine;
853
854 ExtraDataItemsMap mapExtraDataItems;
855
856 SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
857
858 MachineConfigFile(const com::Utf8Str *pstrFilename);
859
860 bool operator==(const MachineConfigFile &m) const;
861
862 void importMachineXML(const xml::ElementNode &elmMachine);
863
864 void write(const com::Utf8Str &strFilename);
865
866 enum
867 {
868 BuildMachineXML_IncludeSnapshots = 0x01,
869 BuildMachineXML_WriteVboxVersionAttribute = 0x02
870 };
871 void buildMachineXML(xml::ElementNode &elmMachine, uint32_t fl);
872
873private:
874 void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
875 void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
876 void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
877 void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
878 void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
879 void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
880 void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
881 void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
882 void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
883 void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
884 void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
885 void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
886 void convertOldOSType_pre1_5(com::Utf8Str &str);
887 void readMachine(const xml::ElementNode &elmMachine);
888
889 void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
890 void buildStorageControllersXML(xml::ElementNode &elmParent, const Storage &st);
891 void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
892
893 void bumpSettingsVersionIfNeeded();
894};
895
896} // namespace settings
897
898
899#endif /* ___VBox_settings_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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