VirtualBox

Ignore:
Timestamp:
Feb 4, 2025 5:24:54 AM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167323
Message:

doc/manual,include/VBox,Frontends/{VBoxManage,VirtualBox/src},Main/{include,SharedFolder,Console,Machine,VirtualBox,VirtualBox.xidl}: Added global shared folders and adjusted fetching and handling of folders between shared folder types bugref:3544

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 edited

Legend:

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

    r108003 r108046  
    27932793        RTPrintf("%-28s ", Info::tr("Shared folders:"));
    27942794    uint32_t numSharedFolders = 0;
    2795 #if 0 // not yet implemented
    27962795    /* globally shared folders first */
    27972796    {
    2798         SafeIfaceArray <ISharedFolder> sfColl;
    2799         CHECK_ERROR_RET(pVirtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sfColl)), rc);
    2800         for (size_t i = 0; i < sfColl.size(); ++i)
    2801         {
    2802             ComPtr<ISharedFolder> sf = sfColl[i];
     2797        com::SafeIfaceArray <ISharedFolder> folders;
     2798        CHECK_ERROR_RET(pVirtualBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), hrc);
     2799        for (size_t i = 0; i < folders.size(); ++i)
     2800        {
     2801            ComPtr<ISharedFolder> sf = folders[i];
    28032802            showSharedFolder(sf, details, Info::tr("global mapping"), "GlobalMapping", i + 1, numSharedFolders == 0);
    28042803            ++numSharedFolders;
    28052804        }
    28062805    }
    2807 #endif
    28082806    /* now VM mappings */
    28092807    {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r108003 r108046  
    16871687     * Done parsing, do some work.
    16881688     */
    1689     ComPtr<IMachine> ptrMachine;
    1690     CHECK_ERROR2I_RET(a->virtualBox, FindMachine(Bstr(pszMachineName).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
    1691     AssertReturn(ptrMachine.isNotNull(), RTEXITCODE_FAILURE);
    1692 
    16931689    HRESULT hrc;
    1694     if (fTransient)
    1695     {
    1696         /* open an existing session for the VM */
    1697         CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Shared), RTEXITCODE_FAILURE);
    1698 
    1699         /* get the session machine */
    1700         ComPtr<IMachine> ptrSessionMachine;
    1701         CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1702 
    1703         /* get the session console */
    1704         ComPtr<IConsole> ptrConsole;
    1705         CHECK_ERROR2I_RET(a->session, COMGETTER(Console)(ptrConsole.asOutParam()), RTEXITCODE_FAILURE);
    1706         if (ptrConsole.isNull())
    1707             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' is not currently running."), pszMachineName);
    1708 
    1709         CHECK_ERROR2(hrc, ptrConsole, CreateSharedFolder(Bstr(pszName).raw(), Bstr(szAbsHostPath).raw(),
    1710                                                          fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));
    1711         a->session->UnlockMachine();
     1690    if (!strcmp(pszMachineName, "global"))
     1691    {
     1692        if (fTransient)
     1693            return errorSyntax(Misc::tr("Invalid option: global and transient both specified"));
     1694        ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     1695        CHECK_ERROR2(hrc, pVirtualBox, CreateSharedFolder(Bstr(pszName).raw(), Bstr(szAbsHostPath).raw(),
     1696                                                          fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));
    17121697    }
    17131698    else
    17141699    {
    1715         /* open a session for the VM */
    1716         CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
    1717 
    1718         /* get the mutable session machine */
    1719         ComPtr<IMachine> ptrSessionMachine;
    1720         CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1721 
    1722         CHECK_ERROR2(hrc, ptrSessionMachine, CreateSharedFolder(Bstr(pszName).raw(), Bstr(szAbsHostPath).raw(),
    1723                                                                 fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));
    1724         if (SUCCEEDED(hrc))
    1725         {
    1726             CHECK_ERROR2(hrc, ptrSessionMachine, SaveSettings());
    1727         }
    1728 
    1729         a->session->UnlockMachine();
     1700        ComPtr<IMachine> ptrMachine;
     1701        CHECK_ERROR2I_RET(a->virtualBox, FindMachine(Bstr(pszMachineName).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
     1702        AssertReturn(ptrMachine.isNotNull(), RTEXITCODE_FAILURE);
     1703
     1704        if (fTransient)
     1705        {
     1706            /* open an existing session for the VM */
     1707            CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Shared), RTEXITCODE_FAILURE);
     1708
     1709            /* get the session machine */
     1710            ComPtr<IMachine> ptrSessionMachine;
     1711            CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
     1712
     1713            /* get the session console */
     1714            ComPtr<IConsole> ptrConsole;
     1715            CHECK_ERROR2I_RET(a->session, COMGETTER(Console)(ptrConsole.asOutParam()), RTEXITCODE_FAILURE);
     1716            if (ptrConsole.isNull())
     1717                return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' is not currently running."), pszMachineName);
     1718
     1719            CHECK_ERROR2(hrc, ptrConsole, CreateSharedFolder(Bstr(pszName).raw(), Bstr(szAbsHostPath).raw(),
     1720                                                             fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));
     1721            a->session->UnlockMachine();
     1722        }
     1723        else
     1724        {
     1725            /* open a session for the VM */
     1726            CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
     1727
     1728            /* get the mutable session machine */
     1729            ComPtr<IMachine> ptrSessionMachine;
     1730            CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
     1731
     1732            CHECK_ERROR2(hrc, ptrSessionMachine, CreateSharedFolder(Bstr(pszName).raw(), Bstr(szAbsHostPath).raw(),
     1733                                                                    fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));
     1734            if (SUCCEEDED(hrc))
     1735            {
     1736                CHECK_ERROR2(hrc, ptrSessionMachine, SaveSettings());
     1737            }
     1738
     1739            a->session->UnlockMachine();
     1740        }
    17301741    }
    17311742
     
    17851796     * Done parsing, do some real work.
    17861797     */
    1787     ComPtr<IMachine> ptrMachine;
    1788     CHECK_ERROR2I_RET(a->virtualBox, FindMachine(Bstr(pszMachineName).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
    1789     AssertReturn(ptrMachine.isNotNull(), RTEXITCODE_FAILURE);
    1790 
    17911798    HRESULT hrc;
    1792     if (fTransient)
    1793     {
    1794         /* open an existing session for the VM */
    1795         CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Shared), RTEXITCODE_FAILURE);
    1796         /* get the session machine */
    1797         ComPtr<IMachine> ptrSessionMachine;
    1798         CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1799         /* get the session console */
    1800         ComPtr<IConsole> ptrConsole;
    1801         CHECK_ERROR2I_RET(a->session, COMGETTER(Console)(ptrConsole.asOutParam()), RTEXITCODE_FAILURE);
    1802         if (ptrConsole.isNull())
    1803             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' is not currently running.\n"), pszMachineName);
    1804 
    1805         CHECK_ERROR2(hrc, ptrConsole, RemoveSharedFolder(Bstr(pszName).raw()));
    1806 
    1807         a->session->UnlockMachine();
     1799    if (!strcmp(pszMachineName, "global"))
     1800    {
     1801        ComPtr<IVirtualBox> pVirtualBox = a->virtualBox;
     1802        CHECK_ERROR2(hrc, pVirtualBox, RemoveSharedFolder(Bstr(pszName).raw()));
    18081803    }
    18091804    else
    18101805    {
    1811         /* open a session for the VM */
    1812         CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
    1813 
    1814         /* get the mutable session machine */
    1815         ComPtr<IMachine> ptrSessionMachine;
    1816         CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1817 
    1818         CHECK_ERROR2(hrc, ptrSessionMachine, RemoveSharedFolder(Bstr(pszName).raw()));
    1819 
    1820         /* commit and close the session */
    1821         if (SUCCEEDED(hrc))
    1822         {
    1823             CHECK_ERROR2(hrc, ptrSessionMachine, SaveSettings());
    1824         }
    1825         a->session->UnlockMachine();
     1806        ComPtr<IMachine> ptrMachine;
     1807        CHECK_ERROR2I_RET(a->virtualBox, FindMachine(Bstr(pszMachineName).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
     1808        AssertReturn(ptrMachine.isNotNull(), RTEXITCODE_FAILURE);
     1809
     1810        if (fTransient)
     1811        {
     1812            /* open an existing session for the VM */
     1813            CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Shared), RTEXITCODE_FAILURE);
     1814            /* get the session machine */
     1815            ComPtr<IMachine> ptrSessionMachine;
     1816            CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
     1817            /* get the session console */
     1818            ComPtr<IConsole> ptrConsole;
     1819            CHECK_ERROR2I_RET(a->session, COMGETTER(Console)(ptrConsole.asOutParam()), RTEXITCODE_FAILURE);
     1820            if (ptrConsole.isNull())
     1821                return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' is not currently running.\n"), pszMachineName);
     1822
     1823            CHECK_ERROR2(hrc, ptrConsole, RemoveSharedFolder(Bstr(pszName).raw()));
     1824
     1825            a->session->UnlockMachine();
     1826        }
     1827        else
     1828        {
     1829            /* open a session for the VM */
     1830            CHECK_ERROR2I_RET(ptrMachine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
     1831
     1832            /* get the mutable session machine */
     1833            ComPtr<IMachine> ptrSessionMachine;
     1834            CHECK_ERROR2I_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
     1835
     1836            CHECK_ERROR2(hrc, ptrSessionMachine, RemoveSharedFolder(Bstr(pszName).raw()));
     1837
     1838            /* commit and close the session */
     1839            if (SUCCEEDED(hrc))
     1840            {
     1841                CHECK_ERROR2(hrc, ptrSessionMachine, SaveSettings());
     1842            }
     1843            a->session->UnlockMachine();
     1844        }
    18261845    }
    18271846
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