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