- Timestamp:
- Oct 26, 2011 1:07:47 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r37525 r39119 189 189 190 190 /* VBoxManageVMInfo.cpp */ 191 voidshowSnapshots(ComPtr<ISnapshot> &rootSnapshot,192 ComPtr<ISnapshot> ¤tSnapshot,193 VMINFO_DETAILS details,194 const com::Bstr &prefix = "",195 int level = 0);191 HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot, 192 ComPtr<ISnapshot> ¤tSnapshot, 193 VMINFO_DETAILS details, 194 const com::Bstr &prefix = "", 195 int level = 0); 196 196 int handleShowVMInfo(HandlerArg *a); 197 197 HRESULT showVMInfo(ComPtr<IVirtualBox> virtualBox, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r38874 r39119 446 446 " [--name <name>]\n" 447 447 " [--description <desc>] |\n" 448 " list [--details|--machinereadable]\n" 448 449 " showvminfo <uuid>|<name>\n" 449 450 "\n"); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r38735 r39119 48 48 /////////////////////////////////////////////////////////////////////////////// 49 49 50 voidshowSnapshots(ComPtr<ISnapshot> &rootSnapshot,51 ComPtr<ISnapshot> ¤tSnapshot,52 VMINFO_DETAILS details,53 const Bstr &prefix /* = ""*/,54 int level /*= 0*/)50 HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot, 51 ComPtr<ISnapshot> ¤tSnapshot, 52 VMINFO_DETAILS details, 53 const Bstr &prefix /* = ""*/, 54 int level /*= 0*/) 55 55 { 56 56 /* start with the root */ 57 57 Bstr name; 58 58 Bstr uuid; 59 rootSnapshot->COMGETTER(Name)(name.asOutParam());60 rootSnapshot->COMGETTER(Id)(uuid.asOutParam());59 CHECK_ERROR2_RET(rootSnapshot,COMGETTER(Name)(name.asOutParam()), hrcCheck); 60 CHECK_ERROR2_RET(rootSnapshot,COMGETTER(Id)(uuid.asOutParam()), hrcCheck); 61 61 if (details == VMINFO_MACHINEREADABLE) 62 62 { … … 77 77 78 78 /* get the children */ 79 HRESULT hrc = S_OK; 79 80 SafeIfaceArray <ISnapshot> coll; 80 rootSnapshot->COMGETTER(Children)(ComSafeArrayAsOutParam(coll));81 CHECK_ERROR2_RET(rootSnapshot,COMGETTER(Children)(ComSafeArrayAsOutParam(coll)), hrcCheck); 81 82 if (!coll.isNull()) 82 83 { … … 95 96 96 97 /* recursive call */ 97 showSnapshots(snapshot, currentSnapshot, details, newPrefix, level + 1); 98 } 99 } 100 } 98 HRESULT hrc2 = showSnapshots(snapshot, currentSnapshot, details, newPrefix, level + 1); 99 if (FAILED(hrc2)) 100 hrc = hrc2; 101 } 102 } 103 } 104 return hrc; 101 105 } 102 106 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r38525 r39119 157 157 } 158 158 159 160 /** 161 * Handles the 'snapshot myvm list' sub-command. 162 * @returns Exit code. 163 * @param pArgs The handler argument package. 164 * @param rptrMachine Reference to the VM (locked) we're operating on. 165 */ 166 static RTEXITCODE handleSnapshotList(HandlerArg *pArgs, ComPtr<IMachine> &rptrMachine) 167 { 168 static const RTGETOPTDEF g_aOptions[] = 169 { 170 { "--details", 'D', RTGETOPT_REQ_NOTHING }, 171 { "--machinereadable", 'M', RTGETOPT_REQ_NOTHING }, 172 }; 173 174 VMINFO_DETAILS enmDetails = VMINFO_STANDARD; 175 176 int c; 177 RTGETOPTUNION ValueUnion; 178 RTGETOPTSTATE GetState; 179 // start at 0 because main() has hacked both the argc and argv given to us 180 RTGetOptInit(&GetState, pArgs->argc, pArgs->argv, g_aOptions, RT_ELEMENTS(g_aOptions), 2 /*iArg*/, 0 /*fFlags*/); 181 while ((c = RTGetOpt(&GetState, &ValueUnion))) 182 { 183 switch (c) 184 { 185 case 'D': enmDetails = VMINFO_FULL; break; 186 case 'M': enmDetails = VMINFO_MACHINEREADABLE; break; 187 default: return errorGetOpt(USAGE_SNAPSHOT, c, &ValueUnion); 188 } 189 } 190 191 /* See showVMInfo. */ 192 ComPtr<ISnapshot> ptrSnapshot; 193 CHECK_ERROR2_RET(rptrMachine, FindSnapshot(Bstr().raw(), ptrSnapshot.asOutParam()), RTEXITCODE_FAILURE); 194 if (ptrSnapshot) 195 { 196 ComPtr<ISnapshot> ptrCurrentSnapshot; 197 CHECK_ERROR2_RET(rptrMachine,COMGETTER(CurrentSnapshot)(ptrCurrentSnapshot.asOutParam()), RTEXITCODE_FAILURE); 198 HRESULT hrc = showSnapshots(ptrSnapshot, ptrCurrentSnapshot, enmDetails); 199 if (FAILED(hrc)) 200 return RTEXITCODE_FAILURE; 201 } 202 return RTEXITCODE_SUCCESS; 203 } 204 159 205 /** 160 206 * Implementation for "VBoxManage snapshot ... dump". This goes thru the machine's … … 226 272 /* the first argument must be the VM */ 227 273 Bstr bstrMachine(a->argv[0]); 228 ComPtr<IMachine> p Machine;274 ComPtr<IMachine> ptrMachine; 229 275 CHECK_ERROR(a->virtualBox, FindMachine(bstrMachine.raw(), 230 p Machine.asOutParam()));231 if (!p Machine)276 ptrMachine.asOutParam())); 277 if (!ptrMachine) 232 278 return 1; 233 279 … … 235 281 { 236 282 /* we have to open a session for this task (new or shared) */ 237 rc = p Machine->LockMachine(a->session, LockType_Shared);283 rc = ptrMachine->LockMachine(a->session, LockType_Shared); 238 284 ComPtr<IConsole> console; 239 285 CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam())); … … 350 396 if (fRestoreCurrent) 351 397 { 352 CHECK_ERROR_BREAK(p Machine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));398 CHECK_ERROR_BREAK(ptrMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam())); 353 399 } 354 400 else 355 401 { 356 402 // restore or delete snapshot: then resolve cmd line argument to snapshot instance 357 CHECK_ERROR_BREAK(p Machine, FindSnapshot(Bstr(a->argv[2]).raw(),403 CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 358 404 pSnapshot.asOutParam())); 359 405 } … … 390 436 || !strcmp(a->argv[2], "-current")) 391 437 { 392 CHECK_ERROR_BREAK(p Machine, COMGETTER(CurrentSnapshot)(snapshot.asOutParam()));438 CHECK_ERROR_BREAK(ptrMachine, COMGETTER(CurrentSnapshot)(snapshot.asOutParam())); 393 439 } 394 440 else 395 441 { 396 CHECK_ERROR_BREAK(p Machine, FindSnapshot(Bstr(a->argv[2]).raw(),397 snapshot.asOutParam()));442 CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 443 snapshot.asOutParam())); 398 444 } 399 445 … … 448 494 ComPtr<ISnapshot> snapshot; 449 495 450 CHECK_ERROR_BREAK(p Machine, FindSnapshot(Bstr(a->argv[2]).raw(),451 snapshot.asOutParam()));496 CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(), 497 snapshot.asOutParam())); 452 498 453 499 /* get the machine of the given snapshot */ 454 ComPtr<IMachine> pMachine2; 455 snapshot->COMGETTER(Machine)(pMachine2.asOutParam()); 456 showVMInfo(a->virtualBox, pMachine2, VMINFO_NONE, console); 457 } 500 ComPtr<IMachine> ptrMachine2; 501 snapshot->COMGETTER(Machine)(ptrMachine2.asOutParam()); 502 showVMInfo(a->virtualBox, ptrMachine2, VMINFO_NONE, console); 503 } 504 else if (!strcmp(a->argv[1], "list")) 505 rc = handleSnapshotList(a, ptrMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL; 458 506 else if (!strcmp(a->argv[1], "dump")) // undocumented parameter to debug snapshot info 459 DumpSnapshot(p Machine);507 DumpSnapshot(ptrMachine); 460 508 else 461 509 {
Note:
See TracChangeset
for help on using the changeset viewer.