VirtualBox

Changeset 61610 in vbox


Ignore:
Timestamp:
Jun 9, 2016 10:22:42 AM (9 years ago)
Author:
vboxsync
Message:

Main: properly inform the user if the VRDE server cannot be started at runtime

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r59787 r61610  
    336336
    337337    void notifyNatDnsChange(PUVM pUVM, const char *pszDevice, ULONG ulInstanceMax);
     338    Utf8Str VRDPServerErrorToMsg(int vrc);
    338339
    339340    /**
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r61536 r61610  
    51735173
    51745174/**
     5175 * Check the return code of mConsoleVRDPServer->Launch. LogRel() the error reason and
     5176 * return an error message appropriate for setError().
     5177 */
     5178Utf8Str Console::VRDPServerErrorToMsg(int vrc)
     5179{
     5180    Utf8Str errMsg;
     5181    if (vrc == VERR_NET_ADDRESS_IN_USE)
     5182    {
     5183        Bstr bstr;
     5184        mVRDEServer->GetVRDEProperty(Bstr("TCP/Ports").raw(), bstr.asOutParam());
     5185        errMsg = Utf8StrFmt(tr("VirtualBox Remote Desktop Extension server can't bind to the port(s): %s"),
     5186                                Utf8Str(bstr).c_str());
     5187        LogRel(("VRDE: Warning: failed to launch VRDE server (%Rrc): '%s'\n", vrc, errMsg.c_str()));
     5188    }
     5189    else if (vrc == VINF_NOT_SUPPORTED)
     5190    {
     5191        /* This means that the VRDE is not installed. */
     5192        LogRel(("VRDE: VirtualBox Remote Desktop Extension is not available.\n"));
     5193        errMsg = Utf8Str("VirtualBox Remote Desktop Extension is not available");
     5194    }
     5195    else if (RT_FAILURE(vrc))
     5196    {
     5197        /* Fail if the server is installed but can't start. */
     5198        switch (vrc)
     5199        {
     5200            case VERR_FILE_NOT_FOUND:
     5201                errMsg = Utf8StrFmt(tr("Could not find the VirtualBox Remote Desktop Extension library."));
     5202                break;
     5203            default:
     5204                errMsg = Utf8StrFmt(tr("Failed to launch the Remote Desktop Extension server (%Rrc)"), vrc);
     5205                break;
     5206        }
     5207        LogRel(("VRDE: Failed: (%Rrc): %s\n", vrc, errMsg.c_str()));
     5208    }
     5209
     5210    return errMsg;
     5211}
     5212
     5213/**
    51755214 * Called by IInternalSessionControl::OnVRDEServerChange().
    51765215 *
     
    52255264
    52265265                            int vrc = mConsoleVRDPServer->Launch();
    5227                             if (RT_FAILURE(vrc))
    5228                                 rc = setError(E_FAIL,
    5229                                               tr("Could not start the VRDP server (%Rrc)"), vrc);
     5266                            Utf8Str errMsg = VRDPServerErrorToMsg(vrc);
     5267                            if (vrc != VINF_SUCCESS)
     5268                                rc = setError(E_FAIL, errMsg.c_str());
    52305269                            else
    52315270                                mConsoleVRDPServer->EnableConnections();
     
    52545293    }
    52555294
     5295    LogRel(("RETURN %Rhrc\n", rc));
    52565296    return rc;
    52575297}
     
    95589598        alock.acquire();
    95599599
    9560         if (vrc == VERR_NET_ADDRESS_IN_USE)
    9561         {
    9562             Utf8Str errMsg;
    9563             Bstr bstr;
    9564             pConsole->mVRDEServer->GetVRDEProperty(Bstr("TCP/Ports").raw(), bstr.asOutParam());
    9565             Utf8Str ports = bstr;
    9566             errMsg = Utf8StrFmt(tr("VirtualBox Remote Desktop Extension server can't bind to the port: %s"),
    9567                                 ports.c_str());
    9568             LogRel(("VRDE: Warning: failed to launch VRDE server (%Rrc): '%s'\n",
    9569                     vrc, errMsg.c_str()));
    9570         }
    9571         else if (vrc == VINF_NOT_SUPPORTED)
    9572         {
    9573             /* This means that the VRDE is not installed. */
    9574             LogRel(("VRDE: VirtualBox Remote Desktop Extension is not available.\n"));
    9575         }
    9576         else if (RT_FAILURE(vrc))
    9577         {
    9578             /* Fail, if the server is installed but can't start. */
    9579             Utf8Str errMsg;
    9580             switch (vrc)
    9581             {
    9582                 case VERR_FILE_NOT_FOUND:
    9583                 {
    9584                     /* VRDE library file is missing. */
    9585                     errMsg = Utf8StrFmt(tr("Could not find the VirtualBox Remote Desktop Extension library."));
    9586                     break;
    9587                 }
    9588                 default:
    9589                     errMsg = Utf8StrFmt(tr("Failed to launch Remote Desktop Extension server (%Rrc)"),
    9590                                         vrc);
    9591             }
    9592             LogRel(("VRDE: Failed: (%Rrc), error message: '%s'\n",
    9593                      vrc, errMsg.c_str()));
     9600        Utf8Str errMsg = pConsole->VRDPServerErrorToMsg(vrc);
     9601        if (   RT_FAILURE(vrc)
     9602            && vrc != VERR_NET_ADDRESS_IN_USE) /* this is not fatal */
    95949603            throw i_setErrorStatic(E_FAIL, errMsg.c_str());
    9595         }
    95969604
    95979605        ComPtr<IMachine> pMachine = pConsole->i_machine();
     
    98559863                 */
    98569864                AssertMsgFailed(("Missing error message during powerup for status code %Rrc\n", vrc));
    9857                 task->mErrorMsg = Utf8StrFmt(tr("Failed to start VM execution (%Rrc)"),
    9858                                              vrc);
     9865                task->mErrorMsg = Utf8StrFmt(tr("Failed to start VM execution (%Rrc)"), vrc);
    98599866            }
    98609867
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