1 | /* $Id: VBoxManageInfo.cpp 21446 2009-07-09 15:09:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManage - The 'showvminfo' command and helper routines.
|
---|
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/errorprint.h>
|
---|
33 |
|
---|
34 | #include <VBox/com/VirtualBox.h>
|
---|
35 |
|
---|
36 | #include <VBox/log.h>
|
---|
37 | #include <iprt/stream.h>
|
---|
38 | #include <iprt/time.h>
|
---|
39 | #include <iprt/string.h>
|
---|
40 | #include <iprt/getopt.h>
|
---|
41 | #include <iprt/ctype.h>
|
---|
42 |
|
---|
43 | #include "VBoxManage.h"
|
---|
44 | using namespace com;
|
---|
45 |
|
---|
46 |
|
---|
47 | // funcs
|
---|
48 | ///////////////////////////////////////////////////////////////////////////////
|
---|
49 |
|
---|
50 | void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix /* = ""*/, int level /*= 0*/)
|
---|
51 | {
|
---|
52 | /* start with the root */
|
---|
53 | Bstr name;
|
---|
54 | Bstr uuid;
|
---|
55 | rootSnapshot->COMGETTER(Name)(name.asOutParam());
|
---|
56 | rootSnapshot->COMGETTER(Id)(uuid.asOutParam());
|
---|
57 | if (details == VMINFO_MACHINEREADABLE)
|
---|
58 | {
|
---|
59 | /* print with hierarchical numbering */
|
---|
60 | RTPrintf("SnapshotName%lS=\"%lS\"\n", prefix.raw(), name.raw());
|
---|
61 | RTPrintf("SnapshotUUID%lS=\"%s\"\n", prefix.raw(), Utf8Str(uuid).raw());
|
---|
62 | }
|
---|
63 | else
|
---|
64 | {
|
---|
65 | /* print with indentation */
|
---|
66 | RTPrintf(" %lSName: %lS (UUID: %s)\n", prefix.raw(), name.raw(), Utf8Str(uuid).raw());
|
---|
67 | }
|
---|
68 |
|
---|
69 | /* get the children */
|
---|
70 | SafeIfaceArray <ISnapshot> coll;
|
---|
71 | rootSnapshot->COMGETTER(Children)(ComSafeArrayAsOutParam(coll));
|
---|
72 | if (!coll.isNull())
|
---|
73 | {
|
---|
74 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
75 | {
|
---|
76 | ComPtr<ISnapshot> snapshot = coll[index];
|
---|
77 | if (snapshot)
|
---|
78 | {
|
---|
79 | Bstr newPrefix;
|
---|
80 | if (details == VMINFO_MACHINEREADABLE)
|
---|
81 | newPrefix = Utf8StrFmt("%lS-%d", prefix.raw(), index + 1);
|
---|
82 | else
|
---|
83 | newPrefix = Utf8StrFmt("%lS ", prefix.raw());
|
---|
84 | /* recursive call */
|
---|
85 | showSnapshots(snapshot, details, newPrefix, level + 1);
|
---|
86 | }
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|
90 |
|
---|
91 | static void makeTimeStr (char *s, int cb, int64_t millies)
|
---|
92 | {
|
---|
93 | RTTIME t;
|
---|
94 | RTTIMESPEC ts;
|
---|
95 |
|
---|
96 | RTTimeSpecSetMilli(&ts, millies);
|
---|
97 |
|
---|
98 | RTTimeExplode (&t, &ts);
|
---|
99 |
|
---|
100 | RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
|
---|
101 | t.i32Year, t.u8Month, t.u8MonthDay,
|
---|
102 | t.u8Hour, t.u8Minute, t.u8Second);
|
---|
103 | }
|
---|
104 |
|
---|
105 | /* Disable global optimizations for MSC 8.0/64 to make it compile in reasonable
|
---|
106 | time. MSC 7.1/32 doesn't have quite as much trouble with it, but still
|
---|
107 | sufficient to qualify for this hack as well since this code isn't performance
|
---|
108 | critical and probably won't gain much from the extra optimizing in real life. */
|
---|
109 | #if defined(_MSC_VER)
|
---|
110 | # pragma optimize("g", off)
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | HRESULT showVMInfo (ComPtr<IVirtualBox> virtualBox,
|
---|
114 | ComPtr<IMachine> machine,
|
---|
115 | VMINFO_DETAILS details /*= VMINFO_NONE*/,
|
---|
116 | ComPtr<IConsole> console /*= ComPtr <IConsole> ()*/)
|
---|
117 | {
|
---|
118 | HRESULT rc;
|
---|
119 |
|
---|
120 | /*
|
---|
121 | * The rules for output in -argdump format:
|
---|
122 | * 1) the key part (the [0-9a-zA-Z_]+ string before the '=' delimiter)
|
---|
123 | * is all lowercase for "VBoxManage modifyvm" parameters. Any
|
---|
124 | * other values printed are in CamelCase.
|
---|
125 | * 2) strings (anything non-decimal) are printed surrounded by
|
---|
126 | * double quotes '"'. If the strings themselves contain double
|
---|
127 | * quotes, these characters are escaped by '\'. Any '\' character
|
---|
128 | * in the original string is also escaped by '\'.
|
---|
129 | * 3) numbers (containing just [0-9\-]) are written out unchanged.
|
---|
130 | */
|
---|
131 |
|
---|
132 | /** @todo the quoting is not yet implemented! */
|
---|
133 | /** @todo error checking! */
|
---|
134 |
|
---|
135 | BOOL accessible = FALSE;
|
---|
136 | CHECK_ERROR (machine, COMGETTER(Accessible) (&accessible));
|
---|
137 | CheckComRCReturnRC (rc);
|
---|
138 |
|
---|
139 | Bstr uuid;
|
---|
140 | rc = machine->COMGETTER(Id) (uuid.asOutParam());
|
---|
141 |
|
---|
142 | if (!accessible)
|
---|
143 | {
|
---|
144 | if (details == VMINFO_COMPACT)
|
---|
145 | RTPrintf("\"<inaccessible>\" {%s}\n", Utf8Str(uuid).raw());
|
---|
146 | else
|
---|
147 | {
|
---|
148 | if (details == VMINFO_MACHINEREADABLE)
|
---|
149 | RTPrintf("name=\"<inaccessible>\"\n");
|
---|
150 | else
|
---|
151 | RTPrintf ("Name: <inaccessible!>\n");
|
---|
152 | if (details == VMINFO_MACHINEREADABLE)
|
---|
153 | RTPrintf ("UUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
154 | else
|
---|
155 | RTPrintf ("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
156 | if (details != VMINFO_MACHINEREADABLE)
|
---|
157 | {
|
---|
158 | Bstr settingsFilePath;
|
---|
159 | rc = machine->COMGETTER(SettingsFilePath) (settingsFilePath.asOutParam());
|
---|
160 | RTPrintf ("Config file: %lS\n", settingsFilePath.raw());
|
---|
161 | ComPtr<IVirtualBoxErrorInfo> accessError;
|
---|
162 | rc = machine->COMGETTER(AccessError) (accessError.asOutParam());
|
---|
163 | RTPrintf ("Access error details:\n");
|
---|
164 | ErrorInfo ei (accessError);
|
---|
165 | GluePrintErrorInfo(ei);
|
---|
166 | RTPrintf ("\n");
|
---|
167 | }
|
---|
168 | }
|
---|
169 | return S_OK;
|
---|
170 | }
|
---|
171 |
|
---|
172 | Bstr machineName;
|
---|
173 | rc = machine->COMGETTER(Name)(machineName.asOutParam());
|
---|
174 |
|
---|
175 | if (details == VMINFO_COMPACT)
|
---|
176 | {
|
---|
177 | RTPrintf("\"%lS\" {%s}\n", machineName.raw(), Utf8Str(uuid).raw());
|
---|
178 | return S_OK;
|
---|
179 | }
|
---|
180 |
|
---|
181 | if (details == VMINFO_MACHINEREADABLE)
|
---|
182 | RTPrintf("name=\"%lS\"\n", machineName.raw());
|
---|
183 | else
|
---|
184 | RTPrintf("Name: %lS\n", machineName.raw());
|
---|
185 |
|
---|
186 | Bstr osTypeId;
|
---|
187 | rc = machine->COMGETTER(OSTypeId)(osTypeId.asOutParam());
|
---|
188 | ComPtr<IGuestOSType> osType;
|
---|
189 | rc = virtualBox->GetGuestOSType (osTypeId, osType.asOutParam());
|
---|
190 | Bstr osName;
|
---|
191 | rc = osType->COMGETTER(Description)(osName.asOutParam());
|
---|
192 | if (details == VMINFO_MACHINEREADABLE)
|
---|
193 | RTPrintf("ostype=\"%lS\"\n", osTypeId.raw());
|
---|
194 | else
|
---|
195 | RTPrintf("Guest OS: %lS\n", osName.raw());
|
---|
196 |
|
---|
197 | if (details == VMINFO_MACHINEREADABLE)
|
---|
198 | RTPrintf("UUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
199 | else
|
---|
200 | RTPrintf("UUID: %s\n", Utf8Str(uuid).raw());
|
---|
201 |
|
---|
202 | Bstr settingsFilePath;
|
---|
203 | rc = machine->COMGETTER(SettingsFilePath)(settingsFilePath.asOutParam());
|
---|
204 | if (details == VMINFO_MACHINEREADABLE)
|
---|
205 | RTPrintf("CfgFile=\"%lS\"\n", settingsFilePath.raw());
|
---|
206 | else
|
---|
207 | RTPrintf("Config file: %lS\n", settingsFilePath.raw());
|
---|
208 |
|
---|
209 | ULONG memorySize;
|
---|
210 | rc = machine->COMGETTER(MemorySize)(&memorySize);
|
---|
211 | if (details == VMINFO_MACHINEREADABLE)
|
---|
212 | RTPrintf("memory=%u\n", memorySize);
|
---|
213 | else
|
---|
214 | RTPrintf("Memory size: %uMB\n", memorySize);
|
---|
215 |
|
---|
216 | ULONG vramSize;
|
---|
217 | rc = machine->COMGETTER(VRAMSize)(&vramSize);
|
---|
218 | if (details == VMINFO_MACHINEREADABLE)
|
---|
219 | RTPrintf("vram=%u\n", vramSize);
|
---|
220 | else
|
---|
221 | RTPrintf("VRAM size: %uMB\n", vramSize);
|
---|
222 |
|
---|
223 | ULONG numCpus;
|
---|
224 | rc = machine->COMGETTER(CPUCount)(&numCpus);
|
---|
225 | if (details == VMINFO_MACHINEREADABLE)
|
---|
226 | RTPrintf("cpus=%u\n", numCpus);
|
---|
227 | else
|
---|
228 | RTPrintf("Number of CPUs: %u\n", numCpus);
|
---|
229 |
|
---|
230 | ComPtr <IBIOSSettings> biosSettings;
|
---|
231 | machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
|
---|
232 |
|
---|
233 | BIOSBootMenuMode_T bootMenuMode;
|
---|
234 | biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
|
---|
235 | const char *pszBootMenu = NULL;
|
---|
236 | switch (bootMenuMode)
|
---|
237 | {
|
---|
238 | case BIOSBootMenuMode_Disabled:
|
---|
239 | pszBootMenu = "disabled";
|
---|
240 | break;
|
---|
241 | case BIOSBootMenuMode_MenuOnly:
|
---|
242 | if (details == VMINFO_MACHINEREADABLE)
|
---|
243 | pszBootMenu = "menuonly";
|
---|
244 | else
|
---|
245 | pszBootMenu = "menu only";
|
---|
246 | break;
|
---|
247 | default:
|
---|
248 | if (details == VMINFO_MACHINEREADABLE)
|
---|
249 | pszBootMenu = "messageandmenu";
|
---|
250 | else
|
---|
251 | pszBootMenu = "message and menu";
|
---|
252 | }
|
---|
253 | if (details == VMINFO_MACHINEREADABLE)
|
---|
254 | RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);
|
---|
255 | else
|
---|
256 | RTPrintf("Boot menu mode: %s\n", pszBootMenu);
|
---|
257 |
|
---|
258 | ULONG maxBootPosition = 0;
|
---|
259 | ComPtr<ISystemProperties> systemProperties;
|
---|
260 | virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
|
---|
261 | systemProperties->COMGETTER(MaxBootPosition)(&maxBootPosition);
|
---|
262 | for (ULONG i = 1; i <= maxBootPosition; i++)
|
---|
263 | {
|
---|
264 | DeviceType_T bootOrder;
|
---|
265 | machine->GetBootOrder(i, &bootOrder);
|
---|
266 | if (bootOrder == DeviceType_Floppy)
|
---|
267 | {
|
---|
268 | if (details == VMINFO_MACHINEREADABLE)
|
---|
269 | RTPrintf("boot%d=\"floppy\"\n", i);
|
---|
270 | else
|
---|
271 | RTPrintf("Boot Device (%d): Floppy\n", i);
|
---|
272 | }
|
---|
273 | else if (bootOrder == DeviceType_DVD)
|
---|
274 | {
|
---|
275 | if (details == VMINFO_MACHINEREADABLE)
|
---|
276 | RTPrintf("boot%d=\"dvd\"\n", i);
|
---|
277 | else
|
---|
278 | RTPrintf("Boot Device (%d): DVD\n", i);
|
---|
279 | }
|
---|
280 | else if (bootOrder == DeviceType_HardDisk)
|
---|
281 | {
|
---|
282 | if (details == VMINFO_MACHINEREADABLE)
|
---|
283 | RTPrintf("boot%d=\"disk\"\n", i);
|
---|
284 | else
|
---|
285 | RTPrintf("Boot Device (%d): HardDisk\n", i);
|
---|
286 | }
|
---|
287 | else if (bootOrder == DeviceType_Network)
|
---|
288 | {
|
---|
289 | if (details == VMINFO_MACHINEREADABLE)
|
---|
290 | RTPrintf("boot%d=\"net\"\n", i);
|
---|
291 | else
|
---|
292 | RTPrintf("Boot Device (%d): Network\n", i);
|
---|
293 | }
|
---|
294 | else if (bootOrder == DeviceType_USB)
|
---|
295 | {
|
---|
296 | if (details == VMINFO_MACHINEREADABLE)
|
---|
297 | RTPrintf("boot%d=\"usb\"\n", i);
|
---|
298 | else
|
---|
299 | RTPrintf("Boot Device (%d): USB\n", i);
|
---|
300 | }
|
---|
301 | else if (bootOrder == DeviceType_SharedFolder)
|
---|
302 | {
|
---|
303 | if (details == VMINFO_MACHINEREADABLE)
|
---|
304 | RTPrintf("boot%d=\"sharedfolder\"\n", i);
|
---|
305 | else
|
---|
306 | RTPrintf("Boot Device (%d): Shared Folder\n", i);
|
---|
307 | }
|
---|
308 | else
|
---|
309 | {
|
---|
310 | if (details == VMINFO_MACHINEREADABLE)
|
---|
311 | RTPrintf("boot%d=\"none\"\n", i);
|
---|
312 | else
|
---|
313 | RTPrintf("Boot Device (%d): Not Assigned\n", i);
|
---|
314 | }
|
---|
315 | }
|
---|
316 |
|
---|
317 | BOOL acpiEnabled;
|
---|
318 | biosSettings->COMGETTER(ACPIEnabled)(&acpiEnabled);
|
---|
319 | if (details == VMINFO_MACHINEREADABLE)
|
---|
320 | RTPrintf("acpi=\"%s\"\n", acpiEnabled ? "on" : "off");
|
---|
321 | else
|
---|
322 | RTPrintf("ACPI: %s\n", acpiEnabled ? "on" : "off");
|
---|
323 |
|
---|
324 | BOOL ioapicEnabled;
|
---|
325 | biosSettings->COMGETTER(IOAPICEnabled)(&ioapicEnabled);
|
---|
326 | if (details == VMINFO_MACHINEREADABLE)
|
---|
327 | RTPrintf("ioapic=\"%s\"\n", ioapicEnabled ? "on" : "off");
|
---|
328 | else
|
---|
329 | RTPrintf("IOAPIC: %s\n", ioapicEnabled ? "on" : "off");
|
---|
330 |
|
---|
331 | BOOL PAEEnabled;
|
---|
332 | machine->COMGETTER(PAEEnabled)(&PAEEnabled);
|
---|
333 | if (details == VMINFO_MACHINEREADABLE)
|
---|
334 | RTPrintf("pae=\"%s\"\n", PAEEnabled ? "on" : "off");
|
---|
335 | else
|
---|
336 | RTPrintf("PAE: %s\n", PAEEnabled ? "on" : "off");
|
---|
337 |
|
---|
338 | LONG64 timeOffset;
|
---|
339 | biosSettings->COMGETTER(TimeOffset)(&timeOffset);
|
---|
340 | if (details == VMINFO_MACHINEREADABLE)
|
---|
341 | RTPrintf("biossystemtimeoffset=%lld\n", timeOffset);
|
---|
342 | else
|
---|
343 | RTPrintf("Time offset: %lld ms\n", timeOffset);
|
---|
344 |
|
---|
345 | BOOL hwVirtExEnabled;
|
---|
346 | machine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled);
|
---|
347 | if (details == VMINFO_MACHINEREADABLE)
|
---|
348 | RTPrintf("hwvirtex=\"%s\"\n", hwVirtExEnabled ? "on" : "off");
|
---|
349 | else
|
---|
350 | RTPrintf("Hardw. virt.ext: %s\n", hwVirtExEnabled ? "on" : "off");
|
---|
351 | BOOL HWVirtExNestedPagingEnabled;
|
---|
352 | machine->COMGETTER(HWVirtExNestedPagingEnabled)(&HWVirtExNestedPagingEnabled);
|
---|
353 | if (details == VMINFO_MACHINEREADABLE)
|
---|
354 | RTPrintf("nestedpaging=\"%s\"\n", HWVirtExNestedPagingEnabled ? "on" : "off");
|
---|
355 | else
|
---|
356 | RTPrintf("Nested Paging: %s\n", HWVirtExNestedPagingEnabled ? "on" : "off");
|
---|
357 |
|
---|
358 | BOOL HWVirtExVPIDEnabled;
|
---|
359 | machine->COMGETTER(HWVirtExVPIDEnabled)(&HWVirtExVPIDEnabled);
|
---|
360 | if (details == VMINFO_MACHINEREADABLE)
|
---|
361 | RTPrintf("vtxvpid=\"%s\"\n", HWVirtExVPIDEnabled ? "on" : "off");
|
---|
362 | else
|
---|
363 | RTPrintf("VT-x VPID: %s\n", HWVirtExVPIDEnabled ? "on" : "off");
|
---|
364 |
|
---|
365 | MachineState_T machineState;
|
---|
366 | const char *pszState = NULL;
|
---|
367 | rc = machine->COMGETTER(State)(&machineState);
|
---|
368 | switch (machineState)
|
---|
369 | {
|
---|
370 | case MachineState_PoweredOff:
|
---|
371 | if (details == VMINFO_MACHINEREADABLE)
|
---|
372 | pszState = "poweroff";
|
---|
373 | else
|
---|
374 | pszState = "powered off";
|
---|
375 | break;
|
---|
376 | case MachineState_Saved:
|
---|
377 | pszState = "saved";
|
---|
378 | break;
|
---|
379 | case MachineState_Aborted:
|
---|
380 | pszState = "aborted";
|
---|
381 | break;
|
---|
382 | case MachineState_Running:
|
---|
383 | pszState = "running";
|
---|
384 | break;
|
---|
385 | case MachineState_Paused:
|
---|
386 | pszState = "paused";
|
---|
387 | break;
|
---|
388 | case MachineState_Starting:
|
---|
389 | pszState = "starting";
|
---|
390 | break;
|
---|
391 | case MachineState_Stopping:
|
---|
392 | pszState = "stopping";
|
---|
393 | break;
|
---|
394 | case MachineState_Saving:
|
---|
395 | pszState = "saving";
|
---|
396 | break;
|
---|
397 | case MachineState_Restoring:
|
---|
398 | pszState = "restoring";
|
---|
399 | break;
|
---|
400 | default:
|
---|
401 | pszState = "unknown";
|
---|
402 | break;
|
---|
403 | }
|
---|
404 | LONG64 stateSince;
|
---|
405 | machine->COMGETTER(LastStateChange)(&stateSince);
|
---|
406 | RTTIMESPEC timeSpec;
|
---|
407 | RTTimeSpecSetMilli(&timeSpec, stateSince);
|
---|
408 | char pszTime[30] = {0};
|
---|
409 | RTTimeSpecToString(&timeSpec, pszTime, sizeof(pszTime));
|
---|
410 | if (details == VMINFO_MACHINEREADABLE)
|
---|
411 | {
|
---|
412 | RTPrintf("VMState=\"%s\"\n", pszState);
|
---|
413 | RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
|
---|
414 | }
|
---|
415 | else
|
---|
416 | RTPrintf("State: %s (since %s)\n", pszState, pszTime);
|
---|
417 |
|
---|
418 | ULONG numMonitors;
|
---|
419 | machine->COMGETTER(MonitorCount)(&numMonitors);
|
---|
420 | if (details == VMINFO_MACHINEREADABLE)
|
---|
421 | RTPrintf("monitorcount=%d\n", numMonitors);
|
---|
422 | else
|
---|
423 | RTPrintf("Monitor count: %d\n", numMonitors);
|
---|
424 |
|
---|
425 | BOOL accelerate3d;
|
---|
426 | machine->COMGETTER(Accelerate3DEnabled)(&accelerate3d);
|
---|
427 | if (details == VMINFO_MACHINEREADABLE)
|
---|
428 | RTPrintf("accelerate3d=\"%s\"\n", accelerate3d ? "on" : "off");
|
---|
429 | else
|
---|
430 | RTPrintf("3D Acceleration: %s\n", accelerate3d ? "on" : "off");
|
---|
431 |
|
---|
432 | ComPtr<IFloppyDrive> floppyDrive;
|
---|
433 | rc = machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
|
---|
434 | if (SUCCEEDED(rc) && floppyDrive)
|
---|
435 | {
|
---|
436 | BOOL fFloppyEnabled;
|
---|
437 | floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled);
|
---|
438 | Utf8Str pszFloppy = "invalid";
|
---|
439 | if (fFloppyEnabled)
|
---|
440 | {
|
---|
441 | DriveState_T floppyState;
|
---|
442 | floppyDrive->COMGETTER(State)(&floppyState);
|
---|
443 | switch (floppyState)
|
---|
444 | {
|
---|
445 | case DriveState_ImageMounted:
|
---|
446 | {
|
---|
447 | ComPtr<IFloppyImage> floppyImage;
|
---|
448 | rc = floppyDrive->GetImage(floppyImage.asOutParam());
|
---|
449 | if (SUCCEEDED(rc) && floppyImage)
|
---|
450 | {
|
---|
451 | Bstr imagePath;
|
---|
452 | floppyImage->COMGETTER(Location)(imagePath.asOutParam());
|
---|
453 | Bstr imageGuid;
|
---|
454 | floppyImage->COMGETTER(Id)(imageGuid.asOutParam());
|
---|
455 | if (details == VMINFO_MACHINEREADABLE)
|
---|
456 | {
|
---|
457 | RTPrintf("FloppyImageUUID=\"%s\"\n", Utf8Str(imageGuid).raw());
|
---|
458 | pszFloppy = Utf8StrFmt("%lS", imagePath.raw());
|
---|
459 | }
|
---|
460 | else
|
---|
461 | pszFloppy = Utf8StrFmt("%lS (UUID: %s)", imagePath.raw(), Utf8Str(imageGuid).raw());
|
---|
462 | }
|
---|
463 | break;
|
---|
464 | }
|
---|
465 |
|
---|
466 | case DriveState_HostDriveCaptured:
|
---|
467 | {
|
---|
468 | ComPtr<IHostFloppyDrive> hostFloppyDrive;
|
---|
469 | rc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam());
|
---|
470 | if (SUCCEEDED(rc) && floppyDrive)
|
---|
471 | {
|
---|
472 | Bstr driveName;
|
---|
473 | hostFloppyDrive->COMGETTER(Name)(driveName.asOutParam());
|
---|
474 | if (details == VMINFO_MACHINEREADABLE)
|
---|
475 | pszFloppy = Utf8StrFmt("host:%lS", driveName.raw());
|
---|
476 | else
|
---|
477 | pszFloppy = Utf8StrFmt("Host drive %lS", driveName.raw());
|
---|
478 | }
|
---|
479 | break;
|
---|
480 | }
|
---|
481 |
|
---|
482 | case DriveState_NotMounted:
|
---|
483 | {
|
---|
484 | pszFloppy = "empty";
|
---|
485 | break;
|
---|
486 | }
|
---|
487 | }
|
---|
488 | }
|
---|
489 | else
|
---|
490 | {
|
---|
491 | pszFloppy = "disabled";
|
---|
492 | }
|
---|
493 | if (details == VMINFO_MACHINEREADABLE)
|
---|
494 | RTPrintf("floppy=\"%s\"\n", pszFloppy.raw());
|
---|
495 | else
|
---|
496 | RTPrintf("Floppy: %s\n", pszFloppy.raw());
|
---|
497 | }
|
---|
498 |
|
---|
499 | /*
|
---|
500 | * SATA.
|
---|
501 | *
|
---|
502 | * Contributed by: James Lucas
|
---|
503 | */
|
---|
504 | #ifdef VBOX_WITH_AHCI
|
---|
505 | ComPtr<IStorageController> SataCtl;
|
---|
506 | bool fSataEnabled = false;
|
---|
507 |
|
---|
508 | rc = machine->GetStorageControllerByName(Bstr("SATA"), SataCtl.asOutParam());
|
---|
509 | if (SUCCEEDED(rc))
|
---|
510 | fSataEnabled = true;
|
---|
511 |
|
---|
512 | if (details == VMINFO_MACHINEREADABLE)
|
---|
513 | RTPrintf("sata=\"%s\"\n", fSataEnabled ? "on" : "off");
|
---|
514 | else
|
---|
515 | RTPrintf("SATA: %s\n", fSataEnabled ? "enabled" : "disabled");
|
---|
516 |
|
---|
517 | /*
|
---|
518 | * SATA Hard disks
|
---|
519 | */
|
---|
520 | if (fSataEnabled)
|
---|
521 | {
|
---|
522 | ComPtr<IHardDisk> hardDisk;
|
---|
523 | Bstr filePath;
|
---|
524 | ULONG cSataPorts;
|
---|
525 |
|
---|
526 | SataCtl->COMGETTER(PortCount)(&cSataPorts);
|
---|
527 | for (ULONG i = 0; i < cSataPorts; ++ i)
|
---|
528 | {
|
---|
529 | rc = machine->GetHardDisk(Bstr("SATA"), i, 0, hardDisk.asOutParam());
|
---|
530 | if (SUCCEEDED(rc) && hardDisk)
|
---|
531 | {
|
---|
532 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
533 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
534 | if (details == VMINFO_MACHINEREADABLE)
|
---|
535 | {
|
---|
536 | RTPrintf("sataport%d=\"%lS\"\n", i, filePath.raw());
|
---|
537 | RTPrintf("SataPortImageUUID%d=\"%s\"\n", i, Utf8Str(uuid).raw());
|
---|
538 | }
|
---|
539 | else
|
---|
540 | RTPrintf("SATA %d: %lS (UUID: %s)\n", i, filePath.raw(), Utf8Str(uuid).raw());
|
---|
541 | }
|
---|
542 | else
|
---|
543 | {
|
---|
544 | if (details == VMINFO_MACHINEREADABLE)
|
---|
545 | RTPrintf("sata%d=\"none\"\n",i);
|
---|
546 | }
|
---|
547 | }
|
---|
548 | }
|
---|
549 | #endif
|
---|
550 |
|
---|
551 | /*
|
---|
552 | * IDE Hard disks
|
---|
553 | */
|
---|
554 | ComPtr<IStorageController> ideController;
|
---|
555 |
|
---|
556 | rc = machine->GetStorageControllerByName(Bstr("IDE"), ideController.asOutParam());
|
---|
557 | if (SUCCEEDED(rc) && ideController)
|
---|
558 | {
|
---|
559 | StorageControllerType_T enmIdeController;
|
---|
560 | const char *pszIdeController = NULL;
|
---|
561 |
|
---|
562 | rc = ideController->COMGETTER(ControllerType)(&enmIdeController);
|
---|
563 |
|
---|
564 | switch (enmIdeController)
|
---|
565 | {
|
---|
566 | case StorageControllerType_PIIX3:
|
---|
567 | pszIdeController = "PIIX3";
|
---|
568 | break;
|
---|
569 | case StorageControllerType_PIIX4:
|
---|
570 | pszIdeController = "PIIX4";
|
---|
571 | break;
|
---|
572 | case StorageControllerType_ICH6:
|
---|
573 | pszIdeController = "ICH6";
|
---|
574 | break;
|
---|
575 | default:
|
---|
576 | pszIdeController = "unknown";
|
---|
577 | }
|
---|
578 | if (details == VMINFO_MACHINEREADABLE)
|
---|
579 | RTPrintf("idecontroller=\"%s\"\n", pszIdeController);
|
---|
580 | else
|
---|
581 | RTPrintf("IDE Controller: %s\n", pszIdeController);
|
---|
582 | }
|
---|
583 |
|
---|
584 | ComPtr<IHardDisk> hardDisk;
|
---|
585 | Bstr filePath;
|
---|
586 | rc = machine->GetHardDisk(Bstr("IDE"), 0, 0, hardDisk.asOutParam());
|
---|
587 | if (SUCCEEDED(rc) && hardDisk)
|
---|
588 | {
|
---|
589 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
590 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
591 | if (details == VMINFO_MACHINEREADABLE)
|
---|
592 | {
|
---|
593 | RTPrintf("hda=\"%lS\"\n", filePath.raw());
|
---|
594 | RTPrintf("HdaImageUUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
595 | }
|
---|
596 | else
|
---|
597 | RTPrintf("Primary master: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw());
|
---|
598 | }
|
---|
599 | else
|
---|
600 | {
|
---|
601 | if (details == VMINFO_MACHINEREADABLE)
|
---|
602 | RTPrintf("hda=\"none\"\n");
|
---|
603 | }
|
---|
604 | rc = machine->GetHardDisk(Bstr("IDE"), 0, 1, hardDisk.asOutParam());
|
---|
605 | if (SUCCEEDED(rc) && hardDisk)
|
---|
606 | {
|
---|
607 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
608 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
609 | if (details == VMINFO_MACHINEREADABLE)
|
---|
610 | {
|
---|
611 | RTPrintf("hdb=\"%lS\"\n", filePath.raw());
|
---|
612 | RTPrintf("HdbImageUUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
613 | }
|
---|
614 | else
|
---|
615 | RTPrintf("Primary slave: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw());
|
---|
616 | }
|
---|
617 | else
|
---|
618 | {
|
---|
619 | if (details == VMINFO_MACHINEREADABLE)
|
---|
620 | RTPrintf("hdb=\"none\"\n");
|
---|
621 | }
|
---|
622 | rc = machine->GetHardDisk(Bstr("IDE"), 1, 1, hardDisk.asOutParam());
|
---|
623 | if (SUCCEEDED(rc) && hardDisk)
|
---|
624 | {
|
---|
625 | hardDisk->COMGETTER(Location)(filePath.asOutParam());
|
---|
626 | hardDisk->COMGETTER(Id)(uuid.asOutParam());
|
---|
627 | if (details == VMINFO_MACHINEREADABLE)
|
---|
628 | {
|
---|
629 | RTPrintf("hdd=\"%lS\"\n", filePath.raw());
|
---|
630 | RTPrintf("HddImageUUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
631 | }
|
---|
632 | else
|
---|
633 | RTPrintf("Secondary slave: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw());
|
---|
634 | }
|
---|
635 | else
|
---|
636 | {
|
---|
637 | if (details == VMINFO_MACHINEREADABLE)
|
---|
638 | RTPrintf("hdd=\"none\"\n");
|
---|
639 | }
|
---|
640 | ComPtr<IDVDDrive> dvdDrive;
|
---|
641 | rc = machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
|
---|
642 | if (SUCCEEDED(rc) && dvdDrive)
|
---|
643 | {
|
---|
644 | ComPtr<IDVDImage> dvdImage;
|
---|
645 | rc = dvdDrive->GetImage(dvdImage.asOutParam());
|
---|
646 | if (SUCCEEDED(rc) && dvdImage)
|
---|
647 | {
|
---|
648 | rc = dvdImage->COMGETTER(Location)(filePath.asOutParam());
|
---|
649 | if (SUCCEEDED(rc) && filePath)
|
---|
650 | {
|
---|
651 | rc = dvdImage->COMGETTER(Id)(uuid.asOutParam());
|
---|
652 | if (details == VMINFO_MACHINEREADABLE)
|
---|
653 | {
|
---|
654 | RTPrintf("dvd=\"%lS\"\n", filePath.raw());
|
---|
655 | RTPrintf("DvdImageUUID=\"%s\"\n", Utf8Str(uuid).raw());
|
---|
656 | }
|
---|
657 | else
|
---|
658 | RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), Utf8Str(uuid).raw());
|
---|
659 | }
|
---|
660 | }
|
---|
661 | else
|
---|
662 | {
|
---|
663 | ComPtr<IHostDVDDrive> hostDVDDrive;
|
---|
664 | rc = dvdDrive->GetHostDrive(hostDVDDrive.asOutParam());
|
---|
665 | if (SUCCEEDED(rc) && hostDVDDrive)
|
---|
666 | {
|
---|
667 | Bstr name;
|
---|
668 | hostDVDDrive->COMGETTER(Name)(name.asOutParam());
|
---|
669 | if (details == VMINFO_MACHINEREADABLE)
|
---|
670 | RTPrintf("dvd=\"host:%lS\"\n", name.raw());
|
---|
671 | else
|
---|
672 | RTPrintf("DVD: Host drive %lS", name.raw());
|
---|
673 | }
|
---|
674 | else
|
---|
675 | {
|
---|
676 | if (details == VMINFO_MACHINEREADABLE)
|
---|
677 | RTPrintf("dvd=\"none\"\n");
|
---|
678 | else
|
---|
679 | RTPrintf("DVD: empty");
|
---|
680 | }
|
---|
681 | BOOL fPassthrough;
|
---|
682 | dvdDrive->COMGETTER(Passthrough)(&fPassthrough);
|
---|
683 | if (details == VMINFO_MACHINEREADABLE)
|
---|
684 | {
|
---|
685 | RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off");
|
---|
686 | }
|
---|
687 | else
|
---|
688 | {
|
---|
689 | if (fPassthrough)
|
---|
690 | RTPrintf(" (passthrough enabled)");
|
---|
691 | RTPrintf("\n");
|
---|
692 | }
|
---|
693 | }
|
---|
694 | }
|
---|
695 |
|
---|
696 | /* get the maximum amount of NICS */
|
---|
697 | ComPtr<ISystemProperties> sysProps;
|
---|
698 | virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
|
---|
699 | ULONG maxNICs = 0;
|
---|
700 | sysProps->COMGETTER(NetworkAdapterCount)(&maxNICs);
|
---|
701 | for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
|
---|
702 | {
|
---|
703 | ComPtr<INetworkAdapter> nic;
|
---|
704 | rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
|
---|
705 | if (SUCCEEDED(rc) && nic)
|
---|
706 | {
|
---|
707 | BOOL fEnabled;
|
---|
708 | nic->COMGETTER(Enabled)(&fEnabled);
|
---|
709 | if (!fEnabled)
|
---|
710 | {
|
---|
711 | if (details == VMINFO_MACHINEREADABLE)
|
---|
712 | RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
|
---|
713 | else
|
---|
714 | RTPrintf("NIC %d: disabled\n", currentNIC + 1);
|
---|
715 | }
|
---|
716 | else
|
---|
717 | {
|
---|
718 | Bstr strMACAddress;
|
---|
719 | nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
|
---|
720 | Utf8Str strAttachment;
|
---|
721 | NetworkAttachmentType_T attachment;
|
---|
722 | nic->COMGETTER(AttachmentType)(&attachment);
|
---|
723 | switch (attachment)
|
---|
724 | {
|
---|
725 | case NetworkAttachmentType_Null:
|
---|
726 | if (details == VMINFO_MACHINEREADABLE)
|
---|
727 | strAttachment = "null";
|
---|
728 | else
|
---|
729 | strAttachment = "none";
|
---|
730 | break;
|
---|
731 | case NetworkAttachmentType_NAT:
|
---|
732 | {
|
---|
733 | Bstr strNetwork;
|
---|
734 | nic->COMGETTER(NATNetwork)(strNetwork.asOutParam());
|
---|
735 | if (details == VMINFO_MACHINEREADABLE)
|
---|
736 | {
|
---|
737 | RTPrintf("natnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
|
---|
738 | strAttachment = "nat";
|
---|
739 | }
|
---|
740 | else if (!strNetwork.isEmpty())
|
---|
741 | strAttachment = Utf8StrFmt("NAT (%lS)", strNetwork.raw());
|
---|
742 | else
|
---|
743 | strAttachment = "NAT";
|
---|
744 | break;
|
---|
745 | }
|
---|
746 | case NetworkAttachmentType_Bridged:
|
---|
747 | {
|
---|
748 | Bstr strBridgeAdp;
|
---|
749 | nic->COMGETTER(HostInterface)(strBridgeAdp.asOutParam());
|
---|
750 | if (details == VMINFO_MACHINEREADABLE)
|
---|
751 | {
|
---|
752 | RTPrintf("bridgeadapter%d=\"%lS\"\n", currentNIC + 1, strBridgeAdp.raw());
|
---|
753 | strAttachment = "bridged";
|
---|
754 | }
|
---|
755 | else
|
---|
756 | strAttachment = Utf8StrFmt("Bridged Interface '%lS'", strBridgeAdp.raw());
|
---|
757 | break;
|
---|
758 | }
|
---|
759 | case NetworkAttachmentType_Internal:
|
---|
760 | {
|
---|
761 | Bstr strNetwork;
|
---|
762 | nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
|
---|
763 | if (details == VMINFO_MACHINEREADABLE)
|
---|
764 | {
|
---|
765 | RTPrintf("intnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
|
---|
766 | strAttachment = "intnet";
|
---|
767 | }
|
---|
768 | else
|
---|
769 | strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).raw());
|
---|
770 | break;
|
---|
771 | }
|
---|
772 | #if defined(VBOX_WITH_NETFLT)
|
---|
773 | case NetworkAttachmentType_HostOnly:
|
---|
774 | {
|
---|
775 | Bstr strHostonlyAdp;
|
---|
776 | nic->COMGETTER(HostInterface)(strHostonlyAdp.asOutParam());
|
---|
777 | if (details == VMINFO_MACHINEREADABLE)
|
---|
778 | {
|
---|
779 | RTPrintf("hostonlyadapter%d=\"%lS\"\n", currentNIC + 1, strHostonlyAdp.raw());
|
---|
780 | strAttachment = "hostonly";
|
---|
781 | }
|
---|
782 | else
|
---|
783 | strAttachment = Utf8StrFmt("Host-only Interface '%lS'", strHostonlyAdp.raw());
|
---|
784 | break;
|
---|
785 | }
|
---|
786 | #endif
|
---|
787 | default:
|
---|
788 | strAttachment = "unknown";
|
---|
789 | break;
|
---|
790 | }
|
---|
791 |
|
---|
792 | /* cable connected */
|
---|
793 | BOOL fConnected;
|
---|
794 | nic->COMGETTER(CableConnected)(&fConnected);
|
---|
795 |
|
---|
796 | /* trace stuff */
|
---|
797 | BOOL fTraceEnabled;
|
---|
798 | nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
|
---|
799 | Bstr traceFile;
|
---|
800 | nic->COMGETTER(TraceFile)(traceFile.asOutParam());
|
---|
801 |
|
---|
802 | /* NIC type */
|
---|
803 | Utf8Str strNICType;
|
---|
804 | NetworkAdapterType_T NICType;
|
---|
805 | nic->COMGETTER(AdapterType)(&NICType);
|
---|
806 | switch (NICType) {
|
---|
807 | case NetworkAdapterType_Am79C970A:
|
---|
808 | strNICType = "Am79C970A";
|
---|
809 | break;
|
---|
810 | case NetworkAdapterType_Am79C973:
|
---|
811 | strNICType = "Am79C973";
|
---|
812 | break;
|
---|
813 | #ifdef VBOX_WITH_E1000
|
---|
814 | case NetworkAdapterType_I82540EM:
|
---|
815 | strNICType = "82540EM";
|
---|
816 | break;
|
---|
817 | case NetworkAdapterType_I82543GC:
|
---|
818 | strNICType = "82543GC";
|
---|
819 | break;
|
---|
820 | case NetworkAdapterType_I82545EM:
|
---|
821 | strNICType = "82545EM";
|
---|
822 | break;
|
---|
823 | #endif
|
---|
824 | default:
|
---|
825 | strNICType = "unknown";
|
---|
826 | break;
|
---|
827 | }
|
---|
828 |
|
---|
829 | /* reported line speed */
|
---|
830 | ULONG ulLineSpeed;
|
---|
831 | nic->COMGETTER(LineSpeed)(&ulLineSpeed);
|
---|
832 |
|
---|
833 | if (details == VMINFO_MACHINEREADABLE)
|
---|
834 | {
|
---|
835 | RTPrintf("macaddress%d=\"%lS\"\n", currentNIC + 1, strMACAddress.raw());
|
---|
836 | RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
|
---|
837 | RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.raw());
|
---|
838 | }
|
---|
839 | else
|
---|
840 | RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps\n",
|
---|
841 | currentNIC + 1, strMACAddress.raw(), strAttachment.raw(),
|
---|
842 | fConnected ? "on" : "off",
|
---|
843 | fTraceEnabled ? "on" : "off",
|
---|
844 | traceFile.isEmpty() ? Bstr("none").raw() : traceFile.raw(),
|
---|
845 | strNICType.raw(),
|
---|
846 | ulLineSpeed / 1000);
|
---|
847 | }
|
---|
848 | }
|
---|
849 | }
|
---|
850 |
|
---|
851 | /* get the maximum amount of UARTs */
|
---|
852 | ULONG maxUARTs = 0;
|
---|
853 | sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
|
---|
854 | for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
|
---|
855 | {
|
---|
856 | ComPtr<ISerialPort> uart;
|
---|
857 | rc = machine->GetSerialPort(currentUART, uart.asOutParam());
|
---|
858 | if (SUCCEEDED(rc) && uart)
|
---|
859 | {
|
---|
860 | BOOL fEnabled;
|
---|
861 | uart->COMGETTER(Enabled)(&fEnabled);
|
---|
862 | if (!fEnabled)
|
---|
863 | {
|
---|
864 | if (details == VMINFO_MACHINEREADABLE)
|
---|
865 | RTPrintf("uart%d=\"off\"\n", currentUART + 1);
|
---|
866 | else
|
---|
867 | RTPrintf("UART %d: disabled\n", currentUART + 1);
|
---|
868 | }
|
---|
869 | else
|
---|
870 | {
|
---|
871 | ULONG ulIRQ, ulIOBase;
|
---|
872 | PortMode_T HostMode;
|
---|
873 | Bstr path;
|
---|
874 | BOOL fServer;
|
---|
875 | uart->COMGETTER(IRQ)(&ulIRQ);
|
---|
876 | uart->COMGETTER(IOBase)(&ulIOBase);
|
---|
877 | uart->COMGETTER(Path)(path.asOutParam());
|
---|
878 | uart->COMGETTER(Server)(&fServer);
|
---|
879 | uart->COMGETTER(HostMode)(&HostMode);
|
---|
880 |
|
---|
881 | if (details == VMINFO_MACHINEREADABLE)
|
---|
882 | RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
|
---|
883 | ulIOBase, ulIRQ);
|
---|
884 | else
|
---|
885 | RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
|
---|
886 | currentUART + 1, ulIOBase, ulIRQ);
|
---|
887 | switch (HostMode)
|
---|
888 | {
|
---|
889 | default:
|
---|
890 | case PortMode_Disconnected:
|
---|
891 | if (details == VMINFO_MACHINEREADABLE)
|
---|
892 | RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
|
---|
893 | else
|
---|
894 | RTPrintf(", disconnected\n");
|
---|
895 | break;
|
---|
896 | case PortMode_RawFile:
|
---|
897 | if (details == VMINFO_MACHINEREADABLE)
|
---|
898 | RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
|
---|
899 | path.raw());
|
---|
900 | else
|
---|
901 | RTPrintf(", attached to raw file '%lS'\n",
|
---|
902 | path.raw());
|
---|
903 | break;
|
---|
904 | case PortMode_HostPipe:
|
---|
905 | if (details == VMINFO_MACHINEREADABLE)
|
---|
906 | RTPrintf("uartmode%d=\"%s,%lS\"\n", currentUART + 1,
|
---|
907 | fServer ? "server" : "client", path.raw());
|
---|
908 | else
|
---|
909 | RTPrintf(", attached to pipe (%s) '%lS'\n",
|
---|
910 | fServer ? "server" : "client", path.raw());
|
---|
911 | break;
|
---|
912 | case PortMode_HostDevice:
|
---|
913 | if (details == VMINFO_MACHINEREADABLE)
|
---|
914 | RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
|
---|
915 | path.raw());
|
---|
916 | else
|
---|
917 | RTPrintf(", attached to device '%lS'\n", path.raw());
|
---|
918 | break;
|
---|
919 | }
|
---|
920 | }
|
---|
921 | }
|
---|
922 | }
|
---|
923 |
|
---|
924 | ComPtr<IAudioAdapter> AudioAdapter;
|
---|
925 | rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
|
---|
926 | if (SUCCEEDED(rc))
|
---|
927 | {
|
---|
928 | const char *pszDrv = "Unknown";
|
---|
929 | const char *pszCtrl = "Unknown";
|
---|
930 | BOOL fEnabled;
|
---|
931 | rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
|
---|
932 | if (SUCCEEDED(rc) && fEnabled)
|
---|
933 | {
|
---|
934 | AudioDriverType_T enmDrvType;
|
---|
935 | rc = AudioAdapter->COMGETTER(AudioDriver)(&enmDrvType);
|
---|
936 | switch (enmDrvType)
|
---|
937 | {
|
---|
938 | case AudioDriverType_Null:
|
---|
939 | if (details == VMINFO_MACHINEREADABLE)
|
---|
940 | pszDrv = "null";
|
---|
941 | else
|
---|
942 | pszDrv = "Null";
|
---|
943 | break;
|
---|
944 | case AudioDriverType_WinMM:
|
---|
945 | if (details == VMINFO_MACHINEREADABLE)
|
---|
946 | pszDrv = "winmm";
|
---|
947 | else
|
---|
948 | pszDrv = "WINMM";
|
---|
949 | break;
|
---|
950 | case AudioDriverType_DirectSound:
|
---|
951 | if (details == VMINFO_MACHINEREADABLE)
|
---|
952 | pszDrv = "dsound";
|
---|
953 | else
|
---|
954 | pszDrv = "DSOUND";
|
---|
955 | break;
|
---|
956 | case AudioDriverType_OSS:
|
---|
957 | if (details == VMINFO_MACHINEREADABLE)
|
---|
958 | pszDrv = "oss";
|
---|
959 | else
|
---|
960 | pszDrv = "OSS";
|
---|
961 | break;
|
---|
962 | case AudioDriverType_ALSA:
|
---|
963 | if (details == VMINFO_MACHINEREADABLE)
|
---|
964 | pszDrv = "alsa";
|
---|
965 | else
|
---|
966 | pszDrv = "ALSA";
|
---|
967 | break;
|
---|
968 | case AudioDriverType_Pulse:
|
---|
969 | if (details == VMINFO_MACHINEREADABLE)
|
---|
970 | pszDrv = "pulse";
|
---|
971 | else
|
---|
972 | pszDrv = "PulseAudio";
|
---|
973 | break;
|
---|
974 | case AudioDriverType_CoreAudio:
|
---|
975 | if (details == VMINFO_MACHINEREADABLE)
|
---|
976 | pszDrv = "coreaudio";
|
---|
977 | else
|
---|
978 | pszDrv = "CoreAudio";
|
---|
979 | break;
|
---|
980 | case AudioDriverType_SolAudio:
|
---|
981 | if (details == VMINFO_MACHINEREADABLE)
|
---|
982 | pszDrv = "solaudio";
|
---|
983 | else
|
---|
984 | pszDrv = "SolAudio";
|
---|
985 | break;
|
---|
986 | default:
|
---|
987 | if (details == VMINFO_MACHINEREADABLE)
|
---|
988 | pszDrv = "unknown";
|
---|
989 | break;
|
---|
990 | }
|
---|
991 | AudioControllerType_T enmCtrlType;
|
---|
992 | rc = AudioAdapter->COMGETTER(AudioController)(&enmCtrlType);
|
---|
993 | switch (enmCtrlType)
|
---|
994 | {
|
---|
995 | case AudioControllerType_AC97:
|
---|
996 | if (details == VMINFO_MACHINEREADABLE)
|
---|
997 | pszCtrl = "ac97";
|
---|
998 | else
|
---|
999 | pszCtrl = "AC97";
|
---|
1000 | break;
|
---|
1001 | case AudioControllerType_SB16:
|
---|
1002 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1003 | pszCtrl = "sb16";
|
---|
1004 | else
|
---|
1005 | pszCtrl = "SB16";
|
---|
1006 | break;
|
---|
1007 | }
|
---|
1008 | }
|
---|
1009 | else
|
---|
1010 | fEnabled = FALSE;
|
---|
1011 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1012 | {
|
---|
1013 | if (fEnabled)
|
---|
1014 | RTPrintf("audio=\"%s\"\n", pszDrv);
|
---|
1015 | else
|
---|
1016 | RTPrintf("audio=\"none\"\n");
|
---|
1017 | }
|
---|
1018 | else
|
---|
1019 | {
|
---|
1020 | RTPrintf("Audio: %s",
|
---|
1021 | fEnabled ? "enabled" : "disabled");
|
---|
1022 | if (fEnabled)
|
---|
1023 | RTPrintf(" (Driver: %s, Controller: %s)",
|
---|
1024 | pszDrv, pszCtrl);
|
---|
1025 | RTPrintf("\n");
|
---|
1026 | }
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | /* Shared clipboard */
|
---|
1030 | {
|
---|
1031 | const char *psz = "Unknown";
|
---|
1032 | ClipboardMode_T enmMode;
|
---|
1033 | rc = machine->COMGETTER(ClipboardMode)(&enmMode);
|
---|
1034 | switch (enmMode)
|
---|
1035 | {
|
---|
1036 | case ClipboardMode_Disabled:
|
---|
1037 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1038 | psz = "disabled";
|
---|
1039 | else
|
---|
1040 | psz = "disabled";
|
---|
1041 | break;
|
---|
1042 | case ClipboardMode_HostToGuest:
|
---|
1043 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1044 | psz = "hosttoguest";
|
---|
1045 | else
|
---|
1046 | psz = "HostToGuest";
|
---|
1047 | break;
|
---|
1048 | case ClipboardMode_GuestToHost:
|
---|
1049 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1050 | psz = "guesttohost";
|
---|
1051 | else
|
---|
1052 | psz = "GuestToHost";
|
---|
1053 | break;
|
---|
1054 | case ClipboardMode_Bidirectional:
|
---|
1055 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1056 | psz = "bidirectional";
|
---|
1057 | else
|
---|
1058 | psz = "Bidirectional";
|
---|
1059 | break;
|
---|
1060 | default:
|
---|
1061 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1062 | psz = "unknown";
|
---|
1063 | break;
|
---|
1064 | }
|
---|
1065 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1066 | RTPrintf("clipboard=\"%s\"\n", psz);
|
---|
1067 | else
|
---|
1068 | RTPrintf("Clipboard Mode: %s\n", psz);
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | if (console)
|
---|
1072 | {
|
---|
1073 | ComPtr<IDisplay> display;
|
---|
1074 | CHECK_ERROR_RET(console, COMGETTER(Display)(display.asOutParam()), rc);
|
---|
1075 | do
|
---|
1076 | {
|
---|
1077 | ULONG xRes, yRes, bpp;
|
---|
1078 | rc = display->COMGETTER(Width)(&xRes);
|
---|
1079 | if (rc == E_ACCESSDENIED)
|
---|
1080 | break; /* VM not powered up */
|
---|
1081 | if (FAILED(rc))
|
---|
1082 | {
|
---|
1083 | com::ErrorInfo info (display);
|
---|
1084 | GluePrintErrorInfo(info);
|
---|
1085 | return rc;
|
---|
1086 | }
|
---|
1087 | rc = display->COMGETTER(Height)(&yRes);
|
---|
1088 | if (rc == E_ACCESSDENIED)
|
---|
1089 | break; /* VM not powered up */
|
---|
1090 | if (FAILED(rc))
|
---|
1091 | {
|
---|
1092 | com::ErrorInfo info (display);
|
---|
1093 | GluePrintErrorInfo(info);
|
---|
1094 | return rc;
|
---|
1095 | }
|
---|
1096 | rc = display->COMGETTER(BitsPerPixel)(&bpp);
|
---|
1097 | if (rc == E_ACCESSDENIED)
|
---|
1098 | break; /* VM not powered up */
|
---|
1099 | if (FAILED(rc))
|
---|
1100 | {
|
---|
1101 | com::ErrorInfo info (display);
|
---|
1102 | GluePrintErrorInfo(info);
|
---|
1103 | return rc;
|
---|
1104 | }
|
---|
1105 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1106 | RTPrintf("VideoMode=\"%d,%d,%d\"\n", xRes, yRes, bpp);
|
---|
1107 | else
|
---|
1108 | RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);
|
---|
1109 | }
|
---|
1110 | while (0);
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | /*
|
---|
1114 | * VRDP
|
---|
1115 | */
|
---|
1116 | ComPtr<IVRDPServer> vrdpServer;
|
---|
1117 | rc = machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
|
---|
1118 | if (SUCCEEDED(rc) && vrdpServer)
|
---|
1119 | {
|
---|
1120 | BOOL fEnabled = false;
|
---|
1121 | vrdpServer->COMGETTER(Enabled)(&fEnabled);
|
---|
1122 | if (fEnabled)
|
---|
1123 | {
|
---|
1124 | ULONG port;
|
---|
1125 | vrdpServer->COMGETTER(Port)(&port);
|
---|
1126 | Bstr address;
|
---|
1127 | vrdpServer->COMGETTER(NetAddress)(address.asOutParam());
|
---|
1128 | BOOL fMultiCon;
|
---|
1129 | vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
|
---|
1130 | BOOL fReuseCon;
|
---|
1131 | vrdpServer->COMGETTER(ReuseSingleConnection)(&fReuseCon);
|
---|
1132 | VRDPAuthType_T vrdpAuthType;
|
---|
1133 | const char *strAuthType;
|
---|
1134 | vrdpServer->COMGETTER(AuthType)(&vrdpAuthType);
|
---|
1135 | switch (vrdpAuthType)
|
---|
1136 | {
|
---|
1137 | case VRDPAuthType_Null:
|
---|
1138 | strAuthType = "null";
|
---|
1139 | break;
|
---|
1140 | case VRDPAuthType_External:
|
---|
1141 | strAuthType = "external";
|
---|
1142 | break;
|
---|
1143 | case VRDPAuthType_Guest:
|
---|
1144 | strAuthType = "guest";
|
---|
1145 | break;
|
---|
1146 | default:
|
---|
1147 | strAuthType = "unknown";
|
---|
1148 | break;
|
---|
1149 | }
|
---|
1150 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1151 | {
|
---|
1152 | RTPrintf("vrdp=\"on\"\n");
|
---|
1153 | RTPrintf("vrdpport=%d\n", port);
|
---|
1154 | RTPrintf("vrdpaddress=\"%lS\"\n", address.raw());
|
---|
1155 | RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType);
|
---|
1156 | RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off");
|
---|
1157 | RTPrintf("vrdpreusecon=\"%s\"\n", fReuseCon ? "on" : "off");
|
---|
1158 | }
|
---|
1159 | else
|
---|
1160 | {
|
---|
1161 | if (address.isEmpty())
|
---|
1162 | address = "0.0.0.0";
|
---|
1163 | RTPrintf("VRDP: enabled (Address %lS, Port %d, MultiConn: %s, ReuseSingleConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", fReuseCon ? "on" : "off", strAuthType);
|
---|
1164 | }
|
---|
1165 | }
|
---|
1166 | else
|
---|
1167 | {
|
---|
1168 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1169 | RTPrintf("vrdp=\"off\"\n");
|
---|
1170 | else
|
---|
1171 | RTPrintf("VRDP: disabled\n");
|
---|
1172 | }
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 | /*
|
---|
1176 | * USB.
|
---|
1177 | */
|
---|
1178 | ComPtr<IUSBController> USBCtl;
|
---|
1179 | rc = machine->COMGETTER(USBController)(USBCtl.asOutParam());
|
---|
1180 | if (SUCCEEDED(rc))
|
---|
1181 | {
|
---|
1182 | BOOL fEnabled;
|
---|
1183 | rc = USBCtl->COMGETTER(Enabled)(&fEnabled);
|
---|
1184 | if (FAILED(rc))
|
---|
1185 | fEnabled = false;
|
---|
1186 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1187 | RTPrintf("usb=\"%s\"\n", fEnabled ? "on" : "off");
|
---|
1188 | else
|
---|
1189 | RTPrintf("USB: %s\n", fEnabled ? "enabled" : "disabled");
|
---|
1190 |
|
---|
1191 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1192 | RTPrintf("\nUSB Device Filters:\n\n");
|
---|
1193 |
|
---|
1194 | SafeIfaceArray <IUSBDeviceFilter> Coll;
|
---|
1195 | CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(Coll)), rc);
|
---|
1196 |
|
---|
1197 | if (Coll.size() == 0)
|
---|
1198 | {
|
---|
1199 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1200 | RTPrintf("<none>\n\n");
|
---|
1201 | }
|
---|
1202 | else
|
---|
1203 | {
|
---|
1204 | for (size_t index = 0; index < Coll.size(); ++index)
|
---|
1205 | {
|
---|
1206 | ComPtr<IUSBDeviceFilter> DevPtr = Coll[index];
|
---|
1207 |
|
---|
1208 | /* Query info. */
|
---|
1209 |
|
---|
1210 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1211 | RTPrintf("Index: %zu\n", index);
|
---|
1212 |
|
---|
1213 | BOOL bActive = FALSE;
|
---|
1214 | CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
|
---|
1215 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1216 | RTPrintf("USBFilterActive%zu=\"%s\"\n", index + 1, bActive ? "on" : "off");
|
---|
1217 | else
|
---|
1218 | RTPrintf("Active: %s\n", bActive ? "yes" : "no");
|
---|
1219 |
|
---|
1220 | Bstr bstr;
|
---|
1221 | CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
|
---|
1222 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1223 | RTPrintf("USBFilterName%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1224 | else
|
---|
1225 | RTPrintf("Name: %lS\n", bstr.raw());
|
---|
1226 | CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
|
---|
1227 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1228 | RTPrintf("USBFilterVendorId%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1229 | else
|
---|
1230 | RTPrintf("VendorId: %lS\n", bstr.raw());
|
---|
1231 | CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
|
---|
1232 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1233 | RTPrintf("USBFilterProductId%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1234 | else
|
---|
1235 | RTPrintf("ProductId: %lS\n", bstr.raw());
|
---|
1236 | CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
|
---|
1237 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1238 | RTPrintf("USBFilterRevision%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1239 | else
|
---|
1240 | RTPrintf("Revision: %lS\n", bstr.raw());
|
---|
1241 | CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
|
---|
1242 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1243 | RTPrintf("USBFilterManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1244 | else
|
---|
1245 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1246 | CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
|
---|
1247 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1248 | RTPrintf("USBFilterProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1249 | else
|
---|
1250 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1251 | CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
|
---|
1252 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1253 | RTPrintf("USBFilterRemote%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1254 | else
|
---|
1255 | RTPrintf("Remote: %lS\n", bstr.raw());
|
---|
1256 | CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
|
---|
1257 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1258 | RTPrintf("USBFilterSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1259 | else
|
---|
1260 | RTPrintf("Serial Number: %lS\n", bstr.raw());
|
---|
1261 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1262 | {
|
---|
1263 | ULONG fMaskedIfs;
|
---|
1264 | CHECK_ERROR_RET (DevPtr, COMGETTER (MaskedInterfaces) (&fMaskedIfs), rc);
|
---|
1265 | if (fMaskedIfs)
|
---|
1266 | RTPrintf("Masked Interfaces: 0x%08x\n", fMaskedIfs);
|
---|
1267 | RTPrintf("\n");
|
---|
1268 | }
|
---|
1269 | }
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | if (console)
|
---|
1273 | {
|
---|
1274 | /* scope */
|
---|
1275 | {
|
---|
1276 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1277 | RTPrintf("Available remote USB devices:\n\n");
|
---|
1278 |
|
---|
1279 | SafeIfaceArray <IHostUSBDevice> coll;
|
---|
1280 | CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (ComSafeArrayAsOutParam(coll)), rc);
|
---|
1281 |
|
---|
1282 | if (coll.size() == 0)
|
---|
1283 | {
|
---|
1284 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1285 | RTPrintf("<none>\n\n");
|
---|
1286 | }
|
---|
1287 | else
|
---|
1288 | {
|
---|
1289 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
1290 | {
|
---|
1291 | ComPtr <IHostUSBDevice> dev = coll[index];
|
---|
1292 |
|
---|
1293 | /* Query info. */
|
---|
1294 | Bstr id;
|
---|
1295 | CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
1296 | USHORT usVendorId;
|
---|
1297 | CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
1298 | USHORT usProductId;
|
---|
1299 | CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
1300 | USHORT bcdRevision;
|
---|
1301 | CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
1302 |
|
---|
1303 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1304 | RTPrintf("USBRemoteUUID%zu=\"%S\"\n"
|
---|
1305 | "USBRemoteVendorId%zu=\"%#06x\"\n"
|
---|
1306 | "USBRemoteProductId%zu=\"%#06x\"\n"
|
---|
1307 | "USBRemoteRevision%zu=\"%#04x%02x\"\n",
|
---|
1308 | index + 1, Utf8Str(id).raw(),
|
---|
1309 | index + 1, usVendorId,
|
---|
1310 | index + 1, usProductId,
|
---|
1311 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1312 | else
|
---|
1313 | RTPrintf("UUID: %S\n"
|
---|
1314 | "VendorId: 0x%04x (%04X)\n"
|
---|
1315 | "ProductId: 0x%04x (%04X)\n"
|
---|
1316 | "Revision: %u.%u (%02u%02u)\n",
|
---|
1317 | Utf8Str(id).raw(),
|
---|
1318 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
1319 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
1320 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1321 |
|
---|
1322 | /* optional stuff. */
|
---|
1323 | Bstr bstr;
|
---|
1324 | CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
1325 | if (!bstr.isEmpty())
|
---|
1326 | {
|
---|
1327 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1328 | RTPrintf("USBRemoteManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1329 | else
|
---|
1330 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1331 | }
|
---|
1332 | CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
1333 | if (!bstr.isEmpty())
|
---|
1334 | {
|
---|
1335 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1336 | RTPrintf("USBRemoteProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1337 | else
|
---|
1338 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1339 | }
|
---|
1340 | CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
1341 | if (!bstr.isEmpty())
|
---|
1342 | {
|
---|
1343 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1344 | RTPrintf("USBRemoteSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1345 | else
|
---|
1346 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
1347 | }
|
---|
1348 | CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
1349 | if (!bstr.isEmpty())
|
---|
1350 | {
|
---|
1351 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1352 | RTPrintf("USBRemoteAddress%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1353 | else
|
---|
1354 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1358 | RTPrintf("\n");
|
---|
1359 | }
|
---|
1360 | }
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | /* scope */
|
---|
1364 | {
|
---|
1365 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1366 | RTPrintf ("Currently Attached USB Devices:\n\n");
|
---|
1367 |
|
---|
1368 | SafeIfaceArray <IUSBDevice> coll;
|
---|
1369 | CHECK_ERROR_RET (console, COMGETTER(USBDevices) (ComSafeArrayAsOutParam(coll)), rc);
|
---|
1370 |
|
---|
1371 | if (coll.size() == 0)
|
---|
1372 | {
|
---|
1373 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1374 | RTPrintf("<none>\n\n");
|
---|
1375 | }
|
---|
1376 | else
|
---|
1377 | {
|
---|
1378 | for (size_t index = 0; index < coll.size(); ++index)
|
---|
1379 | {
|
---|
1380 | ComPtr <IUSBDevice> dev = coll[index];
|
---|
1381 |
|
---|
1382 | /* Query info. */
|
---|
1383 | Bstr id;
|
---|
1384 | CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
|
---|
1385 | USHORT usVendorId;
|
---|
1386 | CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
|
---|
1387 | USHORT usProductId;
|
---|
1388 | CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
|
---|
1389 | USHORT bcdRevision;
|
---|
1390 | CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
|
---|
1391 |
|
---|
1392 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1393 | RTPrintf("USBAttachedUUID%zu=\"%S\"\n"
|
---|
1394 | "USBAttachedVendorId%zu=\"%#06x\"\n"
|
---|
1395 | "USBAttachedProductId%zu=\"%#06x\"\n"
|
---|
1396 | "USBAttachedRevision%zu=\"%#04x%02x\"\n",
|
---|
1397 | index + 1, Utf8Str(id).raw(),
|
---|
1398 | index + 1, usVendorId,
|
---|
1399 | index + 1, usProductId,
|
---|
1400 | index + 1, bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1401 | else
|
---|
1402 | RTPrintf("UUID: %S\n"
|
---|
1403 | "VendorId: 0x%04x (%04X)\n"
|
---|
1404 | "ProductId: 0x%04x (%04X)\n"
|
---|
1405 | "Revision: %u.%u (%02u%02u)\n",
|
---|
1406 | Utf8Str(id).raw(),
|
---|
1407 | usVendorId, usVendorId, usProductId, usProductId,
|
---|
1408 | bcdRevision >> 8, bcdRevision & 0xff,
|
---|
1409 | bcdRevision >> 8, bcdRevision & 0xff);
|
---|
1410 |
|
---|
1411 | /* optional stuff. */
|
---|
1412 | Bstr bstr;
|
---|
1413 | CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
|
---|
1414 | if (!bstr.isEmpty())
|
---|
1415 | {
|
---|
1416 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1417 | RTPrintf("USBAttachedManufacturer%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1418 | else
|
---|
1419 | RTPrintf("Manufacturer: %lS\n", bstr.raw());
|
---|
1420 | }
|
---|
1421 | CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
|
---|
1422 | if (!bstr.isEmpty())
|
---|
1423 | {
|
---|
1424 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1425 | RTPrintf("USBAttachedProduct%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1426 | else
|
---|
1427 | RTPrintf("Product: %lS\n", bstr.raw());
|
---|
1428 | }
|
---|
1429 | CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
|
---|
1430 | if (!bstr.isEmpty())
|
---|
1431 | {
|
---|
1432 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1433 | RTPrintf("USBAttachedSerialNumber%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1434 | else
|
---|
1435 | RTPrintf("SerialNumber: %lS\n", bstr.raw());
|
---|
1436 | }
|
---|
1437 | CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
|
---|
1438 | if (!bstr.isEmpty())
|
---|
1439 | {
|
---|
1440 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1441 | RTPrintf("USBAttachedAddress%zu=\"%lS\"\n", index + 1, bstr.raw());
|
---|
1442 | else
|
---|
1443 | RTPrintf("Address: %lS\n", bstr.raw());
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1447 | RTPrintf("\n");
|
---|
1448 | }
|
---|
1449 | }
|
---|
1450 | }
|
---|
1451 | }
|
---|
1452 | } /* USB */
|
---|
1453 |
|
---|
1454 | /*
|
---|
1455 | * Shared folders
|
---|
1456 | */
|
---|
1457 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1458 | RTPrintf("Shared folders: ");
|
---|
1459 | uint32_t numSharedFolders = 0;
|
---|
1460 | #if 0 // not yet implemented
|
---|
1461 | /* globally shared folders first */
|
---|
1462 | {
|
---|
1463 | SafeIfaceArray <ISharedFolder> sfColl;
|
---|
1464 | CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
|
---|
1465 | for (size_t i = 0; i < sfColl.size(); ++i)
|
---|
1466 | {
|
---|
1467 | ComPtr<ISharedFolder> sf = sfColl[i];
|
---|
1468 | Bstr name, hostPath;
|
---|
1469 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1470 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1471 | RTPrintf("Name: '%lS', Host path: '%lS' (global mapping)\n", name.raw(), hostPath.raw());
|
---|
1472 | ++numSharedFolders;
|
---|
1473 | }
|
---|
1474 | }
|
---|
1475 | #endif
|
---|
1476 | /* now VM mappings */
|
---|
1477 | {
|
---|
1478 | com::SafeIfaceArray <ISharedFolder> folders;
|
---|
1479 |
|
---|
1480 | CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
|
---|
1481 |
|
---|
1482 | for (size_t i = 0; i < folders.size(); ++i)
|
---|
1483 | {
|
---|
1484 | ComPtr <ISharedFolder> sf = folders[i];
|
---|
1485 |
|
---|
1486 | Bstr name, hostPath;
|
---|
1487 | BOOL writable;
|
---|
1488 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1489 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1490 | sf->COMGETTER(Writable)(&writable);
|
---|
1491 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1492 | RTPrintf("\n\n");
|
---|
1493 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1494 | {
|
---|
1495 | RTPrintf("SharedFolderNameMachineMapping%zu=\"%lS\"\n", i + 1,
|
---|
1496 | name.raw());
|
---|
1497 | RTPrintf("SharedFolderPathMachineMapping%zu=\"%lS\"\n", i + 1,
|
---|
1498 | hostPath.raw());
|
---|
1499 | }
|
---|
1500 | else
|
---|
1501 | RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping), %s\n",
|
---|
1502 | name.raw(), hostPath.raw(), writable ? "writable" : "readonly");
|
---|
1503 | ++numSharedFolders;
|
---|
1504 | }
|
---|
1505 | }
|
---|
1506 | /* transient mappings */
|
---|
1507 | if (console)
|
---|
1508 | {
|
---|
1509 | com::SafeIfaceArray <ISharedFolder> folders;
|
---|
1510 |
|
---|
1511 | CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc);
|
---|
1512 |
|
---|
1513 | for (size_t i = 0; i < folders.size(); ++i)
|
---|
1514 | {
|
---|
1515 | ComPtr <ISharedFolder> sf = folders[i];
|
---|
1516 |
|
---|
1517 | Bstr name, hostPath;
|
---|
1518 | sf->COMGETTER(Name)(name.asOutParam());
|
---|
1519 | sf->COMGETTER(HostPath)(hostPath.asOutParam());
|
---|
1520 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1521 | RTPrintf("\n\n");
|
---|
1522 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1523 | {
|
---|
1524 | RTPrintf("SharedFolderNameTransientMapping%zu=\"%lS\"\n", i + 1,
|
---|
1525 | name.raw());
|
---|
1526 | RTPrintf("SharedFolderPathTransientMapping%zu=\"%lS\"\n", i + 1,
|
---|
1527 | hostPath.raw());
|
---|
1528 | }
|
---|
1529 | else
|
---|
1530 | RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
|
---|
1531 | ++numSharedFolders;
|
---|
1532 | }
|
---|
1533 | }
|
---|
1534 | if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
|
---|
1535 | RTPrintf("<none>\n");
|
---|
1536 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1537 | RTPrintf("\n");
|
---|
1538 |
|
---|
1539 | if (console)
|
---|
1540 | {
|
---|
1541 | /*
|
---|
1542 | * Live VRDP info.
|
---|
1543 | */
|
---|
1544 | ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
|
---|
1545 | CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
|
---|
1546 | BOOL Active;
|
---|
1547 | ULONG NumberOfClients;
|
---|
1548 | LONG64 BeginTime;
|
---|
1549 | LONG64 EndTime;
|
---|
1550 | ULONG64 BytesSent;
|
---|
1551 | ULONG64 BytesSentTotal;
|
---|
1552 | ULONG64 BytesReceived;
|
---|
1553 | ULONG64 BytesReceivedTotal;
|
---|
1554 | Bstr User;
|
---|
1555 | Bstr Domain;
|
---|
1556 | Bstr ClientName;
|
---|
1557 | Bstr ClientIP;
|
---|
1558 | ULONG ClientVersion;
|
---|
1559 | ULONG EncryptionStyle;
|
---|
1560 |
|
---|
1561 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Active) (&Active), rc);
|
---|
1562 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(NumberOfClients) (&NumberOfClients), rc);
|
---|
1563 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BeginTime) (&BeginTime), rc);
|
---|
1564 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EndTime) (&EndTime), rc);
|
---|
1565 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSent) (&BytesSent), rc);
|
---|
1566 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSentTotal) (&BytesSentTotal), rc);
|
---|
1567 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceived) (&BytesReceived), rc);
|
---|
1568 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceivedTotal) (&BytesReceivedTotal), rc);
|
---|
1569 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(User) (User.asOutParam ()), rc);
|
---|
1570 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Domain) (Domain.asOutParam ()), rc);
|
---|
1571 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientName) (ClientName.asOutParam ()), rc);
|
---|
1572 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientIP) (ClientIP.asOutParam ()), rc);
|
---|
1573 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientVersion) (&ClientVersion), rc);
|
---|
1574 | CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EncryptionStyle) (&EncryptionStyle), rc);
|
---|
1575 |
|
---|
1576 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1577 | RTPrintf("VRDPActiveConnection=\"%s\"\n", Active ? "on": "off");
|
---|
1578 | else
|
---|
1579 | RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");
|
---|
1580 |
|
---|
1581 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1582 | RTPrintf("VRDPClients=%d\n", NumberOfClients);
|
---|
1583 | else
|
---|
1584 | RTPrintf("Clients so far: %d\n", NumberOfClients);
|
---|
1585 |
|
---|
1586 | if (NumberOfClients > 0)
|
---|
1587 | {
|
---|
1588 | char timestr[128];
|
---|
1589 |
|
---|
1590 | if (Active)
|
---|
1591 | {
|
---|
1592 | makeTimeStr (timestr, sizeof (timestr), BeginTime);
|
---|
1593 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1594 | RTPrintf("VRDPStartTime=\"%s\"\n", timestr);
|
---|
1595 | else
|
---|
1596 | RTPrintf("Start time: %s\n", timestr);
|
---|
1597 | }
|
---|
1598 | else
|
---|
1599 | {
|
---|
1600 | makeTimeStr (timestr, sizeof (timestr), BeginTime);
|
---|
1601 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1602 | RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);
|
---|
1603 | else
|
---|
1604 | RTPrintf("Last started: %s\n", timestr);
|
---|
1605 | makeTimeStr (timestr, sizeof (timestr), EndTime);
|
---|
1606 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1607 | RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);
|
---|
1608 | else
|
---|
1609 | RTPrintf("Last ended: %s\n", timestr);
|
---|
1610 | }
|
---|
1611 |
|
---|
1612 | uint64_t ThroughputSend = 0;
|
---|
1613 | uint64_t ThroughputReceive = 0;
|
---|
1614 | if (EndTime != BeginTime)
|
---|
1615 | {
|
---|
1616 | ThroughputSend = (BytesSent * 1000) / (EndTime - BeginTime);
|
---|
1617 | ThroughputReceive = (BytesReceived * 1000) / (EndTime - BeginTime);
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1621 | {
|
---|
1622 | RTPrintf("VRDPBytesSent=%llu\n", BytesSent);
|
---|
1623 | RTPrintf("VRDPThroughputSend=%llu\n", ThroughputSend);
|
---|
1624 | RTPrintf("VRDPBytesSentTotal=%llu\n", BytesSentTotal);
|
---|
1625 |
|
---|
1626 | RTPrintf("VRDPBytesReceived=%llu\n", BytesReceived);
|
---|
1627 | RTPrintf("VRDPThroughputReceive=%llu\n", ThroughputReceive);
|
---|
1628 | RTPrintf("VRDPBytesReceivedTotal=%llu\n", BytesReceivedTotal);
|
---|
1629 | }
|
---|
1630 | else
|
---|
1631 | {
|
---|
1632 | RTPrintf("Sent: %llu Bytes\n", BytesSent);
|
---|
1633 | RTPrintf("Average speed: %llu B/s\n", ThroughputSend);
|
---|
1634 | RTPrintf("Sent total: %llu Bytes\n", BytesSentTotal);
|
---|
1635 |
|
---|
1636 | RTPrintf("Received: %llu Bytes\n", BytesReceived);
|
---|
1637 | RTPrintf("Speed: %llu B/s\n", ThroughputReceive);
|
---|
1638 | RTPrintf("Received total: %llu Bytes\n", BytesReceivedTotal);
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | if (Active)
|
---|
1642 | {
|
---|
1643 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1644 | {
|
---|
1645 | RTPrintf("VRDPUserName=\"%lS\"\n", User.raw());
|
---|
1646 | RTPrintf("VRDPDomain=\"%lS\"\n", Domain.raw());
|
---|
1647 | RTPrintf("VRDPClientName=\"%lS\"\n", ClientName.raw());
|
---|
1648 | RTPrintf("VRDPClientIP=\"%lS\"\n", ClientIP.raw());
|
---|
1649 | RTPrintf("VRDPClientVersion=%d\n", ClientVersion);
|
---|
1650 | RTPrintf("VRDPEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
1651 | }
|
---|
1652 | else
|
---|
1653 | {
|
---|
1654 | RTPrintf("User name: %lS\n", User.raw());
|
---|
1655 | RTPrintf("Domain: %lS\n", Domain.raw());
|
---|
1656 | RTPrintf("Client name: %lS\n", ClientName.raw());
|
---|
1657 | RTPrintf("Client IP: %lS\n", ClientIP.raw());
|
---|
1658 | RTPrintf("Client version: %d\n", ClientVersion);
|
---|
1659 | RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
|
---|
1660 | }
|
---|
1661 | }
|
---|
1662 | }
|
---|
1663 |
|
---|
1664 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1665 | RTPrintf("\n");
|
---|
1666 | }
|
---|
1667 |
|
---|
1668 | if ( details == VMINFO_STANDARD
|
---|
1669 | || details == VMINFO_FULL
|
---|
1670 | || details == VMINFO_MACHINEREADABLE)
|
---|
1671 | {
|
---|
1672 | Bstr description;
|
---|
1673 | machine->COMGETTER(Description)(description.asOutParam());
|
---|
1674 | if (!description.isEmpty())
|
---|
1675 | {
|
---|
1676 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1677 | RTPrintf("description=\"%lS\"\n", description.raw());
|
---|
1678 | else
|
---|
1679 | RTPrintf("Description:\n%lS\n", description.raw());
|
---|
1680 | }
|
---|
1681 | }
|
---|
1682 |
|
---|
1683 | ULONG guestVal;
|
---|
1684 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1685 | RTPrintf("Guest:\n\n");
|
---|
1686 |
|
---|
1687 | #ifdef VBOX_WITH_MEM_BALLOONING
|
---|
1688 | rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
|
---|
1689 | if (SUCCEEDED(rc))
|
---|
1690 | {
|
---|
1691 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1692 | RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
|
---|
1693 | else
|
---|
1694 | RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
|
---|
1695 | }
|
---|
1696 | #endif
|
---|
1697 | rc = machine->COMGETTER(StatisticsUpdateInterval)(&guestVal);
|
---|
1698 | if (SUCCEEDED(rc))
|
---|
1699 | {
|
---|
1700 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1701 | RTPrintf("GuestStatisticsUpdateInterval=%d\n", guestVal);
|
---|
1702 | else
|
---|
1703 | {
|
---|
1704 | if (guestVal == 0)
|
---|
1705 | RTPrintf("Statistics update: disabled\n");
|
---|
1706 | else
|
---|
1707 | RTPrintf("Statistics update interval: %d seconds\n", guestVal);
|
---|
1708 | }
|
---|
1709 | }
|
---|
1710 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1711 | RTPrintf("\n");
|
---|
1712 |
|
---|
1713 | if ( console
|
---|
1714 | && ( details == VMINFO_STATISTICS
|
---|
1715 | || details == VMINFO_FULL
|
---|
1716 | || details == VMINFO_MACHINEREADABLE))
|
---|
1717 | {
|
---|
1718 | ComPtr <IGuest> guest;
|
---|
1719 |
|
---|
1720 | rc = console->COMGETTER(Guest)(guest.asOutParam());
|
---|
1721 | if (SUCCEEDED(rc))
|
---|
1722 | {
|
---|
1723 | ULONG statVal;
|
---|
1724 |
|
---|
1725 | rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &statVal);
|
---|
1726 | if (SUCCEEDED(rc))
|
---|
1727 | {
|
---|
1728 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1729 | RTPrintf("StatGuestSample=%d\n", statVal);
|
---|
1730 | else
|
---|
1731 | RTPrintf("Guest statistics for sample %d:\n\n", statVal);
|
---|
1732 | }
|
---|
1733 |
|
---|
1734 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Idle, &statVal);
|
---|
1735 | if (SUCCEEDED(rc))
|
---|
1736 | {
|
---|
1737 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1738 | RTPrintf("StatGuestLoadIdleCPU%d=%d\n", 0, statVal);
|
---|
1739 | else
|
---|
1740 | RTPrintf("CPU%d: CPU Load Idle %-3d%%\n", 0, statVal);
|
---|
1741 | }
|
---|
1742 |
|
---|
1743 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Kernel, &statVal);
|
---|
1744 | if (SUCCEEDED(rc))
|
---|
1745 | {
|
---|
1746 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1747 | RTPrintf("StatGuestLoadKernelCPU%d=%d\n", 0, statVal);
|
---|
1748 | else
|
---|
1749 | RTPrintf("CPU%d: CPU Load Kernel %-3d%%\n", 0, statVal);
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 | rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_User, &statVal);
|
---|
1753 | if (SUCCEEDED(rc))
|
---|
1754 | {
|
---|
1755 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1756 | RTPrintf("StatGuestLoadUserCPU%d=%d\n", 0, statVal);
|
---|
1757 | else
|
---|
1758 | RTPrintf("CPU%d: CPU Load User %-3d%%\n", 0, statVal);
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | rc = guest->GetStatistic(0, GuestStatisticType_Threads, &statVal);
|
---|
1762 | if (SUCCEEDED(rc))
|
---|
1763 | {
|
---|
1764 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1765 | RTPrintf("StatGuestThreadsCPU%d=%d\n", 0, statVal);
|
---|
1766 | else
|
---|
1767 | RTPrintf("CPU%d: Threads %d\n", 0, statVal);
|
---|
1768 | }
|
---|
1769 |
|
---|
1770 | rc = guest->GetStatistic(0, GuestStatisticType_Processes, &statVal);
|
---|
1771 | if (SUCCEEDED(rc))
|
---|
1772 | {
|
---|
1773 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1774 | RTPrintf("StatGuestProcessesCPU%d=%d\n", 0, statVal);
|
---|
1775 | else
|
---|
1776 | RTPrintf("CPU%d: Processes %d\n", 0, statVal);
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | rc = guest->GetStatistic(0, GuestStatisticType_Handles, &statVal);
|
---|
1780 | if (SUCCEEDED(rc))
|
---|
1781 | {
|
---|
1782 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1783 | RTPrintf("StatGuestHandlesCPU%d=%d\n", 0, statVal);
|
---|
1784 | else
|
---|
1785 | RTPrintf("CPU%d: Handles %d\n", 0, statVal);
|
---|
1786 | }
|
---|
1787 |
|
---|
1788 | rc = guest->GetStatistic(0, GuestStatisticType_MemoryLoad, &statVal);
|
---|
1789 | if (SUCCEEDED(rc))
|
---|
1790 | {
|
---|
1791 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1792 | RTPrintf("StatGuestMemoryLoadCPU%d=%d\n", 0, statVal);
|
---|
1793 | else
|
---|
1794 | RTPrintf("CPU%d: Memory Load %d%%\n", 0, statVal);
|
---|
1795 | }
|
---|
1796 |
|
---|
1797 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemTotal, &statVal);
|
---|
1798 | if (SUCCEEDED(rc))
|
---|
1799 | {
|
---|
1800 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1801 | RTPrintf("StatGuestMemoryTotalPhysCPU%d=%d\n", 0, statVal);
|
---|
1802 | else
|
---|
1803 | RTPrintf("CPU%d: Total physical memory %-4d MB\n", 0, statVal);
|
---|
1804 | }
|
---|
1805 |
|
---|
1806 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemAvailable, &statVal);
|
---|
1807 | if (SUCCEEDED(rc))
|
---|
1808 | {
|
---|
1809 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1810 | RTPrintf("StatGuestMemoryFreePhysCPU%d=%d\n", 0, statVal);
|
---|
1811 | else
|
---|
1812 | RTPrintf("CPU%d: Free physical memory %-4d MB\n", 0, statVal);
|
---|
1813 | }
|
---|
1814 |
|
---|
1815 | #ifdef VBOX_WITH_MEM_BALLOONING
|
---|
1816 | rc = guest->GetStatistic(0, GuestStatisticType_PhysMemBalloon, &statVal);
|
---|
1817 | if (SUCCEEDED(rc))
|
---|
1818 | {
|
---|
1819 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1820 | RTPrintf("StatGuestMemoryBalloonCPU%d=%d\n", 0, statVal);
|
---|
1821 | else
|
---|
1822 | RTPrintf("CPU%d: Memory balloon size %-4d MB\n", 0, statVal);
|
---|
1823 | }
|
---|
1824 | #endif
|
---|
1825 | rc = guest->GetStatistic(0, GuestStatisticType_MemCommitTotal, &statVal);
|
---|
1826 | if (SUCCEEDED(rc))
|
---|
1827 | {
|
---|
1828 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1829 | RTPrintf("StatGuestMemoryCommittedCPU%d=%d\n", 0, statVal);
|
---|
1830 | else
|
---|
1831 | RTPrintf("CPU%d: Committed memory %-4d MB\n", 0, statVal);
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelTotal, &statVal);
|
---|
1835 | if (SUCCEEDED(rc))
|
---|
1836 | {
|
---|
1837 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1838 | RTPrintf("StatGuestMemoryTotalKernelCPU%d=%d\n", 0, statVal);
|
---|
1839 | else
|
---|
1840 | RTPrintf("CPU%d: Total kernel memory %-4d MB\n", 0, statVal);
|
---|
1841 | }
|
---|
1842 |
|
---|
1843 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelPaged, &statVal);
|
---|
1844 | if (SUCCEEDED(rc))
|
---|
1845 | {
|
---|
1846 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1847 | RTPrintf("StatGuestMemoryPagedKernelCPU%d=%d\n", 0, statVal);
|
---|
1848 | else
|
---|
1849 | RTPrintf("CPU%d: Paged kernel memory %-4d MB\n", 0, statVal);
|
---|
1850 | }
|
---|
1851 |
|
---|
1852 | rc = guest->GetStatistic(0, GuestStatisticType_MemKernelNonpaged, &statVal);
|
---|
1853 | if (SUCCEEDED(rc))
|
---|
1854 | {
|
---|
1855 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1856 | RTPrintf("StatGuestMemoryNonpagedKernelCPU%d=%d\n", 0, statVal);
|
---|
1857 | else
|
---|
1858 | RTPrintf("CPU%d: Nonpaged kernel memory %-4d MB\n", 0, statVal);
|
---|
1859 | }
|
---|
1860 |
|
---|
1861 | rc = guest->GetStatistic(0, GuestStatisticType_MemSystemCache, &statVal);
|
---|
1862 | if (SUCCEEDED(rc))
|
---|
1863 | {
|
---|
1864 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1865 | RTPrintf("StatGuestSystemCacheSizeCPU%d=%d\n", 0, statVal);
|
---|
1866 | else
|
---|
1867 | RTPrintf("CPU%d: System cache size %-4d MB\n", 0, statVal);
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 | rc = guest->GetStatistic(0, GuestStatisticType_PageFileSize, &statVal);
|
---|
1871 | if (SUCCEEDED(rc))
|
---|
1872 | {
|
---|
1873 | if (details == VMINFO_MACHINEREADABLE)
|
---|
1874 | RTPrintf("StatGuestPageFileSizeCPU%d=%d\n", 0, statVal);
|
---|
1875 | else
|
---|
1876 | RTPrintf("CPU%d: Page file size %-4d MB\n", 0, statVal);
|
---|
1877 | }
|
---|
1878 |
|
---|
1879 | RTPrintf("\n");
|
---|
1880 | }
|
---|
1881 | else
|
---|
1882 | {
|
---|
1883 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1884 | {
|
---|
1885 | RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__);
|
---|
1886 | GluePrintRCMessage(rc);
|
---|
1887 | }
|
---|
1888 | }
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | /*
|
---|
1892 | * snapshots
|
---|
1893 | */
|
---|
1894 | ComPtr<ISnapshot> snapshot;
|
---|
1895 | rc = machine->GetSnapshot(Bstr(), snapshot.asOutParam());
|
---|
1896 | if (SUCCEEDED(rc) && snapshot)
|
---|
1897 | {
|
---|
1898 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1899 | RTPrintf("Snapshots:\n\n");
|
---|
1900 | showSnapshots(snapshot, details);
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | if (details != VMINFO_MACHINEREADABLE)
|
---|
1904 | RTPrintf("\n");
|
---|
1905 | return S_OK;
|
---|
1906 | }
|
---|
1907 |
|
---|
1908 | #if defined(_MSC_VER)
|
---|
1909 | # pragma optimize("", on)
|
---|
1910 | #endif
|
---|
1911 |
|
---|
1912 | static const RTGETOPTDEF g_aShowVMInfoOptions[] =
|
---|
1913 | {
|
---|
1914 | { "--details", 'D', RTGETOPT_REQ_NOTHING },
|
---|
1915 | { "-details", 'D', RTGETOPT_REQ_NOTHING }, // deprecated
|
---|
1916 | { "--statistics", 'S', RTGETOPT_REQ_NOTHING },
|
---|
1917 | { "-statistics", 'S', RTGETOPT_REQ_NOTHING }, // deprecated
|
---|
1918 | { "--machinereadable", 'M', RTGETOPT_REQ_NOTHING },
|
---|
1919 | { "-machinereadable", 'M', RTGETOPT_REQ_NOTHING }, // deprecated
|
---|
1920 | };
|
---|
1921 |
|
---|
1922 | int handleShowVMInfo(HandlerArg *a)
|
---|
1923 | {
|
---|
1924 | HRESULT rc;
|
---|
1925 | const char *VMNameOrUuid = NULL;
|
---|
1926 | bool fDetails = false;
|
---|
1927 | bool fStatistics = false;
|
---|
1928 | bool fMachinereadable = false;
|
---|
1929 |
|
---|
1930 | int c;
|
---|
1931 | RTGETOPTUNION ValueUnion;
|
---|
1932 | RTGETOPTSTATE GetState;
|
---|
1933 | // start at 0 because main() has hacked both the argc and argv given to us
|
---|
1934 | RTGetOptInit(&GetState, a->argc, a->argv, g_aShowVMInfoOptions, RT_ELEMENTS(g_aShowVMInfoOptions), 0, 0 /* fFlags */);
|
---|
1935 | while ((c = RTGetOpt(&GetState, &ValueUnion)))
|
---|
1936 | {
|
---|
1937 | switch (c)
|
---|
1938 | {
|
---|
1939 | case 'D': // --details
|
---|
1940 | fDetails = true;
|
---|
1941 | break;
|
---|
1942 |
|
---|
1943 | case 'S': // --statistics
|
---|
1944 | fStatistics = true;
|
---|
1945 | break;
|
---|
1946 |
|
---|
1947 | case 'M': // --machinereadable
|
---|
1948 | fMachinereadable = true;
|
---|
1949 | break;
|
---|
1950 |
|
---|
1951 | case VINF_GETOPT_NOT_OPTION:
|
---|
1952 | if (!VMNameOrUuid)
|
---|
1953 | VMNameOrUuid = ValueUnion.psz;
|
---|
1954 | else
|
---|
1955 | return errorSyntax(USAGE_SHOWVMINFO, "Invalid parameter '%s'", ValueUnion.psz);
|
---|
1956 | break;
|
---|
1957 |
|
---|
1958 | default:
|
---|
1959 | if (c > 0)
|
---|
1960 | {
|
---|
1961 | if (RT_C_IS_PRINT(c))
|
---|
1962 | return errorSyntax(USAGE_SHOWVMINFO, "Invalid option -%c", c);
|
---|
1963 | else
|
---|
1964 | return errorSyntax(USAGE_SHOWVMINFO, "Invalid option case %i", c);
|
---|
1965 | }
|
---|
1966 | else if (c == VERR_GETOPT_UNKNOWN_OPTION)
|
---|
1967 | return errorSyntax(USAGE_SHOWVMINFO, "unknown option: %s\n", ValueUnion.psz);
|
---|
1968 | else if (ValueUnion.pDef)
|
---|
1969 | return errorSyntax(USAGE_SHOWVMINFO, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
|
---|
1970 | else
|
---|
1971 | return errorSyntax(USAGE_SHOWVMINFO, "error: %Rrs", c);
|
---|
1972 | }
|
---|
1973 | }
|
---|
1974 |
|
---|
1975 | /* check for required options */
|
---|
1976 | if (!VMNameOrUuid)
|
---|
1977 | return errorSyntax(USAGE_SHOWVMINFO, "VM name or UUID required");
|
---|
1978 |
|
---|
1979 | /* try to find the given machine */
|
---|
1980 | ComPtr <IMachine> machine;
|
---|
1981 | Bstr uuid (VMNameOrUuid);
|
---|
1982 | if (!Guid (VMNameOrUuid).isEmpty())
|
---|
1983 | {
|
---|
1984 | CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));
|
---|
1985 | }
|
---|
1986 | else
|
---|
1987 | {
|
---|
1988 | CHECK_ERROR (a->virtualBox, FindMachine (Bstr(VMNameOrUuid), machine.asOutParam()));
|
---|
1989 | if (SUCCEEDED (rc))
|
---|
1990 | machine->COMGETTER(Id) (uuid.asOutParam());
|
---|
1991 | }
|
---|
1992 | if (FAILED (rc))
|
---|
1993 | return 1;
|
---|
1994 |
|
---|
1995 | /* 2nd option can be -details, -statistics or -argdump */
|
---|
1996 | VMINFO_DETAILS details = VMINFO_NONE;
|
---|
1997 | if (fMachinereadable)
|
---|
1998 | details = VMINFO_MACHINEREADABLE;
|
---|
1999 | else
|
---|
2000 | if (fDetails && fStatistics)
|
---|
2001 | details = VMINFO_FULL;
|
---|
2002 | else
|
---|
2003 | if (fDetails)
|
---|
2004 | details = VMINFO_STANDARD;
|
---|
2005 | else
|
---|
2006 | if (fStatistics)
|
---|
2007 | details = VMINFO_STATISTICS;
|
---|
2008 |
|
---|
2009 | ComPtr <IConsole> console;
|
---|
2010 |
|
---|
2011 | /* open an existing session for the VM */
|
---|
2012 | rc = a->virtualBox->OpenExistingSession (a->session, uuid);
|
---|
2013 | if (SUCCEEDED(rc))
|
---|
2014 | /* get the session machine */
|
---|
2015 | rc = a->session->COMGETTER(Machine)(machine.asOutParam());
|
---|
2016 | if (SUCCEEDED(rc))
|
---|
2017 | /* get the session console */
|
---|
2018 | rc = a->session->COMGETTER(Console)(console.asOutParam());
|
---|
2019 |
|
---|
2020 | rc = showVMInfo(a->virtualBox, machine, details, console);
|
---|
2021 |
|
---|
2022 | if (console)
|
---|
2023 | a->session->Close();
|
---|
2024 |
|
---|
2025 | return SUCCEEDED (rc) ? 0 : 1;
|
---|
2026 | }
|
---|
2027 |
|
---|
2028 | #endif /* !VBOX_ONLY_DOCS */
|
---|
2029 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|