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