VirtualBox

Changeset 37567 in vbox for trunk/src


Ignore:
Timestamp:
Jun 21, 2011 9:05:46 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72409
Message:

FE/CLI: unregistervm: better error checking; show error on failure

File:
1 edited

Legend:

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

    r37543 r37567  
    150150
    151151    ComPtr<IMachine> machine;
    152     CHECK_ERROR(a->virtualBox, FindMachine(Bstr(VMName).raw(),
    153                                            machine.asOutParam()));
    154     if (machine)
    155     {
    156         SafeIfaceArray<IMedium> aMedia;
    157         CleanupMode_T cleanupMode = CleanupMode_DetachAllReturnNone;
    158         if (fDelete)
    159             cleanupMode = CleanupMode_DetachAllReturnHardDisksOnly;
    160         CHECK_ERROR(machine, Unregister(cleanupMode,
    161                                         ComSafeArrayAsOutParam(aMedia)));
    162         if (SUCCEEDED(rc))
    163         {
    164             if (fDelete)
    165             {
    166                 ComPtr<IProgress> pProgress;
    167                 CHECK_ERROR(machine, Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam()));
    168                 if (SUCCEEDED(rc))
    169                     CHECK_ERROR(pProgress, WaitForCompletion(-1));
    170             }
    171         }
    172     }
    173     return SUCCEEDED(rc) ? 0 : 1;
     152    CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(VMName).raw(),
     153                                               machine.asOutParam()),
     154                    RTEXITCODE_FAILURE);
     155    SafeIfaceArray<IMedium> aMedia;
     156    CHECK_ERROR_RET(machine, Unregister(fDelete ? (CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly : (CleanupMode_T)CleanupMode_DetachAllReturnNone,
     157                                        ComSafeArrayAsOutParam(aMedia)),
     158                    RTEXITCODE_FAILURE);
     159    if (fDelete)
     160    {
     161        ComPtr<IProgress> pProgress;
     162        CHECK_ERROR_RET(machine, Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam()),
     163                        RTEXITCODE_FAILURE);
     164        rc = showProgress(pProgress);
     165        if (FAILED(rc))
     166        {
     167            com::ProgressErrorInfo ErrInfo(pProgress);
     168            com::GluePrintErrorInfo(ErrInfo);
     169            return RTEXITCODE_FAILURE;
     170        }
     171    }
     172    return RTEXITCODE_SUCCESS;
    174173}
    175174
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