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 | {}
|
---|
269 |
|
---|
270 | bool operator==(const VRDPSettings& v) const;
|
---|
271 |
|
---|
272 | bool fEnabled;
|
---|
273 | com::Utf8Str strPort;
|
---|
274 | com::Utf8Str strNetAddress;
|
---|
275 | VRDPAuthType_T authType;
|
---|
276 | uint32_t ulAuthTimeout;
|
---|
277 | bool fAllowMultiConnection,
|
---|
278 | fReuseSingleConnection;
|
---|
279 | };
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
283 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
284 | * your settings might never get saved.
|
---|
285 | */
|
---|
286 | struct BIOSSettings
|
---|
287 | {
|
---|
288 | BIOSSettings()
|
---|
289 | : fACPIEnabled(true),
|
---|
290 | fIOAPICEnabled(false),
|
---|
291 | fLogoFadeIn(true),
|
---|
292 | fLogoFadeOut(true),
|
---|
293 | ulLogoDisplayTime(0),
|
---|
294 | biosBootMenuMode(BIOSBootMenuMode_MessageAndMenu),
|
---|
295 | fPXEDebugEnabled(false),
|
---|
296 | llTimeOffset(0)
|
---|
297 | {}
|
---|
298 |
|
---|
299 | bool operator==(const BIOSSettings &d) const;
|
---|
300 |
|
---|
301 | bool fACPIEnabled,
|
---|
302 | fIOAPICEnabled,
|
---|
303 | fLogoFadeIn,
|
---|
304 | fLogoFadeOut;
|
---|
305 | uint32_t ulLogoDisplayTime;
|
---|
306 | com::Utf8Str strLogoImagePath;
|
---|
307 | BIOSBootMenuMode_T biosBootMenuMode;
|
---|
308 | bool fPXEDebugEnabled;
|
---|
309 | int64_t llTimeOffset;
|
---|
310 | };
|
---|
311 |
|
---|
312 | /**
|
---|
313 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
314 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
315 | * your settings might never get saved.
|
---|
316 | */
|
---|
317 | struct USBController
|
---|
318 | {
|
---|
319 | USBController()
|
---|
320 | : fEnabled(false),
|
---|
321 | fEnabledEHCI(false)
|
---|
322 | {}
|
---|
323 |
|
---|
324 | bool operator==(const USBController &u) const;
|
---|
325 |
|
---|
326 | bool fEnabled;
|
---|
327 | bool fEnabledEHCI;
|
---|
328 | USBDeviceFiltersList llDeviceFilters;
|
---|
329 | };
|
---|
330 |
|
---|
331 | struct NATRule
|
---|
332 | {
|
---|
333 | NATRule(): u32Proto(0),
|
---|
334 | u16HostPort(0),
|
---|
335 | u16GuestPort(0){}
|
---|
336 | com::Utf8Str strName;
|
---|
337 | uint32_t u32Proto;
|
---|
338 | uint16_t u16HostPort;
|
---|
339 | com::Utf8Str strHostIP;
|
---|
340 | uint16_t u16GuestPort;
|
---|
341 | com::Utf8Str strGuestIP;
|
---|
342 | bool operator==(const NATRule &r) const
|
---|
343 | {
|
---|
344 | return strName == r.strName
|
---|
345 | && u32Proto == r.u32Proto
|
---|
346 | && u16HostPort == r.u16HostPort
|
---|
347 | && strHostIP == r.strHostIP
|
---|
348 | && u16GuestPort == r.u16GuestPort
|
---|
349 | && strGuestIP == r.strGuestIP;
|
---|
350 | }
|
---|
351 | };
|
---|
352 | typedef std::list<NATRule> NATRuleList;
|
---|
353 |
|
---|
354 | struct NAT
|
---|
355 | {
|
---|
356 | NAT(): u32Mtu(0),
|
---|
357 | u32SockRcv(0),
|
---|
358 | u32SockSnd(0),
|
---|
359 | u32TcpRcv(0),
|
---|
360 | u32TcpSnd(0),
|
---|
361 | fDnsPassDomain(true), /* historically this value is true */
|
---|
362 | fDnsProxy(false),
|
---|
363 | fDnsUseHostResolver(false),
|
---|
364 | fAliasLog(false),
|
---|
365 | fAliasProxyOnly(false),
|
---|
366 | fAliasUseSamePorts(false){}
|
---|
367 | com::Utf8Str strNetwork;
|
---|
368 | com::Utf8Str strBindIP;
|
---|
369 | uint32_t u32Mtu;
|
---|
370 | uint32_t u32SockRcv;
|
---|
371 | uint32_t u32SockSnd;
|
---|
372 | uint32_t u32TcpRcv;
|
---|
373 | uint32_t u32TcpSnd;
|
---|
374 | com::Utf8Str strTftpPrefix;
|
---|
375 | com::Utf8Str strTftpBootFile;
|
---|
376 | com::Utf8Str strTftpNextServer;
|
---|
377 | bool fDnsPassDomain;
|
---|
378 | bool fDnsProxy;
|
---|
379 | bool fDnsUseHostResolver;
|
---|
380 | bool fAliasLog;
|
---|
381 | bool fAliasProxyOnly;
|
---|
382 | bool fAliasUseSamePorts;
|
---|
383 | NATRuleList llRules;
|
---|
384 | bool operator==(const NAT &n) const
|
---|
385 | {
|
---|
386 | return strNetwork == n.strNetwork
|
---|
387 | && strBindIP == n.strBindIP
|
---|
388 | && u32Mtu == n.u32Mtu
|
---|
389 | && u32SockRcv == n.u32SockRcv
|
---|
390 | && u32SockSnd == n.u32SockSnd
|
---|
391 | && u32TcpSnd == n.u32TcpSnd
|
---|
392 | && u32TcpRcv == n.u32TcpRcv
|
---|
393 | && strTftpPrefix == n.strTftpPrefix
|
---|
394 | && strTftpBootFile == n.strTftpBootFile
|
---|
395 | && strTftpNextServer == n.strTftpNextServer
|
---|
396 | && fDnsPassDomain == n.fDnsPassDomain
|
---|
397 | && fDnsProxy == n.fDnsProxy
|
---|
398 | && fDnsUseHostResolver == n.fDnsUseHostResolver
|
---|
399 | && llRules == n.llRules;
|
---|
400 | }
|
---|
401 | };
|
---|
402 | /**
|
---|
403 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
404 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
405 | * your settings might never get saved.
|
---|
406 | */
|
---|
407 | struct NetworkAdapter
|
---|
408 | {
|
---|
409 | NetworkAdapter()
|
---|
410 | : ulSlot(0),
|
---|
411 | type(NetworkAdapterType_Am79C970A),
|
---|
412 | fEnabled(false),
|
---|
413 | fCableConnected(false),
|
---|
414 | ulLineSpeed(0),
|
---|
415 | fTraceEnabled(false),
|
---|
416 | mode(NetworkAttachmentType_Null),
|
---|
417 | ulBootPriority(0),
|
---|
418 | fHasDisabledNAT(false)
|
---|
419 | {}
|
---|
420 |
|
---|
421 | bool operator==(const NetworkAdapter &n) const;
|
---|
422 |
|
---|
423 | uint32_t ulSlot;
|
---|
424 |
|
---|
425 | NetworkAdapterType_T type;
|
---|
426 | bool fEnabled;
|
---|
427 | com::Utf8Str strMACAddress;
|
---|
428 | bool fCableConnected;
|
---|
429 | uint32_t ulLineSpeed;
|
---|
430 | bool fTraceEnabled;
|
---|
431 | com::Utf8Str strTraceFile;
|
---|
432 |
|
---|
433 | NetworkAttachmentType_T mode;
|
---|
434 | NAT nat;
|
---|
435 | com::Utf8Str strName; // NAT has own attribute
|
---|
436 | // with bridged: host interface or empty;
|
---|
437 | // otherwise: network name (required)
|
---|
438 | uint32_t ulBootPriority;
|
---|
439 | bool fHasDisabledNAT;
|
---|
440 | };
|
---|
441 | typedef std::list<NetworkAdapter> NetworkAdaptersList;
|
---|
442 |
|
---|
443 | /**
|
---|
444 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
445 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
446 | * your settings might never get saved.
|
---|
447 | */
|
---|
448 | struct SerialPort
|
---|
449 | {
|
---|
450 | SerialPort()
|
---|
451 | : ulSlot(0),
|
---|
452 | fEnabled(false),
|
---|
453 | ulIOBase(0x3f8),
|
---|
454 | ulIRQ(4),
|
---|
455 | portMode(PortMode_Disconnected),
|
---|
456 | fServer(false)
|
---|
457 | {}
|
---|
458 |
|
---|
459 | bool operator==(const SerialPort &n) const;
|
---|
460 |
|
---|
461 | uint32_t ulSlot;
|
---|
462 |
|
---|
463 | bool fEnabled;
|
---|
464 | uint32_t ulIOBase;
|
---|
465 | uint32_t ulIRQ;
|
---|
466 | PortMode_T portMode;
|
---|
467 | com::Utf8Str strPath;
|
---|
468 | bool fServer;
|
---|
469 | };
|
---|
470 | typedef std::list<SerialPort> SerialPortsList;
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
474 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
475 | * your settings might never get saved.
|
---|
476 | */
|
---|
477 | struct ParallelPort
|
---|
478 | {
|
---|
479 | ParallelPort()
|
---|
480 | : ulSlot(0),
|
---|
481 | fEnabled(false),
|
---|
482 | ulIOBase(0x378),
|
---|
483 | ulIRQ(4)
|
---|
484 | {}
|
---|
485 |
|
---|
486 | bool operator==(const ParallelPort &d) const;
|
---|
487 |
|
---|
488 | uint32_t ulSlot;
|
---|
489 |
|
---|
490 | bool fEnabled;
|
---|
491 | uint32_t ulIOBase;
|
---|
492 | uint32_t ulIRQ;
|
---|
493 | com::Utf8Str strPath;
|
---|
494 | };
|
---|
495 | typedef std::list<ParallelPort> ParallelPortsList;
|
---|
496 |
|
---|
497 | /**
|
---|
498 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
499 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
500 | * your settings might never get saved.
|
---|
501 | */
|
---|
502 | struct AudioAdapter
|
---|
503 | {
|
---|
504 | AudioAdapter()
|
---|
505 | : fEnabled(true),
|
---|
506 | controllerType(AudioControllerType_AC97),
|
---|
507 | driverType(AudioDriverType_Null)
|
---|
508 | {}
|
---|
509 |
|
---|
510 | bool operator==(const AudioAdapter &a) const
|
---|
511 | {
|
---|
512 | return (this == &a)
|
---|
513 | || ( (fEnabled == a.fEnabled)
|
---|
514 | && (controllerType == a.controllerType)
|
---|
515 | && (driverType == a.driverType)
|
---|
516 | );
|
---|
517 | }
|
---|
518 |
|
---|
519 | bool fEnabled;
|
---|
520 | AudioControllerType_T controllerType;
|
---|
521 | AudioDriverType_T driverType;
|
---|
522 | };
|
---|
523 |
|
---|
524 | /**
|
---|
525 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
526 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
527 | * your settings might never get saved.
|
---|
528 | */
|
---|
529 | struct SharedFolder
|
---|
530 | {
|
---|
531 | SharedFolder()
|
---|
532 | : fWritable(false)
|
---|
533 | {}
|
---|
534 |
|
---|
535 | bool operator==(const SharedFolder &a) const;
|
---|
536 |
|
---|
537 | com::Utf8Str strName,
|
---|
538 | strHostPath;
|
---|
539 | bool fWritable;
|
---|
540 | };
|
---|
541 | typedef std::list<SharedFolder> SharedFoldersList;
|
---|
542 |
|
---|
543 | /**
|
---|
544 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
545 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
546 | * your settings might never get saved.
|
---|
547 | */
|
---|
548 | struct GuestProperty
|
---|
549 | {
|
---|
550 | GuestProperty()
|
---|
551 | : timestamp(0)
|
---|
552 | {};
|
---|
553 |
|
---|
554 | bool operator==(const GuestProperty &g) const;
|
---|
555 |
|
---|
556 | com::Utf8Str strName,
|
---|
557 | strValue;
|
---|
558 | uint64_t timestamp;
|
---|
559 | com::Utf8Str strFlags;
|
---|
560 | };
|
---|
561 | typedef std::list<GuestProperty> GuestPropertiesList;
|
---|
562 |
|
---|
563 | typedef std::map<uint32_t, DeviceType_T> BootOrderMap;
|
---|
564 |
|
---|
565 | /**
|
---|
566 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
567 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
568 | * your settings might never get saved.
|
---|
569 | */
|
---|
570 | struct CpuIdLeaf
|
---|
571 | {
|
---|
572 | CpuIdLeaf()
|
---|
573 | : ulId(UINT32_MAX),
|
---|
574 | ulEax(0),
|
---|
575 | ulEbx(0),
|
---|
576 | ulEcx(0),
|
---|
577 | ulEdx(0)
|
---|
578 | {}
|
---|
579 |
|
---|
580 | bool operator==(const CpuIdLeaf &c) const
|
---|
581 | {
|
---|
582 | return ( (this == &c)
|
---|
583 | || ( (ulId == c.ulId)
|
---|
584 | && (ulEax == c.ulEax)
|
---|
585 | && (ulEbx == c.ulEbx)
|
---|
586 | && (ulEcx == c.ulEcx)
|
---|
587 | && (ulEdx == c.ulEdx)
|
---|
588 | )
|
---|
589 | );
|
---|
590 | }
|
---|
591 |
|
---|
592 | uint32_t ulId;
|
---|
593 | uint32_t ulEax;
|
---|
594 | uint32_t ulEbx;
|
---|
595 | uint32_t ulEcx;
|
---|
596 | uint32_t ulEdx;
|
---|
597 | };
|
---|
598 | typedef std::list<CpuIdLeaf> CpuIdLeafsList;
|
---|
599 |
|
---|
600 | /**
|
---|
601 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
602 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
603 | * your settings might never get saved.
|
---|
604 | */
|
---|
605 | struct Cpu
|
---|
606 | {
|
---|
607 | Cpu()
|
---|
608 | : ulId(UINT32_MAX)
|
---|
609 | {}
|
---|
610 |
|
---|
611 | bool operator==(const Cpu &c) const
|
---|
612 | {
|
---|
613 | return (ulId == c.ulId);
|
---|
614 | }
|
---|
615 |
|
---|
616 | uint32_t ulId;
|
---|
617 | };
|
---|
618 | typedef std::list<Cpu> CpuList;
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
622 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
623 | * your settings might never get saved.
|
---|
624 | */
|
---|
625 | struct IoSettings
|
---|
626 | {
|
---|
627 | IoSettings();
|
---|
628 |
|
---|
629 | bool operator==(const IoSettings &i) const
|
---|
630 | {
|
---|
631 | return ( (ioMgrType == i.ioMgrType)
|
---|
632 | && (ioBackendType == i.ioBackendType)
|
---|
633 | && (fIoCacheEnabled == i.fIoCacheEnabled)
|
---|
634 | && (ulIoCacheSize == i.ulIoCacheSize)
|
---|
635 | && (ulIoBandwidthMax == i.ulIoBandwidthMax));
|
---|
636 | }
|
---|
637 |
|
---|
638 | IoMgrType_T ioMgrType;
|
---|
639 | IoBackendType_T ioBackendType;
|
---|
640 | bool fIoCacheEnabled;
|
---|
641 | uint32_t ulIoCacheSize;
|
---|
642 | uint32_t ulIoBandwidthMax;
|
---|
643 | };
|
---|
644 |
|
---|
645 | /**
|
---|
646 | * Representation of Machine hardware; this is used in the MachineConfigFile.hardwareMachine
|
---|
647 | * field.
|
---|
648 | *
|
---|
649 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
650 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
651 | * your settings might never get saved.
|
---|
652 | */
|
---|
653 | struct Hardware
|
---|
654 | {
|
---|
655 | Hardware();
|
---|
656 |
|
---|
657 | bool operator==(const Hardware&) const;
|
---|
658 |
|
---|
659 | com::Utf8Str strVersion; // hardware version, optional
|
---|
660 | com::Guid uuid; // hardware uuid, optional (null).
|
---|
661 |
|
---|
662 | bool fHardwareVirt,
|
---|
663 | fHardwareVirtExclusive,
|
---|
664 | fNestedPaging,
|
---|
665 | fLargePages,
|
---|
666 | fVPID,
|
---|
667 | fSyntheticCpu,
|
---|
668 | fPAE;
|
---|
669 | uint32_t cCPUs;
|
---|
670 | bool fCpuHotPlug; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
671 | CpuList llCpus; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
672 | bool fHpetEnabled; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
673 |
|
---|
674 | CpuIdLeafsList llCpuIdLeafs;
|
---|
675 |
|
---|
676 | uint32_t ulMemorySizeMB;
|
---|
677 |
|
---|
678 | BootOrderMap mapBootOrder; // item 0 has highest priority
|
---|
679 |
|
---|
680 | uint32_t ulVRAMSizeMB;
|
---|
681 | uint32_t cMonitors;
|
---|
682 | bool fAccelerate3D,
|
---|
683 | fAccelerate2DVideo; // requires settings version 1.8 (VirtualBox 3.1)
|
---|
684 | FirmwareType_T firmwareType; // requires settings version 1.9 (VirtualBox 3.1)
|
---|
685 |
|
---|
686 | PointingHidType_T pointingHidType; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
687 | KeyboardHidType_T keyboardHidType; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
688 |
|
---|
689 | VRDPSettings vrdpSettings;
|
---|
690 |
|
---|
691 | BIOSSettings biosSettings;
|
---|
692 | USBController usbController;
|
---|
693 | NetworkAdaptersList llNetworkAdapters;
|
---|
694 | SerialPortsList llSerialPorts;
|
---|
695 | ParallelPortsList llParallelPorts;
|
---|
696 | AudioAdapter audioAdapter;
|
---|
697 |
|
---|
698 | // technically these two have no business in the hardware section, but for some
|
---|
699 | // clever reason <Hardware> is where they are in the XML....
|
---|
700 | SharedFoldersList llSharedFolders;
|
---|
701 | ClipboardMode_T clipboardMode;
|
---|
702 |
|
---|
703 | uint32_t ulMemoryBalloonSize;
|
---|
704 |
|
---|
705 | GuestPropertiesList llGuestProperties;
|
---|
706 | com::Utf8Str strNotificationPatterns;
|
---|
707 |
|
---|
708 | IoSettings ioSettings; // requires settings version 1.10 (VirtualBox 3.2)
|
---|
709 | };
|
---|
710 |
|
---|
711 | /**
|
---|
712 | * A device attached to a storage controller. This can either be a
|
---|
713 | * hard disk or a DVD drive or a floppy drive and also specifies
|
---|
714 | * which medium is "in" the drive; as a result, this is a combination
|
---|
715 | * of the Main IMedium and IMediumAttachment interfaces.
|
---|
716 | *
|
---|
717 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
718 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
719 | * your settings might never get saved.
|
---|
720 | */
|
---|
721 | struct AttachedDevice
|
---|
722 | {
|
---|
723 | AttachedDevice()
|
---|
724 | : deviceType(DeviceType_Null),
|
---|
725 | fPassThrough(false),
|
---|
726 | lPort(0),
|
---|
727 | lDevice(0)
|
---|
728 | {}
|
---|
729 |
|
---|
730 | bool operator==(const AttachedDevice &a) const;
|
---|
731 |
|
---|
732 | DeviceType_T deviceType; // only HardDisk, DVD or Floppy are allowed
|
---|
733 |
|
---|
734 | // DVDs can be in pass-through mode:
|
---|
735 | bool fPassThrough;
|
---|
736 |
|
---|
737 | int32_t lPort;
|
---|
738 | int32_t lDevice;
|
---|
739 |
|
---|
740 | // if an image file is attached to the device (ISO, RAW, or hard disk image such as VDI),
|
---|
741 | // this is its UUID; it depends on deviceType which media registry this then needs to
|
---|
742 | // be looked up in. If no image file (only permitted for DVDs and floppies), then the UUID is NULL
|
---|
743 | com::Guid uuid;
|
---|
744 |
|
---|
745 | // for DVDs and floppies, the attachment can also be a host device:
|
---|
746 | com::Utf8Str strHostDriveSrc; // if != NULL, value of <HostDrive>/@src
|
---|
747 | };
|
---|
748 | typedef std::list<AttachedDevice> AttachedDevicesList;
|
---|
749 |
|
---|
750 | /**
|
---|
751 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
752 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
753 | * your settings might never get saved.
|
---|
754 | */
|
---|
755 | struct StorageController
|
---|
756 | {
|
---|
757 | StorageController()
|
---|
758 | : storageBus(StorageBus_IDE),
|
---|
759 | controllerType(StorageControllerType_PIIX3),
|
---|
760 | ulPortCount(2),
|
---|
761 | ulInstance(0),
|
---|
762 | ioBackendType(IoBackendType_Buffered),
|
---|
763 | lIDE0MasterEmulationPort(0),
|
---|
764 | lIDE0SlaveEmulationPort(0),
|
---|
765 | lIDE1MasterEmulationPort(0),
|
---|
766 | lIDE1SlaveEmulationPort(0)
|
---|
767 | {}
|
---|
768 |
|
---|
769 | bool operator==(const StorageController &s) const;
|
---|
770 |
|
---|
771 | com::Utf8Str strName;
|
---|
772 | StorageBus_T storageBus; // _SATA, _SCSI, _IDE, _SAS
|
---|
773 | StorageControllerType_T controllerType;
|
---|
774 | uint32_t ulPortCount;
|
---|
775 | uint32_t ulInstance;
|
---|
776 | IoBackendType_T ioBackendType;
|
---|
777 |
|
---|
778 | // only for when controllerType == StorageControllerType_IntelAhci:
|
---|
779 | int32_t lIDE0MasterEmulationPort,
|
---|
780 | lIDE0SlaveEmulationPort,
|
---|
781 | lIDE1MasterEmulationPort,
|
---|
782 | lIDE1SlaveEmulationPort;
|
---|
783 |
|
---|
784 | AttachedDevicesList llAttachedDevices;
|
---|
785 | };
|
---|
786 | typedef std::list<StorageController> StorageControllersList;
|
---|
787 |
|
---|
788 | /**
|
---|
789 | * We wrap the storage controllers list into an extra struct so we can
|
---|
790 | * use an undefined struct without needing std::list<> in all the headers.
|
---|
791 | *
|
---|
792 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
793 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
794 | * your settings might never get saved.
|
---|
795 | */
|
---|
796 | struct Storage
|
---|
797 | {
|
---|
798 | bool operator==(const Storage &s) const;
|
---|
799 |
|
---|
800 | StorageControllersList llStorageControllers;
|
---|
801 | };
|
---|
802 |
|
---|
803 | struct Snapshot;
|
---|
804 | typedef std::list<Snapshot> SnapshotsList;
|
---|
805 |
|
---|
806 | /**
|
---|
807 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
808 | * the operator== which is used by MachineConfigFile::operator==(), or otherwise
|
---|
809 | * your settings might never get saved.
|
---|
810 | */
|
---|
811 | struct Snapshot
|
---|
812 | {
|
---|
813 | bool operator==(const Snapshot &s) const;
|
---|
814 |
|
---|
815 | com::Guid uuid;
|
---|
816 | com::Utf8Str strName,
|
---|
817 | strDescription; // optional
|
---|
818 | RTTIMESPEC timestamp;
|
---|
819 |
|
---|
820 | com::Utf8Str strStateFile; // for online snapshots only
|
---|
821 |
|
---|
822 | Hardware hardware;
|
---|
823 | Storage storage;
|
---|
824 |
|
---|
825 | SnapshotsList llChildSnapshots;
|
---|
826 | };
|
---|
827 |
|
---|
828 | /**
|
---|
829 | * MachineConfigFile represents an XML machine configuration. All the machine settings
|
---|
830 | * that go out to the XML (or are read from it) are in here.
|
---|
831 | *
|
---|
832 | * NOTE: If you add any fields in here, you must update a) the constructor and b)
|
---|
833 | * the operator== which is used by Machine::saveSettings(), or otherwise your settings
|
---|
834 | * might never get saved.
|
---|
835 | */
|
---|
836 | class MachineConfigFile : public ConfigFileBase
|
---|
837 | {
|
---|
838 | public:
|
---|
839 | com::Guid uuid;
|
---|
840 | com::Utf8Str strName;
|
---|
841 | bool fNameSync;
|
---|
842 | com::Utf8Str strDescription;
|
---|
843 | com::Utf8Str strOsType;
|
---|
844 | com::Utf8Str strStateFile;
|
---|
845 | com::Guid uuidCurrentSnapshot;
|
---|
846 | com::Utf8Str strSnapshotFolder;
|
---|
847 | bool fTeleporterEnabled;
|
---|
848 | uint32_t uTeleporterPort;
|
---|
849 | com::Utf8Str strTeleporterAddress;
|
---|
850 | com::Utf8Str strTeleporterPassword;
|
---|
851 | bool fRTCUseUTC;
|
---|
852 |
|
---|
853 | bool fCurrentStateModified; // optional, default is true
|
---|
854 | RTTIMESPEC timeLastStateChange; // optional, defaults to now
|
---|
855 | bool fAborted; // optional, default is false
|
---|
856 |
|
---|
857 | Hardware hardwareMachine;
|
---|
858 | Storage storageMachine;
|
---|
859 |
|
---|
860 | ExtraDataItemsMap mapExtraDataItems;
|
---|
861 |
|
---|
862 | SnapshotsList llFirstSnapshot; // first snapshot or empty list if there's none
|
---|
863 |
|
---|
864 | MachineConfigFile(const com::Utf8Str *pstrFilename);
|
---|
865 |
|
---|
866 | bool operator==(const MachineConfigFile &m) const;
|
---|
867 |
|
---|
868 | void importMachineXML(const xml::ElementNode &elmMachine);
|
---|
869 |
|
---|
870 | void write(const com::Utf8Str &strFilename);
|
---|
871 |
|
---|
872 | enum
|
---|
873 | {
|
---|
874 | BuildMachineXML_IncludeSnapshots = 0x01,
|
---|
875 | BuildMachineXML_WriteVboxVersionAttribute = 0x02
|
---|
876 | };
|
---|
877 | void buildMachineXML(xml::ElementNode &elmMachine, uint32_t fl);
|
---|
878 |
|
---|
879 | private:
|
---|
880 | void readNetworkAdapters(const xml::ElementNode &elmHardware, NetworkAdaptersList &ll);
|
---|
881 | void readAttachedNetworkMode(const xml::ElementNode &pelmMode, bool fEnabled, NetworkAdapter &nic);
|
---|
882 | void readCpuIdTree(const xml::ElementNode &elmCpuid, CpuIdLeafsList &ll);
|
---|
883 | void readCpuTree(const xml::ElementNode &elmCpu, CpuList &ll);
|
---|
884 | void readSerialPorts(const xml::ElementNode &elmUART, SerialPortsList &ll);
|
---|
885 | void readParallelPorts(const xml::ElementNode &elmLPT, ParallelPortsList &ll);
|
---|
886 | void readGuestProperties(const xml::ElementNode &elmGuestProperties, Hardware &hw);
|
---|
887 | void readStorageControllerAttributes(const xml::ElementNode &elmStorageController, StorageController &sctl);
|
---|
888 | void readHardware(const xml::ElementNode &elmHardware, Hardware &hw, Storage &strg);
|
---|
889 | void readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, Storage &strg);
|
---|
890 | void readStorageControllers(const xml::ElementNode &elmStorageControllers, Storage &strg);
|
---|
891 | void readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHardware, Storage &strg);
|
---|
892 | void readSnapshot(const xml::ElementNode &elmSnapshot, Snapshot &snap);
|
---|
893 | void convertOldOSType_pre1_5(com::Utf8Str &str);
|
---|
894 | void readMachine(const xml::ElementNode &elmMachine);
|
---|
895 |
|
---|
896 | void buildHardwareXML(xml::ElementNode &elmParent, const Hardware &hw, const Storage &strg);
|
---|
897 | void buildNetworkXML(NetworkAttachmentType_T mode, xml::ElementNode &elmParent, const NetworkAdapter &nic);
|
---|
898 | void buildStorageControllersXML(xml::ElementNode &elmParent, const Storage &st);
|
---|
899 | void buildSnapshotXML(xml::ElementNode &elmParent, const Snapshot &snap);
|
---|
900 |
|
---|
901 | void bumpSettingsVersionIfNeeded();
|
---|
902 | };
|
---|
903 |
|
---|
904 | } // namespace settings
|
---|
905 |
|
---|
906 |
|
---|
907 | #endif /* ___VBox_settings_h */
|
---|