VirtualBox

Changeset 35967 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 15, 2011 9:37:16 AM (14 years ago)
Author:
vboxsync
Message:

Main/VBoxManage: Update on guest facilities, added IAdditionsFacility; now it's possible to iterate over known facilities (see VBoxManage showvminfo --details). Also, facilities now are grouped into several classes (AdditionsFacilityClass).

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r35907 r35967  
    20692069            }
    20702070
    2071             if (details == VMINFO_FULL)
    2072             {
    2073                 rc = guest->COMGETTER(AdditionsVersion)(guestString.asOutParam());
    2074                 if (   SUCCEEDED(rc)
    2075                     && !guestString.isEmpty())
     2071            rc = guest->COMGETTER(AdditionsVersion)(guestString.asOutParam());
     2072            if (   SUCCEEDED(rc)
     2073                && !guestString.isEmpty())
     2074            {
     2075                if (details == VMINFO_MACHINEREADABLE)
     2076                    RTPrintf("GuestAdditionsVersion=\"%lS\"\n", guestString.raw());
     2077                else
     2078                    RTPrintf("Additions version:                   %lS\n\n", guestString.raw());
     2079            }
     2080
     2081            if (details != VMINFO_MACHINEREADABLE)
     2082                RTPrintf("\nGuest Facilities:\n\n");
     2083
     2084            /* Print information about known Guest Additions facilities: */
     2085            SafeIfaceArray <IAdditionsFacility> collFac;
     2086            CHECK_ERROR_RET(guest, COMGETTER(Facilities)(ComSafeArrayAsOutParam(collFac)), rc);
     2087            LONG64 lLastUpdatedMS;
     2088            char szLastUpdated[32];
     2089            AdditionsFacilityStatus_T curStatus;
     2090            for (size_t index = 0; index < collFac.size(); ++index)
     2091            {
     2092                ComPtr<IAdditionsFacility> fac = collFac[index];
     2093                if (fac)
    20762094                {
    2077                     if (details == VMINFO_MACHINEREADABLE)
    2078                         RTPrintf("GuestAdditionsVersion=\"%lS\"\n", guestString.raw());
    2079                     else
    2080                         RTPrintf("Additions version:                   %lS\n\n", guestString.raw());
     2095                    CHECK_ERROR_RET(fac, COMGETTER(Name)(guestString.asOutParam()), rc);
     2096                    if (!guestString.isEmpty())
     2097                    {
     2098                        CHECK_ERROR_RET(fac, COMGETTER(Status)(&curStatus), rc);
     2099                        CHECK_ERROR_RET(fac, COMGETTER(LastUpdated)(&lLastUpdatedMS), rc);
     2100                        if (details == VMINFO_MACHINEREADABLE)
     2101                            RTPrintf("GuestAdditionsFacility_%lS=%u,%lld\n",
     2102                                     guestString.raw(), curStatus, lLastUpdatedMS);
     2103                        else
     2104                        {
     2105                            makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS);
     2106                            RTPrintf("Facility \"%lS\": %s (last update: %s)\n",
     2107                                     guestString.raw(), facilityStateToName(curStatus, false /* No short naming */), szLastUpdated);
     2108                        }
     2109                    }
     2110                    else
     2111                        AssertMsgFailed(("Facility with undefined name retrieved!\n"));
    20812112                }
    2082 
    2083                 if (details != VMINFO_MACHINEREADABLE)
    2084                     RTPrintf("\nGuest Components:\n\n");
    2085 
    2086                 /* Print information about important Guest Additions parts: */
    2087                 /** @todo Add a makeFacilityStatusStr() to translate facility states into a human readable string! */
    2088                 AdditionsFacilityStatus_T faStatus;
    2089                 LONG64 lLastUpdatedMS = 0;
    2090                 char szLastUpdated[32];
    2091                 rc = guest->GetFacilityStatus(AdditionsFacilityType_VBoxGuestDriver, &lLastUpdatedMS, &faStatus);
    2092                 if (SUCCEEDED(rc))
    2093                 {
    2094                     makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS);
    2095                     if (details == VMINFO_MACHINEREADABLE)
    2096                         RTPrintf("GuestAdditionsFacilityStatusGuestDriver=%u,%ld\n",
    2097                                  faStatus, lLastUpdatedMS);
    2098                     else
    2099                         RTPrintf("Guest driver:                        %u (last update: %s)\n",
    2100                                  facilityStateToName(faStatus, false /* No short naming */), szLastUpdated);
    2101                 }
    2102 
    2103                 rc = guest->GetFacilityStatus(AdditionsFacilityType_VBoxService, &lLastUpdatedMS, &faStatus);
    2104                 if (SUCCEEDED(rc))
    2105                 {
    2106                     makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS);
    2107                     if (details == VMINFO_MACHINEREADABLE)
    2108                         RTPrintf("GuestAdditionsFacilityStatusVBoxService=%u,%ld\n",
    2109                                  faStatus, lLastUpdatedMS);
    2110                     else
    2111                         RTPrintf("VBoxService:                         %s (last update: %s)\n",
    2112                                  facilityStateToName(faStatus, false /* No short naming */), szLastUpdated);
    2113                 }
    2114 
    2115                 rc = guest->GetFacilityStatus(AdditionsFacilityType_VBoxTrayClient, &lLastUpdatedMS, &faStatus);
    2116                 if (SUCCEEDED(rc))
    2117                 {
    2118                     makeTimeStr(szLastUpdated, sizeof(szLastUpdated), lLastUpdatedMS);
    2119                     if (details == VMINFO_MACHINEREADABLE)
    2120                         RTPrintf("GuestAdditionsFacilityStatusVBoxTrayClient=%u,%ld\n",
    2121                                  facilityStateToName(faStatus, false /* No short naming */), lLastUpdatedMS);
    2122                     else
    2123                         RTPrintf("VBoxTray / VBoxClient:               %u (last update: %s)\n",
    2124                                  faStatus, szLastUpdated);
    2125                 }
    2126             }
     2113                else
     2114                    AssertMsgFailed(("Invalid facility returned!\n"));
     2115            }
     2116            if (!collFac.size() && details != VMINFO_MACHINEREADABLE)
     2117                RTPrintf("No active facilities.\n");
    21272118        }
    21282119    }
  • trunk/src/VBox/Main/Makefile.kmk

    r35685 r35967  
    637637        src-all/VirtualBoxErrorInfoImpl.cpp \
    638638        $(if $(VBOX_WITH_EXTPACK),src-all/ExtPackManagerImpl.cpp src-all/ExtPackUtil.cpp,) \
     639        src-client/AdditionsFacilityImpl.cpp \
    639640        src-client/AudioSnifferInterface.cpp \
    640641        src-client/BusAssignmentManager.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r35942 r35967  
    79107910
    79117911  <enum
     7912    name="AdditionsFacilityClass"
     7913    uuid="9cff7275-9a5b-4dcd-b164-523e001a5a9e"
     7914    >
     7915    <desc>
     7916      Guest Additions facility classes.
     7917    </desc>
     7918
     7919    <const name="None"                    value="0">
     7920      <desc>No/invalid class.</desc>
     7921    </const>
     7922    <const name="Driver"                  value="10">
     7923      <desc>Driver.</desc>
     7924    </const>
     7925    <const name="Service"                 value="30">
     7926      <desc>System service.</desc>
     7927    </const>
     7928    <const name="Program"                 value="50">
     7929      <desc>Program.</desc>
     7930    </const>
     7931    <const name="Feature"                 value="100">
     7932      <desc>Feature.</desc>
     7933    </const>
     7934    <const name="ThirdParty"              value="999">
     7935      <desc>Third party.</desc>
     7936    </const>
     7937  </enum>
     7938
     7939  <enum
    79127940    name="AdditionsFacilityStatus"
    79137941    uuid="ce06f9e1-394e-4fe9-9368-5a88c567dbde"
     
    79457973    </const>
    79467974  </enum>
     7975
     7976  <interface
     7977    name="IAdditionsFacility" extends="$unknown"
     7978    uuid="5b681761-e865-4bdd-9d6e-135aa8f26e66"
     7979    wsmap="struct"
     7980    >
     7981    <desc>
     7982      Structure representing a Guest Additions facility.
     7983    </desc>
     7984
     7985    <attribute name="class" type="AdditionsFacilityClass" readonly="yes">
     7986      <desc>Additions facility class.</desc>
     7987    </attribute>
     7988
     7989    <attribute name="lastUpdated" type="long long" readonly="yes">
     7990      <desc>Timestamp of last updated status.</desc>
     7991    </attribute>
     7992
     7993    <attribute name="name" type="wstring" readonly="yes">
     7994      <desc>Additions facility name.</desc>
     7995    </attribute>
     7996
     7997    <attribute name="status" type="AdditionsFacilityStatus" readonly="yes">
     7998      <desc>Additions facility status.</desc>
     7999    </attribute>
     8000
     8001    <attribute name="type" type="AdditionsFacilityType" readonly="yes">
     8002      <desc>Additions facility type.</desc>
     8003    </attribute>
     8004  </interface>
    79478005
    79488006  <enum
     
    81108168        separated by dots + revision number) installed on the guest or empty
    81118169        when the Additions are not installed.
     8170      </desc>
     8171    </attribute>
     8172
     8173    <attribute name="facilities" type="IAdditionsFacility" readonly="yes" safearray="yes">
     8174      <desc>
     8175        Array of current known facilities. Only returns facilities where a status is known,
     8176        e.g. facilities with an unknown status will not be returned.
    81128177      </desc>
    81138178    </attribute>
  • trunk/src/VBox/Main/include/GuestImpl.h

    r35907 r35967  
    2323#include <VBox/ostypes.h>
    2424
     25#include "AdditionsFacilityImpl.h"
    2526#ifdef VBOX_WITH_GUEST_CONTROL
    2627# include <VBox/HostServices/GuestControlSvc.h>
     
    7677    STDMETHOD(COMGETTER(AdditionsRunLevel)) (AdditionsRunLevelType_T *aRunLevel);
    7778    STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
     79    STDMETHOD(COMGETTER(Facilities)) (ComSafeArrayOut(IAdditionsFacility*, aFacilities));
    7880    STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
    7981    STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
     
    110112    void setAdditionsInfo2(Bstr aAdditionsVersion, Bstr aVersionName, Bstr aRevision);
    111113    bool facilityIsActive(VBoxGuestFacilityType enmFacility);
    112     void updateFacility(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus);
     114    HRESULT facilityUpdate(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus);
    113115    void setAdditionsStatus(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus, ULONG aFlags);
    114116    void setSupportedFeatures(uint32_t aCaps);
     
    180182# endif
    181183
    182     struct FacilityData
    183     {
    184         RTTIMESPEC                  tsLastUpdated;
    185         AdditionsFacilityStatus_T   curStatus;
    186     };
    187     typedef std::map< AdditionsFacilityType_T, FacilityData > FacilityMap;
    188     typedef std::map< AdditionsFacilityType_T, FacilityData >::iterator FacilityMapIter;
     184    typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> > FacilityMap;
     185    typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::iterator FacilityMapIter;
     186    typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
    189187
    190188    struct Data
  • trunk/src/VBox/Main/src-client/GuestImpl.cpp

    r35907 r35967  
    237237}
    238238
     239STDMETHODIMP Guest::COMGETTER(Facilities)(ComSafeArrayOut(IAdditionsFacility*, aFacilities))
     240{
     241    CheckComArgOutPointerValid(aFacilities);
     242
     243    AutoCaller autoCaller(this);
     244    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     245
     246    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     247
     248    SafeIfaceArray<IAdditionsFacility> fac(mData.mFacilityMap);
     249    fac.detachTo(ComSafeArrayOutArg(aFacilities));
     250
     251    return S_OK;
     252}
     253
    239254BOOL Guest::isPageFusionEnabled()
    240255{
     
    247262}
    248263
    249 STDMETHODIMP Guest::COMGETTER(MemoryBalloonSize) (ULONG *aMemoryBalloonSize)
     264STDMETHODIMP Guest::COMGETTER(MemoryBalloonSize)(ULONG *aMemoryBalloonSize)
    250265{
    251266    CheckComArgOutPointerValid(aMemoryBalloonSize);
     
    261276}
    262277
    263 STDMETHODIMP Guest::COMSETTER(MemoryBalloonSize) (ULONG aMemoryBalloonSize)
     278STDMETHODIMP Guest::COMSETTER(MemoryBalloonSize)(ULONG aMemoryBalloonSize)
    264279{
    265280    AutoCaller autoCaller(this);
     
    427442    /* Not checking for aTimestamp is intentional; it's optional. */
    428443
    429     FacilityMapIter it = mData.mFacilityMap.find(aType);
     444    FacilityMapIterConst it = mData.mFacilityMap.find(aType);
    430445    if (it != mData.mFacilityMap.end())
    431446    {
    432         *aStatus = it->second.curStatus;
     447        AdditionsFacility *pFacility = it->second;
     448        ComAssert(pFacility);
     449        *aStatus = pFacility->getStatus();
    433450        if (aTimestamp)
    434             *aTimestamp = RTTimeSpecGetMilli(&it->second.tsLastUpdated);
     451            *aTimestamp = pFacility->getLastUpdated();
    435452    }
    436453    else
     
    560577     * and use the setSupportedFeatures function instead.
    561578     */
    562     updateFacility(VBoxGuestFacilityType_Graphics, facilityIsActive(VBoxGuestFacilityType_VBoxGuestDriver) ?
     579    facilityUpdate(VBoxGuestFacilityType_Graphics, facilityIsActive(VBoxGuestFacilityType_VBoxGuestDriver) ?
    563580                   VBoxGuestFacilityStatus_Active : VBoxGuestFacilityStatus_Inactive);
    564581
     
    597614bool Guest::facilityIsActive(VBoxGuestFacilityType enmFacility)
    598615{
    599     return mData.mFacilityMap[(AdditionsFacilityType_T)enmFacility].curStatus == AdditionsFacilityStatus_Active;
    600 }
    601 
    602 void Guest::updateFacility(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus)
    603 {
    604616    Assert(enmFacility < UINT32_MAX);
    605     FacilityData *pData = &mData.mFacilityMap[(AdditionsFacilityType_T)enmFacility];
    606     AssertPtr(pData);
    607 
    608     RTTimeNow(&pData->tsLastUpdated);
    609     pData->curStatus = (AdditionsFacilityStatus_T)enmStatus;
    610 
    611     LogFlowFunc(("Setting guest facility %u = %u (%u)\n",
    612                  enmFacility, pData->curStatus, pData->tsLastUpdated));
     617    FacilityMapIterConst it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility);
     618    if (it != mData.mFacilityMap.end())
     619    {
     620        AdditionsFacility *pFac = it->second;
     621        return (pFac->getStatus() == AdditionsFacilityStatus_Active);
     622    }
     623    return false;
     624}
     625
     626HRESULT Guest::facilityUpdate(VBoxGuestFacilityType enmFacility, VBoxGuestFacilityStatus enmStatus)
     627{
     628    ComAssertRet(enmFacility < UINT32_MAX, E_INVALIDARG);
     629
     630    HRESULT rc;
     631    RTTIMESPEC tsNow;
     632    RTTimeNow(&tsNow);
     633
     634    FacilityMapIter it = mData.mFacilityMap.find((AdditionsFacilityType_T)enmFacility);
     635    if (it != mData.mFacilityMap.end())
     636    {
     637        AdditionsFacility *pFac = it->second;
     638        rc = pFac->update((AdditionsFacilityStatus_T)enmStatus, tsNow);
     639    }
     640    else
     641    {
     642        ComObjPtr<AdditionsFacility> pFacility;
     643        pFacility.createObject();
     644        ComAssert(!pFacility.isNull());
     645        rc = pFacility->init(this,
     646                             (AdditionsFacilityType_T)enmFacility,
     647                             (AdditionsFacilityStatus_T)enmStatus);
     648        if (SUCCEEDED(rc))
     649            mData.mFacilityMap.insert(std::make_pair((AdditionsFacilityType_T)enmFacility, pFacility));
     650    }
     651
     652    LogFlowFunc(("Returned with rc=%Rrc\n"));
     653    return rc;
    613654}
    614655
     
    666707            while (it != mData.mFacilityMap.end())
    667708            {
    668                 updateFacility((VBoxGuestFacilityType)it->first, enmStatus);
     709                facilityUpdate((VBoxGuestFacilityType)it->first, enmStatus);
    669710                it++;
    670711            }
    671712        }
    672713        else /* Update one facility only. */
    673             updateFacility(enmFacility, enmStatus);
     714            facilityUpdate(enmFacility, enmStatus);
    674715    }
    675716}
     
    687728    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    688729
    689     updateFacility(VBoxGuestFacilityType_Seamless, aCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ?
     730    facilityUpdate(VBoxGuestFacilityType_Seamless, aCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ?
    690731                   VBoxGuestFacilityStatus_Active : VBoxGuestFacilityStatus_Inactive);
    691732    /** @todo Add VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING */
    692     updateFacility(VBoxGuestFacilityType_Graphics, aCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ?
     733    facilityUpdate(VBoxGuestFacilityType_Graphics, aCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ?
    693734                   VBoxGuestFacilityStatus_Active : VBoxGuestFacilityStatus_Inactive);
    694735}
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