VirtualBox

Changeset 31364 in vbox


Ignore:
Timestamp:
Aug 4, 2010 4:44:20 PM (14 years ago)
Author:
vboxsync
Message:

Some more fixes for Guest Additions version lookup/status; moved some duplicate helper function to VbglR0.

Location:
trunk
Files:
1 added
11 edited

Legend:

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

    r31355 r31364  
    379379
    380380DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory);
    381 DECLR0VBGL(bool)    VbglR0CanUsePhysPageList(void);
     381DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void);
     382
     383DECLR0VBGL(int) VbglR0MiscReportGuestInfo(VBOXOSTYPE enmOSType);
    382384
    383385#endif /* IN_RING0 && !IN_RING0_AGNOSTIC */
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.cpp

    r31241 r31364  
    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.
    195  *
    196  *  @todo Consider of using vboxGuestInitReportGuestInfo in the ..\common\Helper.cpp
    197  *        module to have a common base and less redundant code.
    198  */
    199 NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt)
    200 {
    201     VMMDevReportGuestInfo *pReq = NULL;
    202     int rc = VbglGRAlloc ((VMMDevRequestHeader **)&pReq, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
    203     dprintf(("hlpVBoxReportGuestInfo: VbglGRAlloc rc = %d\n", rc));
    204     if (RT_SUCCESS(rc))
    205     {
    206         pReq->guestInfo.interfaceVersion = VMMDEV_VERSION;
    207 
    208         /* we've already determined the Windows product before */
    209         switch (winVersion)
    210         {
    211             case WINNT4:
    212                 pReq->guestInfo.osType = VBOXOSTYPE_WinNT4;
    213                 break;
    214             case WIN2K:
    215                 pReq->guestInfo.osType = VBOXOSTYPE_Win2k;
    216                 break;
    217             case WINXP:
    218                 pReq->guestInfo.osType = VBOXOSTYPE_WinXP;
    219                 break;
    220             case WIN2K3:
    221                 pReq->guestInfo.osType = VBOXOSTYPE_Win2k3;
    222                 break;
    223             case WINVISTA:
    224                 pReq->guestInfo.osType = VBOXOSTYPE_WinVista;
    225                 break;
    226             case WIN7:
    227                 pReq->guestInfo.osType = VBOXOSTYPE_Win7;
    228                 break;
    229             default:
    230                 /* we don't know, therefore NT family */
    231                 pReq->guestInfo.osType = VBOXOSTYPE_WinNT;
    232                 break;
    233         }
    234 
    235         /** @todo registry lookup for additional information */
    236 
    237         rc = VbglGRPerform (&pReq->header);
    238         if (RT_FAILURE(rc))
    239         {
    240             dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
    241                      "rc = %Rrc\n", rc));
    242         }
    243 
    244         VbglGRFree (&pReq->header);
    245     }
    246 
    247     VMMDevReportGuestInfo2 *pReq2 = NULL;
    248     if (RT_SUCCESS(rc))
    249         rc = VbglGRAlloc ((VMMDevRequestHeader **)&pReq2, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
    250     dprintf(("hlpVBoxReportGuestInfo2: VbglGRAlloc rc = %d\n", rc));
    251 
    252     if (RT_SUCCESS(rc))
    253     {
    254         pReq2->guestInfo.additionsMajor = VBOX_VERSION_MAJOR;
    255         pReq2->guestInfo.additionsMinor = VBOX_VERSION_MINOR;
    256         pReq2->guestInfo.additionsBuild = VBOX_VERSION_BUILD;
    257         pReq2->guestInfo.additionsRevision = VBOX_SVN_REV;
    258         pReq2->guestInfo.additionsFeatures = 0;
    259         RTStrCopy(pReq2->guestInfo.szName, sizeof(pReq2->guestInfo.szName), VBOX_VERSION_STRING);
    260 
    261         rc = VbglGRPerform (&pReq2->header);
    262         if (RT_FAILURE(rc))
    263         {
    264             dprintf(("VBoxGuest::hlpVBoxReportGuestInfo: Error reporting guest info to VMMDev. "
    265                      "rc = %Rrc\n", rc));
    266         }
    267         if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    268             rc = VINF_SUCCESS;
    269         VbglGRFree (&pReq2->header);
    270     }
    271 
    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 
    293     return RT_FAILURE(rc) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS;
    294 }
    295 
     193VBOXOSTYPE hlpVBoxWinVersionToOSType (winVersion_t winVer)
     194{
     195    switch (winVer)
     196    {
     197        case WINNT4:
     198            return VBOXOSTYPE_WinNT4;
     199
     200        case WIN2K:
     201            return VBOXOSTYPE_Win2k;
     202
     203        case WINXP:
     204            return VBOXOSTYPE_WinXP;
     205
     206        case WIN2K3:
     207            return VBOXOSTYPE_Win2k3;
     208
     209        case WINVISTA:
     210            return VBOXOSTYPE_WinVista;
     211
     212        case WIN7:
     213            return VBOXOSTYPE_Win7;
     214
     215        default:
     216            break;
     217    }
     218
     219    /* We don't know, therefore NT family. */
     220    return VBOXOSTYPE_WinNT;
     221}
     222
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.h

    r28800 r31364  
    33 * VBoxGuest -- VirtualBox Win32 guest support driver
    44 *
    5  * Copyright (C) 2006-2007 Oracle Corporation
     5 * Copyright (C) 2006-2010 Oracle Corporation
    66 *
    77 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444
    4545/**
    46  * Helper to report the guest information to host.
     46 * Helper for mapping the Windows version to the OS type understood by the host.
    4747 *
    48  * @param pDevExt   VMMDev device extension
    49  * @return NT status code
     48 * @return The OS type.
     49 * @param winVer   Windows version to translate.
    5050 */
    51 NTSTATUS hlpVBoxReportGuestInfo (PVBOXGUESTDEVEXT pDevExt);
     51VBOXOSTYPE hlpVBoxWinVersionToOSType (winVersion_t winVer);
    5252
    5353#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/NTLegacy.cpp

    r28800 r31364  
    5454{
    5555    ULONG busNumber, slotNumber;
     56    int vrc = VINF_SUCCESS;
    5657    NTSTATUS rc = STATUS_SUCCESS;
    5758
     
    271272    }
    272273
    273     rc = hlpVBoxReportGuestInfo (pDevExt);
    274     if (!NT_SUCCESS(rc))
    275     {
    276         dprintf(("VBoxGuest::AddDevice: could not report information to host, rc = %d, exiting!\n", rc));
     274    /** @todo Cleanup on failure. */
     275
     276    /** @todo Don't mix up IPRT rc and NTSTATUS rc above! */
     277
     278    vrc = VBoxInitMemBalloon(pDevExt);
     279    if (RT_SUCCESS(vrc))
     280    {
     281        vrc = VbglR0MiscReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
     282        if (RT_FAILURE(vrc))
     283            dprintf(("VBoxGuest::ntCreateDevice: could not report information to host, rc = %d, exiting!\n", rc));
     284    }
     285
     286    if (   NT_ERROR(rc)
     287        || RT_FAILURE(vrc))
     288    {
    277289        freeDeviceResources(pDrvObj, pDevObj);
    278290        return STATUS_UNSUCCESSFUL;
    279291    }
    280292
    281     /** @todo cleanup on failure */
    282 
    283     VBoxInitMemBalloon(pDevExt);
    284 
    285293    // ready to rumble!
    286294    pDevExt->devState = WORKING;
    287     dprintf(("returning from createDevice with rc = 0x%x\n", rc));
     295    dprintf(("returning from ntCreateDevice with rc = 0x%x\n, vrc = %Rrc", rc, vrc));
    288296    return rc;
    289297}
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r30758 r31364  
    774774#endif
    775775
    776 void VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt)
     776int VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt)
    777777{
    778778#ifdef VBOX_WITH_MANAGEMENT
     
    783783    pDevExt->MemBalloon.paMdlMemBalloon = NULL;
    784784
    785     VBoxGuestQueryMemoryBalloon(pDevExt, &dummy);
     785    return VBoxGuestQueryMemoryBalloon(pDevExt, &dummy);
     786#else
     787    return VINF_SUCCESS;
    786788#endif
    787789}
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuestPnP.cpp

    r30201 r31364  
    111111NTSTATUS VBoxGuestPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)
    112112{
    113     PVBOXGUESTDEVEXT    pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
     113    PVBOXGUESTDEVEXT   pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;
    114114    PIO_STACK_LOCATION pStack  = IoGetCurrentIrpStackLocation(pIrp);
    115115    NTSTATUS rc = STATUS_SUCCESS;
     
    208208                    if (NT_SUCCESS(rc))
    209209                    {
    210                         rc = hlpVBoxReportGuestInfo (pDevExt);
    211                         if (!NT_SUCCESS(rc))
    212                         {
    213                             dprintf(("VBoxGuest::START_DEVICE: could not report information to host, rc = %d\n", rc));
    214                         }
    215                     }
    216 
    217                     if (NT_SUCCESS(rc))
    218                     {
    219210                        // register DPC and ISR
    220211                        dprintf(("VBoxGuest::VBoxGuestPnp: initializing DPC...\n"));
     
    250241                pDevExt->HGCMWaitTimeout.QuadPart *= -10000;     /* relative in 100ns units */
    251242
    252                 VBoxInitMemBalloon(pDevExt);
     243                int vrc = VBoxInitMemBalloon(pDevExt);
     244                if (RT_SUCCESS(vrc))
     245                {
     246                    vrc = VbglR0MiscReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
     247                    if (RT_FAILURE(vrc))
     248                        dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report information to host, rc = %d\n", rc));
     249                }
    253250
    254251                // ready to rumble!
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest_Internal.h

    r28800 r31364  
    262262NTSTATUS createThreads(PVBOXGUESTDEVEXT pDevExt);
    263263VOID     unreserveHypervisorMemory(PVBOXGUESTDEVEXT pDevExt);
    264 void     VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt);
     264int      VBoxInitMemBalloon(PVBOXGUESTDEVEXT pDevExt);
    265265void     VBoxCleanupMemBalloon(PVBOXGUESTDEVEXT pDevExt);
    266266}
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r31241 r31364  
    255255
    256256/**
    257  * Report guest information to the VMMDev.
    258  *
    259  * @returns VBox status code.
    260  * @param   pDevExt     The device extension.
    261  * @param   enmOSType   The OS type to report.
    262  */
    263 static int vboxGuestInitReportGuestInfo(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType)
    264 {
    265     /*
    266      * Report general info + capabilities to host.
    267      */
    268     VMMDevReportGuestInfo *pReq;
    269     int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof(*pReq), VMMDevReq_ReportGuestInfo);
    270     if (RT_SUCCESS(rc))
    271     {
    272         pReq->guestInfo.interfaceVersion = VMMDEV_VERSION;
    273         pReq->guestInfo.osType = enmOSType;
    274         rc = VbglGRPerform(&pReq->header);
    275         if (RT_FAILURE(rc))
    276             LogRel(("vboxGuestInitReportGuestInfo: 1st part failed with rc=%Rrc\n", rc));
    277         VbglGRFree(&pReq->header);
    278     }
    279     VMMDevReportGuestInfo2 *pReq2;
    280     if (RT_SUCCESS(rc))
    281         rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq2, sizeof(*pReq2), VMMDevReq_ReportGuestInfo2);
    282     if (RT_SUCCESS(rc))
    283     {
    284         pReq2->guestInfo.additionsMajor = VBOX_VERSION_MAJOR;
    285         pReq2->guestInfo.additionsMinor = VBOX_VERSION_MINOR;
    286         pReq2->guestInfo.additionsBuild = VBOX_VERSION_BUILD;
    287         pReq2->guestInfo.additionsRevision = VBOX_SVN_REV;
    288         pReq2->guestInfo.additionsFeatures = 0;
    289         RTStrCopy(pReq2->guestInfo.szName, sizeof(pReq2->guestInfo.szName), VBOX_VERSION_STRING);
    290         rc = VbglGRPerform(&pReq2->header);
    291         if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    292             rc = VINF_SUCCESS;
    293         if (RT_FAILURE(rc))
    294             LogRel(("vboxGuestInitReportGuestInfo: 2nd part failed with rc=%Rrc\n", rc));
    295         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     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(("vboxGuestInitReportGuestInfo: reporting status failed with rc=%Rrc\n", rc));
    316         VbglGRFree(&pReq3->header);
    317     }
    318     return rc;
    319 }
    320 
    321 
    322 /**
    323257 * Inflate the balloon by one chunk represented by an R0 memory object.
    324258 *
     
    799733            Assert(pDevExt->PhysIrqAckEvents != 0);
    800734
    801             rc = vboxGuestInitReportGuestInfo(pDevExt, enmOSType);
     735            rc = vboxGuestSetFilterMask(pDevExt, fFixedEvents);
    802736            if (RT_SUCCESS(rc))
    803737            {
    804                 rc = vboxGuestSetFilterMask(pDevExt, fFixedEvents);
     738                /*
     739                 * Disable guest graphics capability by default. The guest specific
     740                 * graphics driver will re-enable this when it is necessary.
     741                 */
     742                rc = VBoxGuestSetGuestCapabilities(0, VMMDEV_GUEST_SUPPORTS_GRAPHICS);
    805743                if (RT_SUCCESS(rc))
    806744                {
    807                     /*
    808                      * Disable guest graphics capability by default. The guest specific
    809                      * graphics driver will re-enable this when it is necessary.
    810                      */
    811                     rc = VBoxGuestSetGuestCapabilities(0, VMMDEV_GUEST_SUPPORTS_GRAPHICS);
    812                     if (RT_SUCCESS(rc))
    813                     {
    814                         vboxGuestInitFixateGuestMappings(pDevExt);
    815                         Log(("VBoxGuestInitDevExt: returns success\n"));
    816                         return VINF_SUCCESS;
    817                     }
    818 
    819                     LogRel(("VBoxGuestInitDevExt: VBoxGuestSetGuestCapabilities failed, rc=%Rrc\n", rc));
     745                    vboxGuestInitFixateGuestMappings(pDevExt);
     746
     747                    rc = VbglR0MiscReportGuestInfo(enmOSType);
     748                    if (RT_FAILURE(rc))
     749                        LogRel(("VBoxGuestInitDevExt: VbglR0MiscReportGuestInfo failed, rc=%Rrc\n", rc));
     750
     751                    Log(("VBoxGuestInitDevExt: returns success\n"));
     752                    return VINF_SUCCESS;
    820753                }
    821                 else
    822                     LogRel(("VBoxGuestInitDevExt: vboxGuestSetFilterMask failed, rc=%Rrc\n", rc));
     754
     755                LogRel(("VBoxGuestInitDevExt: VBoxGuestSetGuestCapabilities failed, rc=%Rrc\n", rc));
    823756            }
    824757            else
    825                 LogRel(("VBoxGuestInitDevExt: vboxGuestInitReportGuestInfo failed, rc=%Rrc\n", rc));
    826 
     758                LogRel(("VBoxGuestInitDevExt: vboxGuestSetFilterMask failed, rc=%Rrc\n", rc));
    827759            VbglGRFree((VMMDevRequestHeader *)pDevExt->pIrqAckEvents);
    828760        }
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r31002 r31364  
    6161        VMMDev.cpp \
    6262        HGCM.cpp \
     63        VBoxGuestR0LibMisc.c \
    6364        VBoxGuestR0LibSharedFolders.c \
    6465        VbglR0CanUsePhysPageList.cpp
     66
     67VBoxGuestR0LibMisc.c_DEFS = VBOX_SVN_REV=$(VBOX_SVN_REV)
    6568
    6669
     
    7982        VMMDev.cpp \
    8083        HGCMInternal.cpp \
    81         VbglR0CanUsePhysPageList.cpp
     84        VbglR0CanUsePhysPageList.cpp \
     85        VBoxGuestR0LibMisc.c
    8286
    8387#
  • trunk/src/VBox/Main/GuestImpl.cpp

    r31282 r31364  
    14411441/**
    14421442 * Sets the general Guest Additions information like
    1443  * API (interface) version and OS type.
     1443 * API (interface) version and OS type.  Gets called by
     1444 * vmmdevUpdateGuestInfo.
    14441445 *
    14451446 * @param aInterfaceVersion
     
    14601461    /*
    14611462     * Older Additions rely on the Additions API version whether they
    1462      * are assumed to be active or not. Newer additions will disable
    1463      * this immediately.
     1463     * are assumed to be active or not.  Since newer Additions do report
     1464     * the Additions version *before* calling this function (by calling
     1465     * VMMDevReportGuestInfo2, VMMDevReportGuestStatus, VMMDevReportGuestInfo,
     1466     * in that order) we can tell apart old and new Additions here. Old
     1467     * Additions never would set VMMDevReportGuestInfo2 (which set mData.mAdditionsVersion)
     1468     * so they just rely on the aInterfaceVersion string (which gets set by
     1469     * VMMDevReportGuestInfo).
     1470     *
     1471     * So only mark the Additions as being active when we don't have the Additions
     1472     * version set.
    14641473     */
    1465     mData.mAdditionsActive = !aInterfaceVersion.isEmpty();
     1474    if (mData.mAdditionsVersion.isEmpty())
     1475        mData.mAdditionsActive = !aInterfaceVersion.isEmpty();
    14661476    /*
    14671477     * Older Additions didn't have this finer grained capability bit,
     
    14821492/**
    14831493 * Sets the Guest Additions version information details.
     1494 * Gets called by vmmdevUpdateGuestInfo2.
    14841495 *
    14851496 * @param aAdditionsVersion
     
    15011512/**
    15021513 * Sets the status of a certain Guest Additions facility.
     1514 * Gets called by vmmdevUpdateGuestStatus.
    15031515 *
    15041516 * @param Facility
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r31241 r31364  
    229229        guest->setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */
    230230        guest->setAdditionsInfo2(Bstr(), Bstr()); /* Clear Guest Additions version. */
    231         guest->setAdditionsStatus(VBoxGuestStatusFacility_Unknown,
     231        guest->setAdditionsStatus(VBoxGuestStatusFacility_All,
    232232                                  VBoxGuestStatusCurrent_Disabled,
    233233                                  0); /* Flags; not used. */
     
    269269
    270270        /*
    271          * Tell the console interface about the event
    272          * so that it can notify its consumers.
     271         * No need to tell the console interface about the update;
     272         * vmmdevUpdateGuestInfo takes care of that when called as the
     273         * last event in the chain.
    273274         */
    274         pDrv->pVMMDev->getParent()->onAdditionsStateChange();
    275     }
    276     else
    277     {
    278         /*
    279          * The guest additions was disabled because of a reset
    280          * or driver unload.
    281          */
    282         guest->setAdditionsInfo2(Bstr(), Bstr());
    283         pDrv->pVMMDev->getParent()->onAdditionsStateChange();
    284275    }
    285276}
     
    314305     */
    315306    pDrv->pVMMDev->getParent()->onAdditionsStateChange();
    316 
    317307}
    318308
     
    340330    }
    341331}
    342 
    343332
    344333/**
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