Changeset 953 in vbox
- Timestamp:
- Feb 16, 2007 3:45:20 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 18705
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r614 r953 301 301 } 302 302 #endif /* VBOX_SECURELABEL */ 303 return S_OK; 304 } 305 306 STDMETHOD(OnMediaRegistered) (INPTR GUIDPARAM mediaId, DeviceType_T mediaType, 307 BOOL registered) 308 { 309 NOREF (mediaId); 310 NOREF (mediaType); 311 NOREF (registered); 303 312 return S_OK; 304 313 } -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r809 r953 323 323 /* details generators */ 324 324 325 QString details (const CHardDisk &aHD, bool aPredict = false) const;325 QString details (const CHardDisk &aHD, bool aPredict = false); 326 326 327 327 QString details (const CUSBDevice &aDevice) const; … … 330 330 QString prepareFileNameForHTML (const QString &fn) const; 331 331 332 QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks) const;332 QString detailsReport (const CMachine &m, bool isNewVM, bool withLinks); 333 333 334 334 /* VirtualBox helpers */ … … 354 354 void updateMedia (const VBoxMedia &); 355 355 void removeMedia (VBoxDefs::DiskType, const QUuid &); 356 357 bool findMedia (const CUnknown &, VBoxMedia &) const; 356 358 357 359 /* various helpers */ -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r816 r953 188 188 } 189 189 } 190 return S_OK; 191 } 192 193 STDMETHOD(OnMediaRegistered) (IN_GUIDPARAM id, DeviceType_T type, 194 BOOL registered) 195 { 196 /** @todo */ 197 Q_UNUSED (id); 198 Q_UNUSED (type); 199 Q_UNUSED (registered); 190 200 return S_OK; 191 201 } … … 575 585 * (with the exception mentioned above). 576 586 */ 577 QString VBoxGlobal::details (const CHardDisk &aHD, bool aPredict /* = false */) const587 QString VBoxGlobal::details (const CHardDisk &aHD, bool aPredict /* = false */) 578 588 { 579 589 Assert (!aPredict || aHD.GetParent().isNull()); 590 591 /// @todo (r=dmik) later: we need to keep *all* media (including all hard disk 592 // children) in the current media list in order for the following to work. 593 // VBoxMedia media; 594 // if (!findMedia (CUnknown (aHD), media)) 595 // { 596 // /* media may be new and not alredy in the media list, request refresh */ 597 // startEnumeratingMedia(); 598 // if (!findMedia (CUnknown (aHD), media)) 599 // AssertFailed(); 600 // } 580 601 581 602 CHardDisk root = aHD.GetRoot(); … … 590 611 details = hardDiskTypeString (root); 591 612 592 details += ", " + formatSize (root.GetSize() * _1M); 613 details += ", "; 614 615 /// @todo (r=dmik) prepend the details with the warning/error 616 // icon when not accessible 617 618 /// @todo (r=dmik) later: we need to keep *all* media (including all hard disk 619 // children) in the current media list in order for the following to work. 620 // switch (media.status) 621 // { 622 // case VBoxMedia::Unknown: 623 // details += tr ("<i>Checking...</i>", "hard disk"); 624 // break; 625 // case VBoxMedia::Ok: 626 details += formatSize (root.GetSize() * _1M); 627 // break; 628 // case VBoxMedia::Error: 629 // case VBoxMedia::Inaccessible: 630 // details += tr ("Inaccessible", "hard disk"); 631 // break; 632 // } 593 633 594 634 return details; … … 674 714 * @param withLinks true if section titles should be hypertext links 675 715 */ 676 QString VBoxGlobal::detailsReport ( 677 const CMachine &m, bool isNewVM, bool withLinks) const716 QString VBoxGlobal::detailsReport (const CMachine &m, bool isNewVM, 717 bool withLinks) 678 718 { 679 719 static const char *sTableTpl = … … 1267 1307 1268 1308 /** 1309 * Searches for a VBoxMedia object representing the given COM media object. 1310 * 1311 * @return true if found and false otherwise. 1312 */ 1313 bool VBoxGlobal::findMedia (const CUnknown &aObj, VBoxMedia &aMedia) const 1314 { 1315 for (VBoxMediaList::ConstIterator it = media_list.begin(); 1316 it != media_list.end(); ++ it) 1317 { 1318 if ((*it).disk == aObj) 1319 { 1320 aMedia = (*it); 1321 return true; 1322 } 1323 } 1324 1325 return false; 1326 } 1327 1328 /** 1269 1329 * Changes the language of all global string constants according to the 1270 1330 * currently installed translations tables. … … 1286 1346 sessionStates [CEnums::SessionOpen] = tr ("Open", "SessionState"); 1287 1347 sessionStates [CEnums::SessionSpawning] = tr ("Spawning", "SessionState"); 1288 sessionStates [CEnums::SessionClosing] = tr ("Closing", "SessionState");1348 sessionStates [CEnums::SessionClosing] = tr ("Closing", "SessionState"); 1289 1349 1290 1350 deviceTypes [CEnums::NoDevice] = tr ("None", "DeviceType"); -
trunk/src/VBox/Main/HardDiskImpl.cpp
r911 r953 1005 1005 (*it)->updatePaths (aOldPath, aNewPath); 1006 1006 } 1007 } 1008 1009 /** 1010 * Helper method that deduces a hard disk object type to create from 1011 * the location string format and from the contents of the resource 1012 * pointed to by the location string. 1013 * 1014 * Currently, the location string must be a file path which is 1015 * passed to the HVirtualDiskImage or HVMDKImage initializer in 1016 * attempt to create a hard disk object. 1017 * 1018 * @param aVirtualBox 1019 * @param aLocation 1020 * @param hardDisk 1021 * 1022 * @return 1023 */ 1024 /* static */ 1025 HRESULT HardDisk::openHardDisk (VirtualBox *aVirtualBox, INPTR BSTR aLocation, 1026 ComObjPtr <HardDisk> &hardDisk) 1027 { 1028 AssertReturn (aVirtualBox, E_POINTER); 1029 1030 /* null and empty strings are not allowed locations */ 1031 AssertReturn (aLocation, E_INVALIDARG); 1032 AssertReturn (*aLocation, E_INVALIDARG); 1033 1034 HRESULT rc = S_OK; 1035 1036 /* try to guess the probe order by extension */ 1037 Utf8Str loc = aLocation; 1038 char *ext = RTPathExt (loc); 1039 1040 HardDiskStorageType_T order [2]; 1041 1042 if (RTPathCompare (ext, "vmdk") == 0) 1043 { 1044 order [0] = HardDiskStorageType_VMDKImage; 1045 order [1] = HardDiskStorageType_VirtualDiskImage; 1046 } 1047 else 1048 { 1049 order [0] = HardDiskStorageType_VirtualDiskImage; 1050 order [1] = HardDiskStorageType_VMDKImage; 1051 } 1052 1053 for (size_t i = 0; i < ELEMENTS (order) && SUCCEEDED (rc); ++ i) 1054 { 1055 switch (order [i]) 1056 { 1057 case HardDiskStorageType_VirtualDiskImage: 1058 { 1059 ComObjPtr <HVirtualDiskImage> obj; 1060 obj.createObject(); 1061 rc = obj->init (aVirtualBox, NULL, aLocation, 1062 FALSE /* aRegistered */); 1063 if (SUCCEEDED (rc)) 1064 { 1065 hardDisk = obj; 1066 return rc; 1067 } 1068 break; 1069 } 1070 case HardDiskStorageType_VMDKImage: 1071 { 1072 ComObjPtr <HVMDKImage> obj; 1073 obj.createObject(); 1074 rc = obj->init (aVirtualBox, NULL, aLocation, 1075 FALSE /* aRegistered */); 1076 if (SUCCEEDED (rc)) 1077 { 1078 hardDisk = obj; 1079 return rc; 1080 } 1081 break; 1082 } 1083 default: 1084 { 1085 rc = E_FAIL; 1086 ComAssertComRCBreak (E_FAIL, rc = rc); 1087 } 1088 } 1089 } 1090 1091 return rc; 1007 1092 } 1008 1093 … … 1198 1283 * 1199 1284 * @param aHDNode <HardDisk> node 1200 * @param aVDINod 1285 * @param aVDINode <VirtualDiskImage> node 1201 1286 */ 1202 1287 HRESULT HVirtualDiskImage::init (VirtualBox *aVirtualBox, HardDisk *aParent, … … 1425 1510 if (mState != NotCreated) 1426 1511 return setError (E_ACCESSDENIED, 1427 tr ("Cannot change the file path of the existing VDIhard disk '%ls'"),1512 tr ("Cannot change the file path of the existing hard disk '%ls'"), 1428 1513 toString().raw()); 1429 1514 … … 3170 3255 } 3171 3256 3257 //////////////////////////////////////////////////////////////////////////////// 3258 // HVMDKImage class 3259 //////////////////////////////////////////////////////////////////////////////// 3260 3261 // constructor / destructor 3262 //////////////////////////////////////////////////////////////////////////////// 3263 3264 HRESULT HVMDKImage::FinalConstruct() 3265 { 3266 HRESULT rc = HardDisk::FinalConstruct(); 3267 if (FAILED (rc)) 3268 return rc; 3269 3270 mState = NotCreated; 3271 3272 mStateCheckSem = NIL_RTSEMEVENTMULTI; 3273 mStateCheckWaiters = 0; 3274 3275 mSize = 0; 3276 mActualSize = 0; 3277 3278 return S_OK; 3279 } 3280 3281 void HVMDKImage::FinalRelease() 3282 { 3283 HardDisk::FinalRelease(); 3284 } 3285 3286 // public initializer/uninitializer for internal purposes only 3287 //////////////////////////////////////////////////////////////////////////////// 3288 3289 // public methods for internal purposes only 3290 ///////////////////////////////////////////////////////////////////////////// 3291 3292 /** 3293 * Initializes the VMDK hard disk object by reading its properties from 3294 * the given configuration node. The created hard disk will be marked as 3295 * registered on success. 3296 * 3297 * @param aHDNode <HardDisk> node 3298 * @param aVMDKNode <VirtualDiskImage> node 3299 */ 3300 HRESULT HVMDKImage::init (VirtualBox *aVirtualBox, HardDisk *aParent, 3301 CFGNODE aHDNode, CFGNODE aVMDKNode) 3302 { 3303 LogFlowMember (("HVMDKImage::init (load)\n")); 3304 3305 AssertReturn (aHDNode && aVMDKNode, E_FAIL); 3306 3307 AutoLock alock (this); 3308 ComAssertRet (!isReady(), E_UNEXPECTED); 3309 3310 mStorageType = HardDiskStorageType_VMDKImage; 3311 3312 HRESULT rc = S_OK; 3313 3314 do 3315 { 3316 rc = protectedInit (aVirtualBox, aParent); 3317 CheckComRCBreakRC (rc); 3318 3319 /* set ready to let protectedUninit() be called on failure */ 3320 setReady (true); 3321 3322 /* filePath (required) */ 3323 Bstr filePath; 3324 CFGLDRQueryBSTR (aVMDKNode, "filePath", filePath.asOutParam()); 3325 3326 rc = setFilePath (filePath); 3327 CheckComRCBreakRC (rc); 3328 3329 LogFlowMember ((" '%ls'\n", mFilePathFull.raw())); 3330 3331 /* load basic settings and children */ 3332 rc = loadSettings (aHDNode); 3333 CheckComRCBreakRC (rc); 3334 3335 mState = Created; 3336 mRegistered = TRUE; 3337 3338 /* Don't call queryInformation() for registered hard disks to 3339 * prevent the calling thread (i.e. the VirtualBox server startup 3340 * thread) from an unexpected freeze. The vital mId property (UUID) 3341 * is read from the registry file in loadSettings(). To get the rest, 3342 * the user will have to call COMGETTER(Accessible) manually. */ 3343 } 3344 while (0); 3345 3346 if (FAILED (rc)) 3347 uninit(); 3348 3349 return rc; 3350 } 3351 3352 /** 3353 * Initializes the VMDK hard disk object using the given image file name. 3354 * 3355 * @param aVirtualBox VirtualBox parent. 3356 * @param aParent Currently, must always be NULL. 3357 * @param aFilePath path to the image file (can be NULL to create an 3358 * imageless object) 3359 * @param aRegistered whether to mark this disk as registered or not 3360 * (ignored when \a aFilePath is NULL, assuming FALSE) 3361 */ 3362 HRESULT HVMDKImage::init (VirtualBox *aVirtualBox, HardDisk *aParent, 3363 const BSTR aFilePath, BOOL aRegistered /* = FALSE */) 3364 { 3365 LogFlowMember (("HVirtualDiskImage::init (aFilePath='%ls', aRegistered=%d)\n", 3366 aFilePath, aRegistered)); 3367 3368 AssertReturn (aParent == NULL, E_FAIL); 3369 3370 AutoLock alock (this); 3371 ComAssertRet (!isReady(), E_UNEXPECTED); 3372 3373 mStorageType = HardDiskStorageType_VirtualDiskImage; 3374 3375 HRESULT rc = S_OK; 3376 3377 do 3378 { 3379 rc = protectedInit (aVirtualBox, aParent); 3380 CheckComRCBreakRC (rc); 3381 3382 /* set ready to let protectedUninit() be called on failure */ 3383 setReady (true); 3384 3385 rc = setFilePath (aFilePath); 3386 CheckComRCBreakRC (rc); 3387 3388 Assert (mId.isEmpty()); 3389 3390 if (aFilePath && *aFilePath) 3391 { 3392 mRegistered = aRegistered; 3393 mState = Created; 3394 3395 /* Call queryInformation() anyway (even if it will block), because 3396 * it is the only way to get the UUID of the existing VDI and 3397 * initialize the vital mId property. */ 3398 Bstr errMsg; 3399 rc = queryInformation (&errMsg); 3400 if (SUCCEEDED (rc)) 3401 { 3402 /* We are constructing a new HVirtualDiskImage object. If there 3403 * is a fatal accessibility error (we cannot read image UUID), 3404 * we have to fail. We do so even on non-fatal errors as well, 3405 * because it's not worth to keep going with the inaccessible 3406 * image from the very beginning (when nothing else depends on 3407 * it yet). */ 3408 if (!errMsg.isNull()) 3409 rc = setErrorBstr (E_FAIL, errMsg); 3410 } 3411 } 3412 else 3413 { 3414 mRegistered = FALSE; 3415 mState = NotCreated; 3416 mId.create(); 3417 } 3418 } 3419 while (0); 3420 3421 if (FAILED (rc)) 3422 uninit(); 3423 3424 return rc; 3425 } 3426 3427 /** 3428 * Uninitializes the instance and sets the ready flag to FALSE. 3429 * Called either from FinalRelease(), by the parent when it gets destroyed, 3430 * or by a third party when it decides this object is no more valid. 3431 */ 3432 void HVMDKImage::uninit() 3433 { 3434 LogFlowMember (("HVMDKImage::uninit()\n")); 3435 3436 AutoLock alock (this); 3437 if (!isReady()) 3438 return; 3439 3440 HardDisk::protectedUninit (alock); 3441 } 3442 3443 // IHardDisk properties 3444 //////////////////////////////////////////////////////////////////////////////// 3445 3446 STDMETHODIMP HVMDKImage::COMGETTER(Description) (BSTR *aDescription) 3447 { 3448 if (!aDescription) 3449 return E_POINTER; 3450 3451 AutoLock alock (this); 3452 CHECK_READY(); 3453 3454 mDescription.cloneTo (aDescription); 3455 return S_OK; 3456 } 3457 3458 STDMETHODIMP HVMDKImage::COMSETTER(Description) (INPTR BSTR aDescription) 3459 { 3460 AutoLock alock (this); 3461 CHECK_READY(); 3462 3463 CHECK_BUSY_AND_READERS(); 3464 3465 return E_NOTIMPL; 3466 3467 /// @todo (r=dmik) implement 3468 3469 // if (mState >= Created) 3470 // { 3471 // int vrc = VDISetImageComment (Utf8Str (mFilePathFull), Utf8Str (aDescription)); 3472 // if (VBOX_FAILURE (vrc)) 3473 // return setError (E_FAIL, 3474 // tr ("Could not change the description of the VDI hard disk '%ls' " 3475 // "(%Vrc)"), 3476 // toString().raw(), vrc); 3477 // } 3478 3479 // mDescription = aDescription; 3480 // return S_OK; 3481 } 3482 3483 STDMETHODIMP HVMDKImage::COMGETTER(Size) (ULONG64 *aSize) 3484 { 3485 if (!aSize) 3486 return E_POINTER; 3487 3488 AutoLock alock (this); 3489 CHECK_READY(); 3490 3491 /// @todo (r=dmik) later 3492 3493 // /* only a non-differencing image knows the logical size */ 3494 // if (isDifferencing()) 3495 // return root()->COMGETTER(Size) (aSize); 3496 3497 *aSize = mSize; 3498 return S_OK; 3499 } 3500 3501 STDMETHODIMP HVMDKImage::COMGETTER(ActualSize) (ULONG64 *aActualSize) 3502 { 3503 if (!aActualSize) 3504 return E_POINTER; 3505 3506 AutoLock alock (this); 3507 CHECK_READY(); 3508 3509 *aActualSize = mActualSize; 3510 return S_OK; 3511 } 3512 3513 // IVirtualDiskImage properties 3514 //////////////////////////////////////////////////////////////////////////////// 3515 3516 STDMETHODIMP HVMDKImage::COMGETTER(FilePath) (BSTR *aFilePath) 3517 { 3518 if (!aFilePath) 3519 return E_POINTER; 3520 3521 AutoLock alock (this); 3522 CHECK_READY(); 3523 3524 mFilePathFull.cloneTo (aFilePath); 3525 return S_OK; 3526 } 3527 3528 STDMETHODIMP HVMDKImage::COMSETTER(FilePath) (INPTR BSTR aFilePath) 3529 { 3530 AutoLock alock (this); 3531 CHECK_READY(); 3532 3533 if (mState != NotCreated) 3534 return setError (E_ACCESSDENIED, 3535 tr ("Cannot change the file path of the existing hard disk '%ls'"), 3536 toString().raw()); 3537 3538 CHECK_BUSY_AND_READERS(); 3539 3540 /* append the default path if only a name is given */ 3541 Bstr path = aFilePath; 3542 if (aFilePath && *aFilePath) 3543 { 3544 Utf8Str fp = aFilePath; 3545 if (!RTPathHavePath (fp)) 3546 { 3547 AutoReaderLock propsLock (mVirtualBox->systemProperties()); 3548 path = Utf8StrFmt ("%ls%c%s", 3549 mVirtualBox->systemProperties()->defaultVDIFolder().raw(), 3550 RTPATH_DELIMITER, 3551 fp.raw()); 3552 } 3553 } 3554 3555 return setFilePath (path); 3556 } 3557 3558 STDMETHODIMP HVMDKImage::COMGETTER(Created) (BOOL *aCreated) 3559 { 3560 if (!aCreated) 3561 return E_POINTER; 3562 3563 AutoLock alock (this); 3564 CHECK_READY(); 3565 3566 *aCreated = mState >= Created; 3567 return S_OK; 3568 } 3569 3570 // IVMDKImage methods 3571 ///////////////////////////////////////////////////////////////////////////// 3572 3573 STDMETHODIMP HVMDKImage::CreateDynamicImage (ULONG64 aSize, IProgress **aProgress) 3574 { 3575 if (!aProgress) 3576 return E_POINTER; 3577 3578 AutoLock alock (this); 3579 CHECK_READY(); 3580 3581 return createImage (aSize, TRUE /* aDynamic */, aProgress); 3582 } 3583 3584 STDMETHODIMP HVMDKImage::CreateFixedImage (ULONG64 aSize, IProgress **aProgress) 3585 { 3586 if (!aProgress) 3587 return E_POINTER; 3588 3589 AutoLock alock (this); 3590 CHECK_READY(); 3591 3592 return createImage (aSize, FALSE /* aDynamic */, aProgress); 3593 } 3594 3595 STDMETHODIMP HVMDKImage::DeleteImage() 3596 { 3597 AutoLock alock (this); 3598 CHECK_READY(); 3599 CHECK_BUSY_AND_READERS(); 3600 3601 if (mRegistered) 3602 return setError (E_ACCESSDENIED, 3603 tr ("Cannot delete an image of the registered hard disk image '%ls"), 3604 mFilePathFull.raw()); 3605 if (mState == NotCreated) 3606 return setError (E_FAIL, 3607 tr ("Hard disk image has been already deleted or never created")); 3608 3609 int vrc = RTFileDelete (Utf8Str (mFilePathFull)); 3610 if (VBOX_FAILURE (vrc)) 3611 return setError (E_FAIL, tr ("Could not delete the image file '%ls' (%Vrc)"), 3612 mFilePathFull.raw(), vrc); 3613 3614 mState = NotCreated; 3615 3616 /* reset the fields */ 3617 mSize = 0; 3618 mActualSize = 0; 3619 3620 return S_OK; 3621 } 3622 3623 // public/protected methods for internal purposes only 3624 ///////////////////////////////////////////////////////////////////////////// 3625 3626 /** 3627 * Attempts to mark the hard disk as registered. 3628 * Only VirtualBox can call this method. 3629 */ 3630 HRESULT HVMDKImage::trySetRegistered (BOOL aRegistered) 3631 { 3632 AutoLock alock (this); 3633 CHECK_READY(); 3634 3635 if (aRegistered) 3636 { 3637 if (mState == NotCreated) 3638 return setError (E_FAIL, 3639 tr ("Image file '%ls' is not yet created for this hard disk"), 3640 mFilePathFull.raw()); 3641 /// @todo (r=dmik) later? 3642 // if (isDifferencing()) 3643 // return setError (E_FAIL, 3644 // tr ("Hard disk '%ls' is differencing and cannot be unregistered " 3645 // "explicitly"), 3646 // mFilePathFull.raw()); 3647 } 3648 else 3649 { 3650 ComAssertRet (mState >= Created, E_FAIL); 3651 } 3652 3653 return HardDisk::trySetRegistered (aRegistered); 3654 } 3655 3656 /** 3657 * Checks accessibility of this hard disk image only (w/o parents). 3658 * 3659 * @param aAccessError on output, a null string indicates the hard disk is 3660 * accessible, otherwise contains a message describing 3661 * the reason of inaccessibility. 3662 */ 3663 HRESULT HVMDKImage::getAccessible (Bstr &aAccessError) 3664 { 3665 AutoLock alock (this); 3666 CHECK_READY(); 3667 3668 if (mStateCheckSem != NIL_RTSEMEVENTMULTI) 3669 { 3670 /* An accessibility check in progress on some other thread, 3671 * wait for it to finish. */ 3672 3673 ComAssertRet (mStateCheckWaiters != (ULONG) ~0, E_FAIL); 3674 ++ mStateCheckWaiters; 3675 alock.leave(); 3676 3677 int vrc = RTSemEventMultiWait (mStateCheckSem, RT_INDEFINITE_WAIT); 3678 3679 alock.enter(); 3680 AssertReturn (mStateCheckWaiters != 0, E_FAIL); 3681 -- mStateCheckWaiters; 3682 if (mStateCheckWaiters == 0) 3683 { 3684 RTSemEventMultiDestroy (mStateCheckSem); 3685 mStateCheckSem = NIL_RTSEMEVENTMULTI; 3686 } 3687 3688 AssertRCReturn (vrc, E_FAIL); 3689 3690 /* don't touch aAccessError, it has been already set */ 3691 return S_OK; 3692 } 3693 3694 /* check the basic accessibility */ 3695 HRESULT rc = getBaseAccessible (aAccessError, true /* aCheckBusy */); 3696 if (FAILED (rc) || !aAccessError.isNull()) 3697 return rc; 3698 3699 if (mState >= Created) 3700 { 3701 return queryInformation (&aAccessError); 3702 } 3703 3704 aAccessError = Utf8StrFmt ("Hard disk image '%ls' is not yet created", 3705 mFilePathFull.raw()); 3706 return S_OK; 3707 } 3708 3709 /** 3710 * Saves hard disk settings to the specified storage node and saves 3711 * all children to the specified hard disk node 3712 * 3713 * @param aHDNode <HardDisk> or <DiffHardDisk> node 3714 * @param aStorageNode <VirtualDiskImage> node 3715 */ 3716 HRESULT HVMDKImage::saveSettings (CFGNODE aHDNode, CFGNODE aStorageNode) 3717 { 3718 AssertReturn (aHDNode && aStorageNode, E_FAIL); 3719 3720 AutoLock alock (this); 3721 CHECK_READY(); 3722 3723 /* filePath (required) */ 3724 CFGLDRSetBSTR (aStorageNode, "filePath", mFilePath); 3725 3726 /* save basic settings and children */ 3727 return HardDisk::saveSettings (aHDNode); 3728 } 3729 3730 /** 3731 * Checks if the given change of \a aOldPath to \a aNewPath affects the path 3732 * of this hard disk and updates it if necessary to reflect the new location. 3733 * Intended to be from HardDisk::updatePaths(). 3734 * 3735 * @param aOldPath old path (full) 3736 * @param aNewPath new path (full) 3737 * 3738 * @note Locks this object for writing. 3739 */ 3740 void HVMDKImage::updatePath (const char *aOldPath, const char *aNewPath) 3741 { 3742 AssertReturnVoid (aOldPath); 3743 AssertReturnVoid (aNewPath); 3744 3745 AutoLock alock (this); 3746 AssertReturnVoid (isReady()); 3747 3748 size_t oldPathLen = strlen (aOldPath); 3749 3750 Utf8Str path = mFilePathFull; 3751 LogFlowThisFunc (("VMDK.fullPath={%s}\n", path.raw())); 3752 3753 if (RTPathStartsWith (path, aOldPath)) 3754 { 3755 Utf8Str newPath = Utf8StrFmt ("%s%s", aNewPath, 3756 path.raw() + oldPathLen); 3757 path = newPath; 3758 3759 mVirtualBox->calculateRelativePath (path, path); 3760 3761 unconst (mFilePathFull) = newPath; 3762 unconst (mFilePath) = path; 3763 3764 LogFlowThisFunc (("-> updated: full={%s} short={%s}\n", 3765 newPath.raw(), path.raw())); 3766 } 3767 } 3768 3769 /** 3770 * Returns the string representation of this hard disk. 3771 * When \a aShort is false, returns the full image file path. 3772 * Otherwise, returns the image file name only. 3773 * 3774 * @param aShort if true, a short representation is returned 3775 */ 3776 Bstr HVMDKImage::toString (bool aShort /* = false */) 3777 { 3778 AutoLock alock (this); 3779 3780 if (!aShort) 3781 return mFilePathFull; 3782 else 3783 { 3784 Utf8Str fname = mFilePathFull; 3785 return RTPathFilename (fname.mutableRaw()); 3786 } 3787 } 3788 3789 /** 3790 * Creates a clone of this hard disk by storing hard disk data in the given 3791 * VDI file name. 3792 * 3793 * @param aId UUID to assign to the created image 3794 * @param aTargetPath VDI file where the cloned image is to be to stored 3795 * @param aProgress progress object to run during operation 3796 */ 3797 HRESULT 3798 HVMDKImage::cloneToImage (const Guid &aId, const Utf8Str &aTargetPath, 3799 Progress *aProgress) 3800 { 3801 ComAssertMsgFailed (("Not implemented")); 3802 return E_NOTIMPL; 3803 3804 /// @todo (r=dmik) later? 3805 // Use code from HVirtualDiskImage::cloneToImage as an example. 3806 } 3807 3808 /** 3809 * Creates a new differencing image for this hard disk with the given 3810 * VDI file name. 3811 * 3812 * @param aId UUID to assign to the created image 3813 * @param aTargetPath VDI file where to store the created differencing image 3814 * @param aProgress progress object to run during operation 3815 * (can be NULL) 3816 */ 3817 HRESULT 3818 HVMDKImage::createDiffImage (const Guid &aId, const Utf8Str &aTargetPath, 3819 Progress *aProgress) 3820 { 3821 ComAssertMsgFailed (("Not implemented")); 3822 return E_NOTIMPL; 3823 3824 /// @todo (r=dmik) later? 3825 // Use code from HVirtualDiskImage::createDiffImage as an example. 3826 } 3827 3828 // private methods 3829 ///////////////////////////////////////////////////////////////////////////// 3830 3831 /** 3832 * Helper to set a new file path. 3833 * Resolves a path relatively to the Virtual Box home directory. 3834 * 3835 * @note 3836 * Must be called from under the object's lock! 3837 */ 3838 HRESULT HVMDKImage::setFilePath (const BSTR aFilePath) 3839 { 3840 if (aFilePath && *aFilePath) 3841 { 3842 /* get the full file name */ 3843 char filePathFull [RTPATH_MAX]; 3844 int vrc = RTPathAbsEx (mVirtualBox->homeDir(), Utf8Str (aFilePath), 3845 filePathFull, sizeof (filePathFull)); 3846 if (VBOX_FAILURE (vrc)) 3847 return setError (E_FAIL, 3848 tr ("Invalid image file path '%ls' (%Vrc)"), aFilePath, vrc); 3849 3850 mFilePath = aFilePath; 3851 mFilePathFull = filePathFull; 3852 } 3853 else 3854 { 3855 mFilePath.setNull(); 3856 mFilePathFull.setNull(); 3857 } 3858 3859 return S_OK; 3860 } 3861 3862 /** 3863 * Helper to query information about the VDI hard disk. 3864 * 3865 * @param aAccessError not used when NULL, otherwise see #getAccessible() 3866 * 3867 * @note Must be called from under the object's lock, only after 3868 * CHECK_BUSY_AND_READERS() succeeds. 3869 */ 3870 HRESULT HVMDKImage::queryInformation (Bstr *aAccessError) 3871 { 3872 AssertReturn (isLockedOnCurrentThread(), E_FAIL); 3873 3874 /* create a lock object to completely release it later */ 3875 AutoLock alock (this); 3876 3877 AssertReturn (mStateCheckWaiters == 0, E_FAIL); 3878 3879 ComAssertRet (mState >= Created, E_FAIL); 3880 3881 HRESULT rc = S_OK; 3882 int vrc = VINF_SUCCESS; 3883 3884 /* lazily create a semaphore */ 3885 vrc = RTSemEventMultiCreate (&mStateCheckSem); 3886 ComAssertRCRet (vrc, E_FAIL); 3887 3888 /* go to Busy state to prevent any concurrent modifications 3889 * after releasing the lock below (to unblock getters before 3890 * a lengthy operation) */ 3891 setBusy(); 3892 3893 alock.leave(); 3894 3895 /* VBoxVHDD management interface needs to be optimized: we're opening a 3896 * file three times in a raw to get three bits of information. */ 3897 3898 Utf8Str filePath = mFilePathFull; 3899 Bstr errMsg; 3900 3901 do 3902 { 3903 /// @todo (r=dmik) implement 3904 // 3905 // /* check the image file */ 3906 // Guid id, parentId; 3907 // vrc = VDICheckImage (filePath, NULL, NULL, NULL, 3908 // id.ptr(), parentId.ptr(), NULL, 0); 3909 // 3910 // if (VBOX_FAILURE (vrc)) 3911 // break; 3912 // 3913 // if (!mId.isEmpty()) 3914 // { 3915 // /* check that the actual UUID of the image matches the stored UUID */ 3916 // if (mId != id) 3917 // { 3918 // errMsg = Utf8StrFmt ( 3919 // tr ("Actual UUID {%Vuuid} of the hard disk image '%s' doesn't " 3920 // "match UUID {%Vuuid} stored in the registry"), 3921 // id.ptr(), filePath.raw(), mId.ptr()); 3922 // break; 3923 // } 3924 // } 3925 // else 3926 // { 3927 // /* assgn an UUID read from the image file */ 3928 // mId = id; 3929 // } 3930 // 3931 // if (mParent) 3932 // { 3933 // /* check parent UUID */ 3934 // AutoLock parentLock (mParent); 3935 // if (mParent->id() != parentId) 3936 // { 3937 // errMsg = Utf8StrFmt ( 3938 // tr ("UUID {%Vuuid} of the parent image '%ls' stored in " 3939 // "the hard disk image file '%s' doesn't match " 3940 // "UUID {%Vuuid} stored in the registry"), 3941 // parentId.raw(), mParent->toString().raw(), 3942 // filePath.raw(), mParent->id().raw()); 3943 // break; 3944 // } 3945 // } 3946 // else if (!parentId.isEmpty()) 3947 // { 3948 // errMsg = Utf8StrFmt ( 3949 // tr ("Hard disk image '%s' is a differencing image that is linked " 3950 // "to a hard disk with UUID {%Vuuid} and cannot be used " 3951 // "directly as a base hard disk"), 3952 // filePath.raw(), parentId.raw()); 3953 // break; 3954 // } 3955 // 3956 // { 3957 // RTFILE file = NIL_RTFILE; 3958 // vrc = RTFileOpen (&file, filePath, RTFILE_O_READ); 3959 // if (VBOX_SUCCESS (vrc)) 3960 // { 3961 // uint64_t size = 0; 3962 // vrc = RTFileGetSize (file, &size); 3963 // if (VBOX_SUCCESS (vrc)) 3964 // mActualSize = size; 3965 // RTFileClose (file); 3966 // } 3967 // if (VBOX_FAILURE (vrc)) 3968 // break; 3969 // } 3970 // 3971 // if (!mParent) 3972 // { 3973 // /* query logical size only for non-differencing images */ 3974 // 3975 // PVDIDISK disk = VDIDiskCreate(); 3976 // vrc = VDIDiskOpenImage (disk, Utf8Str (mFilePathFull), 3977 // VDI_OPEN_FLAGS_READONLY); 3978 // if (VBOX_SUCCESS (vrc)) 3979 // { 3980 // uint64_t size = VDIDiskGetSize (disk); 3981 // /* convert to MBytes */ 3982 // mSize = size / 1024 / 1024; 3983 // } 3984 // 3985 // VDIDiskDestroy (disk); 3986 // if (VBOX_FAILURE (vrc)) 3987 // break; 3988 // } 3989 } 3990 while (0); 3991 3992 /* enter the lock again */ 3993 alock.enter(); 3994 3995 /* remove the busy flag */ 3996 clearBusy(); 3997 3998 if (FAILED (rc) || VBOX_FAILURE (vrc) || !errMsg.isNull()) 3999 { 4000 LogWarningFunc (("'%ls' is not accessible " 4001 "(rc=%08X, vrc=%Vrc, errMsg='%ls')\n", 4002 mFilePathFull.raw(), rc, vrc, errMsg.raw())); 4003 4004 if (aAccessError) 4005 { 4006 if (!errMsg.isNull()) 4007 *aAccessError = errMsg; 4008 else if (VBOX_FAILURE (vrc)) 4009 *aAccessError = Utf8StrFmt ( 4010 tr ("Could not access hard disk image '%ls' (%Vrc)"), 4011 mFilePathFull.raw(), vrc); 4012 } 4013 4014 /* downgrade to not accessible */ 4015 mState = Created; 4016 } 4017 else 4018 { 4019 if (aAccessError) 4020 aAccessError->setNull(); 4021 4022 mState = Accessible; 4023 } 4024 4025 /* inform waiters if there are any */ 4026 if (mStateCheckWaiters > 0) 4027 { 4028 RTSemEventMultiSignal (mStateCheckSem); 4029 } 4030 else 4031 { 4032 /* delete the semaphore ourselves */ 4033 RTSemEventMultiDestroy (mStateCheckSem); 4034 mStateCheckSem = NIL_RTSEMEVENTMULTI; 4035 } 4036 4037 return rc; 4038 } 4039 4040 /** 4041 * Helper to create hard disk images. 4042 * 4043 * @param aSize size in MB 4044 * @param aDynamic dynamic or fixed image 4045 * @param aProgress address of IProgress pointer to return 4046 */ 4047 HRESULT HVMDKImage::createImage (ULONG64 aSize, BOOL aDynamic, 4048 IProgress **aProgress) 4049 { 4050 ComAssertMsgFailed (("Not implemented")); 4051 return E_NOTIMPL; 4052 4053 /// @todo (r=dmik) later? 4054 // Use code from HVirtualDiskImage::createImage as an example. 4055 } 4056 4057 /* static */ 4058 DECLCALLBACK(int) HVMDKImage::vdiTaskThread (RTTHREAD thread, void *pvUser) 4059 { 4060 AssertMsgFailed (("Not implemented")); 4061 return VERR_GENERAL_FAILURE; 4062 4063 /// @todo (r=dmik) later? 4064 // Use code from HVirtualDiskImage::vdiTaskThread as an example. 4065 } -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r749 r953 959 959 } 960 960 961 /// @todo (dmik) later 962 // case HardDiskStorageType_PhysicalVolume: 963 // { 964 // break; 965 // } 961 case HardDiskStorageType_VMDKImage: 962 { 963 ComObjPtr <HVMDKImage> vmdk; 964 vmdk.createObject(); 965 rc = vmdk->init (this, NULL, NULL); 966 hardDisk = vmdk; 967 break; 968 } 969 default: 970 AssertFailed(); 966 971 }; 967 972 973 if (SUCCEEDED (rc)) 974 hardDisk.queryInterfaceTo (aHardDisk); 975 976 return rc; 977 } 978 979 /** @note Locks mSystemProperties object for reading. */ 980 STDMETHODIMP VirtualBox::OpenHardDisk (INPTR BSTR aLocation, IHardDisk **aHardDisk) 981 { 982 /* null and empty strings are not allowed locations */ 983 if (!aLocation || !(*aLocation)) 984 return E_INVALIDARG; 985 986 if (!aHardDisk) 987 return E_POINTER; 988 989 AutoCaller autoCaller (this); 990 CheckComRCReturnRC (autoCaller.rc()); 991 992 /* Currently, the location is always a path. So, append the 993 * default path if only a name is given. */ 994 Bstr location = aLocation; 995 { 996 Utf8Str loc = aLocation; 997 if (!RTPathHavePath (loc)) 998 { 999 AutoLock propsLock (mData.mSystemProperties); 1000 location = Utf8StrFmt ("%ls%c%s", 1001 mData.mSystemProperties->defaultVDIFolder().raw(), 1002 RTPATH_DELIMITER, 1003 loc.raw()); 1004 } 1005 } 1006 1007 ComObjPtr <HardDisk> hardDisk; 1008 HRESULT rc = HardDisk::openHardDisk (this, location, hardDisk); 968 1009 if (SUCCEEDED (rc)) 969 1010 hardDisk.queryInterfaceTo (aHardDisk); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r470 r953 406 406 <interface 407 407 name="IVirtualBoxCallback" extends="$unknown" 408 uuid=" FD443EC1-2007-4F5B-9282-D72760A66916"408 uuid="1293842f-0380-47cf-80b5-e4f821861b26" 409 409 > 410 410 <method name="onMachineStateChange"> … … 483 483 </method> 484 484 485 <method name="onMediaRegistered"> 486 <desc> 487 The given media was registered or unregistered 488 within this VirtualBox installation. 489 490 The @a mediaType parameter describes what type of 491 media the specified @a mediaId refers to. Possible 492 values are: 493 494 - <link to="HardDiskDevice"/>: the media is a hard disk 495 that, if registered, can be obtained using the 496 <link to="IVirtualBox::getHardDisk"/> call. 497 - <link to="DVDDevice"/>: the media is a CD/DVD image 498 that, if registered, can be obtained using the 499 <link to="IVirtualBox::getDVDImage"/> call. 500 - <link to="FloppyDevice"/>: the media is a Floppy image 501 that, if registered, can be obtained using the 502 <link to="IVirtualBox::getFloppyImage"/> call. 503 504 Note that if this is a deregistration notification, 505 there is no way to access the object representing the 506 unregistered media. It is supposed that the 507 application will do required cleanup based on the @a 508 mediaId value. 509 </desc> 510 <param name="mediaId" type="uuid" dir="in"> 511 <desc>ID of the media this event relates to.</desc> 512 </param> 513 <param name="mediaType" type="DeviceType" dir="in"> 514 <desc>Type of the media this event relates to.</desc> 515 </param> 516 <param name="registered" type="boolean" dir="in"> 517 <desc> 518 If true, the media was registered, otherwise it was 519 unregistered. 520 </desc> 521 </param> 522 </method> 523 485 524 <method name="onMachineRegistered"> 486 525 <desc> 487 The given machine was registered within this VirtualBox 488 installation or unregistered, as described by the 489 boolean argument. 526 The given machine was registered or unregistered 527 within this VirtualBox installation. 490 528 </desc> 491 529 <param name="machineId" type="uuid" dir="in"> … … 495 533 <desc> 496 534 If true, the machine was registered, otherwise it was 497 deregistered.535 unregistered. 498 536 </desc> 499 537 </param> … … 567 605 <interface 568 606 name="IVirtualBox" extends="$dispatched" 569 uuid=" E1D95593-F579-4F47-B489-0B67181014E1"607 uuid="00f4e8eb-d737-4c88-9ccb-b434edf8b912" 570 608 > 571 609 <desc> … … 860 898 </param> 861 899 900 </method> 901 902 <method name="openHardDisk"> 903 <desc> 904 905 Opens a hard disk from an existing location. 906 907 This method tries to guess the 908 <link to="HardDiskStorageType">hard disk storage 909 type</link> 910 from the format of the location string and from the 911 contens of the resource the location points 912 to. Currently, a <i>file path</i> is the only supported 913 format for the location string which must point to 914 either a VDI file or to a VMDK file. On success, 915 an IHardDisk object will be returned that also 916 implements the corresponding interface (IVirtualDiskImage 917 or IVMDKImage, respectively). The <link 918 to="IHardDisk::storageType"/> property may also be 919 used to determine the storage type of the returned 920 object (instead of trying to query one of these interfaces). 921 922 <note>The specified file path can be absolute (full path) or 923 relative to the <link to="IVirtualBox::homeFolder"> VirtualBox 924 home directory</link>. If only a file name without any path is 925 given, the <link to="ISystemProperties::defaultVDIFolder"> 926 default VDI folder</link> will be used as a path to the image 927 file.</note> 928 929 The opened hard disk remains unregistered 930 until <link to="#registerHardDisk()"/> is called. 931 932 </desc> 933 934 <param name="location" type="wstring" dir="in"> 935 <desc> 936 Location of the resource that contains a valid hard disk. 937 </desc> 938 </param> 939 <param name="hardDisk" type="IHardDisk" dir="return"> 940 <desc>Opened hard disk object.</desc> 941 </param> 862 942 </method> 863 943 … … 4058 4138 <enum 4059 4139 name="HardDiskStorageType" 4060 uuid=" e45e2303-38fd-4f75-a791-5cb321759f53"4140 uuid="48138584-ad99-479d-a36f-eb82a7663685" 4061 4141 > 4062 4142 <desc> … … 4075 4155 SCSI protocol over a TCP/IP network, see 4076 4156 <link to="IISCSIHardDisk"/>) 4157 </desc> 4158 </const> 4159 <const name="VMDKImage" value="2"> 4160 <desc> 4161 WMware Virtual Machine Disk image (a regular file in the file 4162 system of the host OS, see <link to="IVMDKImage"/>) 4077 4163 </desc> 4078 4164 </const> … … 4178 4264 SCSI protocol over a TCP/IP network link (represented by the 4179 4265 <link to="IISCSIHardDisk"/> interface).</li> 4266 4267 <li><i>WMware VMDK Image</i>, a regular file in the file 4268 system of the host OS (represented by the <link 4269 to="IVMDKImage"/> interface).</li> 4180 4270 4181 4271 </ul> … … 4285 4375 type of the hard disk attached to the virtual machine. This is 4286 4376 explained below. 4377 4378 Note that in the current implementation, only the 4379 <link to="VirtualDiskImage"/> storage type is used to 4380 represent differencing hard disks. In other words, all 4381 differencing hard disks are <link to="IVirtualDiskImage"/> 4382 objects. 4287 4383 4288 4384 <b>Normal Hard Disks</b> … … 4834 4930 to="IHardDisk"/> interface. 4835 4931 4836 The <link to="IHardDisk::description">description</link> the iSCSI 4837 hard disk is stored in the VirtualBox configuration file, so it can 4838 be changed (at appropriate times) even when <link 4839 to="IHardDisk::accessible">accessible</link> returns <tt>false</tt>. 4840 However, the hard disk may not be attached to a running virtual 4841 machine. 4932 The <link to="IHardDisk::description">description</link> 4933 of the iSCSI hard disk is stored in the VirtualBox 4934 configuration file, so it can be changed (at appropriate 4935 times) even when 4936 <link to="IHardDisk::accessible">accessible</link> returns 4937 <tt>false</tt>. However, the hard disk must not be 4938 attached to a running virtual machine. 4842 4939 4843 4940 <note>In the current imlementation, the type of all iSCSI hard disks … … 4900 4997 </desc> 4901 4998 </attribute> 4999 5000 </interface> 5001 5002 <!-- 5003 // IVMDKImage 5004 ///////////////////////////////////////////////////////////////////////// 5005 --> 5006 5007 <interface 5008 name="IVMDKImage" extends="$unknown" 5009 uuid="178398f5-8559-4fee-979e-420af5b53eef" 5010 > 5011 <desc> 5012 5013 The IVMDKImage interface represents <link 5014 to="IHardDisk">virtual hard disks</link> that use 5015 WMware Virtual Machine Disk image files to store hard disk data. 5016 5017 Hard disks using VMDK images can be either opened using 5018 <link to="IVirtualBox::openHardDisk()"/> or created from 5019 scratch using <link to="IVirtualBox::createHardDisk()"/>. 5020 5021 Objects that support this interface also support the <link 5022 to="IHardDisk"/> interface. 5023 5024 When a new hard disk object is created from scatch, an image file 5025 for it is not automatically created. To do it, you need to specify a 5026 valid <link to="#filePath">file path</link>, and call <link 5027 to="#createFixedImage()"/> or <link to="#createDynamicImage()"/>. 5028 When it is done, the hard disk object can be registered by calling 5029 <link to="IVirtualBox::registerHardDisk()"/> and then 5030 <link to="IMachine::attachHardDisk()">attached</link> to 5031 virtual machines. 5032 5033 The <link to="IHardDisk::description">description</link> 5034 of the VMDK hard disk is stored in the VirtualBox 5035 configuration file, so it can be changed (at appropriate 5036 times) even when 5037 <link to="IHardDisk::accessible">accessible</link> returns 5038 <tt>false</tt>. However, the hard disk must not be 5039 attached to a running virtual machine. 5040 5041 <note>In the current imlementation, the type of all VMDK hard disks 5042 is <link to="HardDiskType::WritethroughHardDisk">Writethrough</link> 5043 and cannot be changed.</note> 5044 5045 </desc> 5046 5047 <attribute name="filePath" type="wstring"> 5048 <desc> 5049 5050 Full file name of the VMDK image of this hard disk. For 5051 newly created hard disk objects, this value is <tt>null</tt>. 5052 5053 When assigning a new path, it can be absolute (full path) or 5054 relative to the <link to="IVirtualBox::homeFolder"> VirtualBox 5055 home directory</link>. If only a file name without any path is 5056 given, the <link to="ISystemProperties::defaultVDIFolder"> 5057 default VDI folder</link> will be used as a path to the image 5058 file. 5059 5060 When reading this propery, a full path is always returned. 5061 5062 <note>This property cannot be changed when <link to="#created"/> 5063 returns <tt>true</tt>. In this case, the specified file name can 5064 be absolute (full path) or relative to the <link 5065 to="IVirtualBox::homeFolder"> VirtualBox home directory</link>. 5066 If only a file name without any path is given, the <link 5067 to="ISystemProperties::defaultVDIFolder"> default VDI 5068 folder</link> will be used as a path to the image file.</note> 5069 5070 </desc> 5071 </attribute> 5072 5073 <attribute name="created" type="boolean" readonly="yes"> 5074 <desc> 5075 5076 Whether the virual disk image is created or not. For newly 5077 created hard disk objects or after a successful invocation of 5078 <link to="#deleteImage()"/>, this value is <tt>false</tt> until 5079 <link to="#createFixedImage()"/> or <link 5080 to="#createDynamicImage()"/> is called. 5081 5082 </desc> 5083 </attribute> 5084 5085 <method name="createDynamicImage"> 5086 5087 <desc> 5088 5089 Starts creating a dymically expanding hard disk image in the 5090 background. The previous image associated with this object, if 5091 any, must be deleted using <link to="#deleteImage"/>, otherwise 5092 the operation will fail. 5093 5094 <note>After the returned progress object reports that the 5095 operation is complete, this hard disk object can be 5096 <link to="IVirtualBox::registerHardDisk()">registered</link> 5097 within this VirtualBox installation.</note> 5098 5099 </desc> 5100 5101 <param name="size" type="unsigned long long" dir="in"> 5102 <desc>Maximum logical size of the hard disk in megabytes.</desc> 5103 </param> 5104 <param name="progress" type="IProgress" dir="return"> 5105 <desc>Progress object to track the operation completion.</desc> 5106 </param> 5107 5108 </method> 5109 5110 <method name="createFixedImage"> 5111 <desc> 5112 5113 Starts creating a fixed-size hard disk image in the background. 5114 The previous image, if any, must be deleted using <link 5115 to="#deleteImage"/>, otherwise the operation will fail. 5116 5117 <note>After the returned progress object reports that the 5118 operation is complete, this hard disk object can be 5119 <link to="IVirtualBox::registerHardDisk()">registered</link> 5120 within this VirtualBox installation.</note> 5121 5122 </desc> 5123 5124 <param name="size" type="unsigned long long" dir="in"> 5125 <desc>Logical size of the hard disk in megabytes.</desc> 5126 </param> 5127 <param name="progress" type="IProgress" dir="return"> 5128 <desc>Progress object to track the operation completion.</desc> 5129 </param> 5130 5131 </method> 5132 5133 <method name="deleteImage"> 5134 <desc> 5135 5136 Deletes the existing hard disk image. The hard disk must not be 5137 registered within this VirtualBox installation, otherwise the 5138 operation will fail. 5139 5140 <note>After this operation succeeds, it will be impossible to 5141 register the hard disk until the image file is created 5142 again.</note> 5143 5144 <note>This operation is valid only for non-differencing hard 5145 disks, after they are unregistered using <link 5146 to="IVirtualBox::unregisterHardDisk()"/>.</note> 5147 5148 </desc> 5149 </method> 4902 5150 4903 5151 </interface> -
trunk/src/VBox/Main/include/HardDiskImpl.h
r911 r953 174 174 const Bstr &lastAccessError() const { return mLastAccessError; } 175 175 176 static HRESULT openHardDisk (VirtualBox *aVirtualBox, INPTR BSTR aLocation, 177 ComObjPtr <HardDisk> &hardDisk); 178 176 179 // for VirtualBoxSupportErrorInfoImpl 177 180 static const wchar_t *getComponentName() { return L"HardDisk"; } … … 424 427 }; 425 428 429 //////////////////////////////////////////////////////////////////////////////// 430 431 class ATL_NO_VTABLE HVMDKImage : 432 public HardDisk, 433 public VirtualBoxSupportTranslation <HVMDKImage>, 434 public IVMDKImage 435 { 436 437 public: 438 439 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(HVMDKImage) 440 441 DECLARE_NOT_AGGREGATABLE(HVMDKImage) 442 443 DECLARE_PROTECT_FINAL_CONSTRUCT() 444 445 BEGIN_COM_MAP(HVMDKImage) 446 COM_INTERFACE_ENTRY(ISupportErrorInfo) 447 COM_INTERFACE_ENTRY(IHardDisk) 448 COM_INTERFACE_ENTRY(IVMDKImage) 449 END_COM_MAP() 450 451 NS_DECL_ISUPPORTS 452 453 HRESULT FinalConstruct(); 454 void FinalRelease(); 455 456 // public initializer/uninitializer for internal purposes only 457 458 HRESULT init (VirtualBox *aVirtualBox, HardDisk *aParent, 459 CFGNODE aHDNode, CFGNODE aVMDKNode); 460 HRESULT init (VirtualBox *aVirtualBox, HardDisk *aParent, 461 INPTR BSTR aFilePath, BOOL aRegistered = FALSE); 462 void uninit(); 463 464 // IHardDisk properties 465 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription); 466 STDMETHOD(COMSETTER(Description)) (INPTR BSTR aDescription); 467 STDMETHOD(COMGETTER(Size)) (ULONG64 *aSize); 468 STDMETHOD(COMGETTER(ActualSize)) (ULONG64 *aActualSize); 469 470 // IVirtualDiskImage properties 471 STDMETHOD(COMGETTER(FilePath)) (BSTR *aFilePath); 472 STDMETHOD(COMSETTER(FilePath)) (INPTR BSTR aFilePath); 473 STDMETHOD(COMGETTER(Created)) (BOOL *aCreated); 474 475 // IVirtualDiskImage methods 476 STDMETHOD(CreateDynamicImage) (ULONG64 aSize, IProgress **aProgress); 477 STDMETHOD(CreateFixedImage) (ULONG64 aSize, IProgress **aProgress); 478 STDMETHOD(DeleteImage)(); 479 480 // public methods for internal purposes only 481 482 const Bstr &filePath() const { return mFilePath; } 483 const Bstr &filePathFull() const { return mFilePathFull; } 484 485 HRESULT trySetRegistered (BOOL aRegistered); 486 HRESULT getAccessible (Bstr &aAccessError); 487 488 HRESULT saveSettings (CFGNODE aHDNode, CFGNODE aStorageNode); 489 490 void updatePath (const char *aOldPath, const char *aNewPath); 491 492 Bstr toString (bool aShort = false); 493 494 HRESULT cloneToImage (const Guid &aId, const Utf8Str &aTargetPath, 495 Progress *aProgress); 496 HRESULT createDiffImage (const Guid &aId, const Utf8Str &aTargetPath, 497 Progress *aProgress); 498 499 // for VirtualBoxSupportErrorInfoImpl 500 static const wchar_t *getComponentName() { return L"VMDKImage"; } 501 502 private: 503 504 HRESULT setFilePath (const BSTR aFilePath); 505 HRESULT queryInformation (Bstr *aAccessError); 506 HRESULT createImage (ULONG64 aSize, BOOL aDynamic, IProgress **aProgress); 507 508 /** VDI asynchronous operation thread function */ 509 static DECLCALLBACK(int) vdiTaskThread (RTTHREAD thread, void *pvUser); 510 511 enum State 512 { 513 NotCreated, 514 Created, 515 /* the following must be greater than Created */ 516 Accessible, 517 }; 518 519 State mState; 520 521 RTSEMEVENTMULTI mStateCheckSem; 522 ULONG mStateCheckWaiters; 523 524 Bstr mDescription; 525 526 ULONG64 mSize; 527 ULONG64 mActualSize; 528 529 Bstr mFilePath; 530 Bstr mFilePathFull; 531 532 friend class HardDisk; 533 }; 534 426 535 427 536 COM_DECL_READONLY_ENUM_AND_COLLECTION (HardDisk) -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r606 r953 138 138 139 139 STDMETHOD(CreateHardDisk) (HardDiskStorageType_T aStorageType, IHardDisk **aHardDisk); 140 STDMETHOD(OpenHardDisk) (INPTR BSTR aLocation, IHardDisk **aHardDisk); 140 141 STDMETHOD(OpenVirtualDiskImage) (INPTR BSTR aFilePath, IVirtualDiskImage **aImage); 141 142 STDMETHOD(RegisterHardDisk) (IHardDisk *aHardDisk); -
trunk/src/VBox/Main/linux/server.cpp
r826 r953 120 120 NS_DECL_CLASSINFO(HISCSIHardDisk) 121 121 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(HISCSIHardDisk, IHardDisk, IISCSIHardDisk) 122 NS_DECL_CLASSINFO(HVMDKImage) 123 NS_IMPL_THREADSAFE_ISUPPORTS2_CI(HVMDKImage, IHardDisk, IVMDKImage) 122 124 NS_DECL_CLASSINFO(HardDiskAttachment) 123 125 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(HardDiskAttachment, IHardDiskAttachment)
Note:
See TracChangeset
for help on using the changeset viewer.