VirtualBox

Changeset 30938 in vbox


Ignore:
Timestamp:
Jul 20, 2010 5:32:27 PM (15 years ago)
Author:
vboxsync
Message:

Main: add option to VirtualBox::findMachine() whether it should find inaccessible machines as well (fixes VBoxManage unregistervm trunk regression introduced by r62441)

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r30929 r30938  
    13101310
    13111311    ComObjPtr<Machine> machine;
    1312     HRESULT rc = findMachine(Guid(aId), true /* setError */, &machine);
     1312    HRESULT rc = findMachine(Guid(aId),
     1313                             true /* fPermitInaccessible */,
     1314                             true /* setError */,
     1315                             &machine);
    13131316
    13141317    /* the below will set *aMachine to NULL if machine is null */
     
    13811384    // find machine from the given ID
    13821385    ComObjPtr<Machine> pMachine;
    1383     HRESULT rc = findMachine(id, true /* setError */, &pMachine);
     1386    HRESULT rc = findMachine(id,
     1387                             true /* fPermitInaccessible */,
     1388                             true /* setError */,
     1389                             &pMachine);
    13841390    if (FAILED(rc)) return rc;
    13851391
     
    19491955    ComObjPtr<Machine> machine;
    19501956
    1951     HRESULT rc = findMachine(id, true /* setError */, &machine);
     1957    HRESULT rc = findMachine(id,
     1958                             false /* fPermitInaccessible */,
     1959                             true /* setError */,
     1960                             &machine);
    19521961    if (FAILED(rc)) return rc;
    19531962
     
    20052014    ComObjPtr<Machine> machine;
    20062015
    2007     HRESULT rc = findMachine(id, true /* setError */, &machine);
     2016    HRESULT rc = findMachine(id,
     2017                             false /* fPermitInaccessible */,
     2018                             true /* setError */,
     2019                             &machine);
    20082020    if (FAILED(rc)) return rc;
    20092021
     
    20712083    ComObjPtr<Machine> machine;
    20722084
    2073     HRESULT rc = findMachine(id, true /* setError */, &machine);
     2085    HRESULT rc = findMachine(id,
     2086                             false /* fPermitInaccessible */,
     2087                             true /* setError */,
     2088                             &machine);
    20742089    if (FAILED(rc)) return rc;
    20752090
     
    28422857
    28432858/**
    2844  *  Searches for a Machine object with the given ID in the collection
     2859 *  Searches for a machine object with the given ID in the collection
    28452860 *  of registered machines.
    28462861 *
    2847  *  @param id
    2848  *      ID of the machine
    2849  *  @param doSetError
    2850  *      if TRUE, the appropriate error info is set in case when the machine
    2851  *      is not found
    2852  *  @param machine
    2853  *      where to store the found machine object (can be NULL)
    2854  *
    2855  *  @return
    2856  *      S_OK when found or VBOX_E_OBJECT_NOT_FOUND when not found
    2857  *
    2858  *  @note Locks this object for reading.
     2862 * @param aId Machine UUID to look for.
     2863 * @param aPermitInaccessible If true, inaccessible machines will be found;
     2864 *                  if false, this will fail if the given machine is inaccessible.
     2865 * @param aSetError If true, set errorinfo if the machine is not found.
     2866 * @param aMachine Returned machine, if found.
     2867 * @return
    28592868 */
    28602869HRESULT VirtualBox::findMachine(const Guid &aId,
     2870                                bool fPermitInaccessible,
    28612871                                bool aSetError,
    28622872                                ComObjPtr<Machine> *aMachine /* = NULL */)
     
    28752885        {
    28762886            ComObjPtr<Machine> pMachine2 = *it;
    2877             AutoCaller machCaller(pMachine2);
    2878             /* skip inaccessible machines */
    2879             if (FAILED(machCaller.rc()))
    2880                 continue;
     2887
     2888            if (!fPermitInaccessible)
     2889            {
     2890                // skip inaccessible machines
     2891                AutoCaller machCaller(pMachine2);
     2892                if (FAILED(machCaller.rc()))
     2893                    continue;
     2894            }
    28812895
    28822896            if (pMachine2->getId() == aId)
     
    35553569    {
    35563570        ComObjPtr<Machine> pMachine;
    3557         rc = findMachine(aMachine->getId(), false /* aDoSetError */, &pMachine);
     3571        rc = findMachine(aMachine->getId(),
     3572                         true /* fPermitInaccessible */,
     3573                         false /* aDoSetError */,
     3574                         &pMachine);
    35583575        if (SUCCEEDED(rc))
    35593576        {
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r30929 r30938  
    227227    }
    228228
    229     HRESULT findMachine (const Guid &aId, bool aSetError,
     229    HRESULT findMachine (const Guid &aId,
     230                         bool fPermitInaccessible,
     231                         bool aSetError,
    230232                         ComObjPtr<Machine> *machine = NULL);
    231233
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