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