Changeset 98288 in vbox for trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
- Timestamp:
- Jan 24, 2023 3:32:43 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 155493
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r98262 r98288 73 73 ComPtr<IVirtualSystemDescription> &aDescription) 74 74 { 75 HRESULT rc = S_OK;75 HRESULT hrc = S_OK; 76 76 77 77 if (!aAppliance) … … 94 94 95 95 // create a new virtual system to store in the appliance 96 rc = pNewDesc.createObject();97 if (FAILED( rc)) throwrc;98 rc = pNewDesc->init();99 if (FAILED( rc)) throwrc;96 hrc = pNewDesc.createObject(); 97 if (FAILED(hrc)) throw hrc; 98 hrc = pNewDesc->init(); 99 if (FAILED(hrc)) throw hrc; 100 100 101 101 // store the machine object so we can dump the XML in Appliance::Write() … … 106 106 BOOL fUSBEnabled = FALSE; 107 107 com::SafeIfaceArray<IUSBController> usbControllers; 108 rc = COMGETTER(USBControllers)(ComSafeArrayAsOutParam(usbControllers));109 if (SUCCEEDED( rc))108 hrc = COMGETTER(USBControllers)(ComSafeArrayAsOutParam(usbControllers)); 109 if (SUCCEEDED(hrc)) 110 110 { 111 111 for (unsigned i = 0; i < usbControllers.size(); ++i) … … 113 113 USBControllerType_T enmType; 114 114 115 rc = usbControllers[i]->COMGETTER(Type)(&enmType);116 if (FAILED( rc)) throwrc;115 hrc = usbControllers[i]->COMGETTER(Type)(&enmType); 116 if (FAILED(hrc)) throw hrc; 117 117 118 118 if (enmType == USBControllerType_OHCI) … … 126 126 127 127 ComPtr<IAudioAdapter> pAudioAdapter; 128 rc = mAudioSettings->COMGETTER(Adapter)(pAudioAdapter.asOutParam());129 if (FAILED( rc)) throwrc;128 hrc = mAudioSettings->COMGETTER(Adapter)(pAudioAdapter.asOutParam()); 129 if (FAILED(hrc)) throw hrc; 130 130 BOOL fAudioEnabled; 131 rc = pAudioAdapter->COMGETTER(Enabled)(&fAudioEnabled);132 if (FAILED( rc)) throwrc;131 hrc = pAudioAdapter->COMGETTER(Enabled)(&fAudioEnabled); 132 if (FAILED(hrc)) throw hrc; 133 133 AudioControllerType_T audioController; 134 rc = pAudioAdapter->COMGETTER(AudioController)(&audioController);135 if (FAILED( rc)) throwrc;134 hrc = pAudioAdapter->COMGETTER(AudioController)(&audioController); 135 if (FAILED(hrc)) throw hrc; 136 136 137 137 // get name … … 154 154 // Long mode enabled? 155 155 BOOL fLongMode; 156 rc = GetCPUProperty(CPUPropertyType_LongMode, &fLongMode);157 if (FAILED( rc)) throwrc;156 hrc = GetCPUProperty(CPUPropertyType_LongMode, &fLongMode); 157 if (FAILED(hrc)) throw hrc; 158 158 159 159 // snapshotFolder? … … 203 203 /* Fetch all available storage controllers */ 204 204 com::SafeIfaceArray<IStorageController> nwControllers; 205 rc = COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(nwControllers));206 if (FAILED( rc)) throwrc;205 hrc = COMGETTER(StorageControllers)(ComSafeArrayAsOutParam(nwControllers)); 206 if (FAILED(hrc)) throw hrc; 207 207 208 208 ComPtr<IStorageController> pIDEController; … … 214 214 { 215 215 StorageBus_T eType; 216 rc = nwControllers[j]->COMGETTER(Bus)(&eType);217 if (FAILED( rc)) throwrc;216 hrc = nwControllers[j]->COMGETTER(Bus)(&eType); 217 if (FAILED(hrc)) throw hrc; 218 218 if ( eType == StorageBus_IDE 219 219 && pIDEController.isNull()) … … 237 237 { 238 238 StorageControllerType_T ctlr; 239 rc = pIDEController->COMGETTER(ControllerType)(&ctlr);240 if (FAILED( rc)) throwrc;239 hrc = pIDEController->COMGETTER(ControllerType)(&ctlr); 240 if (FAILED(hrc)) throw hrc; 241 241 242 242 Utf8Str strVBox; … … 279 279 { 280 280 StorageControllerType_T ctlr; 281 rc = pSCSIController->COMGETTER(ControllerType)(&ctlr);282 if (SUCCEEDED( rc))281 hrc = pSCSIController->COMGETTER(ControllerType)(&ctlr); 282 if (SUCCEEDED(hrc)) 283 283 { 284 284 Utf8Str strVBox = "LsiLogic"; // the default in VBox … … 296 296 } 297 297 else 298 throw rc;298 throw hrc; 299 299 } 300 300 … … 314 314 { 315 315 StorageControllerType_T ctlr; 316 rc = pVirtioSCSIController->COMGETTER(ControllerType)(&ctlr);317 if (SUCCEEDED( rc))316 hrc = pVirtioSCSIController->COMGETTER(ControllerType)(&ctlr); 317 if (SUCCEEDED(hrc)) 318 318 { 319 319 Utf8Str strVBox = "VirtioSCSI"; // the default in VBox … … 330 330 } 331 331 else 332 throw rc;332 throw hrc; 333 333 } 334 334 … … 349 349 Bstr controllerName; 350 350 351 rc = pHDA->COMGETTER(Controller)(controllerName.asOutParam());352 if (FAILED( rc)) throwrc;353 354 rc = GetStorageControllerByName(controllerName.raw(), ctl.asOutParam());355 if (FAILED( rc)) throwrc;351 hrc = pHDA->COMGETTER(Controller)(controllerName.asOutParam()); 352 if (FAILED(hrc)) throw hrc; 353 354 hrc = GetStorageControllerByName(controllerName.raw(), ctl.asOutParam()); 355 if (FAILED(hrc)) throw hrc; 356 356 357 357 StorageBus_T storageBus; … … 360 360 LONG lDevice; 361 361 362 rc = ctl->COMGETTER(Bus)(&storageBus);363 if (FAILED( rc)) throwrc;364 365 rc = pHDA->COMGETTER(Type)(&deviceType);366 if (FAILED( rc)) throwrc;367 368 rc = pHDA->COMGETTER(Port)(&lChannel);369 if (FAILED( rc)) throwrc;370 371 rc = pHDA->COMGETTER(Device)(&lDevice);372 if (FAILED( rc)) throwrc;373 374 rc = pHDA->COMGETTER(Medium)(pMedium.asOutParam());375 if (FAILED( rc)) throwrc;362 hrc = ctl->COMGETTER(Bus)(&storageBus); 363 if (FAILED(hrc)) throw hrc; 364 365 hrc = pHDA->COMGETTER(Type)(&deviceType); 366 if (FAILED(hrc)) throw hrc; 367 368 hrc = pHDA->COMGETTER(Port)(&lChannel); 369 if (FAILED(hrc)) throw hrc; 370 371 hrc = pHDA->COMGETTER(Device)(&lDevice); 372 if (FAILED(hrc)) throw hrc; 373 374 hrc = pHDA->COMGETTER(Medium)(pMedium.asOutParam()); 375 if (FAILED(hrc)) throw hrc; 376 376 if (pMedium.isNull()) 377 377 { … … 402 402 Bstr bstrLocation; 403 403 404 rc = pMedium->COMGETTER(Location)(bstrLocation.asOutParam());405 if (FAILED( rc)) throwrc;404 hrc = pMedium->COMGETTER(Location)(bstrLocation.asOutParam()); 405 if (FAILED(hrc)) throw hrc; 406 406 strLocation = bstrLocation; 407 407 … … 412 412 // on export, the progress will be based on that (and not the diff image) 413 413 ComPtr<IMedium> pBaseMedium; 414 rc = pMedium->COMGETTER(Base)(pBaseMedium.asOutParam());414 hrc = pMedium->COMGETTER(Base)(pBaseMedium.asOutParam()); 415 415 // returns pMedium if there are no diff images 416 if (FAILED( rc)) throwrc;416 if (FAILED(hrc)) throw hrc; 417 417 418 418 strTargetImageName = Utf8StrFmt("%s-disk%.3d.vmdk", strBasename.c_str(), ++pAppliance->m->cDisks); … … 423 423 // force reading state, or else size will be returned as 0 424 424 MediumState_T ms; 425 rc = pBaseMedium->RefreshState(&ms);426 if (FAILED( rc)) throwrc;427 428 rc = pBaseMedium->COMGETTER(Size)(&llSize);429 if (FAILED( rc)) throwrc;425 hrc = pBaseMedium->RefreshState(&ms); 426 if (FAILED(hrc)) throw hrc; 427 428 hrc = pBaseMedium->COMGETTER(Size)(&llSize); 429 if (FAILED(hrc)) throw hrc; 430 430 431 431 /* If the medium is encrypted add the key identifier to the list. */ … … 479 479 //1. no host drive CD/DVD image 480 480 BOOL fHostDrive = false; 481 rc = pMedium->COMGETTER(HostDrive)(&fHostDrive);482 if (FAILED( rc)) throwrc;481 hrc = pMedium->COMGETTER(HostDrive)(&fHostDrive); 482 if (FAILED(hrc)) throw hrc; 483 483 484 484 if(fHostDrive) … … 487 487 //2. the image must be accessible and readable 488 488 MediumState_T ms; 489 rc = pMedium->RefreshState(&ms);490 if (FAILED( rc)) throwrc;489 hrc = pMedium->RefreshState(&ms); 490 if (FAILED(hrc)) throw hrc; 491 491 492 492 if (ms != MediumState_Created) … … 495 495 //3. only ISO image is exported 496 496 Bstr bstrLocation; 497 rc = pMedium->COMGETTER(Location)(bstrLocation.asOutParam());498 if (FAILED( rc)) throwrc;497 hrc = pMedium->COMGETTER(Location)(bstrLocation.asOutParam()); 498 if (FAILED(hrc)) throw hrc; 499 499 500 500 strLocation = bstrLocation; … … 512 512 tr("Cannot attach image '%s' -- file name too long"), strTargetImageName.c_str()); 513 513 514 rc = pMedium->COMGETTER(Size)(&llSize);515 if (FAILED( rc)) throwrc;514 hrc = pMedium->COMGETTER(Size)(&llSize); 515 if (FAILED(hrc)) throw hrc; 516 516 } 517 517 // and how this translates to the virtual system … … 624 624 { 625 625 ComPtr<INetworkAdapter> pNetworkAdapter; 626 hrc = GetNetworkAdapter((ULONG)a, pNetworkAdapter.asOutParam()); 627 if (FAILED(hrc)) throw hrc; 628 629 /* Enable the network card & set the adapter type */ 626 630 BOOL fEnabled; 627 NetworkAdapterType_T adapterType; 628 NetworkAttachmentType_T attachmentType; 629 630 rc = GetNetworkAdapter((ULONG)a, pNetworkAdapter.asOutParam()); 631 if (FAILED(rc)) throw rc; 632 /* Enable the network card & set the adapter type */ 633 rc = pNetworkAdapter->COMGETTER(Enabled)(&fEnabled); 634 if (FAILED(rc)) throw rc; 631 hrc = pNetworkAdapter->COMGETTER(Enabled)(&fEnabled); 632 if (FAILED(hrc)) throw hrc; 635 633 636 634 if (fEnabled) 637 635 { 638 rc = pNetworkAdapter->COMGETTER(AdapterType)(&adapterType); 639 if (FAILED(rc)) throw rc; 640 641 rc = pNetworkAdapter->COMGETTER(AttachmentType)(&attachmentType); 642 if (FAILED(rc)) throw rc; 636 NetworkAdapterType_T adapterType; 637 hrc = pNetworkAdapter->COMGETTER(AdapterType)(&adapterType); 638 if (FAILED(hrc)) throw hrc; 639 640 NetworkAttachmentType_T attachmentType; 641 hrc = pNetworkAdapter->COMGETTER(AttachmentType)(&attachmentType); 642 if (FAILED(hrc)) throw hrc; 643 643 644 644 Utf8Str strAttachmentType = convertNetworkAttachmentTypeToString(attachmentType); … … 675 675 catch(HRESULT arc) 676 676 { 677 rc = arc;678 } 679 680 return rc;677 hrc = arc; 678 } 679 680 return hrc; 681 681 } 682 682 … … 711 711 } 712 712 713 HRESULT rc = S_OK;713 HRESULT hrc = S_OK; 714 714 // AssertReturn(!(m->optListExport.contains(ExportOptions_CreateManifest) 715 715 // && m->optListExport.contains(ExportOptions_ExportDVDImages)), E_INVALIDARG); … … 720 720 if (m->locInfo.storageType == VFSType_Cloud) 721 721 { 722 rc = S_OK;722 hrc = S_OK; 723 723 ComObjPtr<Progress> progress; 724 724 try 725 725 { 726 rc = i_writeCloudImpl(m->locInfo, progress);726 hrc = i_writeCloudImpl(m->locInfo, progress); 727 727 } 728 728 catch (HRESULT aRC) 729 729 { 730 rc = aRC;731 } 732 733 if (SUCCEEDED( rc))730 hrc = aRC; 731 } 732 733 if (SUCCEEDED(hrc)) 734 734 /* Return progress to the caller */ 735 735 progress.queryInterfaceTo(aProgress.asOutParam()); … … 799 799 800 800 ComObjPtr<Progress> progress; 801 rc = S_OK;801 hrc = S_OK; 802 802 try 803 803 { … … 808 808 { 809 809 case ovf::OVFVersion_unknown: 810 rc = i_writeOPCImpl(ovfF, m->locInfo, progress);810 hrc = i_writeOPCImpl(ovfF, m->locInfo, progress); 811 811 break; 812 812 default: 813 rc = i_writeImpl(ovfF, m->locInfo, progress);813 hrc = i_writeImpl(ovfF, m->locInfo, progress); 814 814 break; 815 815 } … … 818 818 catch (HRESULT aRC) 819 819 { 820 rc = aRC;821 } 822 823 if (SUCCEEDED( rc))820 hrc = aRC; 821 } 822 823 if (SUCCEEDED(hrc)) 824 824 /* Return progress to the caller */ 825 825 progress.queryInterfaceTo(aProgress.asOutParam()); 826 826 } 827 827 828 return rc;828 return hrc; 829 829 } 830 830 … … 1184 1184 Log(("Finding source disk \"%ls\"\n", bstrSrcFilePath.raw())); 1185 1185 1186 HRESULT rc;1186 HRESULT hrc; 1187 1187 1188 1188 if (pDiskEntry->type == VirtualSystemDescriptionType_HardDiskImage) 1189 1189 { 1190 rc = mVirtualBox->OpenMedium(bstrSrcFilePath.raw(),1191 DeviceType_HardDisk,1192 AccessMode_ReadWrite,1193 FALSE /* fForceNewUuid */,1194 pSourceDisk.asOutParam());1195 if (FAILED( rc))1196 throw rc;1190 hrc = mVirtualBox->OpenMedium(bstrSrcFilePath.raw(), 1191 DeviceType_HardDisk, 1192 AccessMode_ReadWrite, 1193 FALSE /* fForceNewUuid */, 1194 pSourceDisk.asOutParam()); 1195 if (FAILED(hrc)) 1196 throw hrc; 1197 1197 } 1198 1198 else if (pDiskEntry->type == VirtualSystemDescriptionType_CDROM)//may be, this is CD/DVD 1199 1199 { 1200 rc = mVirtualBox->OpenMedium(bstrSrcFilePath.raw(),1201 DeviceType_DVD,1202 AccessMode_ReadOnly,1203 FALSE,1204 pSourceDisk.asOutParam());1205 if (FAILED( rc))1206 throw rc;1200 hrc = mVirtualBox->OpenMedium(bstrSrcFilePath.raw(), 1201 DeviceType_DVD, 1202 AccessMode_ReadOnly, 1203 FALSE, 1204 pSourceDisk.asOutParam()); 1205 if (FAILED(hrc)) 1206 throw hrc; 1207 1207 } 1208 1208 1209 1209 Bstr uuidSource; 1210 rc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam());1211 if (FAILED( rc)) throwrc;1210 hrc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam()); 1211 if (FAILED(hrc)) throw hrc; 1212 1212 Guid guidSource(uuidSource); 1213 1213 … … 1227 1227 1228 1228 LONG64 cbCapacity = 0; // size reported to guest 1229 rc = pSourceDisk->COMGETTER(LogicalSize)(&cbCapacity);1230 if (FAILED( rc)) throwrc;1229 hrc = pSourceDisk->COMGETTER(LogicalSize)(&cbCapacity); 1230 if (FAILED(hrc)) throw hrc; 1231 1231 /// @todo r=poetzsch: wrong it is reported in bytes ... 1232 1232 // capacity is reported in megabytes, so... … … 2230 2230 if (FAILED(autoCaller.hrc())) return autoCaller.hrc(); 2231 2231 2232 HRESULT rc = S_OK;2232 HRESULT hrc = S_OK; 2233 2233 2234 2234 // Lock the media tree early to make sure nobody else tries to make changes … … 2241 2241 2242 2242 if (pTask->locInfo.strPath.endsWith(".ovf", Utf8Str::CaseInsensitive)) 2243 rc = i_writeFSOVF(pTask, multiLock);2243 hrc = i_writeFSOVF(pTask, multiLock); 2244 2244 else 2245 rc = i_writeFSOVA(pTask, multiLock);2245 hrc = i_writeFSOVA(pTask, multiLock); 2246 2246 2247 2247 // reset the state so others can call methods again 2248 2248 m->state = ApplianceIdle; 2249 2249 2250 LogFlowFunc((" rc=%Rhrc\n",rc));2250 LogFlowFunc(("hrc=%Rhrc\n", hrc)); 2251 2251 LogFlowFuncLeave(); 2252 return rc;2252 return hrc; 2253 2253 } 2254 2254 … … 2609 2609 LogFlowFuncEnter(); 2610 2610 2611 HRESULT rc = S_OK;2611 HRESULT hrc = S_OK; 2612 2612 int vrc; 2613 2613 try … … 2637 2637 2638 2638 /* Write the ovf file to "disk". */ 2639 rc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize);2640 if (FAILED( rc))2641 throw rc;2639 hrc = i_writeBufferToFile(hVfsFssDst, strOvfFile.c_str(), pvBuf, cbSize); 2640 if (FAILED(hrc)) 2641 throw hrc; 2642 2642 } 2643 2643 … … 2692 2692 if (pDiskEntry->type == VirtualSystemDescriptionType_HardDiskImage) 2693 2693 { 2694 rc = mVirtualBox->i_findHardDiskByLocation(strSrcFilePath, true, &pSourceDisk);2695 if (FAILED( rc)) throwrc;2694 hrc = mVirtualBox->i_findHardDiskByLocation(strSrcFilePath, true, &pSourceDisk); 2695 if (FAILED(hrc)) throw hrc; 2696 2696 } 2697 2697 else//may be CD or DVD 2698 2698 { 2699 rc = mVirtualBox->i_findDVDOrFloppyImage(DeviceType_DVD,2700 NULL,2701 strSrcFilePath,2702 true,2703 &pSourceDisk);2704 if (FAILED( rc)) throwrc;2699 hrc = mVirtualBox->i_findDVDOrFloppyImage(DeviceType_DVD, 2700 NULL, 2701 strSrcFilePath, 2702 true, 2703 &pSourceDisk); 2704 if (FAILED(hrc)) throw hrc; 2705 2705 } 2706 2706 2707 2707 Bstr uuidSource; 2708 rc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam());2709 if (FAILED( rc)) throwrc;2708 hrc = pSourceDisk->COMGETTER(Id)(uuidSource.asOutParam()); 2709 if (FAILED(hrc)) throw hrc; 2710 2710 Guid guidSource(uuidSource); 2711 2711 … … 2743 2743 throw setError(E_FAIL, "i_manifestSetupDigestCalculationForGivenIoStream(%s)", strTargetFilePath.c_str()); 2744 2744 2745 rc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(),2746 format,2747 MediumVariant_VmdkStreamOptimized,2748 m->m_pSecretKeyStore,2749 hVfsIosDst,2750 pTask->pProgress);2745 hrc = pSourceDisk->i_exportFile(strTargetFilePath.c_str(), 2746 format, 2747 MediumVariant_VmdkStreamOptimized, 2748 m->m_pSecretKeyStore, 2749 hVfsIosDst, 2750 pTask->pProgress); 2751 2751 RTVfsIoStrmRelease(hVfsIosDst); 2752 2752 } … … 2757 2757 */ 2758 2758 Assert(pDiskEntry->type == VirtualSystemDescriptionType_CDROM); 2759 rc = pSourceDisk->i_addRawToFss(strTargetFilePath.c_str(), m->m_pSecretKeyStore, hVfsFssDst,2759 hrc = pSourceDisk->i_addRawToFss(strTargetFilePath.c_str(), m->m_pSecretKeyStore, hVfsFssDst, 2760 2760 pTask->pProgress, false /*fSparse*/); 2761 2761 } 2762 if (FAILED( rc)) throwrc;2762 if (FAILED(hrc)) throw hrc; 2763 2763 } 2764 2764 catch (HRESULT rc3) … … 2798 2798 vrc = RTVfsFsStrmAdd(hVfsFssDst, strMfFileName.c_str(), hVfsObjManifest, 0 /*fFlags*/); 2799 2799 if (RT_SUCCESS(vrc)) 2800 rc = S_OK;2800 hrc = S_OK; 2801 2801 else 2802 rc = setErrorVrc(vrc, tr("RTVfsFsStrmAdd failed for the manifest (%Rrc)"), vrc);2802 hrc = setErrorVrc(vrc, tr("RTVfsFsStrmAdd failed for the manifest (%Rrc)"), vrc); 2803 2803 } 2804 2804 else 2805 rc = setErrorVrc(vrc, tr("RTManifestWriteStandard failed (%Rrc)"), vrc);2805 hrc = setErrorVrc(vrc, tr("RTManifestWriteStandard failed (%Rrc)"), vrc); 2806 2806 } 2807 2807 else 2808 rc = setErrorVrc(vrc, tr("RTManifestWriteStandard failed (%Rrc)"), vrc);2808 hrc = setErrorVrc(vrc, tr("RTManifestWriteStandard failed (%Rrc)"), vrc); 2809 2809 RTVfsIoStrmRelease(hVfsIosManifest); 2810 if (FAILED( rc))2811 throw rc;2810 if (FAILED(hrc)) 2811 throw hrc; 2812 2812 } 2813 2813 } 2814 2814 catch (RTCError &x) // includes all XML exceptions 2815 2815 { 2816 rc = setError(VBOX_E_FILE_ERROR, 2817 x.what()); 2816 hrc = setError(VBOX_E_FILE_ERROR, x.what()); 2818 2817 } 2819 2818 catch (HRESULT aRC) 2820 2819 { 2821 rc = aRC;2822 } 2823 2824 LogFlowFunc((" rc=%Rhrc\n",rc));2820 hrc = aRC; 2821 } 2822 2823 LogFlowFunc(("hrc=%Rhrc\n", hrc)); 2825 2824 LogFlowFuncLeave(); 2826 2825 2827 return rc;2826 return hrc; 2828 2827 } 2829 2828
Note:
See TracChangeset
for help on using the changeset viewer.