VirtualBox

Ignore:
Timestamp:
May 22, 2017 8:38:38 AM (8 years ago)
Author:
vboxsync
Message:

Frontends/VBoxManage: Use the default disk image format if the source medium format can't create images

File:
1 edited

Legend:

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

    r66250 r66997  
    942942        else
    943943        {
    944             /* use the format of the source medium if unspecified */
     944            /*
     945             * In case the format is unspecified check that the source medium supports
     946             * image creation and use the same format for the destination image.
     947             * Use the default image format if it is not supported.
     948             */
    945949            if (format.isEmpty())
    946                 CHECK_ERROR_BREAK(pSrcMedium, COMGETTER(Format)(format.asOutParam()));
     950            {
     951                ComPtr<IMediumFormat> pMediumFmt;
     952                com::SafeArray<MediumFormatCapabilities_T> l_caps;
     953                CHECK_ERROR_BREAK(pSrcMedium, COMGETTER(MediumFormat)(pMediumFmt.asOutParam()));
     954                CHECK_ERROR_BREAK(pMediumFmt, COMGETTER(Capabilities)(ComSafeArrayAsOutParam(l_caps)));
     955                ULONG caps=0;
     956                for (size_t i = 0; i < l_caps.size(); i++)
     957                    caps |= l_caps[i];
     958                if (caps & (  MediumFormatCapabilities_CreateDynamic
     959                            | MediumFormatCapabilities_CreateFixed))
     960                    CHECK_ERROR_BREAK(pMediumFmt, COMGETTER(Id)(format.asOutParam()));
     961            }
    947962            Utf8Str strFormat(format);
    948963            if (cmd == CMD_DISK)
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