Changeset 31568 in vbox for trunk/src/VBox
- Timestamp:
- Aug 11, 2010 1:35:59 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r31542 r31568 1475 1475 { 1476 1476 ComPtr<IMedium> hardDisk; 1477 CHECK_ERROR(aVirtualBox, Open HardDisk(filename, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));1477 CHECK_ERROR(aVirtualBox, OpenMedium(filename, DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam())); 1478 1478 } 1479 1479 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r31562 r31568 454 454 { 455 455 unknown = true; 456 rc = a->virtualBox->Open HardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam());456 rc = a->virtualBox->OpenMedium(Bstr(FilenameOrUuid), DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam()); 457 457 if (rc == VBOX_E_FILE_ERROR) 458 458 { … … 464 464 return 1; 465 465 } 466 CHECK_ERROR(a->virtualBox, Open HardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));466 CHECK_ERROR(a->virtualBox, OpenMedium(Bstr(szFilenameAbs), DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam())); 467 467 } 468 else if (FAILED(rc))469 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));470 468 } 471 469 if (SUCCEEDED(rc) && hardDisk) … … 611 609 if (FAILED (rc)) 612 610 { 613 rc = a->virtualBox->Open HardDisk(src, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam());611 rc = a->virtualBox->OpenMedium(src, DeviceType_HardDisk, AccessMode_ReadWrite, srcDisk.asOutParam()); 614 612 if (rc == VBOX_E_FILE_ERROR) 615 613 { … … 621 619 return 1; 622 620 } 623 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam())); 624 } 625 else if (FAILED(rc)) 626 CHECK_ERROR(a->virtualBox, OpenHardDisk(src, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), srcDisk.asOutParam())); 621 CHECK_ERROR(a->virtualBox, OpenMedium(Bstr(szFilenameAbs), DeviceType_HardDisk, AccessMode_ReadWrite, srcDisk.asOutParam())); 622 } 627 623 if (SUCCEEDED (rc)) 628 624 fSrcUnknown = true; … … 641 637 if (FAILED (rc)) 642 638 { 643 rc = a->virtualBox->Open HardDisk(dst, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), dstDisk.asOutParam());639 rc = a->virtualBox->OpenMedium(dst, DeviceType_HardDisk, AccessMode_ReadWrite, dstDisk.asOutParam()); 644 640 if (rc == VBOX_E_FILE_ERROR) 645 641 { … … 651 647 return 1; 652 648 } 653 CHECK_ERROR_BREAK(a->virtualBox, Open HardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), dstDisk.asOutParam()));649 CHECK_ERROR_BREAK(a->virtualBox, OpenMedium(Bstr(szFilenameAbs), DeviceType_HardDisk, AccessMode_ReadWrite, dstDisk.asOutParam())); 654 650 } 655 else if (FAILED(rc))656 CHECK_ERROR_BREAK(a->virtualBox, OpenHardDisk(dst, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), dstDisk.asOutParam()));657 651 if (SUCCEEDED (rc)) 658 652 fDstUnknown = true; … … 1141 1135 if (FAILED (rc)) 1142 1136 { 1143 rc = a->virtualBox->Open HardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam());1137 rc = a->virtualBox->OpenMedium(Bstr(FilenameOrUuid), DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam()); 1144 1138 if (rc == VBOX_E_FILE_ERROR) 1145 1139 { … … 1151 1145 return 1; 1152 1146 } 1153 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1154 } 1155 else if (FAILED(rc)) 1156 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(FilenameOrUuid), AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam())); 1147 CHECK_ERROR(a->virtualBox, OpenMedium(Bstr(szFilenameAbs), DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam())); 1148 } 1157 1149 if (SUCCEEDED (rc)) 1158 {1159 1150 unknown = true; 1160 }1161 1151 } 1162 1152 do … … 1285 1275 HRESULT rc = S_OK; 1286 1276 int vrc; 1287 enum { 1288 CMD_NONE, 1289 CMD_DISK, 1290 CMD_DVD, 1291 CMD_FLOPPY 1292 } cmd = CMD_NONE; 1277 DeviceType_T devType = DeviceType_Null; 1293 1278 const char *Filename = NULL; 1294 1279 MediumType_T DiskType = MediumType_Normal; … … 1312 1297 { 1313 1298 case 'd': // disk 1314 if ( cmd != CMD_NONE)1299 if (devType != DeviceType_Null) 1315 1300 return errorSyntax(USAGE_OPENMEDIUM, "Only one command can be specified: '%s'", ValueUnion.psz); 1316 cmd = CMD_DISK;1301 devType = DeviceType_HardDisk; 1317 1302 break; 1318 1303 1319 1304 case 'D': // DVD 1320 if ( cmd != CMD_NONE)1305 if (devType != DeviceType_Null) 1321 1306 return errorSyntax(USAGE_OPENMEDIUM, "Only one command can be specified: '%s'", ValueUnion.psz); 1322 cmd = CMD_DVD;1307 devType = DeviceType_DVD; 1323 1308 break; 1324 1309 1325 1310 case 'f': // floppy 1326 if ( cmd != CMD_NONE)1311 if (devType != DeviceType_Null) 1327 1312 return errorSyntax(USAGE_OPENMEDIUM, "Only one command can be specified: '%s'", ValueUnion.psz); 1328 cmd = CMD_FLOPPY;1313 devType = DeviceType_Floppy; 1329 1314 break; 1330 1315 … … 1371 1356 1372 1357 /* check for required options */ 1373 if ( cmd == CMD_NONE)1358 if (devType == DeviceType_Null) 1374 1359 return errorSyntax(USAGE_OPENMEDIUM, "Command variant disk/dvd/floppy required"); 1375 1360 if (!Filename) … … 1383 1368 * cases. This is an ugly hack and needs to be removed whevever we have a 1384 1369 * chance to clean up the API semantics. */ 1385 if (cmd == CMD_DISK) 1386 { 1387 ComPtr<IMedium> hardDisk; 1388 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1389 Bstr ParentIdStr = BstrFmt("%RTuuid", &ParentId); 1390 rc = a->virtualBox->OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam()); 1391 if (rc == VBOX_E_FILE_ERROR) 1392 { 1393 char szFilenameAbs[RTPATH_MAX] = ""; 1394 int irc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1395 if (RT_FAILURE(irc)) 1396 { 1397 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1398 return 1; 1399 } 1400 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(szFilenameAbs), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam())); 1401 } 1402 else if (FAILED(rc)) 1403 CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(Filename), AccessMode_ReadWrite, fSetImageId, ImageIdStr, fSetParentId, ParentIdStr, hardDisk.asOutParam())); 1404 if (SUCCEEDED(rc) && hardDisk) 1405 { 1406 /* change the type if requested */ 1370 1371 ComPtr<IMedium> pMedium; 1372 rc = a->virtualBox->OpenMedium(Bstr(Filename), devType, AccessMode_ReadWrite, pMedium.asOutParam()); 1373 if (rc == VBOX_E_FILE_ERROR) 1374 { 1375 char szFilenameAbs[RTPATH_MAX] = ""; 1376 int irc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1377 if (RT_FAILURE(irc)) 1378 { 1379 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1380 return 1; 1381 } 1382 CHECK_ERROR(a->virtualBox, OpenMedium(Bstr(szFilenameAbs), devType, AccessMode_ReadWrite, pMedium.asOutParam())); 1383 } 1384 if (SUCCEEDED(rc) && pMedium) 1385 { 1386 if (devType == DeviceType_HardDisk) 1387 { 1407 1388 if (DiskType != MediumType_Normal) 1408 1389 { 1409 CHECK_ERROR( hardDisk, COMSETTER(Type)(DiskType));1390 CHECK_ERROR(pMedium, COMSETTER(Type)(DiskType)); 1410 1391 } 1411 1392 } 1412 } 1413 else if (cmd == CMD_DVD) 1414 { 1415 if (fDiskType || fSetParentId) 1416 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD images"); 1417 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1418 ComPtr<IMedium> dvdImage; 1419 rc = a->virtualBox->OpenDVDImage(Bstr(Filename), ImageIdStr, dvdImage.asOutParam()); 1420 if (rc == VBOX_E_FILE_ERROR) 1421 { 1422 char szFilenameAbs[RTPATH_MAX] = ""; 1423 int irc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1424 if (RT_FAILURE(irc)) 1425 { 1426 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1427 return 1; 1428 } 1429 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(szFilenameAbs), ImageIdStr, dvdImage.asOutParam())); 1430 } 1431 else if (FAILED(rc)) 1432 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(Filename), ImageIdStr, dvdImage.asOutParam())); 1433 } 1434 else if (cmd == CMD_FLOPPY) 1435 { 1436 if (fDiskType || fSetImageId || fSetParentId) 1437 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for floppy images"); 1438 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1439 ComPtr<IMedium> floppyImage; 1440 rc = a->virtualBox->OpenFloppyImage(Bstr(Filename), ImageIdStr, floppyImage.asOutParam()); 1441 if (rc == VBOX_E_FILE_ERROR) 1442 { 1443 char szFilenameAbs[RTPATH_MAX] = ""; 1444 int irc = RTPathAbs(Filename, szFilenameAbs, sizeof(szFilenameAbs)); 1445 if (RT_FAILURE(irc)) 1446 { 1447 RTPrintf("Cannot convert filename \"%s\" to absolute path\n", Filename); 1448 return 1; 1449 } 1450 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(szFilenameAbs), ImageIdStr, floppyImage.asOutParam())); 1451 } 1452 else if (FAILED(rc)) 1453 CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(Filename), ImageIdStr, floppyImage.asOutParam())); 1393 else 1394 { 1395 // DVD or floppy image 1396 if (fDiskType || fSetParentId) 1397 return errorSyntax(USAGE_OPENMEDIUM, "Invalid option for DVD and floppy images"); 1398 } 1399 if (fSetImageId || fSetParentId) 1400 { 1401 Bstr ImageIdStr = BstrFmt("%RTuuid", &ImageId); 1402 Bstr ParentIdStr = BstrFmt("%RTuuid", &ParentId); 1403 CHECK_ERROR(pMedium, SetIDs(fSetImageId, ImageIdStr, fSetParentId, ParentIdStr)); 1404 } 1454 1405 } 1455 1406 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r31562 r31568 613 613 614 614 case MODIFYVM_HDA: // deprecated 615 { 615 case MODIFYVM_HDB: // deprecated 616 case MODIFYVM_HDD: // deprecated 617 case MODIFYVM_SATAPORT: // deprecated 618 { 619 uint32_t u1, u2 = 0; 620 Bstr bstrController = L"IDE Controller"; 621 622 switch (c) 623 { 624 case MODIFYVM_HDA: // deprecated 625 u1 = 0; 626 break; 627 628 case MODIFYVM_HDB: // deprecated 629 u1 = 0; 630 u2 = 1; 631 break; 632 633 case MODIFYVM_HDD: // deprecated 634 u1 = 1; 635 u2 = 1; 636 break; 637 638 case MODIFYVM_SATAPORT: // deprecated 639 u1 = GetOptState.uIndex; 640 bstrController = L"SATA"; 641 break; 642 } 643 616 644 if (!strcmp(ValueUnion.psz, "none")) 617 645 { 618 machine->DetachDevice( Bstr("IDE Controller"), 0, 0);646 machine->DetachDevice(bstrController, u1, u2); 619 647 } 620 648 else … … 626 654 /* open the new hard disk object */ 627 655 CHECK_ERROR(a->virtualBox, 628 OpenHardDisk(Bstr(ValueUnion.psz), 629 AccessMode_ReadWrite, false, Bstr(""), 630 false, Bstr(""), hardDisk.asOutParam())); 656 OpenMedium(Bstr(ValueUnion.psz), 657 DeviceType_HardDisk, 658 AccessMode_ReadWrite, 659 hardDisk.asOutParam())); 631 660 } 632 661 if (hardDisk) … … 634 663 Bstr uuid; 635 664 hardDisk->COMGETTER(Id)(uuid.asOutParam()); 636 CHECK_ERROR(machine, AttachDevice( Bstr("IDE Controller"), 0, 0, DeviceType_HardDisk, uuid));665 CHECK_ERROR(machine, AttachDevice(bstrController, u1, u2, DeviceType_HardDisk, uuid)); 637 666 } 638 667 else … … 642 671 } 643 672 644 case MODIFYVM_HDB: // deprecated645 {646 if (!strcmp(ValueUnion.psz, "none"))647 {648 machine->DetachDevice(Bstr("IDE Controller"), 0, 1);649 }650 else651 {652 ComPtr<IMedium> hardDisk;653 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz), DeviceType_HardDisk, hardDisk.asOutParam());654 if (FAILED(rc))655 {656 /* open the new hard disk object */657 CHECK_ERROR(a->virtualBox,658 OpenHardDisk(Bstr(ValueUnion.psz),659 AccessMode_ReadWrite, false, Bstr(""),660 false, Bstr(""), hardDisk.asOutParam()));661 }662 if (hardDisk)663 {664 Bstr uuid;665 hardDisk->COMGETTER(Id)(uuid.asOutParam());666 CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 0, 1, DeviceType_HardDisk, uuid));667 }668 else669 rc = E_FAIL;670 }671 break;672 }673 674 case MODIFYVM_HDD: // deprecated675 {676 if (!strcmp(ValueUnion.psz, "none"))677 {678 machine->DetachDevice(Bstr("IDE Controller"), 1, 1);679 }680 else681 {682 ComPtr<IMedium> hardDisk;683 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz), DeviceType_HardDisk, hardDisk.asOutParam());684 if (FAILED(rc))685 {686 /* open the new hard disk object */687 CHECK_ERROR(a->virtualBox,688 OpenHardDisk(Bstr(ValueUnion.psz),689 AccessMode_ReadWrite, false, Bstr(""),690 false, Bstr(""), hardDisk.asOutParam()));691 }692 if (hardDisk)693 {694 Bstr uuid;695 hardDisk->COMGETTER(Id)(uuid.asOutParam());696 CHECK_ERROR(machine, AttachDevice(Bstr("IDE Controller"), 1, 1, DeviceType_HardDisk, uuid));697 }698 else699 rc = E_FAIL;700 }701 break;702 }703 704 673 case MODIFYVM_IDECONTROLLER: // deprecated 705 674 { … … 745 714 if (SUCCEEDED(rc) && ValueUnion.u32 > 0) 746 715 CHECK_ERROR(SataCtl, COMSETTER(PortCount)(ValueUnion.u32)); 747 break;748 }749 750 case MODIFYVM_SATAPORT: // deprecated751 {752 if (!strcmp(ValueUnion.psz, "none"))753 {754 machine->DetachDevice(Bstr("SATA"), GetOptState.uIndex, 0);755 }756 else757 {758 /* first guess is that it's a UUID */759 ComPtr<IMedium> hardDisk;760 rc = a->virtualBox->FindMedium(Bstr(ValueUnion.psz), DeviceType_HardDisk, hardDisk.asOutParam());761 if (FAILED(rc))762 {763 /* open the new hard disk object */764 CHECK_ERROR(a->virtualBox,765 OpenHardDisk(Bstr(ValueUnion.psz), AccessMode_ReadWrite,766 false, Bstr(""), false,767 Bstr(""), hardDisk.asOutParam()));768 }769 if (hardDisk)770 {771 Bstr uuid;772 hardDisk->COMGETTER(Id)(uuid.asOutParam());773 CHECK_ERROR(machine,774 AttachDevice(Bstr("SATA"), GetOptState.uIndex,775 0, DeviceType_HardDisk, uuid));776 }777 else778 rc = E_FAIL;779 }780 716 break; 781 717 } … … 814 750 /* open the new hard disk object */ 815 751 CHECK_ERROR(a->virtualBox, 816 OpenHardDisk(Bstr(ValueUnion.psz), 817 AccessMode_ReadWrite, false, Bstr(""), 818 false, Bstr(""), hardDisk.asOutParam())); 752 OpenMedium(Bstr(ValueUnion.psz), 753 DeviceType_HardDisk, 754 AccessMode_ReadWrite, 755 hardDisk.asOutParam())); 819 756 } 820 757 if (hardDisk) … … 940 877 /* not registered, do that on the fly */ 941 878 Bstr emptyUUID; 942 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(ValueUnion.psz), 943 emptyUUID, dvdMedium.asOutParam())); 879 CHECK_ERROR(a->virtualBox, 880 OpenMedium(Bstr(ValueUnion.psz), 881 DeviceType_DVD, 882 AccessMode_ReadWrite, 883 dvdMedium.asOutParam())); 944 884 } 945 885 if (!dvdMedium) … … 1007 947 Bstr emptyUUID; 1008 948 CHECK_ERROR(a->virtualBox, 1009 OpenFloppyImage(Bstr(ValueUnion.psz), 1010 emptyUUID, 1011 floppyMedium.asOutParam())); 949 OpenMedium(Bstr(ValueUnion.psz), 950 DeviceType_Floppy, 951 AccessMode_ReadWrite, 952 floppyMedium.asOutParam())); 1012 953 } 1013 954 if (!floppyMedium) -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageStorageController.cpp
r31562 r31568 455 455 /* not registered, do that on the fly */ 456 456 Bstr emptyUUID; 457 CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(pszMedium), 458 emptyUUID, dvdMedium.asOutParam())); 457 CHECK_ERROR(a->virtualBox, 458 OpenMedium(Bstr(pszMedium), 459 DeviceType_DVD, 460 AccessMode_ReadWrite, 461 dvdMedium.asOutParam())); 459 462 } 460 463 if (!dvdMedium) … … 490 493 /* open the new hard disk object */ 491 494 CHECK_ERROR(a->virtualBox, 492 OpenHardDisk(Bstr(pszMedium), 493 AccessMode_ReadWrite, false, Bstr(""), 494 false, Bstr(""), hardDisk.asOutParam())); 495 OpenMedium(Bstr(pszMedium), 496 DeviceType_HardDisk, 497 AccessMode_ReadWrite, 498 hardDisk.asOutParam())); 495 499 } 496 500 … … 540 544 Bstr emptyUUID; 541 545 CHECK_ERROR(a->virtualBox, 542 OpenFloppyImage(Bstr(pszMedium), 543 emptyUUID, 544 floppyMedium.asOutParam())); 546 OpenMedium(Bstr(pszMedium), 547 DeviceType_Floppy, 548 AccessMode_ReadWrite, 549 floppyMedium.asOutParam())); 545 550 } 546 551 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r31562 r31568 1418 1418 /* we've not found the image */ 1419 1419 RTPrintf("Adding hard disk '%S'...\n", hdaFile); 1420 virtualBox->Open HardDisk(hdaFileBstr, AccessMode_ReadWrite, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam());1420 virtualBox->OpenMedium(hdaFileBstr, DeviceType_HardDisk, AccessMode_ReadWrite, hardDisk.asOutParam()); 1421 1421 } 1422 1422 /* do we have the right image now? */ … … 1502 1502 /* try to add to the list */ 1503 1503 RTPrintf("Adding floppy image '%S'...\n", fdaFile); 1504 CHECK_ERROR_BREAK(virtualBox, OpenFloppyImage(medium, Bstr(),1505 1504 CHECK_ERROR_BREAK(virtualBox, 1505 OpenMedium(medium, DeviceType_Floppy, AccessMode_ReadWrite, floppyMedium.asOutParam())); 1506 1506 } 1507 1507 } … … 1587 1587 /* try to add to the list */ 1588 1588 RTPrintf("Adding ISO image '%S'...\n", cdromFile); 1589 CHECK_ERROR_BREAK(virtualBox, OpenDVDImage(medium, Bstr(), 1590 dvdMedium.asOutParam())); 1589 CHECK_ERROR_BREAK(virtualBox, OpenMedium(medium, DeviceType_DVD, AccessMode_ReadWrite, dvdMedium.asOutParam())); 1591 1590 } 1592 1591 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r31070 r31568 1498 1498 } 1499 1499 1500 void VBoxMediaManagerDlg::addMediumToList 1500 void VBoxMediaManagerDlg::addMediumToList(const QString &aLocation, VBoxDefs::MediumType aType) 1501 1501 { 1502 1502 AssertReturnVoid (!aLocation.isEmpty()); 1503 1503 1504 QString uuid;1505 1504 VBoxMedium medium; 1505 KDeviceType devType; 1506 1506 1507 1507 switch (aType) 1508 1508 { 1509 1509 case VBoxDefs::MediumType_HardDisk: 1510 { 1511 CMedium hd = mVBox.OpenHardDisk (aLocation, KAccessMode_ReadWrite, false, "", false, ""); 1512 if (mVBox.isOk()) 1513 medium = VBoxMedium (CMedium (hd), VBoxDefs::MediumType_HardDisk, KMediumState_Created); 1514 break; 1515 } 1510 devType = KDeviceType_HardDisk; 1511 break; 1516 1512 case VBoxDefs::MediumType_DVD: 1517 { 1518 CMedium image = mVBox.OpenDVDImage (aLocation, uuid); 1519 if (mVBox.isOk()) 1520 medium = VBoxMedium (CMedium (image), VBoxDefs::MediumType_DVD, KMediumState_Created); 1521 break; 1522 } 1513 devType = KDeviceType_DVD; 1514 break; 1523 1515 case VBoxDefs::MediumType_Floppy: 1524 { 1525 CMedium image = mVBox.OpenFloppyImage (aLocation, uuid); 1526 if (mVBox.isOk()) 1527 medium = VBoxMedium (CMedium (image), VBoxDefs::MediumType_Floppy, KMediumState_Created); 1528 break; 1529 } 1516 devType = KDeviceType_Floppy; 1517 break; 1530 1518 default: 1531 1519 AssertMsgFailedReturnVoid (("Invalid aType %d\n", aType)); 1532 1520 } 1533 1521 1522 CMedium med = mVBox.OpenMedium(aLocation, devType, KAccessMode_ReadWrite); 1523 if (mVBox.isOk()) 1524 medium = VBoxMedium(CMedium(med), aType, KMediumState_Created); 1525 1534 1526 if (!mVBox.isOk()) 1535 vboxProblem().cannotOpenMedium 1527 vboxProblem().cannotOpenMedium(this, mVBox, aType, aLocation); 1536 1528 else 1537 vboxGlobal().addMedium 1529 vboxGlobal().addMedium(medium); 1538 1530 } 1539 1531 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r31562 r31568 360 360 if (image.isNull()) 361 361 { 362 image = vbox.Open DVDImage(strSource, strUuid);362 image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite); 363 363 if (vbox.isOk()) 364 364 strUuid = image.GetId(); -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r31539 r31568 1342 1342 1343 1343 // First open the existing disk image 1344 rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath), 1345 AccessMode_ReadOnly, 1346 false, 1347 NULL, 1348 false, 1349 NULL, 1350 pSourceHD.asOutParam()); 1344 rc = mVirtualBox->OpenMedium(Bstr(strSrcFilePath), 1345 DeviceType_HardDisk, 1346 AccessMode_ReadOnly, 1347 pSourceHD.asOutParam()); 1351 1348 if (FAILED(rc)) DebugBreakThrow(rc); 1352 1349 fSourceHdNeedsClosing = true; -
trunk/src/VBox/Main/MediumImpl.cpp
r31562 r31568 97 97 hddOpenMode(OpenReadWrite), 98 98 autoReset(false), 99 setImageId(false),100 setParentId(false),101 99 hostDrive(false), 102 100 implicit(false), … … 143 141 144 142 /** the following members are invalid after changing UUID on open */ 145 bool setImageId : 1; 146 bool setParentId : 1; 147 const Guid imageId; 148 const Guid parentId; 143 const Guid uuidImage; 144 const Guid uuidParentImage; 149 145 150 146 bool hostDrive : 1; … … 824 820 * @param enOpenMode Whether to open the medium read/write or read-only. 825 821 * @param aDeviceType Device type of medium. 826 * @param aSetImageId Whether to set the medium UUID or not.827 * @param aImageId New medium UUID if @aSetId is true. Empty string means828 * create a new UUID, and a zero UUID is invalid.829 * @param aSetParentId Whether to set the parent UUID or not.830 * @param aParentId New parent UUID if @aSetParentId is true. Empty string831 * means create a new UUID, and a zero UUID is valid.832 822 */ 833 823 HRESULT Medium::init(VirtualBox *aVirtualBox, 834 824 const Utf8Str &aLocation, 835 825 HDDOpenMode enOpenMode, 836 DeviceType_T aDeviceType, 837 BOOL aSetImageId, 838 const Guid &aImageId, 839 BOOL aSetParentId, 840 const Guid &aParentId) 826 DeviceType_T aDeviceType) 841 827 { 842 828 AssertReturn(aVirtualBox, E_INVALIDARG); … … 870 856 if (FAILED(rc)) return rc; 871 857 872 /* save the new uuid values, will be used by queryInfo() */873 m->setImageId = !!aSetImageId;874 unconst(m->imageId) = aImageId;875 m->setParentId = !!aSetParentId;876 unconst(m->parentId) = aParentId;877 878 858 /* get all the information about the medium from the storage unit */ 879 rc = queryInfo( );859 rc = queryInfo(false /* fSetImageId */, false /* fSetParentId */); 880 860 881 861 if (SUCCEEDED(rc)) … … 1655 1635 } 1656 1636 1637 STDMETHODIMP Medium::SetIDs(BOOL aSetImageId, 1638 IN_BSTR aImageId, 1639 BOOL aSetParentId, 1640 IN_BSTR aParentId) 1641 { 1642 AutoCaller autoCaller(this); 1643 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1644 1645 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1646 1647 Guid imageId, parentId; 1648 if (aSetImageId) 1649 { 1650 imageId = Guid(aImageId); 1651 if (imageId.isEmpty()) 1652 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1653 } 1654 if (aSetParentId) 1655 parentId = Guid(aParentId); 1656 1657 unconst(m->uuidImage) = imageId; 1658 unconst(m->uuidParentImage) = parentId; 1659 1660 HRESULT rc = queryInfo(!!aSetImageId /* fSetImageId */, 1661 !!aSetParentId /* fSetParentId */); 1662 1663 return rc; 1664 } 1665 1657 1666 STDMETHODIMP Medium::RefreshState(MediumState_T *aState) 1658 1667 { … … 1673 1682 case MediumState_LockedRead: 1674 1683 { 1675 rc = queryInfo( );1684 rc = queryInfo(false /* fSetImageId */, false /* fSetParentId */); 1676 1685 break; 1677 1686 } … … 3437 3446 * for the first time). Locks mParent for reading. Locks this object for 3438 3447 * writing. 3439 */ 3440 HRESULT Medium::queryInfo() 3448 * 3449 * @param fSetImageId Whether to reset the UUID contained in the image file to the UUID in the medium instance data (see SetIDs()) 3450 * @param fSetParentId Whether to reset the parent UUID contained in the image file to the parent UUID in the medium instance data (see SetIDs()) 3451 * @return 3452 */ 3453 HRESULT Medium::queryInfo(bool fSetImageId, bool fSetParentId) 3441 3454 { 3442 3455 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 3550 3563 /* Modify the UUIDs if necessary. The associated fields are 3551 3564 * not modified by other code, so no need to copy. */ 3552 if ( m->setImageId)3565 if (fSetImageId) 3553 3566 { 3554 vrc = VDSetUuid(hdd, 0, m-> imageId);3567 vrc = VDSetUuid(hdd, 0, m->uuidImage); 3555 3568 ComAssertRCThrow(vrc, E_FAIL); 3556 3569 } 3557 if ( m->setParentId)3570 if (fSetParentId) 3558 3571 { 3559 vrc = VDSetParentUuid(hdd, 0, m-> parentId);3572 vrc = VDSetParentUuid(hdd, 0, m->uuidParentImage); 3560 3573 ComAssertRCThrow(vrc, E_FAIL); 3561 3574 } 3562 3575 /* zap the information, these are no long-term members */ 3563 m->setImageId = false; 3564 unconst(m->imageId).clear(); 3565 m->setParentId = false; 3566 unconst(m->parentId).clear(); 3576 unconst(m->uuidImage).clear(); 3577 unconst(m->uuidParentImage).clear(); 3567 3578 3568 3579 /* check the UUID */ … … 3603 3614 if (isImport) 3604 3615 { 3605 if ( m->setImageId)3606 mediumId = m-> imageId;3616 if (fSetImageId) 3617 mediumId = m->uuidImage; 3607 3618 else 3608 3619 mediumId.create(); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31562 r31568 1404 1404 } 1405 1405 1406 STDMETHODIMP VirtualBox::OpenHardDisk(IN_BSTR aLocation, 1407 AccessMode_T accessMode, 1408 BOOL aSetImageId, 1409 IN_BSTR aImageId, 1410 BOOL aSetParentId, 1411 IN_BSTR aParentId, 1412 IMedium **aHardDisk) 1406 STDMETHODIMP VirtualBox::OpenMedium(IN_BSTR aLocation, 1407 DeviceType_T deviceType, 1408 AccessMode_T accessMode, 1409 IMedium **aMedium) 1413 1410 { 1414 1411 CheckComArgStrNotEmptyOrNull(aLocation); 1415 CheckComArgOutSafeArrayPointerValid(a HardDisk);1412 CheckComArgOutSafeArrayPointerValid(aMedium); 1416 1413 1417 1414 AutoCaller autoCaller(this); … … 1419 1416 1420 1417 /* we don't access non-const data members so no need to lock */ 1421 1422 1418 HRESULT rc = E_FAIL; 1423 1419 1424 ComObjPtr<Medium> hardDisk; 1425 hardDisk.createObject(); 1426 Guid imageId, parentId; 1427 if (aSetImageId) 1428 { 1429 imageId = Guid(aImageId); 1430 if (imageId.isEmpty()) 1431 return setError(E_INVALIDARG, tr("Argument %s is empty"), "aImageId"); 1432 } 1433 if (aSetParentId) 1434 parentId = Guid(aParentId); 1435 rc = hardDisk->init(this, 1436 aLocation, 1437 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1438 DeviceType_HardDisk, 1439 aSetImageId, 1440 imageId, 1441 aSetParentId, 1442 parentId); 1420 switch (deviceType) 1421 { 1422 case DeviceType_HardDisk: 1423 case DeviceType_Floppy: 1424 break; 1425 1426 case DeviceType_DVD: 1427 accessMode = AccessMode_ReadOnly; 1428 break; 1429 1430 default: 1431 return setError(E_INVALIDARG, "Device type must be HardDisk, DVD or Floppy"); 1432 } 1433 1434 ComObjPtr<Medium> pMedium; 1435 pMedium.createObject(); 1436 rc = pMedium->init(this, 1437 aLocation, 1438 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1439 deviceType); 1443 1440 1444 1441 if (SUCCEEDED(rc)) 1445 1442 { 1446 bool fNeedsSaveSettings = false; 1447 { 1448 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1449 rc = registerHardDisk(hardDisk, &fNeedsSaveSettings); 1450 } 1443 bool fNeedsGlobalSaveSettings = false; 1444 1445 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1446 1447 switch (deviceType) 1448 { 1449 case DeviceType_HardDisk: 1450 rc = registerHardDisk(pMedium, &fNeedsGlobalSaveSettings); 1451 break; 1452 1453 case DeviceType_DVD: 1454 case DeviceType_Floppy: 1455 rc = registerImage(pMedium, deviceType, &fNeedsGlobalSaveSettings); 1456 break; 1457 } 1458 1459 treeLock.release(); 1451 1460 1452 1461 /* Note that it's important to call uninit() on failure to register … … 1455 1464 1456 1465 if (SUCCEEDED(rc)) 1457 hardDisk.queryInterfaceTo(aHardDisk);1466 pMedium.queryInterfaceTo(aMedium); 1458 1467 else 1459 hardDisk->uninit();1460 1461 if (fNeeds SaveSettings)1468 pMedium->uninit(); 1469 1470 if (fNeedsGlobalSaveSettings) 1462 1471 { 1463 1472 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS); … … 1508 1517 /* the below will set *aHardDisk to NULL if hardDisk is null */ 1509 1518 pMedium.queryInterfaceTo(aMedium); 1510 1511 return rc;1512 }1513 1514 /** @note Doesn't lock anything. */1515 STDMETHODIMP VirtualBox::OpenDVDImage(IN_BSTR aLocation,1516 IN_BSTR aId,1517 IMedium **aDVDImage)1518 {1519 CheckComArgStrNotEmptyOrNull(aLocation);1520 CheckComArgOutSafeArrayPointerValid(aDVDImage);1521 1522 AutoCaller autoCaller(this);1523 if (FAILED(autoCaller.rc())) return autoCaller.rc();1524 1525 HRESULT rc = VBOX_E_FILE_ERROR;1526 1527 Guid id(aId);1528 /* generate an UUID if not specified */1529 if (id.isEmpty())1530 id.create();1531 1532 ComObjPtr<Medium> image;1533 image.createObject();1534 rc = image->init(this,1535 aLocation,1536 Medium::OpenReadOnly,1537 DeviceType_DVD,1538 true /* aSetImageId */,1539 id,1540 false /* aSetParentId */,1541 Guid());1542 if (SUCCEEDED(rc))1543 {1544 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);1545 bool fNeedsSaveSettings = false;1546 rc = registerImage(image, DeviceType_DVD, &fNeedsSaveSettings);1547 treeLock.release();1548 1549 if (SUCCEEDED(rc))1550 image.queryInterfaceTo(aDVDImage);1551 1552 if (fNeedsSaveSettings)1553 {1554 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);1555 saveSettings();1556 }1557 }1558 1559 return rc;1560 }1561 1562 /** @note Doesn't lock anything. */1563 STDMETHODIMP VirtualBox::OpenFloppyImage(IN_BSTR aLocation,1564 IN_BSTR aId,1565 IMedium **aFloppyImage)1566 {1567 CheckComArgStrNotEmptyOrNull(aLocation);1568 CheckComArgOutSafeArrayPointerValid(aFloppyImage);1569 1570 AutoCaller autoCaller(this);1571 if (FAILED(autoCaller.rc())) return autoCaller.rc();1572 1573 HRESULT rc = VBOX_E_FILE_ERROR;1574 1575 Guid id(aId);1576 /* generate an UUID if not specified */1577 if (id.isEmpty())1578 id.create();1579 1580 ComObjPtr<Medium> image;1581 image.createObject();1582 rc = image->init(this,1583 aLocation,1584 Medium::OpenReadWrite,1585 DeviceType_Floppy,1586 true /* aSetImageId */,1587 id,1588 false /* aSetParentId */,1589 Guid());1590 if (SUCCEEDED(rc))1591 {1592 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);1593 bool fNeedsSaveSettings = false;1594 rc = registerImage(image, DeviceType_Floppy, &fNeedsSaveSettings);1595 treeLock.release();1596 1597 if (SUCCEEDED(rc))1598 image.queryInterfaceTo(aFloppyImage);1599 1600 if (fNeedsSaveSettings)1601 {1602 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS);1603 saveSettings();1604 }1605 }1606 1519 1607 1520 return rc; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31562 r31568 1806 1806 </method> 1807 1807 1808 <method name="openHardDisk"> 1809 <desc> 1810 Opens a medium from an existing location, optionally replacing 1811 the image UUID and/or parent UUID. 1812 1813 After the medium is successfully opened by this method, it gets 1814 remembered by (known to) this VirtualBox installation and will be 1815 accessible through the <link to="#findMedium"/> method. Remembered base media 1816 are also returned as part of the <link to="#hardDisks"/> array and can 1817 be attached to virtual machines. See <link to="IMedium" /> for more details. 1818 1819 If a differencing medium is to be opened by this method, the 1808 <method name="openMedium"> 1809 <desc> 1810 Opens a medium from an existing storage location. 1811 1812 Once a medium has been opened, VirtualBox saves the medium in a media 1813 registry. Prior to VirtualBox 3.3, this registry had to be the global 1814 media registry in the VirtualBox.xml file, which was shared between 1815 all machines and made transporting machines from one host to another 1816 difficult. Now you can optionally specify an <link to="IMachine" /> 1817 instance, in which case the medium will be remembered in that machine's 1818 registry. This is the recommended procedure for machines created with 1819 VirtualBox 3.3 or later. <i>(not yet implemented)</i> 1820 1821 Depending on the given device type, the file at the storage location 1822 must be in one of the media formats understood by VirtualBox: 1823 1824 <ul> 1825 <li>With a "HardDisk" device type, the file must be a hard disk image 1826 in one of the formats supported by VirtualBox (see 1827 <link to="ISystemProperties::mediumFormats" />). 1828 After this method succeeds, if the medium is a base medium, it 1829 will be added to the <link to="#hardDisks"/> array attribute. </li> 1830 <li>With a "DVD" device type, the file must be an ISO 9960 CD/DVD image. 1831 After this method succeeds, the medium will be added to the 1832 <link to="#DVDImages"/> array attribute.</li> 1833 <li>With a "Floppy" device type, the file must be an RAW floppy image. 1834 After this method succeeds, the medium will be added to the 1835 <link to="#floppyImages"/> array attribute.</li> 1836 </ul> 1837 1838 After having been opened, the medium can be found by the <link to="#findMedium"/> 1839 method and can be attached to virtual machines. See <link to="IMedium" /> for more details. 1840 1841 The UUID of the newly opened medium will either be retrieved from the 1842 storage location, if the format supports it (e.g. for hard disk images), 1843 or a new UUID will be randomly generated (e.g. for ISO and RAW files). 1844 If for some reason you need to change the medium's UUID, use 1845 <link to="IMedium::setIDs" />. 1846 1847 If a differencing hard disk medium is to be opened by this method, the 1820 1848 operation will succeed only if its parent medium and all ancestors, 1821 1849 if any, are already known to this VirtualBox installation (for example, 1822 1850 were opened by this method before). 1823 1851 1824 This method tries to guess the storage format of the specified medium1852 This method attempts to guess the storage format of the specified medium 1825 1853 by reading medium data at the specified location. 1826 1854 1827 If @a accessMode is ReadWrite (which it should be), the image is opened 1828 for read/write access and must have according permissions, as VirtualBox 1829 may actually write status information into the disk's metadata sections. 1830 1831 Note that write access is required for all typical image usage in VirtualBox, 1855 If @a accessMode is ReadWrite (which it should be for hard disks and floppies), 1856 the image is opened for read/write access and must have according permissions, 1857 as VirtualBox may actually write status information into the disk's metadata 1858 sections. 1859 1860 Note that write access is required for all typical hard disk usage in VirtualBox, 1832 1861 since VirtualBox may need to write metadata such as a UUID into the image. 1833 1862 The only exception is opening a source image temporarily for copying and 1834 cloning when the image will quickly be closed again. 1835 1836 Note that the format of the location string is storage format specific. 1837 See <link to="IMedium::location"/>, IMedium and 1863 cloning (see <link to="IMedium::cloneTo" /> when the image will be closed 1864 again soon. 1865 1866 The format of the location string is storage format specific. See 1867 <link to="IMedium::location"/>, IMedium and 1838 1868 <link to="ISystemProperties::defaultHardDiskFolder"/> for more details. 1839 1869 … … 1848 1878 Invalid medium storage format. 1849 1879 </result> 1850 1880 <result name="VBOX_E_INVALID_OBJECT_STATE"> 1881 Medium has already been added to a media registry. 1882 </result> 1851 1883 </desc> 1852 1884 <param name="location" type="wstring" dir="in"> … … 1856 1888 </desc> 1857 1889 </param> 1890 <param name="deviceType" type="DeviceType" dir="in"> 1891 <desc> 1892 Must be one of "HardDisk", "DVD" or "Floppy". 1893 </desc> 1894 </param> 1858 1895 <param name="accessMode" type="AccessMode" dir="in"> 1859 <desc> 1860 Determines whether to open the image in read/write or read-only mode. 1861 </desc> 1862 </param> 1863 <param name="setImageId" type="boolean" dir="in"> 1864 <desc> 1865 Select whether a new image UUID is set or not. 1866 </desc> 1867 </param> 1868 <param name="imageId" type="uuid" mod="string" dir="in"> 1869 <desc> 1870 New UUID for the image. If an empty string is passed, then a new 1871 UUID is automatically created. Specifying a zero UUIDs is not valid. 1872 </desc> 1873 </param> 1874 <param name="setParentId" type="boolean" dir="in"> 1875 <desc> 1876 Select whether a new parent UUID is set or not. 1877 </desc> 1878 </param> 1879 <param name="parentId" type="uuid" mod="string" dir="in"> 1880 <desc> 1881 New parent UUID for the image. If an empty string is passed, then a 1882 new UUID is automatically created, provided @a setParentId is 1883 @c true. A zero UUID is valid. 1884 </desc> 1896 <desc>Whether to open the image in read/write or read-only mode. For 1897 a "DVD" device type, this is ignored and read-only mode is always assumed.</desc> 1885 1898 </param> 1886 1899 <param name="medium" type="IMedium" dir="return"> … … 1896 1909 The given medium must be known to this VirtualBox installation, i.e. 1897 1910 it must be previously created by <link to="#createHardDisk"/> or opened 1898 by <link to="#openHardDisk"/> or <link to="#openDVDImage" /> or 1899 <link to="#openFloppyImage" />. 1911 by <link to="#openMedium"/>. 1900 1912 1901 1913 The search is done by comparing the value of the @a location argument to … … 1924 1936 <param name="medium" type="IMedium" dir="return"> 1925 1937 <desc>Medium object, if found.</desc> 1926 </param>1927 </method>1928 1929 <method name="openDVDImage">1930 <desc>1931 Opens a CD/DVD image contained in the specified file of the supported1932 format and assigns it the given UUID.1933 1934 After the image is successfully opened by this method, it gets1935 remembered by (known to) this VirtualBox installation and will be1936 accessible through the <link to="#findMedium"/> method.1937 Remembered images are also returned as part of the <link to="#DVDImages"/>1938 array and can be mounted to virtual machines. See <link to="IMedium" />1939 for more details.1940 1941 See <link to="IMedium::location"/> to get more details about the format1942 of the location string.1943 1944 <note>1945 Currently only ISO 9960 CD/DVD images are supported by VirtualBox.1946 </note>1947 1948 <result name="VBOX_E_FILE_ERROR">1949 Invalid CD/DVD image file location or could not find the CD/DVD1950 image at the specified location.1951 </result>1952 <result name="VBOX_E_INVALID_OBJECT_STATE">1953 CD/DVD image already exists in the media registry.1954 </result>1955 1956 </desc>1957 <param name="location" type="wstring" dir="in">1958 <desc>1959 Full path to the file that contains a valid CD/DVD image.1960 </desc>1961 </param>1962 <param name="id" type="uuid" mod="string" dir="in">1963 <desc>1964 UUID to assign to the given image within this VirtualBox installation.1965 If an empty (@c null) UUID is specified, the system will randomly1966 generate a new UUID.1967 </desc>1968 </param>1969 <param name="image" type="IMedium" dir="return">1970 <desc>Opened CD/DVD image object.</desc>1971 </param>1972 </method>1973 1974 <method name="openFloppyImage">1975 <desc>1976 Opens a floppy image contained in the specified file of the supported1977 format and assigns it the given UUID.1978 1979 After the image is successfully opened by this method, it gets1980 remembered by (known to) this VirtualBox installation and will be1981 accessible through the <link to="#findMedium"/> method.1982 Remembered images are also returned as part of the <link to="#floppyImages"/>1983 array and can be mounted to virtual machines. See <link to="IMedium" />1984 for more details.1985 1986 See <link to="IMedium::location"/> to get more details about the format1987 of the location string.1988 1989 <result name="VBOX_E_FILE_ERROR">1990 Invalid floppy image file location or could not find the floppy1991 image at the specified location.1992 </result>1993 <result name="VBOX_E_INVALID_OBJECT_STATE">1994 Floppy image already exists in the media registry.1995 </result>1996 1997 <note>1998 Currently, only raw floppy images are supported by VirtualBox.1999 </note>2000 </desc>2001 <param name="location" type="wstring" dir="in">2002 <desc>2003 Full path to the file that contains a valid floppy image.2004 </desc>2005 </param>2006 <param name="id" type="uuid" mod="string" dir="in">2007 <desc>2008 UUID to assign to the given image file within this VirtualBox2009 installation. If an empty (@c null) UUID is specified, the system will2010 randomly generate a new UUID.2011 </desc>2012 </param>2013 <param name="image" type="IMedium" dir="return">2014 <desc>Opened floppy image object.</desc>2015 1938 </param> 2016 1939 </method> … … 7342 7265 IMedium, 7343 7266 <link to="IVirtualBox::createHardDisk"/>, 7344 <link to="IVirtualBox::open HardDisk"/>,7267 <link to="IVirtualBox::openMedium"/>, 7345 7268 <link to="IMedium::location"/> 7346 7269 </see> … … 8554 8477 </ul> 8555 8478 8556 Existing media are opened using the following methods, depending on the 8557 media type: 8558 <ul> 8559 <li><link to="IVirtualBox::openHardDisk"/></li> 8560 <li><link to="IVirtualBox::openDVDImage"/></li> 8561 <li><link to="IVirtualBox::openFloppyImage"/></li> 8562 </ul> 8563 8564 New hard disk media can be created with the VirtualBox API using the 8479 Existing media are opened using <link to="IVirtualBox::openMedium"/>; 8480 new hard disk media can be created with the VirtualBox API using the 8565 8481 <link to="IVirtualBox::createHardDisk"/> method. 8566 8482 … … 8653 8569 New base hard disks are created using 8654 8570 <link to="IVirtualBox::createHardDisk"/>. Existing hard disks are 8655 opened using <link to="IVirtualBox::open HardDisk"/>. Differencing hard8571 opened using <link to="IVirtualBox::openMedium"/>. Differencing hard 8656 8572 disks are usually implicitly created by VirtualBox when needed but may 8657 8573 also be created explicitly using <link to="#createDiffStorage"/>. … … 9169 9085 </attribute> 9170 9086 9087 <method name="setIDs"> 9088 <desc> 9089 Changes the UUID and parent UUID for a hard disk medium. 9090 </desc> 9091 <param name="setImageId" type="boolean" dir="in"> 9092 <desc> 9093 Select whether a new image UUID is set or not. 9094 </desc> 9095 </param> 9096 <param name="imageId" type="uuid" mod="string" dir="in"> 9097 <desc> 9098 New UUID for the image. If an empty string is passed, then a new 9099 UUID is automatically created, provided that @a setImageId is @c true. 9100 Specifying a zero UUID is not allowed. 9101 </desc> 9102 </param> 9103 <param name="setParentId" type="boolean" dir="in"> 9104 <desc> 9105 Select whether a new parent UUID is set or not. 9106 </desc> 9107 </param> 9108 <param name="parentId" type="uuid" mod="string" dir="in"> 9109 <desc> 9110 New parent UUID for the image. If an empty string is passed, then a 9111 new UUID is automatically created, provided @a setParentId is 9112 @c true. A zero UUID is valid. 9113 </desc> 9114 </param> 9115 <result name="E_INVALIDARG"> 9116 Invalid parameter combination. 9117 </result> 9118 <result name="VBOX_E_NOT_SUPPORTED"> 9119 Medium is not a hard disk medium. 9120 </result> 9121 </method> 9122 9171 9123 <method name="refreshState"> 9172 9124 <desc> … … 9397 9349 operation will fail. 9398 9350 9399 When the medium is successfully closed, it gets removed from9400 the list of re membered media, but its storage unit is not9401 deleted. In particular, this means that this medium can be9402 later opened again using the <link9403 to="IVirtualBox::openHardDisk"/>call.9351 When the medium is successfully closed, it is removed from 9352 the list of registered media, but its storage unit is not 9353 deleted. In particular, this means that this medium can 9354 later be opened again using the <link to="IVirtualBox::openMedium"/> 9355 call. 9404 9356 9405 9357 Note that after this method successfully returns, the given medium -
trunk/src/VBox/Main/include/MediumImpl.h
r31482 r31568 79 79 const Utf8Str &aLocation, 80 80 HDDOpenMode enOpenMode, 81 DeviceType_T aDeviceType, 82 BOOL aSetImageId, 83 const Guid &aImageId, 84 BOOL aSetParentId, 85 const Guid &aParentId); 81 DeviceType_T aDeviceType); 86 82 87 83 // initializer used when loading settings … … 129 125 130 126 // IMedium methods 127 STDMETHOD(SetIDs)(BOOL aSetImageId, IN_BSTR aImageId, 128 BOOL aSetParentId, IN_BSTR aParentId); 131 129 STDMETHOD(RefreshState)(MediumState_T *aState); 132 130 STDMETHOD(GetSnapshotIds)(IN_BSTR aMachineId, … … 245 243 private: 246 244 247 HRESULT queryInfo( );245 HRESULT queryInfo(bool fSetImageId, bool fSetParentId); 248 246 249 247 HRESULT canClose(); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31562 r31568 132 132 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation, 133 133 IMedium **aHardDisk); 134 STDMETHOD(OpenHardDisk) (IN_BSTR aLocation, AccessMode_T accessMode, 135 BOOL aSetImageId, IN_BSTR aImageId, 136 BOOL aSetParentId, IN_BSTR aParentId, 137 IMedium **aHardDisk); 138 STDMETHOD(FindMedium) (IN_BSTR aLocation, DeviceType_T deviceType, IMedium **aMedium); 139 140 STDMETHOD(OpenDVDImage) (IN_BSTR aLocation, IN_BSTR aId, 141 IMedium **aDVDImage); 142 STDMETHOD(OpenFloppyImage) (IN_BSTR aLocation, IN_BSTR aId, 143 IMedium **aFloppyImage); 134 STDMETHOD(OpenMedium)(IN_BSTR aLocation, 135 DeviceType_T deviceType, 136 AccessMode_T accessMode, 137 IMedium **aMedium); 138 STDMETHOD(FindMedium)(IN_BSTR aLocation, 139 DeviceType_T deviceType, 140 IMedium **aMedium); 144 141 145 142 STDMETHOD(GetGuestOSType) (IN_BSTR aId, IGuestOSType **aType); -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r31070 r31568 356 356 */ 357 357 nsCOMPtr<IMedium> dvdImage; 358 359 rc = virtualBox->OpenDVDImage(NS_LITERAL_STRING("/home/vbox/isos/winnt4ger.iso").get(),360 nsnull, /* NULL UUID, i.e. a new one will be created */361 358 rc = virtualBox->OpenMedium(NS_LITERAL_STRING("/home/vbox/isos/winnt4ger.iso").get(), 359 DeviceType_DVD, 360 AccessMode_ReadOnly, 361 getter_AddRefs(dvdImage)); 362 362 if (NS_FAILED(rc)) 363 {364 363 printf("Error: could not open CD image! rc=%08X\n", rc); 365 }366 364 else 367 365 {
Note:
See TracChangeset
for help on using the changeset viewer.