VirtualBox

Changeset 30758 in vbox


Ignore:
Timestamp:
Jul 9, 2010 12:30:12 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63541
Message:

More fine grained Guest Additions status; now marks Additions as active when VBoxService was started successfully.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r30668 r30758  
    412412VBGLR3DECL(int)     VbglR3SetGuestCaps(uint32_t fOr, uint32_t fNot);
    413413VBGLR3DECL(int)     VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents);
     414
     415VBGLR3DECL(int)     VbglR3ReportAdditionsStatus(uint32_t u32Facility, uint32_t u32Status, uint32_t u32Flags);
    414416VBGLR3DECL(int)     VbglR3GetAdditionsVersion(char **ppszVer, char **ppszRev);
    415417VBGLR3DECL(int)     VbglR3GetAdditionsInstallationPath(char **ppszPath);
  • trunk/include/VBox/VMMDev.h

    r30668 r30758  
    138138    VMMDevReq_ReportGuestInfo            = 50,
    139139    VMMDevReq_ReportGuestInfo2           = 58, /* since version 3.2.0 */
     140    VMMDevReq_ReportGuestStatus          = 59, /* since version 3.2.8 */
    140141    VMMDevReq_GetDisplayChangeRequest    = 51,
    141142    VMMDevReq_VideoModeSupported         = 52,
     
    434435AssertCompileSize(VMMDevReqGuestCapabilities2, 24+8);
    435436
    436 /** @name Guest capability bits .
     437/** @name Guest capability bits.
    437438 * Used by VMMDevReq_ReportGuestCapabilities and VMMDevReq_SetGuestCapabilities.
    438439 * @{ */
     
    645646} VMMDevReportGuestInfo2;
    646647AssertCompileSize(VMMDevReportGuestInfo2, 24+144);
     648
     649
     650/**
     651 * Guest status facility.
     652 */
     653typedef enum
     654{
     655    VBoxGuestStatusFacility_Unknown         = 0,
     656    VBoxGuestStatusFacility_VBoxGuestDriver = 20,
     657    VBoxGuestStatusFacility_VBoxService     = 100,
     658    VBoxGuestStatusFacility_VBoxTray        = 101,
     659    VBoxGuestStatusFacility_All             = 999,
     660    VBoxGuestStatusFacility_SizeHack        = 0x7fffffff
     661} VBoxGuestStatusFacility;
     662AssertCompileSize(VBoxGuestStatusFacility, 4);
     663
     664/**
     665 * The current guest status of a facility.
     666 */
     667typedef enum
     668{
     669    VBoxGuestStatusCurrent_Disabled    = 0,
     670    VBoxGuestStatusCurrent_Inactive    = 1,
     671    VBoxGuestStatusCurrent_PreInit     = 20,
     672    VBoxGuestStatusCurrent_Init        = 30,
     673    VBoxGuestStatusCurrent_Active      = 50,
     674    VBoxGuestStatusCurrent_Terminating = 100,
     675    VBoxGuestStatusCurrent_Terminated  = 101,
     676    VBoxGuestStatusCurrent_SizeHack    = 0x7fffffff
     677} VBoxGuestStatusCurrent;
     678AssertCompileSize(VBoxGuestStatusCurrent, 4);
     679
     680/**
     681 * Guest status structure.
     682 *
     683 * Used by VMMDevReqGuestStatus.
     684 */
     685typedef struct VBoxGuestStatus
     686{
     687    /** Facility the status is indicated for. */
     688    uint32_t facility;
     689    /** Current guest status. */
     690    uint32_t status;
     691    /** Flags, not used. */
     692    uint32_t flags;
     693} VBoxGuestStatus;
     694AssertCompileSize(VBoxGuestStatus, 12);
     695
     696/**
     697 * Guest Additions status structure.
     698 *
     699 * Used by VMMDevReq_ReportGuestStatus.
     700 */
     701typedef struct
     702{
     703    /** Header. */
     704    VMMDevRequestHeader header;
     705    /** Guest information. */
     706    VBoxGuestStatus guestStatus;
     707} VMMDevReportGuestStatus;
     708AssertCompileSize(VMMDevReportGuestStatus, 24+12);
    647709
    648710
     
    16651727        case VMMDevReq_ReportGuestInfo2:
    16661728            return sizeof(VMMDevReportGuestInfo2);
     1729        case VMMDevReq_ReportGuestStatus:
     1730            return sizeof(VMMDevReportGuestStatus);
    16671731        case VMMDevReq_GetDisplayChangeRequest:
    16681732            return sizeof(VMMDevDisplayChangeRequest);
  • trunk/include/VBox/pdmifs.h

    r30467 r30758  
    20902090{
    20912091    /**
    2092      * Report guest OS version.
    2093      * Called whenever the Additions issue a guest version report request.
     2092     * Reports the guest status.
     2093     * Called whenever the Additions issue a guest status report request.
     2094     *
     2095     * @param   pInterface          Pointer to this interface.
     2096     * @param   pGuestStatus        Pointer to guest information structure
     2097     * @thread  The emulation thread.
     2098     */
     2099    DECLR3CALLBACKMEMBER(void, pfnUpdateGuestStatus,(PPDMIVMMDEVCONNECTOR pInterface, const struct VBoxGuestStatus *pGuestStatus));
     2100
     2101    /**
     2102     * Reports the guest API and OS version.
     2103     * Called whenever the Additions issue a guest info report request.
    20942104     *
    20952105     * @param   pInterface          Pointer to this interface.
     
    20972107     * @thread  The emulation thread.
    20982108     */
    2099     DECLR3CALLBACKMEMBER(void, pfnUpdateGuestVersion,(PPDMIVMMDEVCONNECTOR pInterface, struct VBoxGuestInfo *pGuestInfo));
     2109    DECLR3CALLBACKMEMBER(void, pfnUpdateGuestInfo,(PPDMIVMMDEVCONNECTOR pInterface, const struct VBoxGuestInfo *pGuestInfo));
    21002110
    21012111    /**
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.cpp

    r29619 r30758  
    191191}
    192192
    193 /** @todo maybe we should drop this routine entirely later because we detecting
    194  *        the running OS via VBoxService in ring 3 using guest properties since a while. */
     193/** @todo Maybe we should drop this routine entirely later because we detecting
     194 *        the running OS via VBoxService in ring 3 using guest properties since a while.
     195 *
     196 *  @todo Consider of using vboxGuestInitReportGuestInfo in the ..\common\Helper.cpp
     197 *        module to have a common base and less redundant code.
     198 */
    195199NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt)
    196200{
     
    234238        if (RT_FAILURE(rc))
    235239        {
    236             dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: error reporting guest info to VMMDev. "
     240            dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
    237241                     "rc = %Rrc\n", rc));
    238242        }
     
    258262        if (RT_FAILURE(rc))
    259263        {
    260             dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: error reporting guest info to VMMDev. "
     264            dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
    261265                     "rc = %Rrc\n", rc));
    262266        }
    263         if (rc == VERR_NOT_IMPLEMENTED)
     267        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    264268            rc = VINF_SUCCESS;
    265 
    266269        VbglGRFree (&pReq2->header);
    267270    }
    268271
     272    /*
     273     * Report guest status to host.  Because the host set the "Guest Additions active" flag as soon
     274     * as he received the VMMDevReportGuestInfo above to make sure all is compatible with older Guest
     275     * Additions we now have to disable that flag again here (too early, VBoxService and friends need
     276     * to start up first).
     277     */
     278    VMMDevReportGuestStatus *pReq3;
     279    rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq3, sizeof(*pReq3), VMMDevReq_ReportGuestStatus);
     280    if (RT_SUCCESS(rc))
     281    {
     282        pReq3->guestStatus.facility = VBoxGuestStatusFacility_VBoxGuestDriver;
     283        pReq3->guestStatus.status = VBoxGuestStatusCurrent_Active; /** @todo Are we actually *really* active at this point? */
     284        pReq3->guestStatus.flags = 0;
     285        rc = VbglGRPerform(&pReq3->header);
     286        if (RT_FAILURE(rc))
     287            dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Reporting guest status failed with rc=%Rrc\n", rc));
     288        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
     289            rc = VINF_SUCCESS;
     290        VbglGRFree(&pReq3->header);
     291    }
     292
    269293    return RT_FAILURE(rc) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;
    270294}
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r30569 r30758  
    833833NTSTATUS VBoxGuestDeviceControl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    834834{
    835     dprintf(("VBoxGuest::VBoxGuestDeviceControl\n"));
     835    //dprintf(("VBoxGuest::VBoxGuestDeviceControl\n"));
    836836
    837837    NTSTATUS Status = STATUS_SUCCESS;
     
    873873             * time a wait event is arrived.
    874874             */
    875             dprintf(("VBoxGuest::VBoxGuestDeviceControl: VBOXGUEST_IOCTL_WAITEVENT\n"));
     875            //dprintf(("VBoxGuest::VBoxGuestDeviceControl: VBOXGUEST_IOCTL_WAITEVENT\n"));
    876876
    877877            if (pStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(VBoxGuestWaitEventInfo))
     
    927927                rc = KeWaitForSingleObject (&pDevExt->keventNotification, Executive /** @todo UserRequest? */,
    928928                                            KernelMode, TRUE, &timeout);
    929                 dprintf(("VBOXGUEST_IOCTL_WAITEVENT: Wait returned %d -> event %x\n", rc, eventInfo->u32EventFlagsOut));
     929                //dprintf(("VBOXGUEST_IOCTL_WAITEVENT: Wait returned %d -> event %x\n", rc, eventInfo->u32EventFlagsOut));
    930930
    931931                if (!fTimeout && rc == STATUS_TIMEOUT)
     
    14301430    IoCompleteRequest(pIrp, IO_NO_INCREMENT);
    14311431
    1432     dprintf(("VBoxGuest::VBoxGuestDeviceControl: returned cbOut=%d rc=%#x\n", cbOut, Status));
    1433 
     1432    //dprintf(("VBoxGuest::VBoxGuestDeviceControl: returned cbOut=%d rc=%#x\n", cbOut, Status));
    14341433    return Status;
    14351434}
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r29625 r30758  
    263263static int vboxGuestInitReportGuestInfo(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType)
    264264{
     265    /*
     266     * Report general info + capabilities to host.
     267     */
    265268    VMMDevReportGuestInfo *pReq;
    266269    int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_ReportGuestInfo);
     
    271274        rc = VbglGRPerform(&pReq->header);
    272275        if (RT_FAILURE(rc))
    273             LogRel(("vboxGuestInitReportGuestInfo: 1st part failed with rc=%Rrc\n", rc));
     276            LogRel(("Guest Additions: Reporting guest info 1 failed with rc=%Rrc\n", rc));
    274277        VbglGRFree(&pReq->header);
    275278    }
     
    286289        RTStrCopy(pReq2->guestInfo.szName, sizeof(pReq2->guestInfo.szName), VBOX_VERSION_STRING);
    287290        rc = VbglGRPerform(&pReq2->header);
    288         if (rc == VERR_NOT_IMPLEMENTED) /* compatibility with older hosts */
     291        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    289292            rc = VINF_SUCCESS;
    290293        if (RT_FAILURE(rc))
    291             LogRel(("vboxGuestInitReportGuestInfo: 2nd part failed with rc=%Rrc\n", rc));
     294            LogRel(("Guest Additions: Reporting guest info 2 failed with rc=%Rrc\n", rc));
    292295        VbglGRFree(&pReq2->header);
     296    }
     297
     298    /*
     299     * Report guest status to host.  Because the host set the "Guest Additions active" flag as soon
     300     * as he received the VMMDevReportGuestInfo above to make sure all is compatible with older Guest
     301     * Additions we now have to disable that flag again here (too early, VBoxService and friends need
     302     * to start up first).
     303     */
     304    VMMDevReportGuestStatus *pReq3;
     305    int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq3, sizeof(*pReq3), VMMDevReq_ReportGuestStatus);
     306    if (RT_SUCCESS(rc))
     307    {
     308        pReq3->guestStatus.facility = VBoxGuestStatusFacility_VBoxGuestDriver;
     309        pReq3->guestStatus.status = VBoxGuestStatusCurrent_Active; /** @todo Are we actually *really* active at this point? */
     310        pReq3->guestStatus.flags = 0;
     311        rc = VbglGRPerform(&pReq3->header);
     312        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
     313            rc = VINF_SUCCESS;
     314        if (RT_FAILURE(rc))
     315            LogRel(("Guest Additions: Reporting guest status failed with rc=%Rrc\n", rc));
     316        VbglGRFree(&pReq3->header);
    293317    }
    294318    return rc;
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAdditions.cpp

    r28800 r30758  
    140140
    141141/**
     142 * Reports the Guest Additions status of a certain facility to the host.
     143 *
     144 * @returns IPRT status value
     145 * @param uFacility
     146 * @param uStatus
     147 * @param uFlags
     148 */
     149VBGLR3DECL(int) VbglR3ReportAdditionsStatus(uint32_t uFacility, uint32_t uStatus, uint32_t uFlags)
     150{
     151    VMMDevReportGuestStatus Report;
     152    RT_ZERO(Report);
     153    int rc = vmmdevInitRequest((VMMDevRequestHeader*)&Report, VMMDevReq_ReportGuestStatus);
     154    if (RT_SUCCESS(rc))
     155    {
     156
     157        Report.guestStatus.facility = uFacility;
     158        Report.guestStatus.status = uStatus;
     159        Report.guestStatus.flags = uFlags;
     160
     161        rc = vbglR3GRPerform(&Report.header);
     162    }
     163    return rc;
     164}
     165
     166/**
    142167 * Retrieves the installed Guest Additions version and/or revision.
    143168 *
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r30561 r30758  
    437437{
    438438    int rc;
     439
     440    /* Report the host that we're up and running! */
     441    rc = VbglR3ReportAdditionsStatus(VBoxGuestStatusFacility_VBoxService,
     442                                     VBoxGuestStatusCurrent_Active,
     443                                     0); /* Flags; not used. */
     444    if (RT_FAILURE(rc))
     445        VBoxServiceError("Failed to report Guest Additions status to the host! rc=%Rrc\n", rc);
    439446
    440447#ifdef RT_OS_WINDOWS
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r30724 r30758  
    472472        case VMMDevReq_ReportGuestInfo:
    473473        {
    474             if (pRequestHeader->size < sizeof(VMMDevReportGuestInfo))
     474            if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo))
    475475            {
    476476                AssertMsgFailed(("VMMDev guest information structure has an invalid size!\n"));
     
    492492                            pThis->guestInfo.additionsVersion,
    493493                            pThis->guestInfo.osType));
    494                     pThis->pDrv->pfnUpdateGuestVersion(pThis->pDrv, &pThis->guestInfo);
     494                    pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    495495                }
    496496
     
    509509        case VMMDevReq_ReportGuestInfo2:
    510510        {
    511             if (pRequestHeader->size < sizeof(VMMDevReportGuestInfo2))
     511            if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo2))
    512512            {
    513513                AssertMsgFailed(("VMMDev guest information 2 structure has an invalid size!\n"));
     
    520520                        guestInfo2->additionsMajor, guestInfo2->additionsMinor, guestInfo2->additionsBuild,
    521521                        guestInfo2->additionsRevision, sizeof(guestInfo2->szName), guestInfo2->szName));
     522                pRequestHeader->rc = VINF_SUCCESS;
     523            }
     524            break;
     525        }
     526
     527        case VMMDevReq_ReportGuestStatus:
     528        {
     529            if (pRequestHeader->size != sizeof(VMMDevReportGuestStatus))
     530            {
     531                AssertMsgFailed(("VMMDev guest status structure has an invalid size!\n"));
     532                pRequestHeader->rc = VERR_INVALID_PARAMETER;
     533            }
     534            else
     535            {
     536                VBoxGuestStatus *guestStatus = &((VMMDevReportGuestStatus*)pRequestHeader)->guestStatus;
     537                pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, guestStatus);
     538
    522539                pRequestHeader->rc = VINF_SUCCESS;
    523540            }
     
    25892606                pThis->guestInfo.osType));
    25902607        if (pThis->pDrv)
    2591             pThis->pDrv->pfnUpdateGuestVersion(pThis->pDrv, &pThis->guestInfo);
     2608            pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    25922609    }
    25932610    if (pThis->pDrv)
     
    27262743     */
    27272744    if (fVersionChanged)
    2728         pThis->pDrv->pfnUpdateGuestVersion(pThis->pDrv, &pThis->guestInfo);
     2745        pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    27292746    if (fCapsChanged)
    27302747        pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r30724 r30758  
    127127    VBoxGuestInfo guestInfo;
    128128
    129     /** Information reported by guest via VMMDevReportGuestCapabilities
    130      */
     129    /** Information reported by guest via VMMDevReportGuestCapabilities. */
    131130    uint32_t      guestCaps;
    132131
  • trunk/src/VBox/Frontends/VBoxBFE/VMMDev.h

    r30594 r30758  
    4444
    4545private:
    46     static DECLCALLBACK(void)   UpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo);
     46    static DECLCALLBACK(void)   UpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo);
    4747    static DECLCALLBACK(void)   UpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities);
    4848    static DECLCALLBACK(void)   UpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities);
  • trunk/src/VBox/Frontends/VBoxBFE/VMMDevInterface.cpp

    r30594 r30758  
    108108
    109109/**
    110  * Report guest OS version.
     110 * Report guest information.
    111111 * Called whenever the Additions issue a guest version report request.
    112112 *
     
    115115 * @thread  The emulation thread.
    116116 */
    117 DECLCALLBACK(void) VMMDev::UpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo)
     117DECLCALLBACK(void) VMMDev::UpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
    118118{
    119119    return;
     
    385385    pDrvIns->IBase.pfnQueryInterface            = VMMDev::drvQueryInterface;
    386386
    387     pData->Connector.pfnUpdateGuestVersion      = VMMDev::UpdateGuestVersion;
     387    pData->Connector.pfnUpdateGuestInfo         = VMMDev::UpdateGuestInfo;
    388388    pData->Connector.pfnUpdateGuestCapabilities = VMMDev::UpdateGuestCapabilities;
    389389    pData->Connector.pfnUpdateMouseCapabilities = VMMDev::UpdateMouseCapabilities;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r30740 r30758  
    19431943                {
    19441944                    if (details == VMINFO_MACHINEREADABLE)
    1945                         RTPrintf("GuestAdditionsAPIVersion=\"%lS\"\n", guestString.raw());
    1946                     else
    1947                         RTPrintf("Additions API version:               %lS\n\n", guestString.raw());
     1945                        RTPrintf("GuestAdditionsVersion=\"%lS\"\n", guestString.raw());
     1946                    else
     1947                        RTPrintf("Additions version:                   %lS\n\n", guestString.raw());
    19481948                }
    19491949            }
  • trunk/src/VBox/Main/GuestImpl.cpp

    r30714 r30758  
    106106
    107107/**
    108  *  Uninitializes the instance and sets the ready flag to FALSE.
    109  *  Called either from FinalRelease() or by the parent when it gets destroyed.
     108 * Uninitializes the instance and sets the ready flag to FALSE.
     109 * Called either from FinalRelease() or by the parent when it gets destroyed.
    110110 */
    111111void Guest::uninit()
     
    383383}
    384384
    385 HRESULT Guest::SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal)
     385HRESULT Guest::setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal)
    386386{
    387387    AutoCaller autoCaller(this);
     
    14161416/////////////////////////////////////////////////////////////////////////////
    14171417
    1418 void Guest::setAdditionsVersion(Bstr aVersion, VBOXOSTYPE aOsType)
     1418/**
     1419 * Sets the general Guest Additions information like
     1420 * API version and OS type.
     1421 *
     1422 * @param aVersion
     1423 * @param aOsType
     1424 */
     1425void Guest::setAdditionsInfo(Bstr aVersion, VBOXOSTYPE aOsType)
    14191426{
    14201427    AutoCaller autoCaller(this);
     
    14231430    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    14241431
     1432    /*
     1433     * Set the Guest Additions API (interface) version.
     1434     * Note that this is *not* the actual Guest Additions version and may differ!
     1435     */
    14251436    mData.mAdditionsVersion = aVersion;
     1437    /*
     1438     * Older Additions rely on the Additions API version whether they
     1439     * are assumed to be active or not. Newer additions will disable
     1440     * this immediately.
     1441     */
    14261442    mData.mAdditionsActive = !aVersion.isEmpty();
    1427     /* Older Additions didn't have this finer grained capability bit,
     1443    /*
     1444     * Older Additions didn't have this finer grained capability bit,
    14281445     * so enable it by default.  Newer Additions will disable it immediately
    1429      * if relevant. */
     1446     * if relevant.
     1447     */
    14301448    mData.mSupportsGraphics = mData.mAdditionsActive;
    14311449
     1450    /*
     1451     * Note! There is a race going on between setting mAdditionsActive and
     1452     * mSupportsGraphics here and disabling/enabling it later according to
     1453     * its real status when using new(er) Guest Additions.
     1454     */
     1455
    14321456    mData.mOSTypeId = Global::OSTypeId (aOsType);
    14331457}
    14341458
    1435 void Guest::setSupportsSeamless (BOOL aSupportsSeamless)
     1459/**
     1460 * Sets the status of a certain Guest Additions facility.
     1461 *
     1462 * @param ulFacility
     1463 * @param ulStatus
     1464 * @param ulFlags
     1465 */
     1466void Guest::setAdditionsStatus (ULONG ulFacility, ULONG ulStatus, ULONG ulFlags)
    14361467{
    14371468    AutoCaller autoCaller(this);
     
    14401471    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    14411472
    1442     mData.mSupportsSeamless = aSupportsSeamless;
    1443 }
    1444 
    1445 void Guest::setSupportsGraphics (BOOL aSupportsGraphics)
     1473    /*
     1474     * Only mark Guest Additions as active when VBoxService started up.
     1475     */
     1476    mData.mAdditionsActive = (   ulFacility == VBoxGuestStatusFacility_VBoxService
     1477                              && ulStatus   == VBoxGuestStatusCurrent_Active) ? TRUE : FALSE;
     1478}
     1479
     1480/**
     1481 * Sets the supported features (and whether they are active or not).
     1482 *
     1483 * @param ulCaps
     1484 * @param ulActive
     1485 */
     1486void Guest::setSupportedFeatures (ULONG64 ulCaps, ULONG64 ulActive)
    14461487{
    14471488    AutoCaller autoCaller(this);
     
    14501491    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    14511492
    1452     mData.mSupportsGraphics = aSupportsGraphics;
     1493    mData.mSupportsSeamless = (ulCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS);
     1494    /** @todo Add VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING */
     1495    mData.mSupportsGraphics = (ulCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS);
    14531496}
    14541497/* vi: set tabstop=4 shiftwidth=4 expandtab: */
     1498
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r29589 r30758  
    158158
    159159/**
    160  * Report guest OS version.
    161  * Called whenever the Additions issue a guest version report request or the VM is reset.
     160 * Reports Guest Additions status.
     161 * Called whenever the Additions issue a guest status report request or the VM is reset.
    162162 *
    163163 * @param   pInterface          Pointer to this interface.
     
    165165 * @thread  The emulation thread.
    166166 */
    167 DECLCALLBACK(void) vmmdevUpdateGuestVersion(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestInfo *guestInfo)
     167DECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestStatus *guestStatus)
     168{
     169    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     170
     171    Assert(guestStatus);
     172    if (!guestStatus)
     173        return;
     174
     175    /* Store that information in IGuest */
     176    Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
     177    Assert(guest);
     178    if (!guest)
     179        return;
     180
     181    guest->setAdditionsStatus(guestStatus->facility,
     182                              guestStatus->status,
     183                              guestStatus->flags);
     184    pDrv->pVMMDev->getParent()->onAdditionsStateChange();
     185}
     186
     187
     188/**
     189 * Reports Guest Additions API and OS version.
     190 * Called whenever the Additions issue a guest version report request or the VM is reset.
     191 *
     192 * @param   pInterface          Pointer to this interface.
     193 * @param   guestInfo           Pointer to guest information structure
     194 * @thread  The emulation thread.
     195 */
     196DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
    168197{
    169198    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     
    172201    if (!guestInfo)
    173202        return;
     203
     204    /* Store that information in IGuest */
     205    Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
     206    Assert(guest);
     207    if (!guest)
     208        return;
     209
     210    if (guestInfo->additionsVersion != 0)
     211    {
     212        char version[20];
     213        RTStrPrintf(version, sizeof(version), "%d", guestInfo->additionsVersion);
     214        guest->setAdditionsInfo(Bstr(version), guestInfo->osType);
     215
     216        /*
     217         * Tell the console interface about the event
     218         * so that it can notify its consumers.
     219         */
     220        pDrv->pVMMDev->getParent()->onAdditionsStateChange();
     221
     222        if (guestInfo->additionsVersion < VMMDEV_VERSION)
     223            pDrv->pVMMDev->getParent()->onAdditionsOutdated();
     224    }
     225    else
     226    {
     227        /*
     228         * The guest additions was disabled because of a reset
     229         * or driver unload.
     230         */
     231        guest->setAdditionsInfo(Bstr(), guestInfo->osType);
     232        guest->setAdditionsStatus(0,  /* Facility; 0 = Global GA status.  May be changed
     233                                       * later to VBoxService' own facility. */
     234                                  0,  /* Status; 0 = Not active */
     235                                  0); /* Flags; not used. */
     236        pDrv->pVMMDev->getParent()->onAdditionsStateChange();
     237    }
     238}
     239
     240/**
     241 * Update the guest additions capabilities.
     242 * This is called when the guest additions capabilities change. The new capabilities
     243 * are given and the connector should update its internal state.
     244 *
     245 * @param   pInterface          Pointer to this interface.
     246 * @param   newCapabilities     New capabilities.
     247 * @thread  The emulation thread.
     248 */
     249DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
     250{
     251    PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
    174252
    175253    /* store that information in IGuest */
     
    179257        return;
    180258
    181     if (guestInfo->additionsVersion != 0)
    182     {
    183         char version[20];
    184         RTStrPrintf(version, sizeof(version), "%d", guestInfo->additionsVersion);
    185         guest->setAdditionsVersion(Bstr(version), guestInfo->osType);
    186 
    187         /*
    188          * Tell the console interface about the event
    189          * so that it can notify its consumers.
    190          */
    191         pDrv->pVMMDev->getParent()->onAdditionsStateChange();
    192 
    193         if (guestInfo->additionsVersion < VMMDEV_VERSION)
    194             pDrv->pVMMDev->getParent()->onAdditionsOutdated();
    195     }
    196     else
    197     {
    198         /*
    199          * The guest additions was disabled because of a reset
    200          * or driver unload.
    201          */
    202         guest->setAdditionsVersion (Bstr(), guestInfo->osType);
    203         pDrv->pVMMDev->getParent()->onAdditionsStateChange();
    204     }
    205 }
    206 
    207 /**
    208  * Update the guest additions capabilities.
    209  * This is called when the guest additions capabilities change. The new capabilities
    210  * are given and the connector should update its internal state.
    211  *
    212  * @param   pInterface          Pointer to this interface.
    213  * @param   newCapabilities     New capabilities.
    214  * @thread  The emulation thread.
    215  */
    216 DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
    217 {
    218     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
    219 
    220     /* store that information in IGuest */
    221     Guest* guest = pDrv->pVMMDev->getParent()->getGuest();
    222     Assert(guest);
    223     if (!guest)
    224         return;
    225 
    226     guest->setSupportsSeamless(BOOL (newCapabilities & VMMDEV_GUEST_SUPPORTS_SEAMLESS));
    227     guest->setSupportsGraphics(BOOL (newCapabilities & VMMDEV_GUEST_SUPPORTS_GRAPHICS));
     259    /*
     260     * Report our current capabilites (and assume none is active yet).
     261     */
     262    guest->setSupportedFeatures((ULONG64)newCapabilities, 0 /* Active capabilities, not used here. */);
    228263
    229264    /*
     
    543578
    544579    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
    545         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
     580        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle);
    546581
    547582    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
    548         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
     583        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel);
    549584
    550585    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
    551         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
     586        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User);
    552587
    553588
     
    556591     *        preCollect().  I might be wrong ofc, this is convoluted code... */
    557592    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
    558         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
     593        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal);
    559594
    560595    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
    561         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
     596        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail);
    562597
    563598    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
    564         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
     599        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon);
    565600
    566601    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
    567         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
     602        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache);
    568603
    569604    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
    570         guest->SetStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
     605        guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize);
    571606
    572607    return VINF_SUCCESS;
     
    762797    pDrvIns->IBase.pfnQueryInterface                  = VMMDev::drvQueryInterface;
    763798
    764     pData->Connector.pfnUpdateGuestVersion            = vmmdevUpdateGuestVersion;
     799    pData->Connector.pfnUpdateGuestStatus             = vmmdevUpdateGuestStatus;
     800    pData->Connector.pfnUpdateGuestInfo               = vmmdevUpdateGuestInfo;
    765801    pData->Connector.pfnUpdateGuestCapabilities       = vmmdevUpdateGuestCapabilities;
    766802    pData->Connector.pfnUpdateMouseCapabilities       = vmmdevUpdateMouseCapabilities;
  • trunk/src/VBox/Main/include/GuestImpl.h

    r30739 r30758  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6969    void FinalRelease();
    7070
    71     // public initializer/uninitializer for internal purposes only
     71    // Public initializer/uninitializer for internal purposes only
    7272    HRESULT init (Console *aParent);
    7373    void uninit();
     
    7575    // IGuest properties
    7676    STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
     77#if 0
     78    /** @todo Will replace old AdditionsActive call. */
     79    STDMETHOD(COMGETTER(AdditionsActive)) (ULONG aLevel, BOOL *aAdditionsActive);
     80#endif
    7781    STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
     82#if 0
     83    /** @todo Will replace AdditionsVersion to be more clear. */
     84    STDMETHOD(COMGETTER(AdditionsAPIVersion)) (BSTR *aAdditionsVersion);
     85#endif
    7886    STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
     87    /** @todo Remove */
    7988    STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
    8089    STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
     90#if 0
     91    /** @todo Will replace SupportsSeamless, SupportsGraphics, ... */
     92    STDMETHOD(COMGETTER(AdditionsFeatureAvailable)) (ULONG64 aFeature, BOOL *aActive, BOOL *aAvailable);
     93#endif
    8194    STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
    8295    STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
     
    99112                                     ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
    100113
    101     // public methods that are not in IDL
    102     void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
    103 
    104     void setSupportsSeamless (BOOL aSupportsSeamless);
    105 
    106     void setSupportsGraphics (BOOL aSupportsGraphics);
    107 
    108     HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
     114    // Public methods that are not in IDL (only called internally).
     115    void setAdditionsInfo(Bstr aVersion, VBOXOSTYPE aOsType);
     116    void setAdditionsStatus(ULONG ulFacility, ULONG ulStatus, ULONG ulFlags);
     117    void setSupportedFeatures(ULONG64 ulCaps, ULONG64 ulActive);
     118    HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
    109119
    110120# ifdef VBOX_WITH_GUEST_CONTROL
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