VirtualBox

Changeset 31430 in vbox


Ignore:
Timestamp:
Aug 6, 2010 8:47:51 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64495
Message:

Guest Additions version lookup/status: Fixed loading of guest drivers, moved VbglR0MiscReportGuestInfo code to common/VBoxGuest/VBoxHelper.

Location:
trunk
Files:
8 edited
1 moved

Legend:

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

    r31364 r31430  
    380380DECLVBGL(int) VbglQueryVMMDevMemory (VMMDevMemory **ppVMMDevMemory);
    381381DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void);
    382 
    383 DECLR0VBGL(int) VbglR0MiscReportGuestInfo(VBOXOSTYPE enmOSType);
    384382
    385383#endif /* IN_RING0 && !IN_RING0_AGNOSTIC */
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Makefile.kmk

    r29059 r31430  
    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
     
    4343        HelperBugCheck.cpp \
    4444        VBoxGuest.rc
    45 VBoxGuest_LIBS        = \
     45VBoxGuest_SOURCES      += \
     46        ../../common/VBoxGuest/VBoxHelper.cpp
     47VBoxGuest_LIBS          = \
    4648        $(PATH_SDK_W2K3DDK_LIB)/ntoskrnl.lib \
    4749        $(PATH_SDK_W2K3DDK_LIB)/hal.lib \
     
    7173        NTLegacy.cpp \
    7274        VBoxGuest.rc
     75VBoxGuestNT_SOURCES  += \
     76        ../../common/VBoxGuest/VBoxHelper.cpp
     77
    7378VBoxGuestNT_LIBS      = \
    7479        $(PATH_SDK_W2K3DDK_LIB)/exsup.lib \
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/NTLegacy.cpp

    r31364 r31430  
    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
     
    2424
    2525#include <VBox/VBoxGuestLib.h>
     26#include "../../common/VBoxGuest/VBoxHelper.h"
    2627
    2728/*******************************************************************************
     
    276277    /** @todo Don't mix up IPRT rc and NTSTATUS rc above! */
    277278
    278     vrc = VBoxInitMemBalloon(pDevExt);
    279     if (RT_SUCCESS(vrc))
    280     {
    281         vrc = VbglR0MiscReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
     279    if (NT_SUCCESS(rc))
     280    {
     281        vrc = VBoxReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
     282        if (RT_SUCCESS(vrc))
     283        {
     284            vrc = VBoxInitMemBalloon(pDevExt);
     285            if (RT_SUCCESS(vrc))
     286            {
     287                vrc = VBoxReportGuestDriverStatus(true /* Driver is active */);
     288                if (RT_FAILURE(vrc))
     289                    dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest driver status, vrc = %d\n", vrc));
     290            }
     291            else
     292                dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not init mem balloon, vrc = %d\n", vrc));
     293        }
     294        else
     295            dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest information to host, vrc = %d\n", vrc));
     296
    282297        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))
     298            rc = STATUS_UNSUCCESSFUL;
     299    }
     300
     301    if (NT_SUCCESS(rc))
     302    {
     303        // ready to rumble!
     304        pDevExt->devState = WORKING;
     305    }
     306    else
    288307    {
    289308        freeDeviceResources(pDrvObj, pDevObj);
    290         return STATUS_UNSUCCESSFUL;
    291     }
    292 
    293     // ready to rumble!
    294     pDevExt->devState = WORKING;
     309    }
     310
    295311    dprintf(("returning from ntCreateDevice with rc = 0x%x\n, vrc = %Rrc", rc, vrc));
    296312    return rc;
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuestPnP.cpp

    r31364 r31430  
    2525
    2626#include <VBox/VBoxGuestLib.h>
     27#include "../../common/VBoxGuest/VBoxHelper.h"
    2728
    2829/*******************************************************************************
     
    230231                }
    231232            }
     233
     234            /** @todo Don't mix up IPRT rc and NTSTATUS rc above! */
     235
     236            if (NT_SUCCESS(rc))
     237            {
     238                int vrc = VBoxReportGuestInfo(hlpVBoxWinVersionToOSType(winVersion));
     239                if (RT_SUCCESS(vrc))
     240                {
     241                    vrc = VBoxInitMemBalloon(pDevExt);
     242                    if (RT_SUCCESS(vrc))
     243                    {
     244                        vrc = VBoxReportGuestDriverStatus(true /* Driver is active */);
     245                        if (RT_FAILURE(vrc))
     246                            dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest driver status, vrc = %d\n", vrc));
     247                    }
     248                    else
     249                        dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not init mem balloon, vrc = %d\n", vrc));
     250                }
     251                else
     252                    dprintf(("VBoxGuest::VBoxGuestPnp::IRP_MN_START_DEVICE: could not report guest information to host, vrc = %d\n", vrc));
     253
     254                if (RT_FAILURE(vrc))
     255                    rc = STATUS_UNSUCCESSFUL;
     256            }
     257
    232258            if (NT_SUCCESS(rc))
    233259            {
     
    241267                pDevExt->HGCMWaitTimeout.QuadPart *= -10000;     /* relative in 100ns units */
    242268
    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                 }
    250 
    251269                // ready to rumble!
    252270                dprintf(("VBoxGuest::VBoxGuestPnp: device is ready!\n"));
    253271                pDevExt->devState = WORKING;
    254             } else
     272            }
     273            else
    255274            {
    256275                dprintf(("VBoxGuest::VBoxGuestPnp: error: rc = 0x%x\n", rc));
  • trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk

    r29044 r31430  
    4545   VBoxGuest_SOURCES     = VBoxGuest-$(KBUILD_TARGET).c
    4646  endif
    47   VBoxGuest_SOURCES     += VBoxGuest.cpp
     47  VBoxGuest_SOURCES     += \
     48        VBoxGuest.cpp \
     49        VBoxHelper.cpp
    4850  VBoxGuest_LIBS         = \
    4951        $(VBOX_LIB_VBGL_R0BASE) \
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r31364 r31430  
    3636# include <iprt/thread.h>
    3737#endif
     38#include "VBoxHelper.h"
    3839#include "version-generated.h"
    3940#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
     
    733734            Assert(pDevExt->PhysIrqAckEvents != 0);
    734735
    735             rc = vboxGuestSetFilterMask(pDevExt, fFixedEvents);
     736            rc = VBoxReportGuestInfo(enmOSType);
    736737            if (RT_SUCCESS(rc))
    737738            {
    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);
     739                rc = vboxGuestSetFilterMask(pDevExt, fFixedEvents);
    743740                if (RT_SUCCESS(rc))
    744741                {
    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;
     742                    /*
     743                     * Disable guest graphics capability by default. The guest specific
     744                     * graphics driver will re-enable this when it is necessary.
     745                     */
     746                    rc = VBoxGuestSetGuestCapabilities(0, VMMDEV_GUEST_SUPPORTS_GRAPHICS);
     747                    if (RT_SUCCESS(rc))
     748                    {
     749                        vboxGuestInitFixateGuestMappings(pDevExt);
     750
     751                        rc = VBoxReportGuestDriverStatus(true /* Driver is active */);
     752                        if (RT_FAILURE(rc))
     753                            LogRel(("VBoxGuestInitDevExt: VBoxReportGuestDriverStatus failed, rc=%Rrc\n", rc));
     754
     755                        Log(("VBoxGuestInitDevExt: returns success\n"));
     756                        return VINF_SUCCESS;
     757                    }
     758
     759                    LogRel(("VBoxGuestInitDevExt: VBoxGuestSetGuestCapabilities failed, rc=%Rrc\n", rc));
    753760                }
    754 
    755                 LogRel(("VBoxGuestInitDevExt: VBoxGuestSetGuestCapabilities failed, rc=%Rrc\n", rc));
     761                else
     762                    LogRel(("VBoxGuestInitDevExt: vboxGuestSetFilterMask failed, rc=%Rrc\n", rc));
    756763            }
    757764            else
    758                 LogRel(("VBoxGuestInitDevExt: vboxGuestSetFilterMask failed, rc=%Rrc\n", rc));
     765                LogRel(("VBoxGuestInitDevExt: VBoxReportGuestInfo failed, rc=%Rrc\n", rc));
    759766            VbglGRFree((VMMDevRequestHeader *)pDevExt->pIrqAckEvents);
    760767        }
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxHelper.cpp

    r31388 r31430  
    11/* $Id$ */
    22/** @file
    3  * VBoxGuestR0LibMisc - Miscellaneous functions.
     3 * VBoxHelper - Miscellaneous functions.
    44 */
    55
     
    3232
    3333
    34 DECLR0VBGL(int) VbglR0MiscReportGuestInfo(VBOXOSTYPE enmOSType)
     34int VBoxReportGuestInfo(VBOXOSTYPE enmOSType)
    3535{
     36    /*
     37     * Important: VMMDev *awaits* a VMMDevReportGuestInfo or VMMDevReportGuestInfo2 message
     38     *            first in order to accept all other VMMDev messages! Otherwise you'd get
     39     *            a VERR_NOT_SUPPORTED error.
     40     */
    3641    VMMDevReportGuestInfo2 *pReq = NULL;
    3742    int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
     43    Log(("VBoxReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
    3844    if (RT_SUCCESS(rc))
    3945    {
     
    4652
    4753        rc = VbglGRPerform(&pReq->header);
     54        Log(("VBoxReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
    4855        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    4956            rc = VINF_SUCCESS;
    5057        VbglGRFree(&pReq->header);
    51     }
    52 
    53     /*
    54      * Report guest status of the VBox driver to the host.
    55      */
    56     if (RT_SUCCESS(rc))
    57     {
    58         VMMDevReportGuestStatus *pReq2;
    59         rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq2, sizeof(*pReq2), VMMDevReq_ReportGuestStatus);
    60         if (RT_SUCCESS(rc))
    61         {
    62             pReq2->guestStatus.facility = VBoxGuestStatusFacility_VBoxGuestDriver;
    63             pReq2->guestStatus.status = VBoxGuestStatusCurrent_Active; /** @todo Are we actually *really* active at this point? */
    64             pReq2->guestStatus.flags = 0;
    65             rc = VbglGRPerform(&pReq2->header);
    66             if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
    67                 rc = VINF_SUCCESS;
    68             VbglGRFree(&pReq2->header);
    69         }
    7058    }
    7159
     
    7866        VMMDevReportGuestInfo *pReq3 = NULL;
    7967        rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq3, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
     68        Log(("VBoxReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
    8069        if (RT_SUCCESS(rc))
    8170        {
     
    8473
    8574            rc = VbglGRPerform(&pReq3->header);
     75            Log(("VBoxReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
    8676            VbglGRFree(&pReq3->header);
    8777        }
     
    9181}
    9282
     83int VBoxReportGuestDriverStatus(bool fActive)
     84{
     85    /*
     86     * Report guest status of the VBox driver to the host.
     87     */
     88    VMMDevReportGuestStatus *pReq2 = NULL;
     89    int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq2, sizeof(*pReq2), VMMDevReq_ReportGuestStatus);
     90    Log(("VBoxReportGuestDriverStatus: VbglGRAlloc VMMDevReportGuestStatus completed with rc=%Rrc\n", rc));
     91    if (RT_SUCCESS(rc))
     92    {
     93        pReq2->guestStatus.facility = VBoxGuestStatusFacility_VBoxGuestDriver;
     94        pReq2->guestStatus.status = fActive ?
     95                                    VBoxGuestStatusCurrent_Active
     96                                  : VBoxGuestStatusCurrent_Inactive;
     97        pReq2->guestStatus.flags = 0;
     98        rc = VbglGRPerform(&pReq2->header);
     99        Log(("VBoxReportGuestDriverStatus: VbglGRPerform VMMDevReportGuestStatus completed with fActive=%d, rc=%Rrc\n",
     100             rc, fActive ? 1 : 0));
     101        if (rc == VERR_NOT_IMPLEMENTED) /* Compatibility with older hosts. */
     102            rc = VINF_SUCCESS;
     103        VbglGRFree(&pReq2->header);
     104    }
     105
     106    return rc;
     107}
     108
  • trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk

    r31426 r31430  
    6161        VMMDev.cpp \
    6262        HGCM.cpp \
    63         VBoxGuestR0LibMisc.c \
    6463        VBoxGuestR0LibSharedFolders.c \
    6564        VbglR0CanUsePhysPageList.cpp
    66 
    67 VBoxGuestR0LibMisc.c_DEFS = VBOX_SVN_REV=$(VBOX_SVN_REV)
    68 
    6965
    7066#
     
    8278        VMMDev.cpp \
    8379        HGCMInternal.cpp \
    84         VbglR0CanUsePhysPageList.cpp \
    85         VBoxGuestR0LibMisc.c
     80        VbglR0CanUsePhysPageList.cpp
    8681
    8782#
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r31241 r31430  
    425425    Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
    426426
    427     if (    requestHeader.requestType != VMMDevReq_ReportGuestInfo
    428         && !pThis->fu32AdditionsOk)
     427    /* Because VMMDevReq_ReportGuestInfo is sent last in the first information chain
     428     * from the guest also check for VMMDevReq_ReportGuestInfo2. */
     429    if (    requestHeader.requestType != VMMDevReq_ReportGuestInfo2
     430        && (   requestHeader.requestType != VMMDevReq_ReportGuestInfo
     431            && !pThis->fu32AdditionsOk))
    429432    {
    430433        Log(("VMMDev: guest has not yet reported to us. Refusing operation.\n"));
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