VirtualBox

Changeset 2918 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 29, 2007 2:26:58 PM (18 years ago)
Author:
vboxsync
Message:

VBoxManage: 'registerimage' can now register images of any supproted type (currently, VDI and VMDK).

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r2643 r2918  
    48774877    if (strcmp(argv[0], "disk") == 0)
    48784878    {
    4879         const char *type = "normal";
     4879        const char *type = NULL;
    48804880        /* there can be a type parameter */
    48814881        if ((argc > 2) && (argc != 4))
     
    48984898        }
    48994899
    4900         ComPtr<IVirtualDiskImage> vdi;
    4901 
    4902         CHECK_ERROR(virtualBox, OpenVirtualDiskImage(filepath, vdi.asOutParam()));
    4903         if (SUCCEEDED(rc) && vdi)
    4904         {
    4905             ComPtr<IHardDisk> hardDisk = vdi;
     4900        ComPtr<IHardDisk> hardDisk;
     4901        CHECK_ERROR(virtualBox, OpenHardDisk(filepath, hardDisk.asOutParam()));
     4902        if (SUCCEEDED(rc) && hardDisk)
     4903        {
    49064904            /* change the type if requested */
    4907             if (strcmp(type, "normal") == 0)
    4908                 CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_NormalHardDisk));
    4909             else if (strcmp(type, "immutable") == 0)
    4910                 CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_ImmutableHardDisk));
    4911             else if (strcmp(type, "writethrough") == 0)
    4912                 CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_WritethroughHardDisk));
    4913             CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
     4905            if (type)
     4906            {
     4907                if (strcmp(type, "normal") == 0)
     4908                    CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_NormalHardDisk));
     4909                else if (strcmp(type, "immutable") == 0)
     4910                    CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_ImmutableHardDisk));
     4911                else if (strcmp(type, "writethrough") == 0)
     4912                    CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_WritethroughHardDisk));
     4913            }
     4914            if (SUCCEEDED(rc))
     4915                CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
    49144916        }
    49154917    }
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r2358 r2918  
    251251            tr ("You cannot change the type of the registered hard disk '%ls'"),
    252252            toString().raw());
     253
     254    /* return silently if nothing to do */
     255    if (mType == aType)
     256        return S_OK;
     257
     258    if (mStorageType == HardDiskStorageType_VMDKImage)
     259        return setError (E_FAIL,
     260            tr ("Currently, changing the type of VMDK hard disks is not allowed"));
    253261
    254262    if (mStorageType == HardDiskStorageType_ISCSIHardDisk)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette