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