VirtualBox

source: vbox/trunk/src/VBox/Main/include/ovfreader.h@ 78228

Last change on this file since 78228 was 76562, checked in by vboxsync, 6 years ago

Main: Use MAIN_INCLUDED_ and MAIN_INCLUDED_SRC_ as header guard prefixes with scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.7 KB
Line 
1/* $Id: ovfreader.h 76562 2019-01-01 03:22:50Z vboxsync $ */
2/** @file
3 * VirtualBox Main - OVF reader declarations.
4 *
5 * Depends only on IPRT, including the RTCString and IPRT XML classes.
6 */
7
8/*
9 * Copyright (C) 2008-2019 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#ifndef MAIN_INCLUDED_ovfreader_h
21#define MAIN_INCLUDED_ovfreader_h
22#ifndef RT_WITHOUT_PRAGMA_ONCE
23# pragma once
24#endif
25
26#include "iprt/cpp/xml.h"
27#include <map>
28#include <vector>
29
30namespace ovf
31{
32
33////////////////////////////////////////////////////////////////////////////////
34//
35// Errors
36//
37////////////////////////////////////////////////////////////////////////////////
38
39/**
40 * Thrown by OVFReader for any kind of error that is not an XML error but
41 * still makes the OVF impossible to parse. Based on xml::LogicError so
42 * that one catch() for all xml::LogicError can handle all possible errors.
43 */
44class OVFLogicError : public xml::LogicError
45{
46public:
47 OVFLogicError(const char *aFormat, ...);
48};
49
50
51////////////////////////////////////////////////////////////////////////////////
52//
53// Enumerations
54//
55////////////////////////////////////////////////////////////////////////////////
56
57/**
58 * CIM OS values.
59 *
60 * The OVF 1.10 spec refers to some CIM_OperatingSystem.mof doc. Could this be it:
61 * http://cvs.opengroup.org/cgi-bin/cvsweb.cgi/pegasus/Schemas/CIM231/DMTF/System/CIM_OperatingSystem.mof
62 *
63 * @todo r=bird: Why are the values are repeating 'CIMOS'. CIMOSType_T is also
64 * repeating it self, 'Type' and '_T'. Why not call it kCIOMOpSys,
65 * easier to read as well.
66 * Then also apply: s/CIMOSType_CIMOS_/kCIMOpSys_/g
67 */
68enum CIMOSType_T
69{
70 CIMOSType_CIMOS_Unknown = 0,
71 CIMOSType_CIMOS_Other = 1,
72 CIMOSType_CIMOS_MACOS = 2,
73 CIMOSType_CIMOS_ATTUNIX = 3,
74 CIMOSType_CIMOS_DGUX = 4,
75 CIMOSType_CIMOS_DECNT = 5,
76 CIMOSType_CIMOS_Tru64UNIX = 6,
77 CIMOSType_CIMOS_OpenVMS = 7,
78 CIMOSType_CIMOS_HPUX = 8,
79 CIMOSType_CIMOS_AIX = 9,
80 CIMOSType_CIMOS_MVS = 10,
81 CIMOSType_CIMOS_OS400 = 11,
82 CIMOSType_CIMOS_OS2 = 12,
83 CIMOSType_CIMOS_JavaVM = 13,
84 CIMOSType_CIMOS_MSDOS = 14,
85 CIMOSType_CIMOS_WIN3x = 15,
86 CIMOSType_CIMOS_WIN95 = 16,
87 CIMOSType_CIMOS_WIN98 = 17,
88 CIMOSType_CIMOS_WINNT = 18,
89 CIMOSType_CIMOS_WINCE = 19,
90 CIMOSType_CIMOS_NCR3000 = 20,
91 CIMOSType_CIMOS_NetWare = 21,
92 CIMOSType_CIMOS_OSF = 22,
93 CIMOSType_CIMOS_DCOS = 23,
94 CIMOSType_CIMOS_ReliantUNIX = 24,
95 CIMOSType_CIMOS_SCOUnixWare = 25,
96 CIMOSType_CIMOS_SCOOpenServer = 26,
97 CIMOSType_CIMOS_Sequent = 27,
98 CIMOSType_CIMOS_IRIX = 28,
99 CIMOSType_CIMOS_Solaris = 29,
100 CIMOSType_CIMOS_SunOS = 30,
101 CIMOSType_CIMOS_U6000 = 31,
102 CIMOSType_CIMOS_ASERIES = 32,
103 CIMOSType_CIMOS_HPNonStopOS = 33,
104 CIMOSType_CIMOS_HPNonStopOSS = 34,
105 CIMOSType_CIMOS_BS2000 = 35,
106 CIMOSType_CIMOS_LINUX = 36,
107 CIMOSType_CIMOS_Lynx = 37,
108 CIMOSType_CIMOS_XENIX = 38,
109 CIMOSType_CIMOS_VM = 39,
110 CIMOSType_CIMOS_InteractiveUNIX = 40,
111 CIMOSType_CIMOS_BSDUNIX = 41,
112 CIMOSType_CIMOS_FreeBSD = 42,
113 CIMOSType_CIMOS_NetBSD = 43,
114 CIMOSType_CIMOS_GNUHurd = 44,
115 CIMOSType_CIMOS_OS9 = 45,
116 CIMOSType_CIMOS_MACHKernel = 46,
117 CIMOSType_CIMOS_Inferno = 47,
118 CIMOSType_CIMOS_QNX = 48,
119 CIMOSType_CIMOS_EPOC = 49,
120 CIMOSType_CIMOS_IxWorks = 50,
121 CIMOSType_CIMOS_VxWorks = 51,
122 CIMOSType_CIMOS_MiNT = 52,
123 CIMOSType_CIMOS_BeOS = 53,
124 CIMOSType_CIMOS_HPMPE = 54,
125 CIMOSType_CIMOS_NextStep = 55,
126 CIMOSType_CIMOS_PalmPilot = 56,
127 CIMOSType_CIMOS_Rhapsody = 57,
128 CIMOSType_CIMOS_Windows2000 = 58,
129 CIMOSType_CIMOS_Dedicated = 59,
130 CIMOSType_CIMOS_OS390 = 60,
131 CIMOSType_CIMOS_VSE = 61,
132 CIMOSType_CIMOS_TPF = 62,
133 CIMOSType_CIMOS_WindowsMe = 63,
134 CIMOSType_CIMOS_CalderaOpenUNIX = 64,
135 CIMOSType_CIMOS_OpenBSD = 65,
136 CIMOSType_CIMOS_NotApplicable = 66,
137 CIMOSType_CIMOS_WindowsXP = 67,
138 CIMOSType_CIMOS_zOS = 68,
139 CIMOSType_CIMOS_MicrosoftWindowsServer2003 = 69,
140 CIMOSType_CIMOS_MicrosoftWindowsServer2003_64 = 70,
141 CIMOSType_CIMOS_WindowsXP_64 = 71,
142 CIMOSType_CIMOS_WindowsXPEmbedded = 72,
143 CIMOSType_CIMOS_WindowsVista = 73,
144 CIMOSType_CIMOS_WindowsVista_64 = 74,
145 CIMOSType_CIMOS_WindowsEmbeddedforPointofService = 75,
146 CIMOSType_CIMOS_MicrosoftWindowsServer2008 = 76,
147 CIMOSType_CIMOS_MicrosoftWindowsServer2008_64 = 77,
148 CIMOSType_CIMOS_FreeBSD_64 = 78,
149 CIMOSType_CIMOS_RedHatEnterpriseLinux = 79,
150 CIMOSType_CIMOS_RedHatEnterpriseLinux_64 = 80,
151 CIMOSType_CIMOS_Solaris_64 = 81,
152 CIMOSType_CIMOS_SUSE = 82,
153 CIMOSType_CIMOS_SUSE_64 = 83,
154 CIMOSType_CIMOS_SLES = 84,
155 CIMOSType_CIMOS_SLES_64 = 85,
156 CIMOSType_CIMOS_NovellOES = 86,
157 CIMOSType_CIMOS_NovellLinuxDesktop = 87,
158 CIMOSType_CIMOS_SunJavaDesktopSystem = 88,
159 CIMOSType_CIMOS_Mandriva = 89,
160 CIMOSType_CIMOS_Mandriva_64 = 90,
161 CIMOSType_CIMOS_TurboLinux = 91,
162 CIMOSType_CIMOS_TurboLinux_64 = 92,
163 CIMOSType_CIMOS_Ubuntu = 93,
164 CIMOSType_CIMOS_Ubuntu_64 = 94,
165 CIMOSType_CIMOS_Debian = 95,
166 CIMOSType_CIMOS_Debian_64 = 96,
167 CIMOSType_CIMOS_Linux_2_4_x = 97,
168 CIMOSType_CIMOS_Linux_2_4_x_64 = 98,
169 CIMOSType_CIMOS_Linux_2_6_x = 99,
170 CIMOSType_CIMOS_Linux_2_6_x_64 = 100,
171 CIMOSType_CIMOS_Linux_64 = 101,
172 CIMOSType_CIMOS_Other_64 = 102,
173 // types added with CIM 2.25.0 follow:
174 CIMOSType_CIMOS_WindowsServer2008R2 = 103,
175 CIMOSType_CIMOS_VMwareESXi = 104,
176 CIMOSType_CIMOS_Windows7 = 105,
177 CIMOSType_CIMOS_CentOS = 106,
178 CIMOSType_CIMOS_CentOS_64 = 107,
179 CIMOSType_CIMOS_OracleEnterpriseLinux = 108,
180 CIMOSType_CIMOS_OracleEnterpriseLinux_64 = 109,
181 CIMOSType_CIMOS_eComStation = 110
182 // no new types added with CIM 2.26.0
183};
184
185enum OVFVersion_T
186{
187 OVFVersion_unknown,
188 OVFVersion_0_9,
189 OVFVersion_1_0,
190 OVFVersion_2_0
191};
192
193const char* const OVF09_URI_string = "http://www.vmware.com/schema/ovf/1/envelope";
194const char* const OVF10_URI_string = "http://schemas.dmtf.org/ovf/envelope/1";
195const char* const OVF20_URI_string = "http://schemas.dmtf.org/ovf/envelope/2";
196
197const char* const DTMF_SPECS_URI = "http://schemas.dmtf.org/wbem/cim-html/2/";
198
199////////////////////////////////////////////////////////////////////////////////
200//
201// Envelope data
202//
203////////////////////////////////////////////////////////////////////////////////
204struct EnvelopeData
205{
206 OVFVersion_T version;//OVF standard version, it is used internally only by VirtualBox
207 RTCString lang;//language
208
209 OVFVersion_T getOVFVersion() const
210 {
211 return version;
212 }
213
214
215 RTCString getStringOVFVersion() const
216 {
217 if (version == OVFVersion_0_9)
218 return "0.9";
219 else if (version == OVFVersion_1_0)
220 return "1.0";
221 else if (version == OVFVersion_2_0)
222 return "2.0";
223 else
224 return "";
225 }
226
227 void setOVFVersion(OVFVersion_T v)
228 {
229 version = v;
230 }
231};
232
233
234struct FileReference
235{
236 RTCString strHref; // value from /References/File/@href (filename)
237 RTCString strDiskId; // value from /References/File/@id ()
238};
239
240typedef std::map<uint32_t, FileReference> FileReferenceMap;
241
242////////////////////////////////////////////////////////////////////////////////
243//
244// Hardware definition structs
245//
246////////////////////////////////////////////////////////////////////////////////
247
248struct DiskImage
249{
250 // fields from /DiskSection/Disk
251 RTCString strDiskId; // value from DiskSection/Disk/@diskId
252 int64_t iCapacity; // value from DiskSection/Disk/@capacity;
253 // (maximum size for dynamic images, I guess; we always translate this to bytes)
254 int64_t iPopulatedSize; // optional value from DiskSection/Disk/@populatedSize
255 // (actual used size of disk, always in bytes; can be an estimate of used disk
256 // space, but cannot be larger than iCapacity; -1 if not set)
257 RTCString strFormat; // value from DiskSection/Disk/@format
258 // typically http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized
259 RTCString uuidVBox; // optional; if the file was exported by VirtualBox >= 3.2,
260 // then this has the UUID with which the disk was registered
261
262 // fields from /References/File; the spec says the file reference from disk can be empty,
263 // so in that case, strFilename will be empty, then a new disk should be created
264 RTCString strHref; // value from /References/File/@href (filename); if empty, then the remaining fields are ignored
265 int64_t iSize; // value from /References/File/@size (optional according to spec; then we set -1 here)
266 int64_t iChunkSize; // value from /References/File/@chunkSize (optional, unsupported)
267 RTCString strCompression; // value from /References/File/@compression (optional, can be "gzip" according to spec)
268
269 // additional field which has a descriptive size in megabytes derived from the above; this can be used for progress reports
270 uint32_t ulSuggestedSizeMB;
271};
272
273enum ResourceType_T
274{ ResourceType_Other = 1,
275 ResourceType_ComputerSystem = 2,
276 ResourceType_Processor = 3,
277 ResourceType_Memory = 4,
278 ResourceType_IDEController = 5,
279 ResourceType_ParallelSCSIHBA = 6,
280 ResourceType_FCHBA = 7,
281 ResourceType_iSCSIHBA = 8,
282 ResourceType_IBHCA = 9,
283 ResourceType_EthernetAdapter = 10,
284 ResourceType_OtherNetworkAdapter = 11,
285 ResourceType_IOSlot = 12,
286 ResourceType_IODevice = 13,
287 ResourceType_FloppyDrive = 14,
288 ResourceType_CDDrive = 15,
289 ResourceType_DVDDrive = 16,
290 ResourceType_HardDisk = 17,
291 ResourceType_OtherStorageDevice = 20,
292 ResourceType_USBController = 23,
293 ResourceType_SoundCard = 35
294};
295
296
297enum StorageAccessType_T
298{ StorageAccessType_Unknown = 0,
299 StorageAccessType_Readable = 1,
300 StorageAccessType_Writeable = 2,
301 StorageAccessType_ReadWrite = 3
302};
303
304enum ComplianceType_T
305{ ComplianceType_No = 0,
306 ComplianceType_Soft = 1,
307 ComplianceType_Medium = 2,
308 ComplianceType_Strong = 3
309};
310
311class VirtualHardwareItem
312{
313public:
314 RTCString strDescription;
315 RTCString strCaption;
316 RTCString strElementName;
317
318 uint32_t ulInstanceID;
319 uint32_t ulParent;
320
321 ResourceType_T resourceType;
322 RTCString strOtherResourceType;
323 RTCString strResourceSubType;
324 bool fResourceRequired;
325
326 RTCString strHostResource; // "Abstractly specifies how a device shall connect to a resource on the deployment platform.
327 // Not all devices need a backing." Used with disk items, for which this references a virtual
328 // disk from the Disks section.
329 bool fAutomaticAllocation;
330 bool fAutomaticDeallocation;
331 RTCString strConnection; // "All Ethernet adapters that specify the same abstract network connection name within an OVF
332 // package shall be deployed on the same network. The abstract network connection name shall be
333 // listed in the NetworkSection at the outermost envelope level." We ignore this and only set up
334 // a network adapter depending on the network name.
335 RTCString strAddress; // "Device-specific. For an Ethernet adapter, this specifies the MAC address."
336 int32_t lAddress; // strAddress as an integer, if applicable.
337 RTCString strAddressOnParent; // "For a device, this specifies its location on the controller."
338 RTCString strAllocationUnits; // "Specifies the units of allocation used. For example, “byte * 2^20”."
339 uint64_t ullVirtualQuantity; // "Specifies the quantity of resources presented. For example, “256”."
340 uint64_t ullReservation; // "Specifies the minimum quantity of resources guaranteed to be available."
341 uint64_t ullLimit; // "Specifies the maximum quantity of resources that will be granted."
342 uint64_t ullWeight; // "Specifies a relative priority for this allocation in relation to other allocations."
343
344 RTCString strConsumerVisibility;
345 RTCString strMappingBehavior;
346 RTCString strPoolID;
347 uint32_t ulBusNumber; // seen with IDE controllers, but not listed in OVF spec
348
349 uint32_t ulLineNumber; // line number of <Item> element in XML source; cached for error messages
350
351 VirtualHardwareItem()
352 : ulInstanceID(0),
353 fResourceRequired(false),
354 fAutomaticAllocation(false),
355 fAutomaticDeallocation(false),
356 ullVirtualQuantity(0),
357 ullReservation(0),
358 ullLimit(0),
359 ullWeight(0),
360 ulBusNumber(0),
361 ulLineNumber(0),
362 fDefault(false)
363 {
364 itemName = "Item";
365 };
366
367 virtual ~VirtualHardwareItem() { /* Makes MSC happy. */ }
368
369 void fillItem(const xml::ElementNode *item);
370
371 void setDefaultFlag()
372 {
373 fDefault = true;
374 }
375
376 bool isThereDefaultValues() const
377 {
378 return fDefault;
379 }
380
381 void checkConsistencyAndCompliance() RT_THROW(OVFLogicError)
382 {
383 _checkConsistencyAndCompliance();
384 }
385
386protected:
387 virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
388 virtual const RTCString& getItemName()
389 {
390 return _getItemName();
391 }
392
393private:
394 RTCString itemName;
395 bool fDefault;//true means that some fields were absent in the XML and some default values were assigned to.
396
397 virtual const RTCString& _getItemName()
398 {
399 return itemName;
400 }
401};
402
403class StorageItem: public VirtualHardwareItem
404{
405 //see DMTF Schema Documentation http://schemas.dmtf.org/wbem/cim-html/2/
406 StorageAccessType_T accessType;
407 RTCString strHostExtentName;
408 int16_t hostExtentNameFormat;
409 int16_t hostExtentNameNamespace;
410 int64_t hostExtentStartingAddress;
411 int64_t hostResourceBlockSize;
412 int64_t limit;
413 RTCString strOtherHostExtentNameFormat;
414 RTCString strOtherHostExtentNameNamespace;
415 int64_t reservation;
416 int64_t virtualQuantity;
417 RTCString strVirtualQuantityUnits;
418 int64_t virtualResourceBlockSize;
419
420public:
421 StorageItem(): VirtualHardwareItem(),
422 accessType(StorageAccessType_Unknown),
423 hostExtentNameFormat(-1),
424 hostExtentNameNamespace(-1),
425 hostExtentStartingAddress(-1),
426 hostResourceBlockSize(-1),
427 limit(-1),
428 reservation(-1),
429 virtualQuantity(-1),
430 virtualResourceBlockSize(-1)
431 {
432 itemName = "StorageItem";
433 };
434
435 void fillItem(const xml::ElementNode *item);
436
437protected:
438 virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
439private:
440 RTCString itemName;
441
442 virtual const RTCString& _getItemName()
443 {
444 return itemName;
445 }
446};
447
448
449class EthernetPortItem: public VirtualHardwareItem
450{
451 //see DMTF Schema Documentation http://schemas.dmtf.org/wbem/cim-html/2/
452 uint16_t DefaultPortVID;
453 uint16_t DefaultPriority;
454 uint16_t DesiredVLANEndpointMode;
455 uint32_t GroupID;
456 uint32_t ManagerID;
457 RTCString strNetworkPortProfileID;
458 uint16_t NetworkPortProfileIDType;
459 RTCString strOtherEndpointMode;
460 RTCString strOtherNetworkPortProfileIDTypeInfo;
461 RTCString strPortCorrelationID;
462 uint16_t PortVID;
463 bool Promiscuous;
464 uint64_t ReceiveBandwidthLimit;
465 uint16_t ReceiveBandwidthReservation;
466 bool SourceMACFilteringEnabled;
467 uint32_t VSITypeID;
468 uint8_t VSITypeIDVersion;
469 uint16_t AllowedPriorities[256];
470 RTCString strAllowedToReceiveMACAddresses;
471 uint16_t AllowedToReceiveVLANs[256];
472 RTCString strAllowedToTransmitMACAddresses;
473 uint16_t AllowedToTransmitVLANs[256];
474
475public:
476 EthernetPortItem(): VirtualHardwareItem()
477 {
478 itemName = "EthernetPortItem";
479 };
480
481 void fillItem(const xml::ElementNode *item);
482
483protected:
484 virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
485private:
486 RTCString itemName;
487
488 virtual const RTCString& _getItemName()
489 {
490 return itemName;
491 }
492};
493
494typedef std::map<RTCString, DiskImage> DiskImagesMap;
495
496struct VirtualSystem;
497
498
499/**
500 * VirtualHardwareItem pointer vector with safe cleanup.
501 *
502 * We need to use object pointers because we also want EthernetPortItem and
503 * StorageItems to go into the container.
504 */
505class HardwareItemVector : public std::vector<VirtualHardwareItem *>
506{
507public:
508 HardwareItemVector() : std::vector<VirtualHardwareItem *>() { }
509 ~HardwareItemVector()
510 {
511 for (iterator it = begin(); it != end(); ++it)
512 delete(*it);
513 clear();
514 }
515
516 /* There is no copying of this vector. We'd need something like shared_ptr for that. */
517private:
518 HardwareItemVector(const VirtualSystem &);
519
520};
521
522struct HardDiskController
523{
524 uint32_t idController; // instance ID (Item/InstanceId); this gets referenced from VirtualDisk
525
526 enum ControllerSystemType { IDE, SATA, SCSI };
527 ControllerSystemType system; // one of IDE, SATA, SCSI
528
529 RTCString strControllerType;
530 // controller subtype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE)
531 // note that we treat LsiLogicSAS as a SCSI controller (system == SCSI) even though VirtualBox
532 // treats it as a fourth class besides IDE, SATA, SCSI
533
534 int32_t lAddress; // value from OVF "Address" element
535 bool fPrimary; // controller index; this is determined heuristically by the OVF reader and will
536 // be true for the first controller of this type (e.g. IDE primary ctler) or
537 // false for the next (e.g. IDE secondary ctler)
538
539 HardDiskController()
540 : idController(0),
541 lAddress(0),
542 fPrimary(true)
543 { }
544};
545
546typedef std::map<uint32_t, HardDiskController> ControllersMap;
547
548struct VirtualDisk
549{
550 uint32_t idController;// SCSI (or IDE) controller this disk is connected to;
551 // this must match HardDiskController.idController and
552 // points into VirtualSystem.mapControllers
553 uint32_t ulAddressOnParent;// parsed strAddressOnParent of hardware item; will be 0 or 1 for IDE
554 // and possibly higher for disks attached to SCSI controllers (untested)
555 RTCString strDiskId;// if the hard disk has an ovf:/disk/<id> reference,
556 // this receives the <id> component; points to one of the
557 // references in Appliance::Data.mapDisks
558 bool fEmpty;//true - empty disk, e.g. the component <rasd:HostResource>...</rasd:HostResource> is absent.
559};
560
561typedef std::map<RTCString, VirtualDisk> VirtualDisksMap;
562
563/**
564 * A list of EthernetAdapters is contained in VirtualSystem, representing the
565 * ethernet adapters in the virtual system.
566 */
567struct EthernetAdapter
568{
569 RTCString strAdapterType; // "PCNet32" or "E1000" or whatever; from <rasd:ResourceSubType>
570 RTCString strNetworkName; // from <rasd:Connection>
571};
572
573typedef std::list<EthernetAdapter> EthernetAdaptersList;
574
575/**
576 * A list of VirtualSystem structs is created by OVFReader::read(). Each refers to
577 * a \<VirtualSystem\> block in the OVF file.
578 */
579struct VirtualSystem
580{
581 RTCString strName; // copy of VirtualSystem/@id
582
583 RTCString strDescription; // copy of VirtualSystem/AnnotationSection content, if any
584
585 CIMOSType_T cimos;
586 RTCString strCimosDesc; // readable description of the cimos type in the case of cimos = 0/1/102
587 RTCString strTypeVBox; // optional type from @vbox:ostype attribute (VirtualBox 4.0 or higher)
588
589 RTCString strVirtualSystemType; // generic hardware description; OVF says this can be something like "vmx-4" or "xen";
590 // VMware Workstation 6.5 is "vmx-07"
591
592 HardwareItemVector vecHardwareItems; //< vector containing all virtual hardware items in parsing order.
593
594 uint64_t ullMemorySize; // always in bytes, copied from llHardwareItems; default = 0 (unspecified)
595 uint16_t cCPUs; // no. of CPUs, copied from llHardwareItems; default = 1
596
597 EthernetAdaptersList llEthernetAdapters; // (one for each VirtualSystem/Item[@ResourceType=10]element)
598
599 ControllersMap mapControllers;
600 // list of hard disk controllers
601 // (one for each VirtualSystem/Item[@ResourceType=6] element with accumulated data from children)
602
603 VirtualDisksMap mapVirtualDisks;
604 // (one for each VirtualSystem/Item[@ResourceType=17] element with accumulated data from children)
605
606 bool fHasFloppyDrive; // true if there's a floppy item in mapHardwareItems
607 bool fHasCdromDrive; // true if there's a CD-ROM item in mapHardwareItems; ISO images are not yet supported by OVFtool
608 bool fHasUsbController; // true if there's a USB controller item in mapHardwareItems
609
610 RTCString strSoundCardType; // if not empty, then the system wants a soundcard; this then specifies the hardware;
611 // VMware Workstation 6.5 uses "ensoniq1371" for example
612
613 RTCString strLicenseText; // license info if any; receives contents of VirtualSystem/EulaSection/License
614
615 RTCString strProduct; // product info if any; receives contents of VirtualSystem/ProductSection/Product
616 RTCString strVendor; // product info if any; receives contents of VirtualSystem/ProductSection/Vendor
617 RTCString strVersion; // product info if any; receives contents of VirtualSystem/ProductSection/Version
618 RTCString strProductUrl; // product info if any; receives contents of VirtualSystem/ProductSection/ProductUrl
619 RTCString strVendorUrl; // product info if any; receives contents of VirtualSystem/ProductSection/VendorUrl
620
621 const xml::ElementNode *pelmVBoxMachine; // pointer to <vbox:Machine> element under <VirtualSystem> element or NULL if not present
622
623 VirtualSystem()
624 : cimos(CIMOSType_CIMOS_Unknown),
625 ullMemorySize(0),
626 cCPUs(1),
627 fHasFloppyDrive(false),
628 fHasCdromDrive(false),
629 fHasUsbController(false),
630 pelmVBoxMachine(NULL)
631 {
632 }
633};
634
635////////////////////////////////////////////////////////////////////////////////
636//
637// Class OVFReader
638//
639////////////////////////////////////////////////////////////////////////////////
640
641/**
642 * OVFReader attempts to open, read in and parse an OVF XML file. This is all done
643 * in the constructor; if there is any kind of error in the file -- filesystem error
644 * from IPRT, XML parsing errors from libxml, or OVF logical errors --, exceptions
645 * are thrown. These are all based on xml::Error.
646 *
647 * Hence, use this class as follows:
648<code>
649 OVFReader *pReader = NULL;
650 try
651 {
652 pReader = new("/path/to/file.ovf");
653 }
654 catch (xml::Error &e)
655 {
656 printf("A terrible thing happened: %s", e.what());
657 }
658 // now go look at pReader->m_llVirtualSystem and what's in there
659 if (pReader)
660 delete pReader;
661</code>
662 */
663class OVFReader
664{
665public:
666 OVFReader(const void *pvBuf, size_t cbSize, const RTCString &path);
667 OVFReader(const RTCString &path);
668
669 // Data fields
670 EnvelopeData m_envelopeData; //data of root element "Envelope"
671 RTCString m_strPath; // file name given to constructor
672 DiskImagesMap m_mapDisks; // map of DiskImage structs, sorted by DiskImage.strDiskId
673 std::list<VirtualSystem> m_llVirtualSystems; // list of virtual systems, created by and valid after read()
674
675private:
676 xml::Document m_doc;
677
678 void parse();
679 void LoopThruSections(const xml::ElementNode *pReferencesElem, const xml::ElementNode *pCurElem);
680 void HandleDiskSection(const xml::ElementNode *pReferencesElem, const xml::ElementNode *pSectionElem);
681 void HandleNetworkSection(const xml::ElementNode *pSectionElem);
682 void HandleVirtualSystemContent(const xml::ElementNode *pContentElem);
683};
684
685} // end namespace ovf
686
687#endif /* !MAIN_INCLUDED_ovfreader_h */
688
Note: See TracBrowser for help on using the repository browser.

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