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