- Timestamp:
- Nov 2, 2010 2:23:20 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r33567 r33691 1425 1425 /* we don't access non-const data members so no need to lock */ 1426 1426 1427 // check if the device type is correct, and see if a medium for the 1428 // given path has already initialized; if so, return that 1427 1429 switch (deviceType) 1428 1430 { 1429 1431 case DeviceType_HardDisk: 1432 findHardDiskByLocation(aLocation, 1433 false, /* aSetError */ 1434 &pMedium); 1435 break; 1436 1430 1437 case DeviceType_Floppy: 1431 break;1432 1433 1438 case DeviceType_DVD: 1434 accessMode = AccessMode_ReadOnly; 1439 findDVDOrFloppyImage(deviceType, 1440 NULL, /* guid */ 1441 aLocation, 1442 false, /* aSetError */ 1443 &pMedium); 1444 1445 // enforce read-only for DVDs even if caller specified ReadWrite 1446 if (deviceType == DeviceType_DVD) 1447 accessMode = AccessMode_ReadOnly; 1435 1448 break; 1436 1449 … … 1439 1452 } 1440 1453 1441 pMedium.createObject(); 1442 HRESULT rc = pMedium->init(this, 1443 aLocation, 1444 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1445 deviceType); 1446 1447 if (SUCCEEDED(rc)) 1448 { 1449 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1450 1451 switch (deviceType) 1452 { 1453 case DeviceType_HardDisk: 1454 rc = registerHardDisk(pMedium, 1455 &fNeedsGlobalSaveSettings); 1456 break; 1457 1458 case DeviceType_DVD: 1459 case DeviceType_Floppy: 1460 rc = registerImage(pMedium, 1461 deviceType, 1462 &fNeedsGlobalSaveSettings); 1463 break; 1464 } 1465 1466 treeLock.release(); 1467 1468 /* Note that it's important to call uninit() on failure to register 1469 * because the differencing hard disk would have been already associated 1470 * with the parent and this association needs to be broken. */ 1471 1472 if (FAILED(rc)) 1473 pMedium->uninit(); 1454 HRESULT rc = S_OK; 1455 1456 if (pMedium.isNull()) 1457 { 1458 pMedium.createObject(); 1459 rc = pMedium->init(this, 1460 aLocation, 1461 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1462 deviceType); 1463 1464 if (SUCCEEDED(rc)) 1465 { 1466 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1467 1468 switch (deviceType) 1469 { 1470 case DeviceType_HardDisk: 1471 rc = registerHardDisk(pMedium, 1472 &fNeedsGlobalSaveSettings); 1473 break; 1474 1475 case DeviceType_DVD: 1476 case DeviceType_Floppy: 1477 rc = registerImage(pMedium, 1478 deviceType, 1479 &fNeedsGlobalSaveSettings); 1480 break; 1481 } 1482 1483 treeLock.release(); 1484 1485 /* Note that it's important to call uninit() on failure to register 1486 * because the differencing hard disk would have been already associated 1487 * with the parent and this association needs to be broken. */ 1488 1489 if (FAILED(rc)) 1490 pMedium->uninit(); 1491 } 1474 1492 } 1475 1493
Note:
See TracChangeset
for help on using the changeset viewer.