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