Changeset 53354 in vbox
- Timestamp:
- Nov 19, 2014 6:32:03 PM (10 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r51889 r53354 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 481 481 { "clonevm", USAGE_CLONEVM, handleCloneVM }, 482 482 { "hdproperty", USAGE_HDPROPERTY, handleMediumProperty }, 483 { "createdvd", USAGE_CREATEDVD, handleCreateDVD }, 484 { "createfloppy", USAGE_CREATEFLOPPY, handleCreateFloppy }, 483 485 { "createhd", USAGE_CREATEHD, handleCreateHardDisk }, 484 486 { "createvdi", USAGE_CREATEHD, handleCreateHardDisk }, /* backward compatibility */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r53266 r53354 5 5 6 6 /* 7 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 105 105 #define USAGE_NATNETWORK RT_BIT_64(59) 106 106 #define USAGE_HDPROPERTY RT_BIT_64(60) 107 #define USAGE_CREATEFLOPPY RT_BIT_64(61) 108 #define USAGE_CREATEDVD RT_BIT_64(62) 107 109 #define USAGE_ALL (~(uint64_t)0) 108 110 /** @} */ … … 259 261 bool fSilent); 260 262 int handleCreateHardDisk(HandlerArg *a); 263 int handleCreateDVD(HandlerArg *a); 264 int handleCreateFloppy(HandlerArg *a); 261 265 int handleModifyHardDisk(HandlerArg *a); 262 266 int handleCloneHardDisk(HandlerArg *a); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r51889 r53354 187 187 } 188 188 189 static HRESULT createFloppy(HandlerArg *a, const char *pszFormat, 190 const char *pszFilename, ComPtr<IMedium> &pMedium) 191 { 192 HRESULT rc; 193 char szFilenameAbs[RTPATH_MAX] = ""; 194 195 /** @todo laziness shortcut. should really check the MediumFormatCapabilities */ 196 if (RTStrICmp(pszFormat, "iSCSI")) 197 { 198 int irc = RTPathAbs(pszFilename, szFilenameAbs, sizeof(szFilenameAbs)); 199 if (RT_FAILURE(irc)) 200 { 201 RTMsgError("Cannot convert filename \"%s\" to absolute path", pszFilename); 202 return E_FAIL; 203 } 204 pszFilename = szFilenameAbs; 205 } 206 207 CHECK_ERROR(a->virtualBox, CreateMedium(Bstr(pszFormat).raw(), 208 Bstr(pszFilename).raw(), 209 AccessMode_ReadWrite, 210 TRUE, 211 DeviceType_Floppy, 212 pMedium.asOutParam())); 213 return rc; 214 } 215 216 static HRESULT createDVD(HandlerArg *a, const char *pszFormat, 217 const char *pszFilename, ComPtr<IMedium> &pMedium) 218 { 219 HRESULT rc; 220 char szFilenameAbs[RTPATH_MAX] = ""; 221 222 /** @todo laziness shortcut. should really check the MediumFormatCapabilities */ 223 if (RTStrICmp(pszFormat, "iSCSI")) 224 { 225 int irc = RTPathAbs(pszFilename, szFilenameAbs, sizeof(szFilenameAbs)); 226 if (RT_FAILURE(irc)) 227 { 228 RTMsgError("Cannot convert filename \"%s\" to absolute path", pszFilename); 229 return E_FAIL; 230 } 231 pszFilename = szFilenameAbs; 232 } 233 234 CHECK_ERROR(a->virtualBox, CreateMedium(Bstr(pszFormat).raw(), 235 Bstr(pszFilename).raw(), 236 AccessMode_ReadWrite, 237 TRUE, 238 DeviceType_DVD, 239 pMedium.asOutParam())); 240 return rc; 241 } 242 189 243 static HRESULT createHardDisk(HandlerArg *a, const char *pszFormat, 190 244 const char *pszFilename, ComPtr<IMedium> &pMedium) … … 399 453 400 454 CHECK_ERROR(hardDisk, Close()); 455 } 456 return SUCCEEDED(rc) ? 0 : 1; 457 } 458 459 int handleCreateFloppy(HandlerArg *a) 460 { 461 HRESULT rc; 462 int vrc; 463 const char *filename = NULL; 464 const char *diffparent = NULL; 465 uint64_t size = 0; 466 const char *format = NULL; 467 bool fBase = true; 468 MediumVariant_T DiskVariant = MediumVariant_Standard; 469 470 int c; 471 RTGETOPTUNION ValueUnion; 472 RTGETOPTSTATE GetState; 473 // start at 0 because main() has hacked both the argc and argv given to us 474 RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateHardDiskOptions, RT_ELEMENTS(g_aCreateHardDiskOptions), 475 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 476 while ((c = RTGetOpt(&GetState, &ValueUnion))) 477 { 478 switch (c) 479 { 480 case 'f': // --filename 481 filename = ValueUnion.psz; 482 break; 483 484 case 'd': // --diffparent 485 diffparent = ValueUnion.psz; 486 fBase = false; 487 break; 488 489 case 's': // --size 490 size = ValueUnion.u64 * _1M; 491 break; 492 493 case 'S': // --sizebyte 494 size = ValueUnion.u64; 495 break; 496 497 case 'o': // --format 498 format = ValueUnion.psz; 499 break; 500 501 case 'F': // --static ("fixed"/"flat") 502 { 503 unsigned uDiskVariant = (unsigned)DiskVariant; 504 uDiskVariant |= MediumVariant_Fixed; 505 DiskVariant = (MediumVariant_T)uDiskVariant; 506 break; 507 } 508 509 case 'm': // --variant 510 vrc = parseDiskVariant(ValueUnion.psz, &DiskVariant); 511 if (RT_FAILURE(vrc)) 512 return errorArgument("Invalid medium variant '%s'", ValueUnion.psz); 513 break; 514 515 case VINF_GETOPT_NOT_OPTION: 516 return errorSyntax(USAGE_CREATEFLOPPY, "Invalid parameter '%s'", ValueUnion.psz); 517 518 default: 519 if (c > 0) 520 { 521 if (RT_C_IS_PRINT(c)) 522 return errorSyntax(USAGE_CREATEFLOPPY, "Invalid option -%c", c); 523 else 524 return errorSyntax(USAGE_CREATEFLOPPY, "Invalid option case %i", c); 525 } 526 else if (c == VERR_GETOPT_UNKNOWN_OPTION) 527 return errorSyntax(USAGE_CREATEFLOPPY, "unknown option: %s\n", ValueUnion.psz); 528 else if (ValueUnion.pDef) 529 return errorSyntax(USAGE_CREATEFLOPPY, "%s: %Rrs", ValueUnion.pDef->pszLong, c); 530 else 531 return errorSyntax(USAGE_CREATEFLOPPY, "error: %Rrs", c); 532 } 533 } 534 535 /* check the outcome */ 536 ComPtr<IMedium> parentMedium; 537 if (fBase) 538 { 539 if ( !filename 540 || !*filename 541 || size == 0) 542 return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required"); 543 if (!format || !*format) 544 format = "RAW"; 545 } 546 else 547 { 548 if ( !filename 549 || !*filename) 550 return errorSyntax(USAGE_CREATEHD, "Parameters --filename is required"); 551 size = 0; 552 DiskVariant = MediumVariant_Diff; 553 if (!format || !*format) 554 { 555 const char *pszExt = RTPathSuffix(filename); 556 /* Skip over . if there is an extension. */ 557 if (pszExt) 558 pszExt++; 559 if (!pszExt || !*pszExt) 560 format = "RAW"; 561 else 562 format = pszExt; 563 } 564 rc = openMedium(a, diffparent, DeviceType_Floppy, 565 AccessMode_ReadWrite, parentMedium, 566 false /* fForceNewUuidOnOpen */, false /* fSilent */); 567 if (FAILED(rc)) 568 return 1; 569 if (parentMedium.isNull()) 570 { 571 RTMsgError("Invalid parent medium reference, avoiding crash"); 572 return 1; 573 } 574 MediumState_T state; 575 CHECK_ERROR(parentMedium, COMGETTER(State)(&state)); 576 if (FAILED(rc)) 577 return 1; 578 if (state == MediumState_Inaccessible) 579 { 580 CHECK_ERROR(parentMedium, RefreshState(&state)); 581 if (FAILED(rc)) 582 return 1; 583 } 584 } 585 /* check for filename extension */ 586 /** @todo use IMediumFormat to cover all extensions generically */ 587 Utf8Str strName(filename); 588 if (!RTPathHasSuffix(strName.c_str())) 589 { 590 Utf8Str strFormat(format); 591 strName.append(".raw"); 592 filename = strName.c_str(); 593 } 594 595 ComPtr<IMedium> medium; 596 rc = createFloppy(a, format, filename, medium); 597 if (SUCCEEDED(rc) && medium) 598 { 599 ComPtr<IProgress> progress; 600 com::SafeArray<MediumVariant_T> l_variants(sizeof(MediumVariant_T)*8); 601 602 for (ULONG i = 0; i < l_variants.size(); ++i) 603 { 604 ULONG temp = DiskVariant; 605 temp &= 1<<i; 606 l_variants [i] = (MediumVariant_T)temp; 607 } 608 609 if (fBase) 610 CHECK_ERROR(medium, CreateBaseStorage(size, ComSafeArrayAsInParam(l_variants), progress.asOutParam())); 611 else 612 CHECK_ERROR(parentMedium, CreateDiffStorage(medium, ComSafeArrayAsInParam(l_variants), progress.asOutParam())); 613 if (SUCCEEDED(rc) && progress) 614 { 615 rc = showProgress(progress); 616 CHECK_PROGRESS_ERROR(progress, ("Failed to create Floppy")); 617 if (SUCCEEDED(rc)) 618 { 619 Bstr uuid; 620 CHECK_ERROR(medium, COMGETTER(Id)(uuid.asOutParam())); 621 RTPrintf("Disk image created. UUID: %s\n", Utf8Str(uuid).c_str()); 622 } 623 } 624 625 CHECK_ERROR(medium, Close()); 626 } 627 return SUCCEEDED(rc) ? 0 : 1; 628 } 629 630 int handleCreateDVD(HandlerArg *a) 631 { 632 HRESULT rc; 633 int vrc; 634 const char *filename = NULL; 635 const char *diffparent = NULL; 636 uint64_t size = 0; 637 const char *format = NULL; 638 bool fBase = true; 639 MediumVariant_T DiskVariant = MediumVariant_Standard; 640 641 int c; 642 RTGETOPTUNION ValueUnion; 643 RTGETOPTSTATE GetState; 644 // start at 0 because main() has hacked both the argc and argv given to us 645 RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateHardDiskOptions, RT_ELEMENTS(g_aCreateHardDiskOptions), 646 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 647 while ((c = RTGetOpt(&GetState, &ValueUnion))) 648 { 649 switch (c) 650 { 651 case 'f': // --filename 652 filename = ValueUnion.psz; 653 break; 654 655 case 'd': // --diffparent 656 diffparent = ValueUnion.psz; 657 fBase = false; 658 break; 659 660 case 's': // --size 661 size = ValueUnion.u64 * _1M; 662 break; 663 664 case 'S': // --sizebyte 665 size = ValueUnion.u64; 666 break; 667 668 case 'o': // --format 669 format = ValueUnion.psz; 670 break; 671 672 case 'F': // --static ("fixed"/"flat") 673 { 674 unsigned uDiskVariant = (unsigned)DiskVariant; 675 uDiskVariant |= MediumVariant_Fixed; 676 DiskVariant = (MediumVariant_T)uDiskVariant; 677 break; 678 } 679 680 case 'm': // --variant 681 vrc = parseDiskVariant(ValueUnion.psz, &DiskVariant); 682 if (RT_FAILURE(vrc)) 683 return errorArgument("Invalid medium variant '%s'", ValueUnion.psz); 684 break; 685 686 case VINF_GETOPT_NOT_OPTION: 687 return errorSyntax(USAGE_CREATEDVD, "Invalid parameter '%s'", ValueUnion.psz); 688 689 default: 690 if (c > 0) 691 { 692 if (RT_C_IS_PRINT(c)) 693 return errorSyntax(USAGE_CREATEDVD, "Invalid option -%c", c); 694 else 695 return errorSyntax(USAGE_CREATEDVD, "Invalid option case %i", c); 696 } 697 else if (c == VERR_GETOPT_UNKNOWN_OPTION) 698 return errorSyntax(USAGE_CREATEDVD, "unknown option: %s\n", ValueUnion.psz); 699 else if (ValueUnion.pDef) 700 return errorSyntax(USAGE_CREATEDVD, "%s: %Rrs", ValueUnion.pDef->pszLong, c); 701 else 702 return errorSyntax(USAGE_CREATEDVD, "error: %Rrs", c); 703 } 704 } 705 706 /* check the outcome */ 707 ComPtr<IMedium> parentMedium; 708 if (fBase) 709 { 710 if ( !filename 711 || !*filename 712 || size == 0) 713 return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required"); 714 if (!format || !*format) 715 format = "ISO"; 716 } 717 else 718 { 719 if ( !filename 720 || !*filename) 721 return errorSyntax(USAGE_CREATEHD, "Parameters --filename is required"); 722 size = 0; 723 DiskVariant = MediumVariant_Diff; 724 if (!format || !*format) 725 { 726 const char *pszExt = RTPathSuffix(filename); 727 /* Skip over . if there is an extension. */ 728 if (pszExt) 729 pszExt++; 730 if (!pszExt || !*pszExt) 731 format = "ISO"; 732 else 733 format = pszExt; 734 } 735 rc = openMedium(a, diffparent, DeviceType_DVD, 736 AccessMode_ReadWrite, parentMedium, 737 false /* fForceNewUuidOnOpen */, false /* fSilent */); 738 if (FAILED(rc)) 739 return 1; 740 if (parentMedium.isNull()) 741 { 742 RTMsgError("Invalid parent hard disk reference, avoiding crash"); 743 return 1; 744 } 745 MediumState_T state; 746 CHECK_ERROR(parentMedium, COMGETTER(State)(&state)); 747 if (FAILED(rc)) 748 return 1; 749 if (state == MediumState_Inaccessible) 750 { 751 CHECK_ERROR(parentMedium, RefreshState(&state)); 752 if (FAILED(rc)) 753 return 1; 754 } 755 } 756 /* check for filename extension */ 757 /** @todo use IMediumFormat to cover all extensions generically */ 758 Utf8Str strName(filename); 759 if (!RTPathHasSuffix(strName.c_str())) 760 { 761 Utf8Str strFormat(format); 762 strName.append(".iso"); 763 filename = strName.c_str(); 764 } 765 766 ComPtr<IMedium> medium; 767 rc = createDVD(a, format, filename, medium); 768 if (SUCCEEDED(rc) && medium) 769 { 770 ComPtr<IProgress> progress; 771 com::SafeArray<MediumVariant_T> l_variants(sizeof(MediumVariant_T)*8); 772 773 for (ULONG i = 0; i < l_variants.size(); ++i) 774 { 775 ULONG temp = DiskVariant; 776 temp &= 1<<i; 777 l_variants [i] = (MediumVariant_T)temp; 778 } 779 780 if (fBase) 781 CHECK_ERROR(medium, CreateBaseStorage(size, ComSafeArrayAsInParam(l_variants), progress.asOutParam())); 782 else 783 CHECK_ERROR(parentMedium, CreateDiffStorage(medium, ComSafeArrayAsInParam(l_variants), progress.asOutParam())); 784 if (SUCCEEDED(rc) && progress) 785 { 786 rc = showProgress(progress); 787 CHECK_PROGRESS_ERROR(progress, ("Failed to create DVD")); 788 if (SUCCEEDED(rc)) 789 { 790 Bstr uuid; 791 CHECK_ERROR(medium, COMGETTER(Id)(uuid.asOutParam())); 792 RTPrintf("Disk image created. UUID: %s\n", Utf8Str(uuid).c_str()); 793 } 794 } 795 796 CHECK_ERROR(medium, Close()); 401 797 } 402 798 return SUCCEEDED(rc) ? 0 : 1; -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r53297 r53354 1813 1813 <interface 1814 1814 name="IVirtualBox" extends="$unknown" 1815 uuid=" fafa4e17-1ee2-4905-a10e-fe7c18bf5554"1815 uuid="5e67bc8a-5f8f-11e4-aa15-123b93f75cba" 1816 1816 wsmap="managed" 1817 1817 > … … 2281 2281 <param name="appliance" type="IAppliance" dir="return"> 2282 2282 <desc>New appliance.</desc> 2283 </param> 2284 </method> 2285 2286 <method name="createMedium"> 2287 <desc> 2288 Creates a new base medium object that will use the given storage 2289 format and location for medium data. 2290 2291 The actual storage unit is not created by this method. In order to 2292 do it, and before you are able to attach the created medium to 2293 virtual machines, you must call one of the following methods to 2294 allocate a format-specific storage unit at the specified location: 2295 <ul> 2296 <li><link to="IMedium::createBaseStorage"/></li> 2297 <li><link to="IMedium::createDiffStorage"/></li> 2298 </ul> 2299 2300 Some medium attributes, such as <link to="IMedium::id"/>, may 2301 remain uninitialized until the medium storage unit is successfully 2302 created by one of the above methods. 2303 2304 Depending on the given device type, the file at the storage location 2305 must be in one of the media formats understood by VirtualBox: 2306 2307 <ul> 2308 <li>With a "HardDisk" device type, the file must be a hard disk image 2309 in one of the formats supported by VirtualBox (see 2310 <link to="ISystemProperties::mediumFormats" />). 2311 After the storage unit is successfully created and this method succeeds, 2312 if the medium is a base medium, it 2313 will be added to the <link to="#hardDisks"/> array attribute. </li> 2314 <li>With a "DVD" device type, the file must be an ISO 9960 CD/DVD image. 2315 After this method succeeds, the medium will be added to the 2316 <link to="#DVDImages"/> array attribute.</li> 2317 <li>With a "Floppy" device type, the file must be an RAW floppy image. 2318 After this method succeeds, the medium will be added to the 2319 <link to="#floppyImages"/> array attribute.</li> 2320 </ul> 2321 2322 The list of all storage formats supported by this VirtualBox 2323 installation can be obtained using 2324 <link to="ISystemProperties::mediumFormats"/>. If the @a format 2325 attribute is empty or @c null then the default storage format 2326 specified by <link to="ISystemProperties::defaultHardDiskFormat"/> will 2327 be used for disks r creating a storage unit of the medium. 2328 2329 Note that the format of the location string is storage format specific. 2330 See <link to="IMedium::location"/> and IMedium for more details. 2331 2332 <result name="VBOX_E_OBJECT_NOT_FOUND"> 2333 @a format identifier is invalid. See 2334 <link to="ISystemProperties::mediumFormats"/>. 2335 </result> 2336 <result name="VBOX_E_FILE_ERROR"> 2337 @a location is a not valid file name (for file-based formats only). 2338 </result> 2339 </desc> 2340 <param name="format" type="wstring" dir="in"> 2341 <desc> 2342 Identifier of the storage format to use for the new medium. 2343 </desc> 2344 </param> 2345 <param name="location" type="wstring" dir="in"> 2346 <desc> 2347 Location of the storage unit for the new medium. 2348 </desc> 2349 </param> 2350 <param name="accessMode" type="AccessMode" dir="in"> 2351 <desc>Whether to open the image in read/write or read-only mode. For 2352 a "DVD" device type, this is ignored and read-only mode is always assumed.</desc> 2353 </param> 2354 <param name="forceNewUuid" type="boolean" dir="in"> 2355 <desc>Allows the caller to request a completely new medium UUID for 2356 the image which is to be opened. Useful if one intends to open an exact 2357 copy of a previously opened image, as this would normally fail due to 2358 the duplicate UUID.</desc> 2359 </param> 2360 <param name="aDeviceTypeType" type="DeviceType" dir="in"> 2361 <desc> 2362 Must be one of "HardDisk", "DVD" or "Floppy". 2363 </desc> 2364 </param> 2365 <param name="medium" type="IMedium" dir="return"> 2366 <desc>Created medium object.</desc> 2283 2367 </param> 2284 2368 </method> -
trunk/src/VBox/Main/include/MediumImpl.h
r52324 r53354 18 18 */ 19 19 20 20 21 #ifndef ____H_MEDIUMIMPL 21 22 #define ____H_MEDIUMIMPL … … 55 56 // public initializer/uninitializer for internal purposes only 56 57 57 // initializer to create empty medium (VirtualBox::Create HardDisk())58 // initializer to create empty medium (VirtualBox::CreateMedium()) 58 59 HRESULT init(VirtualBox *aVirtualBox, 59 60 const Utf8Str &aFormat, 60 61 const Utf8Str &aLocation, 61 const Guid &uuidMachineRegistry); 62 const Guid &uuidMachineRegistry, 63 const DeviceType_T aDeviceType); 62 64 63 65 // initializer for opening existing media -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r53323 r53354 217 217 int i_calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult); 218 218 void i_copyPathRelativeToConfig(const Utf8Str &strSource, Utf8Str &strTarget); 219 HRESULT i_registerMedium(const ComObjPtr<Medium> &pMedium, ComObjPtr<Medium> *ppMedium, DeviceType_T argType, AutoWriteLock &mediaTreeLock); 219 HRESULT i_registerMedium(const ComObjPtr<Medium> &pMedium, ComObjPtr<Medium> *ppMedium, DeviceType_T argType, 220 AutoWriteLock &mediaTreeLock); 220 221 HRESULT i_unregisterMedium(Medium *pMedium); 221 222 void i_pushMediumToListWithChildren(MediaList &llMedia, Medium *pMedium); … … 240 241 void i_storeSettingsKey(const Utf8Str &aKey); 241 242 bool i_isMediaUuidInUse(const Guid &aId, DeviceType_T deviceType); 243 244 242 245 243 246 private: … … 295 298 const com::Utf8Str &aLocation, 296 299 ComPtr<IMedium> &aMedium); 300 HRESULT createMedium(const com::Utf8Str &aFormat, 301 const com::Utf8Str &aLocation, 302 AccessMode_T aAccessMode, 303 BOOL aForceNewUuid, 304 DeviceType_T aDeviceType, 305 ComPtr<IMedium> &aMedium); 297 306 HRESULT openMedium(const com::Utf8Str &aLocation, 298 307 DeviceType_T aDeviceType, -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r52813 r53354 5 5 6 6 /* 7 * Copyright (C) 2008-201 3Oracle Corporation7 * Copyright (C) 2008-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 751 751 } 752 752 753 AssertReturn(!(m->optListImport.contains(ImportOptions_KeepAllMACs) && m->optListImport.contains(ImportOptions_KeepNATMACs)), E_INVALIDARG); 753 AssertReturn(!(m->optListImport.contains 754 (ImportOptions_KeepAllMACs) 755 && m->optListImport.contains(ImportOptions_KeepNATMACs) 756 ), E_INVALIDARG); 754 757 755 758 // do not allow entering this method if the appliance is busy reading or writing … … 2513 2516 strTrgFormat, 2514 2517 *strTargetPath, 2515 Guid::Empty /* media registry: none yet */); 2518 Guid::Empty /* media registry: none yet */, 2519 DeviceType_HardDisk); 2516 2520 if (FAILED(rc)) throw rc; 2517 2521 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r53171 r53354 4093 4093 medium->i_getPreferredDiffFormat(), 4094 4094 strFullSnapshotFolder.append(RTPATH_SLASH_STR), 4095 uuidRegistryParent); 4095 uuidRegistryParent, 4096 DeviceType_HardDisk); 4096 4097 if (FAILED(rc)) return rc; 4097 4098 … … 10586 10587 pMedium->i_getPreferredDiffFormat(), 10587 10588 strFullSnapshotFolder.append(RTPATH_SLASH_STR), 10588 uuidRegistryParent); 10589 uuidRegistryParent, 10590 DeviceType_HardDisk); 10589 10591 if (FAILED(rc)) throw rc; 10590 10592 -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r52095 r53354 677 677 pParent->i_getPreferredDiffFormat(), 678 678 Utf8StrFmt("%s%c", strSnapshotFolder.c_str(), RTPATH_DELIMITER), 679 Guid::Empty /* empty media registry */); 679 Guid::Empty /* empty media registry */, 680 DeviceType_HardDisk); 680 681 if (FAILED(rc)) throw rc; 681 682 … … 1204 1205 Utf8Str(bstrSrcFormat), 1205 1206 strFile, 1206 Guid::Empty /* empty media registry */); 1207 Guid::Empty /* empty media registry */, 1208 DeviceType_HardDisk); 1207 1209 if (FAILED(rc)) throw rc; 1208 1210 -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r52880 r53354 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 17 #include "MediumImpl.h" 19 18 #include "TokenImpl.h" … … 899 898 * @param uuidMachineRegistry The registry to which this medium should be added 900 899 * (global registry UUID or machine UUID or empty if none). 900 * @param deviceType Device Type. 901 901 */ 902 902 HRESULT Medium::init(VirtualBox *aVirtualBox, 903 903 const Utf8Str &aFormat, 904 904 const Utf8Str &aLocation, 905 const Guid &uuidMachineRegistry) 905 const Guid &uuidMachineRegistry, 906 const DeviceType_T aDeviceType) 906 907 { 907 908 AssertReturn(aVirtualBox != NULL, E_FAIL); … … 925 926 m->hostDrive = false; 926 927 928 m->devType = aDeviceType; 929 927 930 /* No storage unit is created yet, no need to call Medium::i_queryInfo */ 928 931 … … 937 940 ) 938 941 { 939 /* Storage for hard disks of this format can neither be explicitly940 * created by VirtualBox nor deleted, so we place the hard diskto942 /* Storage for mediums of this format can neither be explicitly 943 * created by VirtualBox nor deleted, so we place the medium to 941 944 * Inaccessible state here and also add it to the registry. The 942 945 * state means that one has to use RefreshState() to update the … … 959 962 bool fInUse; 960 963 961 fInUse = m->pVirtualBox->i_isMediaUuidInUse(m->id, DeviceType_HardDisk);964 fInUse = m->pVirtualBox->i_isMediaUuidInUse(m->id, aDeviceType); 962 965 if (fInUse) 963 966 { … … 969 972 } 970 973 971 rc = m->pVirtualBox->i_registerMedium(this, &pMedium, DeviceType_HardDisk, treeLock);974 rc = m->pVirtualBox->i_registerMedium(this, &pMedium, aDeviceType, treeLock); 972 975 Assert(this == pMedium || FAILED(rc)); 973 976 } … … 6076 6079 */ 6077 6080 HRESULT Medium::i_setLocation(const Utf8Str &aLocation, 6078 const Utf8Str &aFormat /* = Utf8Str::Empty */)6081 const Utf8Str &aFormat /* = Utf8Str::Empty */) 6079 6082 { 6080 6083 AssertReturn(!aLocation.isEmpty(), E_FAIL); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r53323 r53354 1740 1740 { 1741 1741 /* we don't access non-const data members so no need to lock */ 1742 HRESULT rc = createMedium(aFormat, aLocation, AccessMode_ReadWrite, TRUE, DeviceType_HardDisk, aMedium); 1743 1744 return rc; 1745 } 1746 1747 HRESULT VirtualBox::createMedium(const com::Utf8Str &aFormat, 1748 const com::Utf8Str &aLocation, 1749 AccessMode_T aAccessMode, 1750 BOOL aForceNewUuid, 1751 DeviceType_T aDeviceType, 1752 ComPtr<IMedium> &aMedium) 1753 { 1754 HRESULT rc = S_OK; 1755 1756 ComObjPtr<Medium> medium; 1757 medium.createObject(); 1742 1758 com::Utf8Str format = aFormat; 1743 if (format.isEmpty()) 1744 i_getDefaultHardDiskFormat(format); 1745 1746 ComObjPtr<Medium> hardDisk; 1747 hardDisk.createObject(); 1748 HRESULT rc = hardDisk->init(this, 1749 format, 1750 aLocation, 1751 Guid::Empty /* media registry: none yet */); 1759 1760 switch (aDeviceType) 1761 { 1762 case DeviceType_HardDisk: 1763 { 1764 1765 /* we don't access non-const data members so no need to lock */ 1766 if (format.isEmpty()) 1767 i_getDefaultHardDiskFormat(format); 1768 1769 rc = medium->init(this, 1770 format, 1771 aLocation, 1772 Guid::Empty /* media registry: none yet */, 1773 aDeviceType); 1774 } 1775 break; 1776 1777 case DeviceType_DVD: 1778 case DeviceType_Floppy: 1779 { 1780 1781 if (format.isEmpty()) 1782 return setError(E_INVALIDARG, "Format must be Valid Type%s", format.c_str()); 1783 1784 // enforce read-only for DVDs even if caller specified ReadWrite 1785 if (aDeviceType == DeviceType_DVD) 1786 aAccessMode = AccessMode_ReadOnly; 1787 1788 rc = medium->init(this, 1789 format, 1790 aLocation, 1791 Guid::Empty /* media registry: none yet */, 1792 aDeviceType); 1793 1794 } 1795 break; 1796 1797 default: 1798 return setError(E_INVALIDARG, "Device type must be HardDisk, DVD or Floppy %d", aDeviceType); 1799 } 1800 1752 1801 if (SUCCEEDED(rc)) 1753 hardDisk.queryInterfaceTo(aMedium.asOutParam());1802 medium.queryInterfaceTo(aMedium.asOutParam()); 1754 1803 1755 1804 return rc; … … 1788 1837 if (id.isValid() && !id.isZero()) 1789 1838 rc = i_findDVDOrFloppyImage(aDeviceType, &id, Utf8Str::Empty, 1790 false /* setError */, &pMedium);1839 false /* setError */, &pMedium); 1791 1840 else 1792 1841 rc = i_findDVDOrFloppyImage(aDeviceType, NULL, aLocation, 1793 false /* setError */, &pMedium);1842 false /* setError */, &pMedium); 1794 1843 1795 1844 // enforce read-only for DVDs even if caller specified ReadWrite
Note:
See TracChangeset
for help on using the changeset viewer.