VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp@ 16515

Last change on this file since 16515 was 16515, checked in by vboxsync, 16 years ago

OVF: bring back string references; look up controllers by array item index, not internal refid; fix image config

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 KB
Line 
1/* $Id: VBoxManageImport.cpp 16515 2009-02-04 15:01:28Z vboxsync $ */
2/** @file
3 * VBoxManage - The appliance-related commands.
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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 VBOX_ONLY_DOCS
23
24/*******************************************************************************
25* Header Files *
26*******************************************************************************/
27#ifndef VBOX_ONLY_DOCS
28#include <VBox/com/com.h>
29#include <VBox/com/string.h>
30#include <VBox/com/Guid.h>
31#include <VBox/com/array.h>
32#include <VBox/com/ErrorInfo.h>
33#include <VBox/com/EventQueue.h>
34
35#include <VBox/com/VirtualBox.h>
36
37#include <list>
38#endif /* !VBOX_ONLY_DOCS */
39
40#include <iprt/stream.h>
41
42#include <VBox/log.h>
43
44#include "VBoxManage.h"
45using namespace com;
46
47
48// funcs
49///////////////////////////////////////////////////////////////////////////////
50
51int handleImportAppliance(HandlerArg *a)
52{
53 HRESULT rc = S_OK;
54
55 Utf8Str strOvfFilename;
56
57 for (int i = 0; i < a->argc; i++)
58 {
59 if (!strOvfFilename)
60 strOvfFilename = a->argv[i];
61 else
62 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Too many arguments for \"import\" command.");
63 }
64
65 if (!strOvfFilename)
66 return errorSyntax(USAGE_IMPORTAPPLIANCE, "Not enough arguments for \"import\" command.");
67
68 do
69 {
70 Bstr bstrOvfFilename(strOvfFilename);
71 ComPtr<IAppliance> appliance;
72 CHECK_ERROR_BREAK(a->virtualBox, OpenAppliance(bstrOvfFilename, appliance.asOutParam()));
73
74 RTPrintf("Interpreting...\n");
75 CHECK_ERROR_BREAK(appliance, Interpret());
76 RTPrintf("OK.\n");
77
78 // fetch all disks
79 com::SafeArray<BSTR> retDisks;
80 CHECK_ERROR_BREAK(appliance,
81 COMGETTER(Disks)(ComSafeArrayAsOutParam(retDisks)));
82 if (retDisks.size() > 0)
83 {
84 RTPrintf("Disks:");
85 for (unsigned i = 0; i < retDisks.size(); i++)
86 RTPrintf(" %ls", retDisks[i]);
87 RTPrintf("\n");
88 }
89
90 // fetch virtual system descriptions
91 com::SafeIfaceArray<IVirtualSystemDescription> aVirtualSystemDescriptions;
92 CHECK_ERROR_BREAK(appliance,
93 COMGETTER(VirtualSystemDescriptions)(ComSafeArrayAsOutParam(aVirtualSystemDescriptions)));
94 if (aVirtualSystemDescriptions.size() > 0)
95 {
96 for (unsigned i = 0; i < aVirtualSystemDescriptions.size(); ++i)
97 {
98 com::SafeArray<VirtualSystemDescriptionType_T> retTypes;
99 com::SafeArray<BSTR> aRefs;
100 com::SafeArray<BSTR> aOrigValues;
101 com::SafeArray<BSTR> aConfigValues;
102 com::SafeArray<BSTR> aExtraConfigValues;
103 CHECK_ERROR_BREAK(aVirtualSystemDescriptions[i],
104 GetDescription(ComSafeArrayAsOutParam(retTypes),
105 ComSafeArrayAsOutParam(aRefs),
106 ComSafeArrayAsOutParam(aOrigValues),
107 ComSafeArrayAsOutParam(aConfigValues),
108 ComSafeArrayAsOutParam(aExtraConfigValues)));
109
110 RTPrintf("Virtual system %i:\n", i);
111 for (unsigned a = 0; a < retTypes.size(); ++a)
112 {
113 VirtualSystemDescriptionType_T t = retTypes[a];
114
115 Bstr bstrVMname;
116 Bstr bstrOstype;
117 uint32_t ulMemMB;
118 bool fUSB = false;
119
120 switch (t)
121 {
122 case VirtualSystemDescriptionType_Name:
123 bstrVMname = aConfigValues[a];
124 RTPrintf("%2d: Suggested VM name \"%ls\""
125 "\n (change with \"-vsys %d -vmname <name>\")\n",
126 a, bstrVMname.raw(), i);
127 break;
128
129 case VirtualSystemDescriptionType_OS:
130 bstrOstype = aConfigValues[a];
131 RTPrintf("%2d: Suggested OS type: \"%ls\""
132 "\n (change with \"-vsys %d -ostype <type>\"; use \"list ostypes\" to list all)\n",
133 a, bstrOstype.raw(), i);
134 break;
135
136 case VirtualSystemDescriptionType_CPU:
137 RTPrintf("%2d: Number of CPUs (ignored): %ls\n",
138 a, aConfigValues[a]);
139 break;
140
141 case VirtualSystemDescriptionType_Memory:
142 Utf8Str(Bstr(aConfigValues[a])).toInt(ulMemMB);
143 ulMemMB /= 1024 * 1024;
144 RTPrintf("%2d: Guest memory: %u MB\n (change with \"-vsys %d -memory <MB>\")\n",
145 a, ulMemMB, i);
146 break;
147
148 case VirtualSystemDescriptionType_HardDiskControllerIDE:
149 RTPrintf("%2d: IDE controller, type %ls"
150 "\n (disable with \"-vsys %d -ignore %d\")\n",
151 a,
152 aConfigValues[a],
153 i, a);
154 break;
155
156 case VirtualSystemDescriptionType_HardDiskControllerSATA:
157 RTPrintf("%2d: SATA controller, type %ls"
158 "\n (disable with \"-vsys %d -ignore %d\")\n",
159 a,
160 aConfigValues[a],
161 i, a);
162 break;
163
164 case VirtualSystemDescriptionType_HardDiskControllerSCSI:
165 RTPrintf("%2d: SCSI controller, type %ls"
166 "\n (change with \"-vsys %d -type%d={BusLogic|LsiLogic}\";"
167 "\n disable with \"-vsys %d -ignore %d\")\n",
168 a,
169 aConfigValues[a],
170 i, a, i, a);
171 break;
172
173 case VirtualSystemDescriptionType_HardDiskImage:
174 RTPrintf("%2d: Hard disk image: source image=%ls, target path=%ls, %ls"
175 "\n (change controller with \"-vsys %d -controller%d=<id>\";"
176 "\n disable with \"-vsys %d -ignore %d\")\n",
177 a,
178 aOrigValues[a],
179 aConfigValues[a],
180 aExtraConfigValues[a],
181 i, a, i, a);
182 break;
183
184 case VirtualSystemDescriptionType_CDROM:
185 RTPrintf("%2d: CD-ROM"
186 "\n (disable with \"-vsys %d -ignore %d\")\n",
187 a, i, a);
188 break;
189
190 case VirtualSystemDescriptionType_Floppy:
191 RTPrintf("%2d: Floppy"
192 "\n (disable with \"-vsys %d -ignore %d\")\n",
193 a, i, a);
194 break;
195
196 case VirtualSystemDescriptionType_NetworkAdapter:
197 RTPrintf("%2d: Network adapter: orig %ls, config %ls, extra %ls\n",
198 a,
199 aOrigValues[a],
200 aConfigValues[a],
201 aExtraConfigValues[a]);
202 break;
203
204 case VirtualSystemDescriptionType_USBController:
205 RTPrintf("%2d: USB controller"
206 "\n (disable with \"-vsys %d -ignore %d\")\n",
207 a, i, a);
208 break;
209
210 case VirtualSystemDescriptionType_SoundCard:
211 RTPrintf("%2d: Sound card (appliance expects \"%ls\", can change on import)"
212 "\n (disable with \"-vsys %d -ignore %d\")\n",
213 a,
214 aOrigValues[a],
215 i,
216 a);
217 break;
218 }
219 }
220 }
221 RTPrintf("\n");
222 }
223 } while (0);
224
225 return SUCCEEDED(rc) ? 0 : 1;
226}
227
228#endif /* !VBOX_ONLY_DOCS */
Note: See TracBrowser for help on using the repository browser.

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