1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox Appliance private data definitions
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_APPLIANCEIMPLPRIVATE
|
---|
23 | #define ____H_APPLIANCEIMPLPRIVATE
|
---|
24 |
|
---|
25 | class VirtualSystemDescription;
|
---|
26 |
|
---|
27 | #include "ovfreader.h"
|
---|
28 |
|
---|
29 | ////////////////////////////////////////////////////////////////////////////////
|
---|
30 | //
|
---|
31 | // Appliance data definition
|
---|
32 | //
|
---|
33 | ////////////////////////////////////////////////////////////////////////////////
|
---|
34 |
|
---|
35 | /* Describe a location for the import/export. The location could be a file on a
|
---|
36 | * local hard disk or a remote target based on the supported inet protocols. */
|
---|
37 | struct Appliance::LocationInfo
|
---|
38 | {
|
---|
39 | LocationInfo()
|
---|
40 | : storageType(VFSType_File) {}
|
---|
41 | VFSType_T storageType; /* Which type of storage should be handled */
|
---|
42 | Utf8Str strPath; /* File path for the import/export */
|
---|
43 | Utf8Str strHostname; /* Hostname on remote storage locations (could be empty) */
|
---|
44 | Utf8Str strUsername; /* Username on remote storage locations (could be empty) */
|
---|
45 | Utf8Str strPassword; /* Password on remote storage locations (could be empty) */
|
---|
46 | };
|
---|
47 |
|
---|
48 | // opaque private instance data of Appliance class
|
---|
49 | struct Appliance::Data
|
---|
50 | {
|
---|
51 | enum ApplianceState { ApplianceIdle, ApplianceImporting, ApplianceExporting };
|
---|
52 |
|
---|
53 | Data()
|
---|
54 | : state(ApplianceIdle),
|
---|
55 | pReader(NULL)
|
---|
56 | {
|
---|
57 | }
|
---|
58 |
|
---|
59 | ~Data()
|
---|
60 | {
|
---|
61 | if (pReader)
|
---|
62 | {
|
---|
63 | delete pReader;
|
---|
64 | pReader = NULL;
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | ApplianceState state;
|
---|
69 |
|
---|
70 | LocationInfo locInfo; // location info for the currently processed OVF
|
---|
71 |
|
---|
72 | ovf::OVFReader *pReader;
|
---|
73 |
|
---|
74 | bool fBusyWriting; // state protection; while this is true nobody else can call methods
|
---|
75 |
|
---|
76 | std::list< ComObjPtr<VirtualSystemDescription> >
|
---|
77 | virtualSystemDescriptions;
|
---|
78 |
|
---|
79 | std::list<Utf8Str> llWarnings;
|
---|
80 |
|
---|
81 | ULONG ulWeightPerOperation;
|
---|
82 | ULONG ulTotalDisksMB;
|
---|
83 | ULONG cDisks;
|
---|
84 | Utf8Str strOVFSHA1Digest;
|
---|
85 | };
|
---|
86 |
|
---|
87 | struct Appliance::XMLStack
|
---|
88 | {
|
---|
89 | std::map<Utf8Str, const VirtualSystemDescriptionEntry*> mapDisks;
|
---|
90 | std::map<Utf8Str, bool> mapNetworks;
|
---|
91 | };
|
---|
92 |
|
---|
93 | struct Appliance::TaskOVF
|
---|
94 | {
|
---|
95 | enum TaskType
|
---|
96 | {
|
---|
97 | Read,
|
---|
98 | Import,
|
---|
99 | Write
|
---|
100 | };
|
---|
101 |
|
---|
102 | TaskOVF(Appliance *aThat,
|
---|
103 | TaskType aType,
|
---|
104 | LocationInfo aLocInfo,
|
---|
105 | ComObjPtr<Progress> &aProgress)
|
---|
106 | : pAppliance(aThat),
|
---|
107 | taskType(aType),
|
---|
108 | locInfo(aLocInfo),
|
---|
109 | pProgress(aProgress),
|
---|
110 | enFormat(unspecified),
|
---|
111 | rc(S_OK)
|
---|
112 | {}
|
---|
113 |
|
---|
114 | static int updateProgress(unsigned uPercent, void *pvUser);
|
---|
115 |
|
---|
116 | int startThread();
|
---|
117 |
|
---|
118 | Appliance *pAppliance;
|
---|
119 | TaskType taskType;
|
---|
120 | const LocationInfo locInfo;
|
---|
121 | ComObjPtr<Progress> pProgress;
|
---|
122 |
|
---|
123 | OVFFormat enFormat;
|
---|
124 |
|
---|
125 | HRESULT rc;
|
---|
126 | };
|
---|
127 |
|
---|
128 | struct MyHardDiskAttachment
|
---|
129 | {
|
---|
130 | Bstr bstrUuid;
|
---|
131 | ComPtr<IMachine> pMachine;
|
---|
132 | Bstr controllerType;
|
---|
133 | int32_t lChannel;
|
---|
134 | int32_t lDevice;
|
---|
135 | };
|
---|
136 |
|
---|
137 | ////////////////////////////////////////////////////////////////////////////////
|
---|
138 | //
|
---|
139 | // VirtualSystemDescription data definition
|
---|
140 | //
|
---|
141 | ////////////////////////////////////////////////////////////////////////////////
|
---|
142 |
|
---|
143 | struct VirtualSystemDescription::Data
|
---|
144 | {
|
---|
145 | std::list<VirtualSystemDescriptionEntry>
|
---|
146 | llDescriptions; // item descriptions
|
---|
147 |
|
---|
148 | ComPtr<Machine> pMachine; // VirtualBox machine this description was exported from (export only)
|
---|
149 |
|
---|
150 | settings::MachineConfigFile
|
---|
151 | *pConfig; // machine config created from <vbox:Machine> element if found (import only)
|
---|
152 | };
|
---|
153 |
|
---|
154 | ////////////////////////////////////////////////////////////////////////////////
|
---|
155 | //
|
---|
156 | // Internal helpers
|
---|
157 | //
|
---|
158 | ////////////////////////////////////////////////////////////////////////////////
|
---|
159 |
|
---|
160 | void convertCIMOSType2VBoxOSType(Utf8Str &strType, ovf::CIMOSType_T c, const Utf8Str &cStr);
|
---|
161 |
|
---|
162 | ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox);
|
---|
163 |
|
---|
164 | #endif // ____H_APPLIANCEIMPLPRIVATE
|
---|