VirtualBox

Ignore:
Timestamp:
Sep 2, 2010 8:34:18 AM (14 years ago)
Author:
vboxsync
Message:

VBoxGuestReportGuestInfo: r65464 wasn't quite perfect as <= 3.1 will also return VERR_NOT_SUPPORTED, not VERR_NOT_IMPLEMENTED, just like 3.2* does. This should then lead to function failure when doing the Info2 report.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest2.cpp

    r32180 r32187  
    3838{
    3939    /*
    40      * Important: VMMDev *awaits* a VMMDevReportGuestInfo or VMMDevReportGuestInfo2 message
    41      *            first in order to accept all other VMMDev messages! Otherwise you'd get
    42      *            a VERR_NOT_SUPPORTED error.
    43      *
    44      * VBox version <= 3.2: VMMDevReportGuestInfo must always come first.
     40     * Allocate and fill in the two guest info reports.
    4541     */
    46     VMMDevReportGuestInfo2 *pReq = NULL;
    47     VMMDevReportGuestInfo *pReq3 = NULL;
    48     int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
     42    VMMDevReportGuestInfo2 *pReqInfo2 = NULL;
     43    VMMDevReportGuestInfo  *pReqInfo1 = NULL;
     44    int rc = VbglGRAlloc((VMMDevRequestHeader **)&pReqInfo2, sizeof (VMMDevReportGuestInfo2), VMMDevReq_ReportGuestInfo2);
    4945    Log(("VBoxGuestReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
    5046    if (RT_SUCCESS(rc))
    5147    {
    52         pReq->guestInfo.additionsMajor = VBOX_VERSION_MAJOR;
    53         pReq->guestInfo.additionsMinor = VBOX_VERSION_MINOR;
    54         pReq->guestInfo.additionsBuild = VBOX_VERSION_BUILD;
    55         pReq->guestInfo.additionsRevision = VBOX_SVN_REV;
    56         pReq->guestInfo.additionsFeatures = 0; /* Not (never?) used. */
    57         RTStrCopy(pReq->guestInfo.szName, sizeof(pReq->guestInfo.szName), VBOX_VERSION_STRING);
    58        
    59         rc = VbglGRAlloc((VMMDevRequestHeader **)&pReq3, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
     48        pReqInfo2->guestInfo.additionsMajor    = VBOX_VERSION_MAJOR;
     49        pReqInfo2->guestInfo.additionsMinor    = VBOX_VERSION_MINOR;
     50        pReqInfo2->guestInfo.additionsBuild    = VBOX_VERSION_BUILD;
     51        pReqInfo2->guestInfo.additionsRevision = VBOX_SVN_REV;
     52        pReqInfo2->guestInfo.additionsFeatures = 0; /* (no features defined yet) */
     53        RTStrCopy(pReqInfo2->guestInfo.szName, sizeof(pReqInfo2->guestInfo.szName), VBOX_VERSION_STRING);
     54
     55        rc = VbglGRAlloc((VMMDevRequestHeader **)&pReqInfo1, sizeof (VMMDevReportGuestInfo), VMMDevReq_ReportGuestInfo);
    6056        Log(("VBoxGuestReportGuestInfo: VbglGRAlloc VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
    6157        if (RT_SUCCESS(rc))
    6258        {
    63             pReq3->guestInfo.interfaceVersion = VMMDEV_VERSION;
    64             pReq3->guestInfo.osType = enmOSType;
     59            pReqInfo1->guestInfo.interfaceVersion = VMMDEV_VERSION;
     60            pReqInfo1->guestInfo.osType          = enmOSType;
    6561
    66             rc = VbglGRPerform(&pReq->header);
     62            /*
     63             * There are two protocols here:
     64             *      1. Info2 + Info1. Supported by >=3.2.51.
     65             *      2. Info1 and optionally Info2. The old protocol.
     66             *
     67             * We try protocol 1 first.  It will fail with VERR_NOT_SUPPORTED
     68             * if not supported by the VMMDev (message ordering requirement).
     69             */
     70            rc = VbglGRPerform(&pReqInfo2->header);
    6771            Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
    68             if (rc == VERR_NOT_IMPLEMENTED)
     72            if (RT_SUCCESS(rc))
    6973            {
    70                 /* Compatibility with pre VBox-3.2 hosts -- VMMDevReportGuestInfo2 not implemented. */
    71                 rc = VINF_SUCCESS;
    72             }
    73             if (rc == VERR_NOT_SUPPORTED)
    74             {
    75                 /* Compatibility with VBox 3.2 hosts:
    76                  * They rely on sending VMMDevReportGuestInfo as the very first request */
    77                 rc = VbglGRPerform(&pReq3->header);
    78                 Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
    79                 rc = VbglGRPerform(&pReq->header);
    80                 Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
    81             }
    82             else
    83             {
    84                 /*
    85                  * Hosts newer than VBox 3.2:
    86                  * VMMDevReportGuestInfo acts as a beacon and signals the host that all
    87                  * guest information is now complete. So always send this report last!
    88                  */
    89                 rc = VbglGRPerform(&pReq3->header);
     74                rc = VbglGRPerform(&pReqInfo1->header);
    9075                Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
    9176            }
    92             VbglGRFree(&pReq3->header);
     77            else if (   rc == VERR_NOT_SUPPORTED
     78                     || rc == VERR_NOT_IMPLEMENTED)
     79            {
     80                rc = VbglGRPerform(&pReqInfo1->header);
     81                Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo completed with rc=%Rrc\n", rc));
     82                if (RT_SUCCESS(rc))
     83                {
     84                    rc = VbglGRPerform(&pReqInfo2->header);
     85                    Log(("VBoxGuestReportGuestInfo: VbglGRPerform VMMDevReportGuestInfo2 completed with rc=%Rrc\n", rc));
     86                    if (rc == VERR_NOT_IMPLEMENTED)
     87                        rc = VINF_SUCCESS;
     88                }
     89            }
     90            VbglGRFree(&pReqInfo1->header);
    9391        }
    94         VbglGRFree(&pReq->header);
     92        VbglGRFree(&pReqInfo2->header);
    9593    }
    9694
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