VirtualBox

Changeset 46524 in vbox


Ignore:
Timestamp:
Jun 13, 2013 12:10:23 PM (11 years ago)
Author:
vboxsync
Message:

Main/IGuest::UpdateGuestAdditions: Implemented support for passing optional command line arguments to the performing installer on the guest (untested).

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/SDKRef.xml

    r46478 r46524  
    36443644            the host.</para>
    36453645        </listitem>
     3646
     3647        <listitem>
     3648          <para>The parameter list for <xref
     3649          linkend="IGuest__updateGuestAdditions"
     3650          xreflabel="IMedium::updateGuestAdditions()" /> was modified.</para>
     3651          It now supports specifying optional command line arguments for the
     3652          Guest Additions installer performing the actual update on the guest.
     3653        </listitem>
    36463654      </itemizedlist>
    36473655    </sect1>
  • trunk/doc/manual/en_US/user_VBoxManage.xml

    r46207 r46524  
    32163216          <screen>VBoxManage guestcontrol &lt;vmname&gt;|&lt;uuid&gt; updateadditions
    32173217            [--source "&lt;guest additions .ISO file to use&gt;"] [--verbose]
    3218             [--wait-start]</screen>
     3218            [--wait-start] [-- [&lt;argument1&gt;] ... [&lt;argumentN&gt;]]</screen>
    32193219
    32203220          <para>where the parameters mean: <glosslist>
     
    32543254                  <para>When omitting this flag VBoxManage will wait for the
    32553255                    whole Guest Additions update to complete.</para>
     3256                </glossdef>
     3257              </glossentry>
     3258
     3259              <glossentry>
     3260                <glossterm>[-- [&lt;argument1s&gt;] ... [&lt;argumentNs&gt;]]</glossterm>
     3261
     3262                <glossdef>
     3263                  <para>Optional command line arguments to use for the Guest Additions
     3264                  installer. Useful for retrofitting features which weren't installed
     3265                  before on the guest.</para>
     3266                  <para>Arguments containing spaces must be enclosed in
     3267                  quotation marks.</para>
    32563268                </glossdef>
    32573269              </glossentry>
  • trunk/doc/manual/user_ChangeLogImpl.xml

    r46100 r46524  
    3838          media, and support the <computeroutput>--long</computeroutput>
    3939          option to show really all available details</para>
     40      </listitem>
     41
     42      <listitem>
     43        <para>VBoxManage: added support for optional command line parameters for
     44          the automatic Guest Additions update.</para>
    4045      </listitem>
    4146
  • trunk/src/VBox

  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r46009 r46524  
    261261                 "                            [--source <guest additions .ISO>] [--verbose]\n"
    262262                 "                            [--wait-start]\n"
     263                 "                            [-- [<argument1>] ... [<argumentN>]]\n"
    263264                 "\n", pcszSep1, pcszSep2);
    264265}
     
    633634    com::SafeArray<ProcessCreateFlag_T>  aCreateFlags;
    634635    com::SafeArray<ProcessWaitForFlag_T> aWaitFlags;
    635     com::SafeArray<IN_BSTR>              args;
    636     com::SafeArray<IN_BSTR>              env;
     636    com::SafeArray<IN_BSTR>              aArgs;
     637    com::SafeArray<IN_BSTR>              aEnv;
    637638    Utf8Str                              strUsername;
    638639    Utf8Str                              strPassword;
     
    669670                    return errorSyntax(USAGE_GUESTCONTROL, "Failed to parse environment value, rc=%Rrc", vrc);
    670671                for (int j = 0; j < cArgs; j++)
    671                     env.push_back(Bstr(papszArg[j]).raw());
     672                    aEnv.push_back(Bstr(papszArg[j]).raw());
    672673
    673674                RTGetOptArgvFree(papszArg);
     
    742743            case VINF_GETOPT_NOT_OPTION:
    743744            {
    744                 if (args.size() == 0 && strCmd.isEmpty())
     745                if (aArgs.size() == 0 && strCmd.isEmpty())
    745746                    strCmd = ValueUnion.psz;
    746747                else
    747                     args.push_back(Bstr(ValueUnion.psz).raw());
     748                    aArgs.push_back(Bstr(ValueUnion.psz).raw());
    748749                break;
    749750            }
     
    837838        ComPtr<IGuestProcess> pProcess;
    838839        rc = pGuestSession->ProcessCreate(Bstr(strCmd).raw(),
    839                                           ComSafeArrayAsInParam(args),
    840                                           ComSafeArrayAsInParam(env),
     840                                          ComSafeArrayAsInParam(aArgs),
     841                                          ComSafeArrayAsInParam(aEnv),
    841842                                          ComSafeArrayAsInParam(aCreateFlags),
    842843                                          cMsTimeout,
     
    26522653     */
    26532654    Utf8Str strSource;
     2655    com::SafeArray<IN_BSTR> aArgs;
    26542656    bool fVerbose = false;
    26552657    bool fWaitStartOnly = false;
     
    26842686                fWaitStartOnly = true;
    26852687                break;
     2688
     2689            case VINF_GETOPT_NOT_OPTION:
     2690            {
     2691                if (aArgs.size() == 0 && strSource.isEmpty())
     2692                    strSource = ValueUnion.psz;
     2693                else
     2694                    aArgs.push_back(Bstr(ValueUnion.psz).raw());
     2695                break;
     2696            }
    26862697
    26872698            default:
     
    27312742        ComPtr<IProgress> pProgress;
    27322743        CHECK_ERROR(guest, UpdateGuestAdditions(Bstr(strSource).raw(),
     2744                                                ComSafeArrayAsInParam(aArgs),
    27332745                                                /* Wait for whole update process to complete. */
    27342746                                                ComSafeArrayAsInParam(aUpdateFlags),
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r46430 r46524  
    490490#else
    491491    CGuest guest = session().GetConsole().GetGuest();
    492     QVector<KAdditionsUpdateFlag> flagsUpdate;
    493     CProgress progressInstall = guest.UpdateGuestAdditions(strSource, flagsUpdate);
     492    QVector<KAdditionsUpdateFlag> aFlagsUpdate;
     493    QVector<QString> aArgs;
     494    CProgress progressInstall = guest.UpdateGuestAdditions(strSource,
     495                                                           aArgs, aFlagsUpdate);
    494496    bool fResult = guest.isOk();
    495497    if (fResult)
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r46523 r46524  
    85828582    <attribute name="loggingLevel" type="wstring">
    85838583      <desc>
    8584         Specifies the logging level in current use by VirtualBox. 
     8584        Specifies the logging level in current use by VirtualBox.
    85858585      </desc>
    85868586    </attribute>
     
    1120611206  <interface
    1120711207    name="IGuest" extends="$unknown"
    11208     uuid="19c32350-0618-4ede-b0c3-2b4311bf0d9b"
     11208    uuid="1a1969c1-a583-4975-9810-1dd0f0e3a8ae"
    1120911209    wsmap="managed"
    1121011210    >
     
    1169911699      <param name="source" type="wstring" dir="in">
    1170011700        <desc>
    11701           Path to the Guest Additions .ISO file to use for the upate.
     11701          Path to the Guest Additions .ISO file to use for the update.
     11702        </desc>
     11703      </param>
     11704      <param name="arguments" type="wstring" dir="in" safearray="yes">
     11705        <desc>
     11706          Optional command line arguments to use for the Guest Additions
     11707          installer. Useful for retrofitting features which weren't installed
     11708          before on the guest.
    1170211709        </desc>
    1170311710      </param>
     
    2035520362    </desc>
    2035620363  </interface>
    20357  
     20364
    2035820365  <interface
    2035920366    name="IVideoCaptureChangedEvent" extends="IEvent"
  • trunk/src/VBox/Main/include/GuestImpl.h

    r46457 r46524  
    109109                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
    110110                                     ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
    111     STDMETHOD(UpdateGuestAdditions)(IN_BSTR aSource, ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags), IProgress **aProgress);
     111    STDMETHOD(UpdateGuestAdditions)(IN_BSTR aSource, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags), IProgress **aProgress);
    112112
    113113public:
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r45780 r46524  
    159159
    160160    SessionTaskUpdateAdditions(GuestSession *pSession,
    161                                const Utf8Str &strSource, uint32_t uFlags);
     161                               const Utf8Str &strSource, const ProcessArguments &aArguments,
     162                               uint32_t uFlags);
    162163
    163164    virtual ~SessionTaskUpdateAdditions(void);
     
    220221    };
    221222
     223    int addProcessArguments(ProcessArguments &aArgumentsDest,
     224                            const ProcessArguments &aArgumentsSource);
    222225    int copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
    223226                        Utf8Str const &strFileSource, const Utf8Str &strFileDest,
     
    230233     *  which will be used for the updating process. */
    231234    Utf8Str                    mSource;
     235    /** (Optional) installer command line arguments. */
     236    ProcessArguments           mArguments;
    232237    /** Update flags. */
    233238    uint32_t                   mFlags;
  • trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp

    r45415 r46524  
    115115#endif /* VBOX_WITH_GUEST_CONTROL */
    116116
    117 STDMETHODIMP Guest::UpdateGuestAdditions(IN_BSTR aSource, ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags), IProgress **aProgress)
     117STDMETHODIMP Guest::UpdateGuestAdditions(IN_BSTR aSource, ComSafeArrayIn(AdditionsUpdateFlag_T, aFlags),
     118                                         ComSafeArrayIn(IN_BSTR, aArguments), IProgress **aProgress)
    118119{
    119120#ifndef VBOX_WITH_GUEST_CONTROL
     
    139140        if (!(fFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly))
    140141            return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), aFlags);
     142    }
     143
     144    int rc = VINF_SUCCESS;
     145
     146    ProcessArguments aArgs;
     147    if (aArguments)
     148    {
     149        try
     150        {
     151            com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
     152            for (size_t i = 0; i < arguments.size(); i++)
     153                aArgs.push_back(Utf8Str(arguments[i]));
     154        }
     155        catch(std::bad_alloc &)
     156        {
     157            rc = VERR_NO_MEMORY;
     158        }
    141159    }
    142160
     
    154172
    155173    ComObjPtr<GuestSession> pSession;
    156     int rc = sessionCreate(startupInfo, guestCreds, pSession);
     174    if (RT_SUCCESS(rc))
     175        rc = sessionCreate(startupInfo, guestCreds, pSession);
    157176    if (RT_FAILURE(rc))
    158177    {
     
    188207                ComObjPtr<Progress> pProgress;
    189208                SessionTaskUpdateAdditions *pTask = new SessionTaskUpdateAdditions(pSession /* GuestSession */,
    190                                                                                    Utf8Str(aSource), fFlags);
     209                                                                                   Utf8Str(aSource), aArgs, fFlags);
    191210                rc = pSession->startTaskAsync(tr("Updating Guest Additions"), pTask, pProgress);
    192211                if (RT_SUCCESS(rc))
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r45572 r46524  
    840840
    841841SessionTaskUpdateAdditions::SessionTaskUpdateAdditions(GuestSession *pSession,
    842                                                        const Utf8Str &strSource, uint32_t uFlags)
     842                                                       const Utf8Str &strSource,
     843                                                       const ProcessArguments &aArguments,
     844                                                       uint32_t uFlags)
    843845                                                       : GuestSessionTask(pSession)
    844846{
    845847    mSource = strSource;
     848    mArguments = aArguments;
    846849    mFlags  = uFlags;
    847850}
     
    850853{
    851854
     855}
     856
     857int SessionTaskUpdateAdditions::addProcessArguments(ProcessArguments &aArgumentsDest,
     858                                                    const ProcessArguments &aArgumentsSource)
     859{
     860    int rc = VINF_SUCCESS;
     861
     862    try
     863    {
     864        /* Filter out arguments which already are in the destination to
     865         * not end up having them specified twice. Not the fastest method on the
     866         * planet but does the job. */
     867        ProcessArguments::const_iterator itSource = aArgumentsSource.begin();
     868        while (itSource != aArgumentsSource.end())
     869        {
     870            bool fFound = false;
     871            ProcessArguments::iterator itDest = aArgumentsDest.begin();
     872            while (itDest != aArgumentsDest.end())
     873            {
     874                if ((*itDest).equalsIgnoreCase((*itSource)))
     875                {
     876                    fFound = true;
     877                    break;
     878                }
     879                itDest++;
     880            }
     881
     882            if (!fFound)
     883                aArgumentsDest.push_back((*itSource));
     884
     885            itSource++;
     886        }
     887    }
     888    catch(std::bad_alloc &)
     889    {
     890        return VERR_NO_MEMORY;
     891    }
     892
     893    return rc;
    852894}
    853895
     
    13311373                         * Windows taskbar. */
    13321374                        siInstaller.mArguments.push_back(Utf8Str("/post_installstatus"));
     1375                        /* Add optional installer command line arguments from the API to the
     1376                         * installer's startup info. */
     1377                        rc = addProcessArguments(siInstaller.mArguments, mArguments);
     1378                        AssertRC(rc);
    13331379                        /* If the caller does not want to wait for out guest update process to end,
    13341380                         * complete the progress object now so that the caller can do other work. */
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