VirtualBox

Changeset 42178 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 17, 2012 12:35:07 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79176
Message:

Autostart: Make the path to the autostart database configurable

Location:
trunk/src/VBox
Files:
8 edited

Legend:

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

    r42176 r42178  
    591591                     "                            websrvauthlibrary default|null|<library> |\n"
    592592                     "                            vrdeextpack null|<library> |\n"
     593                     "                            autostartdbpath null|<folder> |\n"
    593594                     "                            loghistorycount <value>\n"
    594595                     "\n");
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r42176 r42178  
    857857        CHECK_ERROR(systemProperties, COMSETTER(LogHistoryCount)(uVal));
    858858    }
     859    else if (!strcmp(a->argv[0], "autostartdbpath"))
     860    {
     861        /* disable? */
     862        if (!strcmp(a->argv[1], "null"))
     863            CHECK_ERROR(systemProperties, COMSETTER(AutostartDatabasePath)(NULL));
     864        else
     865            CHECK_ERROR(systemProperties, COMSETTER(AutostartDatabasePath)(Bstr(a->argv[1]).raw()));
     866    }
    859867    else
    860868        return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", a->argv[0]);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r42176 r42178  
    79817981    name="ISystemProperties"
    79827982    extends="$unknown"
    7983     uuid="8a0ab9ab-48c1-4d04-954b-4a751413d084"
     7983    uuid="20fc263c-e1e9-4e86-b9b0-835950790d13"
    79847984    wsmap="managed"
    79857985    >
     
    82318231    </attribute>
    82328232
     8233    <attribute name="autostartDatabasePath" type="wstring">
     8234      <desc>
     8235        The path to the autostart database. Depending on the host this might
     8236        be a filesystem path or something else.
     8237      </desc>
     8238    </attribute>
    82338239
    82348240    <method name="getMaxNetworkAdapters">
  • trunk/src/VBox/Main/include/AutostartDb.h

    r41999 r42178  
    3030
    3131        /**
     32         * Sets the path to the autostart database.
     33         *
     34         * @returns VBox status code.
     35         * @param   pszAutostartDbPathNew    Path to the autostart database.
     36         */
     37        int setAutostartDbPath(const char *pszAutostartDbPathNew);
     38
     39        /**
    3240         * Add a autostart VM to the global database.
    3341         *
    3442         * @returns VBox status code.
     43         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
    3544         * @param   pszVMId    ID of the VM to add.
    3645         */
     
    4150         *
    4251         * @returns VBox status code.
     52         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
    4353         * @param   pszVMId    ID of the VM to remove.
    4454         */
     
    4959         *
    5060         * @returns VBox status code.
     61         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
    5162         * @param   pszVMId    ID of the VM to add.
    5263         */
     
    5768         *
    5869         * @returns VBox status code.
     70         * @retval VERR_PATH_NOT_FOUND if the autostart database directory is not set.
    5971         * @param   pszVMId    ID of the VM to remove.
    6072         */
     
    6678        /** Critical section protecting the database against concurrent access. */
    6779        RTCRITSECT      CritSect;
     80        /** Path to the autostart database. */
     81        char           *m_pszAutostartDbPath;
     82
     83        /**
     84         * Autostart database modification worker.
     85         *
     86         * @returns VBox status code.
     87         * @param   fAutostart    Flag whether the autostart or autostop database is modified.
     88         * @param   fAddVM        Flag whether a VM is added or removed from the database.
     89         */
     90        int autostartModifyDb(bool fAutostart, bool fAddVM);
    6891#endif
    6992};
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r35761 r42178  
    9292    STDMETHOD(COMSETTER(LogHistoryCount))(ULONG count);
    9393    STDMETHOD(COMGETTER(DefaultAudioDriver))(AudioDriverType_T *aAudioDriver);
     94    STDMETHOD(COMGETTER(AutostartDatabasePath))(BSTR *aAutostartDbPath);
     95    STDMETHOD(COMSETTER(AutostartDatabasePath))(IN_BSTR aAutostartDbPath);
    9496
    9597    STDMETHOD(GetMaxNetworkAdapters)(ChipsetType_T aChipset, ULONG *aMaxInstances);
     
    124126    HRESULT setWebServiceAuthLibrary(const Utf8Str &aPath);
    125127    HRESULT setDefaultVRDEExtPack(const Utf8Str &aPath);
     128    HRESULT setAutostartDatabasePath(const Utf8Str &aPath);
    126129
    127130    VirtualBox * const  mParent;
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r42177 r42178  
    66406640                hrc = setError(VBOX_E_NOT_SUPPORTED,
    66416641                               tr("The VM autostart feature is not supported on this platform"));
     6642            else if (vrc == VERR_PATH_NOT_FOUND)
     6643                hrc = setError(E_FAIL,
     6644                               tr("The path to the autostart database is not set"));
    66426645            else
    66436646                hrc = setError(E_UNEXPECTED,
     
    67286731                hrc = setError(VBOX_E_NOT_SUPPORTED,
    67296732                               tr("The VM autostop feature is not supported on this platform"));
     6733            else if (vrc == VERR_PATH_NOT_FOUND)
     6734                hrc = setError(E_FAIL,
     6735                               tr("The path to the autostart database is not set"));
    67306736            else
    67316737                hrc = setError(E_UNEXPECTED,
  • trunk/src/VBox/Main/src-server/SystemPropertiesImpl.cpp

    r39248 r42178  
    2626#include "Global.h"
    2727#include "Logging.h"
     28#include "AutostartDb.h"
    2829
    2930// generated header
     
    918919}
    919920
     921STDMETHODIMP SystemProperties::COMGETTER(AutostartDatabasePath)(BSTR *aAutostartDbPath)
     922{
     923    CheckComArgOutPointerValid(aAutostartDbPath);
     924
     925    AutoCaller autoCaller(this);
     926    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     927
     928    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     929
     930    m->strAutostartDatabasePath.cloneTo(aAutostartDbPath);
     931
     932    return S_OK;
     933}
     934
     935STDMETHODIMP SystemProperties::COMSETTER(AutostartDatabasePath)(IN_BSTR aAutostartDbPath)
     936{
     937    AutoCaller autoCaller(this);
     938    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     939
     940    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     941    HRESULT rc = setAutostartDatabasePath(aAutostartDbPath);
     942    alock.release();
     943
     944    if (SUCCEEDED(rc))
     945    {
     946        // VirtualBox::saveSettings() needs vbox write lock
     947        AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS);
     948        rc = mParent->saveSettings();
     949    }
     950
     951    return rc;
     952}
     953
    920954// public methods only for internal purposes
    921955/////////////////////////////////////////////////////////////////////////////
     
    946980
    947981    m->ulLogHistoryCount = data.ulLogHistoryCount;
     982
     983    rc = setAutostartDatabasePath(data.strAutostartDatabasePath);
     984    if (FAILED(rc)) return rc;
    948985
    949986    return S_OK;
     
    11241161    return S_OK;
    11251162}
     1163
     1164HRESULT SystemProperties::setAutostartDatabasePath(const Utf8Str &aPath)
     1165{
     1166    HRESULT rc = S_OK;
     1167    AutostartDb *autostartDb = this->mParent->getAutostartDb();
     1168
     1169    if (!aPath.isEmpty())
     1170    {
     1171        /* Update path in the autostart database. */
     1172        int vrc = autostartDb->setAutostartDbPath(aPath.c_str());
     1173        if (RT_SUCCESS(vrc))
     1174            m->strAutostartDatabasePath = aPath;
     1175        else
     1176            rc = setError(E_FAIL,
     1177                          tr("Cannot set the autostart database path (%Rrc)"),
     1178                          vrc);
     1179    }
     1180    else
     1181    {
     1182        int vrc = autostartDb->setAutostartDbPath(NULL);
     1183        AssertRC(vrc);
     1184        m->strAutostartDatabasePath = "";
     1185    }
     1186
     1187    return rc;
     1188}
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r42177 r42178  
    423423        if (FAILED(rc)) throw rc;
    424424
     425        /*
     426         * Create autostart database object early, because the system properties
     427         * might need it.
     428         */
     429        unconst(m->pAutostartDb) = new AutostartDb;
     430
    425431        /* create the system properties object, someone may need it too */
    426432        unconst(m->pSystemProperties).createObject();
     
    489495            throw rc;
    490496#endif
    491 
    492         unconst(m->pAutostartDb) = new AutostartDb;
    493497    }
    494498    catch (HRESULT err)
Note: See TracChangeset for help on using the changeset viewer.

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