Changeset 73132 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 13, 2018 6:10:44 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 123720
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ApplianceImpl.h
r72902 r73132 124 124 bool i_isApplianceIdle(); 125 125 HRESULT i_searchUniqueVMName(Utf8Str& aName) const; 126 HRESULT i_searchUniqueDiskImageFilePath(const Utf8Str &aMachineFolder, Utf8Str &aName) const; 126 HRESULT i_searchUniqueImageFilePath(const Utf8Str &aMachineFolder, 127 DeviceType_T aDeviceType, 128 Utf8Str &aName) const; 127 129 HRESULT i_setUpProgress(ComObjPtr<Progress> &pProgress, 128 130 const Utf8Str &strDescription, -
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r72973 r73132 896 896 char *tmpName = RTStrDup(aName.c_str()); 897 897 int i = 1; 898 /** @todo Maybe too cost-intensive; try to find a lighter way */899 898 while (mVirtualBox->FindMachine(Bstr(tmpName).raw(), &machine) != VBOX_E_OBJECT_NOT_FOUND) 900 899 { … … 909 908 } 910 909 911 HRESULT Appliance::i_searchUnique DiskImageFilePath(const Utf8Str &aMachineFolder, Utf8Str &aName) const912 { 913 IMedium * harddisk= NULL;910 HRESULT Appliance::i_searchUniqueImageFilePath(const Utf8Str &aMachineFolder, DeviceType_T aDeviceType, Utf8Str &aName) const 911 { 912 IMedium *pMedium = NULL; 914 913 char *tmpName = RTStrDup(aName.c_str()); 915 914 char *tmpAbsName = RTPathAbsExDup(aMachineFolder.c_str(), tmpName); 916 915 int i = 1; 917 /* Check if the file exists or if a file with this path is registered 918 * already */ 919 /** @todo Maybe too cost-intensive; try to find a lighter way */ 916 /* Check if the file exists or if a medium with this path is registered already */ 920 917 while ( RTPathExists(tmpAbsName) 921 || mVirtualBox->OpenMedium(Bstr(tmpAbsName).raw(), DeviceType_HardDisk, AccessMode_ReadWrite,922 FALSE /* fForceNewUuid */, & harddisk) != VBOX_E_OBJECT_NOT_FOUND)918 || mVirtualBox->OpenMedium(Bstr(tmpAbsName).raw(), aDeviceType, AccessMode_ReadWrite, 919 FALSE /* fForceNewUuid */, &pMedium) != VBOX_E_OBJECT_NOT_FOUND) 923 920 { 924 921 RTStrFree(tmpAbsName); … … 928 925 RTPathStripSuffix(tmpFile); 929 926 const char *pszTmpSuff = RTPathSuffix(aName.c_str()); 930 RTStrAPrintf(&tmpName, "%s%c%s_%d%s", tmpDir, RTPATH_DELIMITER, tmpFile, i, pszTmpSuff); 927 if (!strcmp(tmpDir, ".")) 928 RTStrAPrintf(&tmpName, "%s_%d%s", tmpFile, i, pszTmpSuff); 929 else 930 RTStrAPrintf(&tmpName, "%s%c%s_%d%s", tmpDir, RTPATH_DELIMITER, tmpFile, i, pszTmpSuff); 931 931 tmpAbsName = RTPathAbsExDup(aMachineFolder.c_str(), tmpName); 932 932 RTStrFree(tmpFile); … … 1157 1157 { 1158 1158 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 1159 /* One for every hard diskof the Virtual System */1159 /* One for every medium of the Virtual System */ 1160 1160 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 1161 1161 std::list<VirtualSystemDescriptionEntry*>::const_iterator itH; … … 1550 1550 * Internal method; adds a new description item to the member list. 1551 1551 * @param aType Type of description for the new item. 1552 * @param strRef Reference item; only used with hard diskcontrollers.1552 * @param strRef Reference item; only used with storage controllers. 1553 1553 * @param aOvfValue Corresponding original value from OVF. 1554 1554 * @param aVBoxValue Initial configuration value (can be overridden by caller with setFinalValues). -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r73003 r73132 134 134 135 135 // Change the appliance state so we can safely leave the lock while doing time-consuming 136 // diskimports; also the below method calls do all kinds of locking which conflicts with136 // medium imports; also the below method calls do all kinds of locking which conflicts with 137 137 // the appliance object lock 138 138 m->state = Data::ApplianceImporting; … … 549 549 pNewDesc->i_addEntry(VirtualSystemDescriptionType_CDROM, "", "", ""); 550 550 551 /* Hard diskController */551 /* Storage Controller */ 552 552 uint16_t cIDEused = 0; 553 553 uint16_t cSATAused = 0; NOREF(cSATAused); 554 554 uint16_t cSCSIused = 0; NOREF(cSCSIused); 555 555 ovf::ControllersMap::const_iterator hdcIt; 556 /* Iterate through all hard diskcontrollers */556 /* Iterate through all storage controllers */ 557 557 for (hdcIt = vsysThis.mapControllers.begin(); 558 558 hdcIt != vsysThis.mapControllers.end(); … … 644 644 } 645 645 646 /* Hard disks*/646 /* Storage devices (hard disks/DVDs/...) */ 647 647 if (vsysThis.mapVirtualDisks.size() > 0) 648 648 { 649 649 ovf::VirtualDisksMap::const_iterator itVD; 650 /* Iterate through all hard disks ()*/650 /* Iterate through all storage devices */ 651 651 for (itVD = vsysThis.mapVirtualDisks.begin(); 652 652 itVD != vsysThis.mapVirtualDisks.end(); … … 654 654 { 655 655 const ovf::VirtualDisk &hd = itVD->second; 656 /* Get the associated diskimage */656 /* Get the associated image */ 657 657 ovf::DiskImage di; 658 658 std::map<RTCString, ovf::DiskImage>::iterator foundDisk; … … 667 667 668 668 /* 669 * Figure out from URI which format the image of disk has. 670 * URI must have inside section <Disk> . 671 * But there aren't strong requirements about correspondence one URI for one disk virtual format. 672 * So possibly, we aren't able to recognize some URIs. 669 * Figure out from URI which format the image has. 670 * There is no strict mapping of image URI to image format. 671 * It's possible we aren't able to recognize some URIs. 673 672 */ 674 673 … … 690 689 691 690 Utf8Str strFilename = di.strHref; 691 DeviceType_T devType = DeviceType_Null; 692 692 if (vdf.compare("VMDK", Utf8Str::CaseInsensitive) == 0) 693 693 { … … 695 695 if (!strFilename.length()) 696 696 strFilename = Utf8StrFmt("%s.vmdk", hd.strDiskId.c_str()); 697 devType = DeviceType_HardDisk; 697 698 } 698 699 else if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0) … … 701 702 if (!strFilename.length()) 702 703 strFilename = Utf8StrFmt("%s.iso", hd.strDiskId.c_str()); 704 devType = DeviceType_DVD; 703 705 } 704 706 else … … 714 716 strFilename.stripSuffix(); 715 717 716 i_searchUnique DiskImageFilePath(strMachineFolder, strFilename);717 718 /* find the description for the hard diskcontroller718 i_searchUniqueImageFilePath(strMachineFolder, devType, strFilename); 719 720 /* find the description for the storage controller 719 721 * that has the same ID as hd.idController */ 720 722 const VirtualSystemDescriptionEntry *pController; 721 723 if (!(pController = pNewDesc->i_findControllerFromID(hd.idController))) 722 724 throw setError(E_FAIL, 723 tr("Cannot find hard diskcontroller with OVF instance ID %RI32 "724 "to which disk\"%s\" should be attached"),725 tr("Cannot find storage controller with OVF instance ID %RI32 " 726 "to which medium \"%s\" should be attached"), 725 727 hd.idController, 726 728 di.strHref.c_str()); … … 2032 2034 2033 2035 /* Change the appliance state so we can safely leave the lock while doing 2034 * time-consuming diskimports; also the below method calls do all kinds of2036 * time-consuming image imports; also the below method calls do all kinds of 2035 2037 * locking which conflicts with the appliance object lock. */ 2036 2038 AutoWriteLock writeLock(this COMMA_LOCKVAL_SRC_POS); … … 2053 2055 { 2054 2056 /* With _whatever_ error we've had, do a complete roll-back of 2055 * machines and disks we've created */2057 * machines and images we've created */ 2056 2058 writeLock.release(); 2057 2059 ErrorInfoKeeper eik; … … 2274 2276 * @param hdc in: the HardDiskController structure to attach to. 2275 2277 * @param ulAddressOnParent in: the AddressOnParent parameter from OVF. 2276 * @param controllerName out: the name of the hard diskcontroller to attach to (e.g. "IDE").2278 * @param controllerName out: the name of the storage controller to attach to (e.g. "IDE"). 2277 2279 * @param lControllerPort out: the channel (controller port) of the controller to attach to. 2278 2280 * @param lDevice out: the device number to attach to. … … 2372 2374 2373 2375 /** 2374 * Imports one diskimage.2376 * Imports one image. 2375 2377 * 2376 2378 * This is common code shared between … … 2383 2385 * the caller needs to pass in the ovf::DiskImage structure from ovfreader.cpp. 2384 2386 * 2385 * As a result, in both cases, if di.strHref is empty, we create a new diskas per the OVF2387 * As a result, in both cases, if di.strHref is empty, we create a new image as per the OVF 2386 2388 * spec, even though this cannot really happen in the vbox:Machine case since such data 2387 2389 * would never have been exported. 2388 2390 * 2389 * This advances stack.pProgress by one operation with the disk's weight.2390 * 2391 * @param di ovfreader.cpp structure describing the diskimage from the OVF that is to be imported2391 * This advances stack.pProgress by one operation with the image's weight. 2392 * 2393 * @param di ovfreader.cpp structure describing the image from the OVF that is to be imported 2392 2394 * @param strDstPath Where to create the target image. 2393 * @param pTarget HD out: The newly created target disk. This also gets pushed on stack.llHardDisksCreated for cleanup.2395 * @param pTargetMedium out: The newly created target medium. This also gets pushed on stack.llHardDisksCreated for cleanup. 2394 2396 * @param stack 2395 2397 */ 2396 2398 void Appliance::i_importOneDiskImage(const ovf::DiskImage &di, 2397 2399 const Utf8Str &strDstPath, 2398 ComObjPtr<Medium> &pTarget HD,2400 ComObjPtr<Medium> &pTargetMedium, 2399 2401 ImportStack &stack) 2400 2402 { … … 2432 2434 2433 2435 /* First of all check if the original (non-absolute) destination path is 2434 * a valid hard disk UUID. If so, the user wants to import the diskinto2436 * a valid medium UUID. If so, the user wants to import the image into 2435 2437 * an existing path. This is useful for iSCSI for example. */ 2438 /** @todo r=klaus the code structure after this point is totally wrong, 2439 * full of unnecessary code duplication and other issues. 4.2 still had 2440 * the right structure for importing into existing medium objects, which 2441 * the current code can't possibly handle. */ 2436 2442 RTUUID uuid; 2437 2443 int vrc = RTUuidFromStr(&uuid, strDstPath.c_str()); 2438 2444 if (vrc == VINF_SUCCESS) 2439 2445 { 2440 rc = mVirtualBox->i_findHardDiskById(Guid(uuid), true, &pTarget HD);2446 rc = mVirtualBox->i_findHardDiskById(Guid(uuid), true, &pTargetMedium); 2441 2447 if (FAILED(rc)) throw rc; 2442 2448 } … … 2446 2452 2447 2453 /* check read file to GZIP compression */ 2448 bool const fGzipped = di.strCompression.compare("gzip", Utf8Str::CaseInsensitive) == 0;2454 bool const fGzipped = di.strCompression.compare("gzip", Utf8Str::CaseInsensitive) == 0; 2449 2455 Utf8Str strDeleteTemp; 2450 2456 try … … 2514 2520 } 2515 2521 2516 /* Create an IMedium object. */2517 pTargetHD.createObject();2518 2519 2522 /*CD/DVD case*/ 2520 2523 if (strTrgFormat.compare("RAW", Utf8Str::CaseInsensitive) == 0) … … 2526 2529 else 2527 2530 i_importCopyFile(stack, strSrcFilePath, strAbsDstPath, strSourceOVF.c_str()); 2531 2532 ComPtr<IMedium> pTmp; 2533 rc = mVirtualBox->OpenMedium(Bstr(strAbsDstPath).raw(), 2534 DeviceType_DVD, 2535 AccessMode_ReadWrite, 2536 false, 2537 pTmp.asOutParam()); 2538 if (FAILED(rc)) 2539 throw rc; 2540 2541 IMedium *iM = pTmp; 2542 pTargetMedium = static_cast<Medium*>(iM); 2528 2543 } 2529 2544 catch (HRESULT /*arc*/) … … 2540 2555 else/* HDD case*/ 2541 2556 { 2542 rc = pTargetHD->init(mVirtualBox, 2543 strTrgFormat, 2544 strAbsDstPath, 2545 Guid::Empty /* media registry: none yet */, 2546 DeviceType_HardDisk); 2547 if (FAILED(rc)) throw rc; 2548 2549 /* Now create an empty hard disk. */ 2550 rc = mVirtualBox->CreateMedium(Bstr(strTrgFormat).raw(), 2551 Bstr(strAbsDstPath).raw(), 2552 AccessMode_ReadWrite, DeviceType_HardDisk, 2553 ComPtr<IMedium>(pTargetHD).asOutParam()); 2557 /* Create an IMedium object. */ 2558 pTargetMedium.createObject(); 2559 2560 rc = pTargetMedium->init(mVirtualBox, 2561 strTrgFormat, 2562 strAbsDstPath, 2563 Guid::Empty /* media registry: none yet */, 2564 DeviceType_HardDisk); 2554 2565 if (FAILED(rc)) throw rc; 2555 2566 … … 2560 2571 mediumVariant.push_back(MediumVariant_Standard); 2561 2572 2562 /* Kick of the creation of a dynamic growing disk image with the given capacity. */2563 rc = pTarget HD->CreateBaseStorage(di.iCapacity / _1M,2573 /* Kick off the creation of a dynamic growing disk image with the given capacity. */ 2574 rc = pTargetMedium->CreateBaseStorage(di.iCapacity / _1M, 2564 2575 ComSafeArrayAsInParam(mediumVariant), 2565 2576 ComPtr<IProgress>(pProgress).asOutParam()); … … 2622 2633 /* Start the source image cloning operation. */ 2623 2634 ComObjPtr<Medium> nullParent; 2624 rc = pTarget HD->i_importFile(strSrcFilePath.c_str(),2625 srcFormat,2626 MediumVariant_Standard,2627 hVfsIosReadAhead,2628 nullParent,2629 pProgress);2635 rc = pTargetMedium->i_importFile(strSrcFilePath.c_str(), 2636 srcFormat, 2637 MediumVariant_Standard, 2638 hVfsIosReadAhead, 2639 nullParent, 2640 pProgress); 2630 2641 RTVfsIoStrmRelease(hVfsIosReadAhead); 2631 2642 hVfsIosSrc = NIL_RTVFSIOSTREAM; … … 2640 2651 } 2641 2652 2642 /* Now wait for the background diskoperation to complete; this throws2653 /* Now wait for the background import operation to complete; this throws 2643 2654 * HRESULTs on error. */ 2644 2655 ComPtr<IProgress> pp(pProgress); … … 2930 2941 } 2931 2942 2932 // IDE Hard disk controller2943 // Storage controller IDE 2933 2944 std::list<VirtualSystemDescriptionEntry*> vsdeHDCIDE = 2934 2945 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerIDE); … … 2963 2974 } 2964 2975 2965 /* Hard diskcontroller SATA */2976 /* Storage controller SATA */ 2966 2977 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSATA = 2967 2978 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSATA); … … 2986 2997 } 2987 2998 2988 /* Hard diskcontroller SCSI */2999 /* Storage controller SCSI */ 2989 3000 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSCSI = 2990 3001 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI); … … 3021 3032 } 3022 3033 3023 /* Hard diskcontroller SAS */3034 /* Storage controller SAS */ 3024 3035 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSAS = 3025 3036 vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskControllerSAS); … … 3038 3049 } 3039 3050 3040 /* Now its time to register the machine before we add any hard disks */3051 /* Now its time to register the machine before we add any storage devices */ 3041 3052 rc = mVirtualBox->RegisterMachine(pNewMachine); 3042 3053 if (FAILED(rc)) throw rc; … … 3108 3119 if (FAILED(rc)) throw rc; 3109 3120 3110 // only now that we're done with all disks, close the session3121 // only now that we're done with all storage devices, close the session 3111 3122 rc = stack.pSession->UnlockMachine(); 3112 3123 if (FAILED(rc)) throw rc; … … 3127 3138 } 3128 3139 3129 // create the hard disks & connect them to the appropriate controllers3140 // create the storage devices & connect them to the appropriate controllers 3130 3141 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->i_findByType(VirtualSystemDescriptionType_HardDiskImage); 3131 3142 if (!avsdeHDs.empty()) … … 3173 3184 3174 3185 Log(("diCurrent.strDiskId=%s diCurrent.strHref=%s\n", diCurrent.strDiskId.c_str(), diCurrent.strHref.c_str())); 3175 /* Iterate over all given diskimages of the virtual system3176 * d isks description. We need to find the target diskpath,3186 /* Iterate over all given images of the virtual system 3187 * description. We need to find the target image path, 3177 3188 * which could be changed by the user. */ 3178 3189 VirtualSystemDescriptionEntry *vsdeTargetHD = NULL; … … 3190 3201 if (!vsdeTargetHD) 3191 3202 { 3192 /* possible case if a diskimage belongs to other virtual system (OVF package with multiple VMs inside) */3203 /* possible case if an image belongs to other virtual system (OVF package with multiple VMs inside) */ 3193 3204 Log1Warning(("OVA/OVF import: Disk image %s was missed during import of VM %s\n", 3194 3205 oit->first.c_str(), vmNameEntry->strOvf.c_str())); … … 3198 3209 } 3199 3210 3200 //diCurrent.strDiskId contains the diskidentifier (e.g. "vmdisk1"), which should exist3201 //in the virtual system's disks map under that ID and also in the global images map3211 //diCurrent.strDiskId contains the image identifier (e.g. "vmdisk1"), which should exist 3212 //in the virtual system's images map under that ID and also in the global images map 3202 3213 ovf::VirtualDisksMap::const_iterator itVDisk = vsysThis.mapVirtualDisks.find(diCurrent.strDiskId); 3203 3214 if (itVDisk == vsysThis.mapVirtualDisks.end()) … … 3216 3227 if (h != disksResolvedNames.end()) 3217 3228 { 3218 /* Yes, diskname was found, we can skip it*/3229 /* Yes, image name was found, we can skip it*/ 3219 3230 ++oit; 3220 3231 continue; … … 3227 3238 if (RTStrICmp(diCurrent.strHref.c_str(), stack.pszOvaLookAheadName) != 0) 3228 3239 { 3229 /* availableImage contains the diskfile reference (e.g. "disk1.vmdk"), which should3240 /* availableImage contains the image file reference (e.g. "disk1.vmdk"), which should 3230 3241 * exist in the global images map. 3231 * And find the diskfrom the OVF's disk list */3242 * And find the image from the OVF's disk list */ 3232 3243 ovf::DiskImagesMap::const_iterator itDiskImage; 3233 3244 for (itDiskImage = stack.mapDisks.begin(); … … 3244 3255 } 3245 3256 3246 /* replace with a new found diskimage */3257 /* replace with a new found image */ 3247 3258 diCurrent = *(&itDiskImage->second); 3248 3259 3249 3260 /* 3250 * Again iterate over all given diskimages of the virtual system3251 * d isks description using the found diskimage3261 * Again iterate over all given images of the virtual system 3262 * description using the found image 3252 3263 */ 3253 3264 for (list<VirtualSystemDescriptionEntry*>::const_iterator itHD = avsdeHDs.begin(); … … 3295 3306 } 3296 3307 3297 /* very important to store diskname for the next checks */3308 /* very important to store image name for the next checks */ 3298 3309 disksResolvedNames.insert(diCurrent.strHref); 3299 3310 ////// end of duplicated code. 3300 3311 const ovf::VirtualDisk &ovfVdisk = itVDisk->second; 3301 3312 3302 ComObjPtr<Medium> pTargetHD; 3303 3304 Utf8Str savedVBoxCurrent = vsdeTargetHD->strVBoxCurrent; 3305 3313 ComObjPtr<Medium> pTargetMedium; 3306 3314 i_importOneDiskImage(diCurrent, 3307 3315 vsdeTargetHD->strVBoxCurrent, 3308 pTarget HD,3316 pTargetMedium, 3309 3317 stack); 3310 3318 3311 // now use the new uuid to attach the disk imageto our new machine3319 // now use the new uuid to attach the medium to our new machine 3312 3320 ComPtr<IMachine> sMachine; 3313 3321 rc = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); … … 3331 3339 vsdeTargetHD->strVBoxCurrent.c_str(), mhda.lControllerPort, mhda.lDevice)); 3332 3340 3333 ComObjPtr<MediumFormat> mediumFormat;3334 rc = i_findMediumFormatFromDiskImage(diCurrent, mediumFormat);3341 DeviceType_T devType = DeviceType_Null; 3342 rc = pTargetMedium->COMGETTER(DeviceType)(&devType); 3335 3343 if (FAILED(rc)) 3336 3344 throw rc; 3337 3345 3338 Bstr bstrFormatName; 3339 rc = mediumFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 3346 rc = sMachine->AttachDevice(Bstr(mhda.controllerName).raw(),// name 3347 mhda.lControllerPort, // long controllerPort 3348 mhda.lDevice, // long device 3349 devType, // DeviceType_T type 3350 pTargetMedium); 3340 3351 if (FAILED(rc)) 3341 3352 throw rc; 3342 3343 Utf8Str vdf = Utf8Str(bstrFormatName);3344 3345 if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0)3346 {3347 ComPtr<IMedium> dvdImage(pTargetHD);3348 3349 rc = mVirtualBox->OpenMedium(Bstr(vsdeTargetHD->strVBoxCurrent).raw(),3350 DeviceType_DVD,3351 AccessMode_ReadWrite,3352 false,3353 dvdImage.asOutParam());3354 3355 if (FAILED(rc))3356 throw rc;3357 3358 rc = sMachine->AttachDevice(Bstr(mhda.controllerName).raw(),// name3359 mhda.lControllerPort, // long controllerPort3360 mhda.lDevice, // long device3361 DeviceType_DVD, // DeviceType_T type3362 dvdImage);3363 if (FAILED(rc))3364 throw rc;3365 }3366 else3367 {3368 rc = sMachine->AttachDevice(Bstr(mhda.controllerName).raw(),// name3369 mhda.lControllerPort, // long controllerPort3370 mhda.lDevice, // long device3371 DeviceType_HardDisk, // DeviceType_T type3372 pTargetHD);3373 3374 if (FAILED(rc))3375 throw rc;3376 }3377 3353 3378 3354 stack.llHardDiskAttachments.push_back(mhda); … … 3381 3357 if (FAILED(rc)) 3382 3358 throw rc; 3383 3384 /* restore */3385 vsdeTargetHD->strVBoxCurrent = savedVBoxCurrent;3386 3359 3387 3360 ++cImportedDisks; … … 3817 3790 settings::StorageController &sc = *sit; 3818 3791 3819 // find the OVF virtual system description entry for this storage controller3820 /** @todo3821 * r=bird: What on earh this is switch supposed to do? (I've added the default:break;, so don't3822 * get confused by it.) Kind of looks like it's supposed to do something error handling related3823 * in the default case...3824 */3825 switch (sc.storageBus)3826 {3827 case StorageBus_SATA:3828 break;3829 case StorageBus_SCSI:3830 break;3831 case StorageBus_IDE:3832 break;3833 case StorageBus_SAS:3834 break;3835 default: break; /* Shut up MSC. */3836 }3837 3838 3792 // for each medium attachment to this controller... 3839 3793 for (settings::AttachedDevicesList::iterator dit = sc.llAttachedDevices.begin(); … … 3873 3827 * step 3: import disk 3874 3828 */ 3875 Utf8Str savedVBoxCurrent = vsdeTargetHD->strVBoxCurrent; 3876 ComObjPtr<Medium> pTargetHD; 3877 3829 ComObjPtr<Medium> pTargetMedium; 3878 3830 i_importOneDiskImage(diCurrent, 3879 3831 vsdeTargetHD->strVBoxCurrent, 3880 pTarget HD,3832 pTargetMedium, 3881 3833 stack); 3882 3834 3835 // ... and replace the old UUID in the machine config with the one of 3836 // the imported disk that was just created 3883 3837 Bstr hdId; 3884 3885 ComObjPtr<MediumFormat> mediumFormat; 3886 rc = i_findMediumFormatFromDiskImage(diCurrent, mediumFormat); 3887 if (FAILED(rc)) 3888 throw rc; 3889 3890 Bstr bstrFormatName; 3891 rc = mediumFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 3892 if (FAILED(rc)) 3893 throw rc; 3894 3895 Utf8Str vdf = Utf8Str(bstrFormatName); 3896 3897 if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0) 3898 { 3899 ComPtr<IMedium> dvdImage(pTargetHD); 3900 3901 rc = mVirtualBox->OpenMedium(Bstr(vsdeTargetHD->strVBoxCurrent).raw(), 3902 DeviceType_DVD, 3903 AccessMode_ReadWrite, 3904 false, 3905 dvdImage.asOutParam()); 3906 3907 if (FAILED(rc)) throw rc; 3908 3909 // ... and replace the old UUID in the machine config with the one of 3910 // the imported disk that was just created 3911 rc = dvdImage->COMGETTER(Id)(hdId.asOutParam()); 3912 if (FAILED(rc)) throw rc; 3913 } 3914 else 3915 { 3916 // ... and replace the old UUID in the machine config with the one of 3917 // the imported disk that was just created 3918 rc = pTargetHD->COMGETTER(Id)(hdId.asOutParam()); 3919 if (FAILED(rc)) throw rc; 3920 } 3921 3922 /* restore */ 3923 vsdeTargetHD->strVBoxCurrent = savedVBoxCurrent; 3838 rc = pTargetMedium->COMGETTER(Id)(hdId.asOutParam()); 3839 if (FAILED(rc)) throw rc; 3924 3840 3925 3841 /*
Note:
See TracChangeset
for help on using the changeset viewer.