1 | /* $Id: VBoxManageList.cpp 17218 2009-02-27 18:02:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'list' command.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2009 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 VBOX_ONLY_DOCS
|
---|
23 |
|
---|
24 | /*******************************************************************************
|
---|
25 | * Header Files *
|
---|
26 | *******************************************************************************/
|
---|
27 | #include <VBox/com/com.h>
|
---|
28 | #include <VBox/com/string.h>
|
---|
29 | #include <VBox/com/Guid.h>
|
---|
30 | #include <VBox/com/array.h>
|
---|
31 | #include <VBox/com/ErrorInfo.h>
|
---|
32 | #include <VBox/com/errorprint2.h>
|
---|
33 |
|
---|
34 | #include <VBox/com/VirtualBox.h>
|
---|
35 |
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <iprt/stream.h>
|
---|
38 | #include <iprt/string.h>
|
---|
39 | #include <iprt/time.h>
|
---|
40 | #include <iprt/getopt.h>
|
---|
41 |
|
---|
42 | #include "VBoxManage.h"
|
---|
43 | using namespace com;
|
---|
44 |
|
---|
45 | #ifdef VBOX_WITH_HOSTNETIF_API
|
---|
46 | static const char *getHostIfTypeText(HostNetworkInterfaceType_T enmType)
|
---|
47 | {
|
---|
48 | switch (enmType)
|
---|
49 | {
|
---|
50 | case HostNetworkInterfaceType_Ethernet: return "Ethernet";
|
---|
51 | case HostNetworkInterfaceType_PPP: return "PPP";
|
---|
52 | case HostNetworkInterfaceType_SLIP: return "SLIP";
|
---|
53 | }
|
---|
54 | return "Unknown";
|
---|
55 | }
|
---|
56 |
|
---|
57 | static const char *getHostIfStatusText(HostNetworkInterfaceStatus_T enmStatus)
|
---|
58 | {
|
---|
59 | switch (enmStatus)
|
---|
60 | {
|
---|
61 | case HostNetworkInterfaceStatus_Up: return "Up";
|
---|
62 | case HostNetworkInterfaceStatus_Down: return "Down";
|
---|
63 | }
|
---|
64 | return "Unknown";
|
---|
65 | }
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | enum enOptionCodes
|
---|
69 | {
|
---|
70 | LISTVMS = 1000,
|
---|
71 | LISTRUNNINGVMS,
|
---|
72 | LISTOSTYPES,
|
---|
73 | LISTHOSTDVDS,
|
---|
74 | LISTHOSTFLOPPIES,
|
---|
75 | LISTHOSTIFS,
|
---|
76 | LISTHOSTINFO,
|
---|
77 | LISTHDDBACKENDS,
|
---|
78 | LISTHDDS,
|
---|
79 | LISTDVDS,
|
---|
80 | LISTFLOPPIES,
|
---|
81 | LISTUSBHOST,
|
---|
82 | LISTUSBFILTERS,
|
---|
83 | LISTSYSTEMPROPERTIES
|
---|
84 | };
|
---|
85 |
|
---|
86 | static const RTGETOPTDEF g_aListOptions[]
|
---|
87 | = {
|
---|
88 | { "--long", 'l', RTGETOPT_REQ_NOTHING },
|
---|
89 | { "vms", LISTVMS, RTGETOPT_REQ_NOTHING },
|
---|
90 | { "runningvms", LISTRUNNINGVMS, RTGETOPT_REQ_NOTHING },
|
---|
91 | { "ostypes", LISTOSTYPES, RTGETOPT_REQ_NOTHING },
|
---|
92 | { "hostdvds", LISTHOSTDVDS, RTGETOPT_REQ_NOTHING },
|
---|
93 | { "hostfloppies", LISTHOSTFLOPPIES, RTGETOPT_REQ_NOTHING },
|
---|
94 | { "hostifs", LISTHOSTIFS, RTGETOPT_REQ_NOTHING },
|
---|
95 | { "hostinfo", LISTHOSTINFO, RTGETOPT_REQ_NOTHING },
|
---|
96 | { "hddbackends", LISTHDDBACKENDS, RTGETOPT_REQ_NOTHING },
|
---|
97 | { "hdds", LISTHDDS, RTGETOPT_REQ_NOTHING },
|
---|
98 | { "dvds", LISTDVDS, RTGETOPT_REQ_NOTHING },
|
---|
99 | { "floppies", LISTFLOPPIES, RTGETOPT_REQ_NOTHING },
|
---|
100 | { "usbhost", LISTUSBHOST, RTGETOPT_REQ_NOTHING },
|
---|
101 | { "usbfilters", LISTUSBFILTERS, RTGETOPT_REQ_NOTHING },
|
---|
102 | { "systemproperties", LISTSYSTEMPROPERTIES, RTGETOPT_REQ_NOTHING }
|
---|
103 | };
|
---|
104 |
|
---|
105 | int handleList(HandlerArg *a)
|
---|
106 | {
|
---|
107 | HRESULT rc = S_OK;
|
---|
108 |
|
---|
109 | bool fOptLong = false;
|
---|
110 |
|
---|
111 | int command = 0;
|
---|
112 | int c;
|
---|
113 |
|
---|
114 | RTGETOPTUNION ValueUnion;
|
---|
115 | RTGETOPTSTATE GetState;
|
---|
116 | RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions), 0, 0 /* fFlags */);
|
---|
117 | while ((c = RTGetOpt(&GetState, &ValueUnion)))
|
---|
118 | {
|
---|
119 | switch (c)
|
---|
120 | {
|
---|
121 | case 'l': // --long
|
---|
122 | fOptLong = true;
|
---|
123 | break;
|
---|
124 |
|
---|
125 | case LISTVMS:
|
---|
126 | case LISTRUNNINGVMS:
|
---|
127 | case LISTOSTYPES:
|
---|
128 | case LISTHOSTDVDS:
|
---|
129 | case LISTHOSTFLOPPIES:
|
---|
130 | case LISTHOSTIFS:
|
---|
131 | case LISTHOSTINFO:
|
---|
132 | case LISTHDDBACKENDS:
|
---|
133 | case LISTHDDS:
|
---|
134 | case LISTDVDS:
|
---|
135 | case LISTFLOPPIES:
|
---|
136 | case LISTUSBHOST:
|
---|
137 | case LISTUSBFILTERS:
|
---|
138 | case LISTSYSTEMPROPERTIES:
|
---|
139 | if (command)
|
---|
140 | return errorSyntax(USAGE_LIST, "Too many subcommands for \"list\" command.\n");
|
---|
141 |
|
---|
142 | command = c;
|
---|
143 | break;
|
---|
144 |
|
---|
145 | default:
|
---|
146 | if (c > 0)
|
---|
147 | return errorSyntax(USAGE_LIST, "missing case: %c\n", c);
|
---|
148 | else if (ValueUnion.pDef)
|
---|
149 | return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
|
---|
150 | else
|
---|
151 | return errorSyntax(USAGE_LIST, "%Rrs", c);
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | if (!command)
|
---|
156 | return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
|
---|
157 |
|
---|
158 | /* which object? */
|
---|
159 | switch (command)
|
---|
160 | {
|
---|
161 | case LISTVMS:
|
---|
162 | {
|
---|
163 | /*
|
---|
164 | * Get the list of all registered VMs
|
---|
165 | */
|
---|
166 | com::SafeIfaceArray <IMachine> machines;
|
---|
167 | rc = a->virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
|
---|
168 | if (SUCCEEDED(rc))
|
---|
169 | {
|
---|
170 | /*
|
---|
171 | * Iterate through the collection
|
---|
172 | */
|
---|
173 | for (size_t i = 0; i < machines.size(); ++ i)
|
---|
174 | {
|
---|
175 | if (machines [i])
|
---|
176 | rc = showVMInfo(a->virtualBox,
|
---|
177 | machines[i],
|
---|
178 | (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
179 | }
|
---|
180 | }
|
---|
181 | }
|
---|
182 | break;
|
---|
183 |
|
---|
184 | case LISTRUNNINGVMS:
|
---|
185 | {
|
---|
186 | /*
|
---|
187 | * Get the list of all _running_ VMs
|
---|
188 | */
|
---|
189 | com::SafeIfaceArray <IMachine> machines;
|
---|
190 | rc = a->virtualBox->COMGETTER(Machines2)(ComSafeArrayAsOutParam (machines));
|
---|
191 | if (SUCCEEDED(rc))
|
---|
192 | {
|
---|
193 | /*
|
---|
194 | * Iterate through the collection
|
---|
195 | */
|
---|
196 | for (size_t i = 0; i < machines.size(); ++ i)
|
---|
197 | {
|
---|
198 | if (machines [i])
|
---|
199 | {
|
---|
200 | MachineState_T machineState;
|
---|
201 | rc = machines [i]->COMGETTER(State)(&machineState);
|
---|
202 | if (SUCCEEDED(rc))
|
---|
203 | {
|
---|
204 | switch (machineState)
|
---|
205 | {
|
---|
206 | case MachineState_Running:
|
---|
207 | case MachineState_Paused:
|
---|
208 | rc = showVMInfo(a->virtualBox,
|
---|
209 | machines[i],
|
---|
210 | (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
|
---|
211 | }
|
---|
212 | }
|
---|
213 | }
|
---|
214 | }
|
---|
215 | }
|
---|
216 | }
|
---|
217 | break;
|
---|
218 |
|
---|
219 | case LISTOSTYPES:
|
---|
220 | {
|
---|
221 | com::SafeIfaceArray <IGuestOSType> coll;
|
---|
222 | rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
|
---|
223 | if (SUCCEEDED(rc))
|
---|
224 | {
|
---|
225 | /*
|
---|
226 | * Iterate through the collection.
|
---|
227 | */
|
---|
228 | for (size_t i = 0; i < coll.size(); ++ i)
|
---|
229 | {
|
---|
230 | ComPtr<IGuestOSType> guestOS;
|
---|
231 | guestOS = coll[i];
|
---|
232 | Bstr guestId;
|
---|
233 | guestOS->COMGETTER(Id)(guestId.asOutParam());
|
---|
234 | RTPrintf("ID: %lS\n", guestId.raw());
|
---|
235 | Bstr guestDescription;
|
---|
236 | guestOS->COMGETTER(Description)(guestDescription.asOutParam());
|
---|
237 | RTPrintf("Description: %lS\n\n", guestDescription.raw());
|
---|
238 | }
|
---|
239 | }
|
---|
240 | }
|
---|
241 | break;
|
---|
242 |
|
---|
243 | case LISTHOSTDVDS:
|
---|
244 | {
|
---|
245 | ComPtr<IHost> host;
|
---|
246 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
247 | ComPtr<IHostDVDDriveCollection> coll;
|
---|
248 | ComPtr<IHostDVDDriveEnumerator> enumerator;
|
---|
249 | CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
|
---|
250 | if (SUCCEEDED(rc) && coll)
|
---|
251 | {
|
---|
252 | CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
|
---|
253 | BOOL hasMore;
|
---|
254 | while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
|
---|
255 | {
|
---|
256 | ComPtr<IHostDVDDrive> dvdDrive;
|
---|
257 | CHECK_ERROR_BREAK(enumerator, GetNext(dvdDrive.asOutParam()));
|
---|
258 | Bstr name;
|
---|
259 | dvdDrive->COMGETTER(Name)(name.asOutParam());
|
---|
260 | RTPrintf("Name: %lS\n\n", name.raw());
|
---|
261 | }
|
---|
262 | }
|
---|
263 | }
|
---|
264 | break;
|
---|
265 |
|
---|
266 | case LISTHOSTFLOPPIES:
|
---|
267 | {
|
---|
268 | ComPtr<IHost> host;
|
---|
269 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
270 | ComPtr<IHostFloppyDriveCollection> coll;
|
---|
271 | ComPtr<IHostFloppyDriveEnumerator> enumerator;
|
---|
272 | CHECK_ERROR(host, COMGETTER(FloppyDrives)(coll.asOutParam()));
|
---|
273 | if (SUCCEEDED(rc) && coll)
|
---|
274 | {
|
---|
275 | CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
|
---|
276 | BOOL hasMore;
|
---|
277 | while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
|
---|
278 | {
|
---|
279 | ComPtr<IHostFloppyDrive> floppyDrive;
|
---|
280 | CHECK_ERROR_BREAK(enumerator, GetNext(floppyDrive.asOutParam()));
|
---|
281 | Bstr name;
|
---|
282 | floppyDrive->COMGETTER(Name)(name.asOutParam());
|
---|
283 | RTPrintf("Name: %lS\n\n", name.raw());
|
---|
284 | }
|
---|
285 | }
|
---|
286 | }
|
---|
287 | break;
|
---|
288 |
|
---|
289 | case LISTHOSTIFS:
|
---|
290 | {
|
---|
291 | ComPtr<IHost> host;
|
---|
292 | CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
|
---|
293 | com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
|
---|
294 | CHECK_ERROR(host,
|
---|
295 | COMGETTER(NetworkInterfaces) (ComSafeArrayAsOutParam (hostNetworkInterfaces)));
|
---|
296 | for (size_t i = 0; i < hostNetworkInterfaces.size(); ++i)
|
---|
297 | {
|
---|
298 | ComPtr<IHostNetworkInterface> networkInterface = hostNetworkInterfaces[i];
|
---|
299 | #ifndef VBOX_WITH_HOSTNETIF_API
|
---|
300 | Bstr interfaceName;
|
---|
301 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
302 | RTPrintf("Name: %lS\n", interfaceName.raw());
|
---|
303 | Guid interfaceGuid;
|
---|
304 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
305 | RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()).raw());
|
---|
306 | #else /* VBOX_WITH_HOSTNETIF_API */
|
---|
307 | Bstr interfaceName;
|
---|
308 | networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
|
---|
309 | RTPrintf("Name: %lS\n", interfaceName.raw());
|
---|
310 | Guid interfaceGuid;
|
---|
311 | networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
|
---|
312 | RTPrintf("GUID: %lS\n", Bstr(interfaceGuid.toString()).raw());
|
---|
313 | ULONG IPAddress;
|
---|
314 | networkInterface->COMGETTER(IPAddress)(&IPAddress);
|
---|
315 | RTPrintf("IPAddress: %d.%d.%d.%d\n",
|
---|
316 | ((uint8_t*)&IPAddress)[0],
|
---|
317 | ((uint8_t*)&IPAddress)[1],
|
---|
318 | ((uint8_t*)&IPAddress)[2],
|
---|
319 | ((uint8_t*)&IPAddress)[3]);
|
---|
320 | ULONG NetworkMask;
|
---|
321 | networkInterface->COMGETTER(NetworkMask)(&NetworkMask);
|
---|
322 | RTPrintf("NetworkMask: %d.%d.%d.%d\n",
|
---|
323 | ((uint8_t*)&NetworkMask)[0],
|
---|
324 | ((uint8_t*)&NetworkMask)[1],
|
---|
325 | ((uint8_t*)&NetworkMask)[2],
|
---|
326 | ((uint8_t*)&NetworkMask)[3]);
|
---|
327 | Bstr IPV6Address;
|
---|
328 | networkInterface->COMGETTER(IPV6Address)(IPV6Address.asOutParam());
|
---|
329 | RTPrintf("IPV6Address: %lS\n", IPV6Address.raw());
|
---|
330 | Bstr IPV6NetworkMask;
|
---|
331 | networkInterface->COMGETTER(IPV6NetworkMask)(IPV6NetworkMask.asOutParam());
|
---|
332 | RTPrintf("IPV6NetworkMask: %lS\n", IPV6NetworkMask.raw());
|
---|
333 | Bstr HardwareAddress;
|
---|
334 | networkInterface->COMGETTER(HardwareAddress)(HardwareAddress.asOutParam());
|
---|
335 | RTPrintf("HardwareAddress: %lS\n", HardwareAddress.raw());
|
---|
336 | HostNetworkInterfaceType_T Type;
|
---|
337 | networkInterface->COMGETTER(Type)(&Type);
|
---|
338 | RTPrintf("Type: %s\n", getHostIfTypeText(Type));
|
---|
339 | HostNetworkInterfaceStatus_T Status;
|
---|
340 | networkInterface->COMGETTER(Status)(&Status);
|
---|
341 | RTPrintf("Status: %s\n\n", getHostIfStatusText(Status));
|
---|
342 | #endif
|
---|
343 | }
|
---|
344 | }
|
---|
345 | break;
|
---|
346 |
|
---|
347 | case LISTHOSTINFO:
|
---|
348 | {
|
---|
349 | ComPtr<IHost> Host;
|
---|
350 | CHECK_ERROR (a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
|
---|
351 |
|
---|
352 | RTPrintf("Host Information:\n\n");
|
---|
353 |
|
---|
354 | LONG64 uTCTime = 0;
|
---|
355 | CHECK_ERROR (Host, COMGETTER(UTCTime)(&uTCTime));
|
---|
356 | RTTIMESPEC timeSpec;
|
---|
357 | RTTimeSpecSetMilli(&timeSpec, uTCTime);
|
---|
358 | char pszTime[30] = {0};
|
---|
359 | RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
|
---|
360 | RTPrintf("Host time: %s\n", pszTime);
|
---|
361 |
|
---|
362 | ULONG processorOnlineCount = 0;
|
---|
363 | CHECK_ERROR (Host, COMGETTER(ProcessorOnlineCount)(&processorOnlineCount));
|
---|
364 | RTPrintf("Processor online count: %lu\n", processorOnlineCount);
|
---|
365 | ULONG processorCount = 0;
|
---|
366 | CHECK_ERROR (Host, COMGETTER(ProcessorCount)(&processorCount));
|
---|
367 | RTPrintf("Processor count: %lu\n", processorCount);
|
---|
368 | ULONG processorSpeed = 0;
|
---|
369 | Bstr processorDescription;
|
---|
370 | for (ULONG i = 0; i < processorCount; i++)
|
---|
371 | {
|
---|
372 | CHECK_ERROR (Host, GetProcessorSpeed(i, &processorSpeed));
|
---|
373 | if (processorSpeed)
|
---|
374 | RTPrintf("Processor#%u speed: %lu MHz\n", i, processorSpeed);
|
---|
375 | else
|
---|
376 | RTPrintf("Processor#%u speed: unknown\n", i, processorSpeed);
|
---|
377 | #if 0 /* not yet implemented in Main */
|
---|
378 | CHECK_ERROR (Host, GetProcessorDescription(i, processorDescription.asOutParam()));
|
---|
379 | RTPrintf("Processor#%u description: %lS\n", i, processorDescription.raw());
|
---|
380 | #endif
|
---|
381 | }
|
---|
382 |
|
---|
383 | #if 0 /* not yet implemented in Main */
|
---|
384 | ULONG memorySize = 0;
|
---|
385 | CHECK_ERROR (Host, COMGETTER(MemorySize)(&memorySize));
|
---|
386 | RTPrintf("Memory size: %lu MByte\n", memorySize);
|
---|
387 |
|
---|
388 | ULONG memoryAvailable = 0;
|
---|
389 | CHECK_ERROR (Host, COMGETTER(MemoryAvailable)(&memoryAvailable));
|
---|
390 | RTPrintf("Memory available: %lu MByte\n", memoryAvailable);
|
---|
391 |
|
---|
392 | Bstr operatingSystem;
|
---|
393 | CHECK_ERROR (Host, COMGETTER(OperatingSystem)(operatingSystem.asOutParam()));
|
---|
394 | RTPrintf("Operating system: %lS\n", operatingSystem.raw());
|
---|
395 |
|
---|
396 | Bstr oSVersion;
|
---|
397 | CHECK_ERROR (Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
|
---|
398 | RTPrintf("Operating system version: %lS\n", oSVersion.raw());
|
---|
399 | #endif
|
---|
400 | }
|
---|
401 | break;
|
---|
402 |
|
---|
403 | case LISTHDDBACKENDS:
|
---|
404 | {
|
---|
405 | ComPtr<ISystemProperties> systemProperties;
|
---|
406 | CHECK_ERROR(a->virtualBox,
|
---|
407 | COMGETTER(SystemProperties) (systemProperties.asOutParam()));
|
---|
408 | com::SafeIfaceArray <IHardDiskFormat> hardDiskFormats;
|
---|
409 | CHECK_ERROR(systemProperties,
|
---|
410 | COMGETTER(HardDiskFormats) (ComSafeArrayAsOutParam (hardDiskFormats)));
|
---|
411 |
|
---|
412 | RTPrintf("Supported hard disk backends:\n\n");
|
---|
413 | for (size_t i = 0; i < hardDiskFormats.size(); ++ i)
|
---|
414 | {
|
---|
415 | /* General information */
|
---|
416 | Bstr id;
|
---|
417 | CHECK_ERROR(hardDiskFormats [i],
|
---|
418 | COMGETTER(Id) (id.asOutParam()));
|
---|
419 |
|
---|
420 | Bstr description;
|
---|
421 | CHECK_ERROR(hardDiskFormats [i],
|
---|
422 | COMGETTER(Id) (description.asOutParam()));
|
---|
423 |
|
---|
424 | ULONG caps;
|
---|
425 | CHECK_ERROR(hardDiskFormats [i],
|
---|
426 | COMGETTER(Capabilities) (&caps));
|
---|
427 |
|
---|
428 | RTPrintf("Backend %u: id='%ls' description='%ls' capabilities=%#06x extensions='",
|
---|
429 | i, id.raw(), description.raw(), caps);
|
---|
430 |
|
---|
431 | /* File extensions */
|
---|
432 | com::SafeArray <BSTR> fileExtensions;
|
---|
433 | CHECK_ERROR(hardDiskFormats [i],
|
---|
434 | COMGETTER(FileExtensions) (ComSafeArrayAsOutParam (fileExtensions)));
|
---|
435 | for (size_t a = 0; a < fileExtensions.size(); ++ a)
|
---|
436 | {
|
---|
437 | RTPrintf ("%ls", Bstr (fileExtensions [a]).raw());
|
---|
438 | if (a != fileExtensions.size()-1)
|
---|
439 | RTPrintf (",");
|
---|
440 | }
|
---|
441 | RTPrintf ("'");
|
---|
442 |
|
---|
443 | /* Configuration keys */
|
---|
444 | com::SafeArray <BSTR> propertyNames;
|
---|
445 | com::SafeArray <BSTR> propertyDescriptions;
|
---|
446 | com::SafeArray <DataType_T> propertyTypes;
|
---|
447 | com::SafeArray <ULONG> propertyFlags;
|
---|
448 | com::SafeArray <BSTR> propertyDefaults;
|
---|
449 | CHECK_ERROR(hardDiskFormats [i],
|
---|
450 | DescribeProperties (ComSafeArrayAsOutParam (propertyNames),
|
---|
451 | ComSafeArrayAsOutParam (propertyDescriptions),
|
---|
452 | ComSafeArrayAsOutParam (propertyTypes),
|
---|
453 | ComSafeArrayAsOutParam (propertyFlags),
|
---|
454 | ComSafeArrayAsOutParam (propertyDefaults)));
|
---|
455 |
|
---|
456 | RTPrintf (" properties=(");
|
---|
457 | if (propertyNames.size() > 0)
|
---|
458 | {
|
---|
459 | for (size_t a = 0; a < propertyNames.size(); ++ a)
|
---|
460 | {
|
---|
461 | RTPrintf ("\n name='%ls' desc='%ls' type=",
|
---|
462 | Bstr (propertyNames [a]).raw(), Bstr (propertyDescriptions [a]).raw());
|
---|
463 | switch (propertyTypes [a])
|
---|
464 | {
|
---|
465 | case DataType_Int32: RTPrintf ("int"); break;
|
---|
466 | case DataType_Int8: RTPrintf ("byte"); break;
|
---|
467 | case DataType_String: RTPrintf ("string"); break;
|
---|
468 | }
|
---|
469 | RTPrintf (" flags=%#04x", propertyFlags [a]);
|
---|
470 | RTPrintf (" default='%ls'", Bstr (propertyDefaults [a]).raw());
|
---|
471 | if (a != propertyNames.size()-1)
|
---|
472 | RTPrintf (", ");
|
---|
473 | }
|
---|
474 | }
|
---|
475 | RTPrintf (")\n");
|
---|
476 | }
|
---|
477 | }
|
---|
478 | break;
|
---|
479 |
|
---|
480 | case LISTHDDS:
|
---|
481 | {
|
---|
482 | com::SafeIfaceArray<IHardDisk> hdds;
|
---|
483 | CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam (hdds)));
|
---|
484 | for (size_t i = 0; i < hdds.size(); ++ i)
|
---|
485 | {
|
---|
486 | ComPtr<IHardDisk> hdd = hdds[i];
|
---|
487 | Guid uuid;
|
---|
488 | hdd->COMGETTER(Id)(uuid.asOutParam());
|
---|
489 | RTPrintf("UUID: %s\n", uuid.toString().raw());
|
---|
490 | Bstr format;
|
---|
491 | hdd->COMGETTER(Format)(format.asOutParam());
|
---|
492 | RTPrintf("Format: %lS\n", format.raw());
|
---|
493 | Bstr filepath;
|
---|
494 | hdd->COMGETTER(Location)(filepath.asOutParam());
|
---|
495 | RTPrintf("Location: %lS\n", filepath.raw());
|
---|
496 | MediaState_T enmState;
|
---|
497 | /// @todo NEWMEDIA check accessibility of all parents
|
---|
498 | /// @todo NEWMEDIA print the full state value
|
---|
499 | hdd->COMGETTER(State)(&enmState);
|
---|
500 | RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
|
---|
501 | com::SafeGUIDArray machineIds;
|
---|
502 | hdd->COMGETTER(MachineIds)(ComSafeArrayAsOutParam(machineIds));
|
---|
503 | for (size_t j = 0; j < machineIds.size(); ++ j)
|
---|
504 | {
|
---|
505 | ComPtr<IMachine> machine;
|
---|
506 | CHECK_ERROR(a->virtualBox, GetMachine(machineIds[j], machine.asOutParam()));
|
---|
507 | ASSERT(machine);
|
---|
508 | Bstr name;
|
---|
509 | machine->COMGETTER(Name)(name.asOutParam());
|
---|
510 | machine->COMGETTER(Id)(uuid.asOutParam());
|
---|
511 | RTPrintf("%s%lS (UUID: %RTuuid)\n",
|
---|
512 | j == 0 ? "Usage: " : " ",
|
---|
513 | name.raw(), &machineIds[j]);
|
---|
514 | }
|
---|
515 | /// @todo NEWMEDIA check usage in snapshots too
|
---|
516 | /// @todo NEWMEDIA also list children and say 'differencing' for
|
---|
517 | /// hard disks with the parent or 'base' otherwise.
|
---|
518 | RTPrintf("\n");
|
---|
519 | }
|
---|
520 | }
|
---|
521 | break;
|
---|
522 |
|
---|
523 | case LISTDVDS:
|
---|
524 | {
|
---|
525 | com::SafeIfaceArray<IDVDImage> dvds;
|
---|
526 | CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
|
---|
527 | for (size_t i = 0; i < dvds.size(); ++ i)
|
---|
528 | {
|
---|
529 | ComPtr<IDVDImage> dvdImage = dvds[i];
|
---|
530 | Guid uuid;
|
---|
531 | dvdImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
532 | RTPrintf("UUID: %s\n", uuid.toString().raw());
|
---|
533 | Bstr filePath;
|
---|
534 | dvdImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
535 | RTPrintf("Path: %lS\n", filePath.raw());
|
---|
536 | MediaState_T enmState;
|
---|
537 | dvdImage->COMGETTER(State)(&enmState);
|
---|
538 | RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
|
---|
539 | /** @todo usage */
|
---|
540 | RTPrintf("\n");
|
---|
541 | }
|
---|
542 | }
|
---|
543 | break;
|
---|
544 |
|
---|
545 | case LISTFLOPPIES:
|
---|
546 | {
|
---|
547 | com::SafeIfaceArray<IFloppyImage> floppies;
|
---|
548 | CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
|
---|
549 | for (size_t i = 0; i < floppies.size(); ++ i)
|
---|
550 | {
|
---|
551 | ComPtr<IFloppyImage> floppyImage = floppies[i];
|
---|
552 | Guid uuid;
|
---|
553 | floppyImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
554 | RTPrintf("UUID: %s\n", uuid.toString().raw());
|
---|
555 | Bstr filePath;
|
---|
556 | floppyImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
557 | RTPrintf("Path: %lS\n", filePath.raw());
|
---|
558 | MediaState_T enmState;
|
---|
559 | floppyImage->COMGETTER(State)(&enmState);
|
---|
560 | RTPrintf("Accessible: %s\n", enmState != MediaState_Inaccessible ? "yes" : "no");
|
---|
561 | /** @todo usage */
|
---|
562 | RTPrintf("\n");
|
---|
563 | }
|
---|
564 | }
|
---|
565 | break;
|
---|
566 |
|
---|
567 | case LISTUSBHOST:
|
---|
568 | {
|
---|
569 | ComPtr<IHost> Host;
|
---|
570 | CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
|
---|
571 |
|
---|
572 | ComPtr<IHostUSBDeviceCollection> CollPtr;
|
---|
573 | CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(CollPtr.asOutParam()), 1);
|
---|
574 |
|
---|
575 | ComPtr<IHostUSBDeviceEnumerator> EnumPtr;
|
---|
576 | CHECK_ERROR_RET (CollPtr, Enumerate(EnumPtr.asOutParam()), 1);
|
---|
577 |
|
---|
578 | RTPrintf("Host USB Devices:\n\n");
|
---|
579 |
|
---|
580 | BOOL fMore = FALSE;
|
---|
581 | ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
|
---|
582 | if (FAILED(rc))
|
---|
583 | return rc;
|
---|
584 |
|
---|
585 | if (!fMore)
|
---|
586 | {
|
---|
587 | RTPrintf("<none>\n\n");
|
---|
588 | }
|
---|
589 | else
|
---|
590 | while (fMore)
|
---|
591 | {
|
---|
592 | ComPtr <IHostUSBDevice> dev;
|
---|
593 | ASSERT(SUCCEEDED(rc = EnumPtr->GetNext (dev.asOutParam())));
|
---|
594 | if (FAILED(rc))
|
---|
595 | return rc;
|
---|
596 |
|
---|
597 | /* Query info. */
|
---|
598 | Guid id;
|
---|
599 | CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
|
---|
600 | USHORT usVendorId;
|
---|
601 | CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
|
---|
602 | USHORT usProductId;
|
---|
603 | CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
|
---|
604 | USHORT bcdRevision;
|
---|
605 | CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
|
---|
606 |
|
---|
607 | RTPrintf("UUID: %S\n"
|
---|
608 | "VendorId: 0x%04x (%04X)\n"
|
---|
609 | "ProductId: 0x%04x (%04X)\n"
|
---|
610 | "Revision: %u.%u (%02u%02u)\n",
|
---|
611 | id.toString().raw(),
|
---|
612 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
613 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
614 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
615 |
|
---|
616 | /* optional stuff. */
|
---|
617 | Bstr bstr;
|
---|
618 | CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
|
---|
619 | if (!bstr.isEmpty())
|
---|
620 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
621 | CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
|
---|
622 | if (!bstr.isEmpty())
|
---|
623 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
624 | CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
|
---|
625 | if (!bstr.isEmpty())
|
---|
626 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
627 | CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
|
---|
628 | if (!bstr.isEmpty())
|
---|
629 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
630 |
|
---|
631 | /* current state */
|
---|
632 | USBDeviceState_T state;
|
---|
633 | CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
|
---|
634 | const char *pszState = "?";
|
---|
635 | switch (state)
|
---|
636 | {
|
---|
637 | case USBDeviceState_NotSupported:
|
---|
638 | pszState = "Not supported"; break;
|
---|
639 | case USBDeviceState_Unavailable:
|
---|
640 | pszState = "Unavailable"; break;
|
---|
641 | case USBDeviceState_Busy:
|
---|
642 | pszState = "Busy"; break;
|
---|
643 | case USBDeviceState_Available:
|
---|
644 | pszState = "Available"; break;
|
---|
645 | case USBDeviceState_Held:
|
---|
646 | pszState = "Held"; break;
|
---|
647 | case USBDeviceState_Captured:
|
---|
648 | pszState = "Captured"; break;
|
---|
649 | default:
|
---|
650 | ASSERT (false);
|
---|
651 | break;
|
---|
652 | }
|
---|
653 | RTPrintf("Current State: %s\n\n", pszState);
|
---|
654 |
|
---|
655 | ASSERT(SUCCEEDED(rc = EnumPtr->HasMore (&fMore)));
|
---|
656 | if (FAILED(rc))
|
---|
657 | return rc;
|
---|
658 | }
|
---|
659 | }
|
---|
660 | break;
|
---|
661 |
|
---|
662 | case LISTUSBFILTERS:
|
---|
663 | {
|
---|
664 | RTPrintf("Global USB Device Filters:\n\n");
|
---|
665 |
|
---|
666 | ComPtr <IHost> host;
|
---|
667 | CHECK_ERROR_RET (a->virtualBox, COMGETTER(Host) (host.asOutParam()), 1);
|
---|
668 |
|
---|
669 | ComPtr<IHostUSBDeviceFilterCollection> coll;
|
---|
670 | CHECK_ERROR_RET (host, COMGETTER (USBDeviceFilters)(coll.asOutParam()), 1);
|
---|
671 |
|
---|
672 | ComPtr<IHostUSBDeviceFilterEnumerator> en;
|
---|
673 | CHECK_ERROR_RET (coll, Enumerate(en.asOutParam()), 1);
|
---|
674 |
|
---|
675 | ULONG index = 0;
|
---|
676 | BOOL more = FALSE;
|
---|
677 | ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
|
---|
678 | if (FAILED(rc))
|
---|
679 | return rc;
|
---|
680 |
|
---|
681 | if (!more)
|
---|
682 | {
|
---|
683 | RTPrintf("<none>\n\n");
|
---|
684 | }
|
---|
685 | else
|
---|
686 | while (more)
|
---|
687 | {
|
---|
688 | ComPtr<IHostUSBDeviceFilter> flt;
|
---|
689 | ASSERT(SUCCEEDED(rc = en->GetNext (flt.asOutParam())));
|
---|
690 | if (FAILED(rc))
|
---|
691 | return rc;
|
---|
692 |
|
---|
693 | /* Query info. */
|
---|
694 |
|
---|
695 | RTPrintf("Index: %lu\n", index);
|
---|
696 |
|
---|
697 | BOOL active = FALSE;
|
---|
698 | CHECK_ERROR_RET (flt, COMGETTER (Active) (&active), 1);
|
---|
699 | RTPrintf("Active: %s\n", active ? "yes" : "no");
|
---|
700 |
|
---|
701 | USBDeviceFilterAction_T action;
|
---|
702 | CHECK_ERROR_RET (flt, COMGETTER (Action) (&action), 1);
|
---|
703 | const char *pszAction = "<invalid>";
|
---|
704 | switch (action)
|
---|
705 | {
|
---|
706 | case USBDeviceFilterAction_Ignore:
|
---|
707 | pszAction = "Ignore";
|
---|
708 | break;
|
---|
709 | case USBDeviceFilterAction_Hold:
|
---|
710 | pszAction = "Hold";
|
---|
711 | break;
|
---|
712 | default:
|
---|
713 | break;
|
---|
714 | }
|
---|
715 | RTPrintf("Action: %s\n", pszAction);
|
---|
716 |
|
---|
717 | Bstr bstr;
|
---|
718 | CHECK_ERROR_RET (flt, COMGETTER (Name) (bstr.asOutParam()), 1);
|
---|
719 | RTPrintf("Name: %lS\n", bstr.raw());
|
---|
720 | CHECK_ERROR_RET (flt, COMGETTER (VendorId) (bstr.asOutParam()), 1);
|
---|
721 | RTPrintf("VendorId: %lS\n", bstr.raw());
|
---|
722 | CHECK_ERROR_RET (flt, COMGETTER (ProductId) (bstr.asOutParam()), 1);
|
---|
723 | RTPrintf("ProductId: %lS\n", bstr.raw());
|
---|
724 | CHECK_ERROR_RET (flt, COMGETTER (Revision) (bstr.asOutParam()), 1);
|
---|
725 | RTPrintf("Revision: %lS\n", bstr.raw());
|
---|
726 | CHECK_ERROR_RET (flt, COMGETTER (Manufacturer) (bstr.asOutParam()), 1);
|
---|
727 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
728 | CHECK_ERROR_RET (flt, COMGETTER (Product) (bstr.asOutParam()), 1);
|
---|
729 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
730 | CHECK_ERROR_RET (flt, COMGETTER (SerialNumber) (bstr.asOutParam()), 1);
|
---|
731 | RTPrintf("Serial Number: %lS\n\n", bstr.raw());
|
---|
732 |
|
---|
733 | ASSERT(SUCCEEDED(rc = en->HasMore (&more)));
|
---|
734 | if (FAILED(rc))
|
---|
735 | return rc;
|
---|
736 |
|
---|
737 | index ++;
|
---|
738 | }
|
---|
739 | }
|
---|
740 | break;
|
---|
741 |
|
---|
742 | case LISTSYSTEMPROPERTIES:
|
---|
743 | {
|
---|
744 | ComPtr<ISystemProperties> systemProperties;
|
---|
745 | a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
|
---|
746 |
|
---|
747 | Bstr str;
|
---|
748 | ULONG ulValue;
|
---|
749 | ULONG64 ul64Value;
|
---|
750 | BOOL flag;
|
---|
751 |
|
---|
752 | systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
|
---|
753 | RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
|
---|
754 | systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
|
---|
755 | RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
|
---|
756 | systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
|
---|
757 | RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
|
---|
758 | systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
|
---|
759 | RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
|
---|
760 | systemProperties->COMGETTER(DefaultHardDiskFolder)(str.asOutParam());
|
---|
761 | RTPrintf("Default hard disk folder: %lS\n", str.raw());
|
---|
762 | systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
|
---|
763 | RTPrintf("Default machine folder: %lS\n", str.raw());
|
---|
764 | systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
|
---|
765 | RTPrintf("VRDP authentication library: %lS\n", str.raw());
|
---|
766 | systemProperties->COMGETTER(WebServiceAuthLibrary)(str.asOutParam());
|
---|
767 | RTPrintf("Webservice auth. library: %lS\n", str.raw());
|
---|
768 | systemProperties->COMGETTER(HWVirtExEnabled)(&flag);
|
---|
769 | RTPrintf("Hardware virt. extensions: %s\n", flag ? "yes" : "no");
|
---|
770 | systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
|
---|
771 | RTPrintf("Log history count: %u\n", ulValue);
|
---|
772 |
|
---|
773 | }
|
---|
774 | break;
|
---|
775 | } // end switch
|
---|
776 |
|
---|
777 | return SUCCEEDED(rc) ? 0 : 1;
|
---|
778 | }
|
---|
779 |
|
---|
780 | #endif /* !VBOX_ONLY_DOCS */
|
---|
781 |
|
---|