Changeset 38525 in vbox
- Timestamp:
- Aug 25, 2011 11:40:58 AM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r38469 r38525 2092 2092 } 2093 2093 2094 #include <VBox/com/array.h> 2095 int CmdTest(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 2096 { 2097 /* one parameter, guest name */ 2098 if (argc < 1) 2099 return errorSyntax(USAGE_GUESTSTATS, "Missing VM name/UUID"); 2100 2101 /* 2102 * Parse the command. 2103 */ 2104 ULONG aUpdateInterval = 0; 2105 2106 static const RTGETOPTDEF s_aOptions[] = 2107 { 2108 { "--interval", 'i', RTGETOPT_REQ_UINT32 } 2109 }; 2110 2111 int ch; 2112 RTGETOPTUNION ValueUnion; 2113 RTGETOPTSTATE GetState; 2114 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0); 2115 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 2116 { 2117 switch (ch) 2118 { 2119 case 'i': 2120 aUpdateInterval = ValueUnion.u32; 2121 break; 2122 2123 default: 2124 return errorGetOpt(USAGE_GUESTSTATS , ch, &ValueUnion); 2125 } 2126 } 2127 2128 if (argc > 1 && aUpdateInterval == 0) 2129 return errorSyntax(USAGE_GUESTSTATS, "Invalid update interval specified"); 2130 2131 RTPrintf("argc=%d interval=%u\n", argc, aUpdateInterval); 2132 2133 ComPtr<IMachine> ptrMachine; 2134 HRESULT rc; 2135 CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]).raw(), 2136 ptrMachine.asOutParam()), 1); 2137 2138 CHECK_ERROR_RET(ptrMachine, LockMachine(aSession, LockType_Write), 1); 2139 Utf8Str trgPath = "/home/poetzsch/downloads/matt_diff.vdi"; 2140 2141 ComPtr<IMedium> sourceImage; 2142 ComPtr<IMedium> targetImage; 2143 CHECK_ERROR_RET(aVirtualBox, OpenMedium(Bstr("/home/poetzsch/downloads/matt.vdi").raw(), DeviceType_HardDisk, AccessMode_ReadWrite, false, sourceImage.asOutParam()), 1); 2144 CHECK_ERROR_RET(aVirtualBox, CreateHardDisk(Bstr("VDI").raw(), Bstr(trgPath).raw(), targetImage.asOutParam()), 1); 2145 // sourceImage.lockRead(); 2146 ComPtr<IProgress> progress; 2147 CHECK_ERROR_RET(sourceImage, CreateDiffStorage(targetImage, (long) MediumVariant_Diff, progress.asOutParam()), 1); 2148 CHECK_ERROR_RET(progress, WaitForCompletion(-1), 1); 2149 // sourceImage.unlockRead(); 2150 ComPtr<IMedium> targetImage1; 2151 CHECK_ERROR_RET(aVirtualBox, OpenMedium(Bstr(trgPath).raw(), DeviceType_HardDisk, AccessMode_ReadWrite, false, targetImage1.asOutParam()), 1); 2152 2153 { 2154 ComPtr<IMachine> mutMachine; 2155 CHECK_ERROR_RET(aSession, COMGETTER(Machine)(mutMachine.asOutParam()), 1); 2156 CHECK_ERROR_RET(mutMachine, AttachDevice(Bstr("IDE Controller").raw(), 0, 0, DeviceType_HardDisk, targetImage1), 1); 2157 CHECK_ERROR_RET(mutMachine, SaveSettings(), 1); 2158 2159 CHECK_ERROR_RET(aSession, UnlockMachine(), 1); 2160 } 2161 2162 com::SafeIfaceArray<IMedium> mediums; 2163 CHECK_ERROR_RET(ptrMachine, Unregister(CleanupMode_Full, ComSafeArrayAsOutParam(mediums)), 1); 2164 ComPtr<IProgress> progress1; 2165 com::SafeIfaceArray<IMedium> m(0); 2166 CHECK_ERROR_RET(ptrMachine, Delete(ComSafeArrayAsInParam(m), progress1.asOutParam()), 1); 2167 CHECK_ERROR_RET(progress1, WaitForCompletion(-1), 1); 2168 RTPrintf("bla %d\n", mediums.size()); 2169 for (int i = 0; i < mediums.size(); ++i) 2170 { 2171 // ComPtr<IMedium> mm = ; 2172 Bstr loc; 2173 CHECK_ERROR_RET(mediums[i], COMGETTER(Location)(loc.asOutParam()), 1); 2174 RTPrintf("%ls\n", loc.raw()); 2175 CHECK_ERROR_RET(mediums[i], Close(), 1); 2176 } 2177 2178 return 0; 2179 } 2180 2094 2181 2095 2182 /** … … 2136 2223 if (!strcmp(pszCmd, "gueststats")) 2137 2224 return CmdGuestStats(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2225 if (!strcmp(pszCmd, "test")) 2226 return CmdTest(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2227 2138 2228 2139 2229 /* default: */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp
r37862 r38525 304 304 305 305 rc = showProgress(progressRead); 306 307 if (FAILED(rc)) 308 { 309 com::ProgressErrorInfo info(progressRead); 310 com::GluePrintErrorInfo(info); 311 com::GluePrintErrorContext("ImportAppliance", __FILE__, __LINE__); 312 return 1; 313 } 306 CHECK_PROGRESS_ERROR_RET(progressRead, ("Appliance read failed"), RTEXITCODE_FAILURE); 314 307 315 308 Bstr path; /* fetch the path, there is stuff like username/password removed if any */ … … 747 740 if (fIgnoreThis) 748 741 { 749 742 RTPrintf("%2u: Sound card \"%ls\" -- disabled\n", 750 743 a, 751 744 aOvfValues[a]); … … 786 779 787 780 rc = showProgress(progress); 788 789 if (FAILED(rc)) 790 { 791 com::ProgressErrorInfo info(progress); 792 com::GluePrintErrorInfo(info); 793 com::GluePrintErrorContext("ImportAppliance", __FILE__, __LINE__); 794 return 1; 795 } 796 else 781 CHECK_PROGRESS_ERROR_RET(progress, ("Appliance import failed"), RTEXITCODE_FAILURE); 782 783 if (SUCCEEDED(rc)) 797 784 RTPrintf("Successfully imported the appliance.\n"); 798 785 } … … 800 787 } while (0); 801 788 802 return SUCCEEDED(rc) ? 0 : 1;789 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 803 790 } 804 791 … … 1052 1039 1053 1040 rc = showProgress(progress); 1054 1055 if (FAILED(rc)) 1056 { 1057 com::ProgressErrorInfo info(progress); 1058 com::GluePrintErrorInfo(info); 1059 com::GluePrintErrorContext("Write", __FILE__, __LINE__); 1060 return 1; 1061 } 1062 else 1041 CHECK_PROGRESS_ERROR_RET(progress, ("Appliance write failed"), RTEXITCODE_FAILURE); 1042 1043 if (SUCCEEDED(rc)) 1063 1044 RTPrintf("Successfully exported %d machine(s).\n", llMachines.size()); 1064 1045 1065 1046 } while (0); 1066 1047 1067 return SUCCEEDED(rc) ? 0 : 1;1048 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1068 1049 } 1069 1050 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
r37202 r38525 169 169 170 170 rc = showProgress(progress); 171 if (FAILED(rc)) 172 { 173 com::ProgressErrorInfo info(progress); 174 if (info.isBasicAvailable()) 175 RTMsgError("Failed to power off machine. Error message: %lS", info.getText().raw()); 176 else 177 RTMsgError("Failed to power off machine. No error message available!"); 178 } 171 CHECK_PROGRESS_ERROR(progress, ("Failed to power off machine")); 179 172 } 180 173 else if (!strcmp(a->argv[1], "savestate")) … … 207 200 208 201 rc = showProgress(progress); 202 CHECK_PROGRESS_ERROR(progress, ("Failed to save machine state")); 209 203 if (FAILED(rc)) 210 {211 com::ProgressErrorInfo info(progress);212 if (info.isBasicAvailable())213 RTMsgError("Failed to save machine state. Error message: %lS", info.getText().raw());214 else215 RTMsgError("Failed to save machine state. No error message available!");216 204 console->Resume(); 217 }218 205 } 219 206 else if (!strcmp(a->argv[1], "acpipowerbutton")) … … 1099 1086 1100 1087 rc = showProgress(progress); 1101 if (FAILED(rc)) 1102 { 1103 com::ProgressErrorInfo info(progress); 1104 if (info.isBasicAvailable()) 1105 RTMsgError("Teleportation failed. Error message: %lS", info.getText().raw()); 1106 else 1107 RTMsgError("Teleportation failed. No error message available!"); 1108 } 1088 CHECK_PROGRESS_ERROR(progress, ("Teleportation failed")); 1109 1089 } 1110 1090 else if (!strcmp(a->argv[1], "screenshotpng")) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r38469 r38525 355 355 { 356 356 rc = showProgress(progress); 357 if (FAILED(rc)) 358 { 359 com::ProgressErrorInfo info(progress); 360 if (info.isBasicAvailable()) 361 RTMsgError("Failed to create hard disk. Error message: %lS", info.getText().raw()); 362 else 363 RTMsgError("Failed to create hard disk. No error message available!"); 364 } 365 else 357 CHECK_PROGRESS_ERROR(progress, ("Failed to create hard disk")); 358 if (SUCCEEDED(rc)) 366 359 { 367 360 Bstr uuid; … … 513 506 RTMsgError("Compact hard disk operation for this format is not implemented yet!"); 514 507 else 515 com::GluePrintRCMessage(rc);508 CHECK_PROGRESS_ERROR(progress, ("Failed to compact hard disk")); 516 509 } 517 510 } … … 530 523 RTMsgError("Resize hard disk operation for this format is not implemented yet!"); 531 524 else 532 com::GluePrintRCMessage(rc);525 CHECK_PROGRESS_ERROR(progress, ("Failed to resize hard disk")); 533 526 } 534 527 } … … 665 658 666 659 rc = showProgress(progress); 667 if (FAILED(rc)) 668 { 669 com::ProgressErrorInfo info(progress); 670 if (info.isBasicAvailable()) 671 RTMsgError("Failed to clone hard disk. Error message: %lS", info.getText().raw()); 672 else 673 RTMsgError("Failed to clone hard disk. No error message available!"); 674 break; 675 } 660 CHECK_PROGRESS_ERROR_BREAK(progress, ("Failed to clone hard disk")); 676 661 677 662 Bstr uuid; … … 1169 1154 { 1170 1155 rc = showProgress(progress); 1171 if (FAILED(rc)) 1172 { 1173 com::ProgressErrorInfo info(progress); 1174 if (info.isBasicAvailable()) 1175 RTMsgError("Failed to delete medium. Error message: %lS", info.getText().raw()); 1176 else 1177 RTMsgError("Failed to delete medium. No error message available!"); 1178 } 1156 CHECK_PROGRESS_ERROR(progress, ("Failed to delete medium")); 1179 1157 } 1180 1158 else -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r38456 r38525 1073 1073 int vrc = VINF_SUCCESS; 1074 1074 ComPtr<IProgress> progress; 1075 HRESULT hr;1075 HRESULT rc; 1076 1076 if (pContext->fHostToGuest) 1077 1077 { 1078 hr= pContext->pGuest->CopyToGuest(Bstr(pszFileSource).raw(), Bstr(pszFileDest).raw(),1078 rc = pContext->pGuest->CopyToGuest(Bstr(pszFileSource).raw(), Bstr(pszFileDest).raw(), 1079 1079 Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(), 1080 1080 fFlags, progress.asOutParam()); … … 1082 1082 else 1083 1083 { 1084 hr= pContext->pGuest->CopyFromGuest(Bstr(pszFileSource).raw(), Bstr(pszFileDest).raw(),1084 rc = pContext->pGuest->CopyFromGuest(Bstr(pszFileSource).raw(), Bstr(pszFileDest).raw(), 1085 1085 Bstr(pContext->pszUsername).raw(), Bstr(pContext->pszPassword).raw(), 1086 1086 fFlags, progress.asOutParam()); 1087 1087 } 1088 1088 1089 if (FAILED( hr))1089 if (FAILED(rc)) 1090 1090 vrc = ctrlPrintError(pContext->pGuest, COM_IIDOF(IGuest)); 1091 1091 else 1092 1092 { 1093 hr = showProgress(progress); 1094 if (FAILED(hr)) 1095 vrc = ctrlPrintProgressError(progress); 1093 rc = showProgress(progress); 1094 CHECK_PROGRESS_ERROR(progress, ("File copy failed")); 1096 1095 } 1097 1096 … … 2038 2037 { 2039 2038 rc = showProgress(progress); 2040 if (FAILED(rc))2041 vrc = ctrlPrintProgressError(progress);2042 else if (fVerbose)2039 CHECK_PROGRESS_ERROR(progress, ("Guest additions update failed")); 2040 if ( SUCCEEDED(rc) 2041 && fVerbose) 2043 2042 RTPrintf("Guest Additions update successful.\n"); 2044 2043 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHostonly.cpp
r35330 r38525 66 66 rc = showProgress(progress); 67 67 *pcProcessed = index - iStart; 68 if (FAILED(rc)) 69 { 70 com::ProgressErrorInfo info(progress); 71 if (info.isBasicAvailable()) 72 RTMsgError("Failed to create the host-only adapter. Error message: %lS", info.getText().raw()); 73 else 74 RTMsgError("Failed to create the host-only adapter. No error message available, code: %Rhrc", rc); 75 76 return 1; 77 } 68 CHECK_PROGRESS_ERROR_RET(progress, ("Failed to create the host-only adapter"), 1); 78 69 79 70 Bstr name; … … 110 101 rc = showProgress(progress); 111 102 *pcProcessed = index - iStart; 112 if (FAILED(rc)) 113 { 114 com::ProgressErrorInfo info(progress); 115 if (info.isBasicAvailable()) 116 RTMsgError("Failed to remove the host-only adapter. Error message: %lS", info.getText().raw()); 117 else 118 RTMsgError("Failed to remove the host-only adapter. No error message available, code: %Rhrc", rc); 119 120 return 1; 121 } 103 CHECK_PROGRESS_ERROR_RET(progress, ("Failed to remove the host-only adapter"), 1); 122 104 123 105 return 0; -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r38191 r38525 164 164 CHECK_ERROR_RET(machine, Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam()), 165 165 RTEXITCODE_FAILURE); 166 166 167 rc = showProgress(pProgress); 167 if (FAILED(rc)) 168 { 169 com::ProgressErrorInfo ErrInfo(pProgress); 170 com::GluePrintErrorInfo(ErrInfo); 171 return RTEXITCODE_FAILURE; 172 } 168 CHECK_PROGRESS_ERROR_RET(pProgress, ("Machine delete failed"), RTEXITCODE_FAILURE); 173 169 } 174 170 return RTEXITCODE_SUCCESS; … … 446 442 RTEXITCODE_FAILURE); 447 443 rc = showProgress(progress); 448 if (FAILED(rc)) 449 { 450 com::ProgressErrorInfo ErrInfo(progress); 451 com::GluePrintErrorInfo(ErrInfo); 452 return RTEXITCODE_FAILURE; 453 } 444 CHECK_PROGRESS_ERROR_RET(progress, ("Clone VM failed"), RTEXITCODE_FAILURE); 454 445 455 446 if (fRegister) … … 1083 1074 CHECK_ERROR2_RET(ptrExtPackFile, Install(fReplace, NULL, ptrProgress.asOutParam()), RTEXITCODE_FAILURE); 1084 1075 hrc = showProgress(ptrProgress); 1085 if (FAILED(hrc)) 1086 { 1087 com::ProgressErrorInfo ErrInfo(ptrProgress); 1088 if (ErrInfo.isBasicAvailable()) 1089 RTMsgError("Failed to install \"%s\": %lS", szPath, ErrInfo.getText().raw()); 1090 else 1091 RTMsgError("Failed to install \"%s\": No error message available!", szPath); 1092 return RTEXITCODE_FAILURE; 1093 } 1076 CHECK_PROGRESS_ERROR_RET(ptrProgress, ("Failed to install \"%s\"", szPath), RTEXITCODE_FAILURE); 1077 1094 1078 RTPrintf("Successfully installed \"%lS\".\n", bstrName.raw()); 1095 1079 } … … 1130 1114 CHECK_ERROR2_RET(ptrExtPackMgr, Uninstall(bstrName.raw(), fForced, NULL, ptrProgress.asOutParam()), RTEXITCODE_FAILURE); 1131 1115 hrc = showProgress(ptrProgress); 1132 if (FAILED(hrc)) 1133 { 1134 com::ProgressErrorInfo ErrInfo(ptrProgress); 1135 if (ErrInfo.isBasicAvailable()) 1136 RTMsgError("Failed to uninstall \"%s\": %lS", pszName, ErrInfo.getText().raw()); 1137 else 1138 RTMsgError("Failed to uninstall \"%s\": No error message available!", pszName); 1139 return RTEXITCODE_FAILURE; 1140 } 1116 CHECK_PROGRESS_ERROR_RET(ptrProgress, ("Failed to uninstall \"%s\"", pszName), RTEXITCODE_FAILURE); 1117 1141 1118 RTPrintf("Successfully uninstalled \"%s\".\n", pszName); 1142 1119 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
r33425 r38525 307 307 308 308 rc = showProgress(progress); 309 if (FAILED(rc)) 310 { 311 com::ProgressErrorInfo info(progress); 312 if (info.isBasicAvailable()) 313 RTMsgError("Failed to take snapshot. Error message: %lS", info.getText().raw()); 314 else 315 RTMsgError("Failed to take snapshot. No error message available!"); 316 } 309 CHECK_PROGRESS_ERROR(progress, ("Failed to take snapshot")); 317 310 318 311 if (fPause) … … 381 374 382 375 rc = showProgress(pProgress); 383 if (FAILED(rc)) 384 { 385 com::ProgressErrorInfo info(pProgress); 386 if (info.isBasicAvailable()) 387 RTMsgError("Snapshot operation failed. Error message: %lS", info.getText().raw()); 388 else 389 RTMsgError("Snapshot operation failed. No error message available!"); 390 } 376 CHECK_PROGRESS_ERROR(pProgress, ("Snapshot operation failed")); 391 377 } 392 378 else if (!strcmp(a->argv[1], "edit"))
Note:
See TracChangeset
for help on using the changeset viewer.