VirtualBox

Changeset 100174 in vbox for trunk


Ignore:
Timestamp:
Jun 14, 2023 8:13:43 AM (18 months ago)
Author:
vboxsync
Message:

FE/Qt: Disable guest control related functionality (and RAM usage metric) if GA version is not 6.1 or newer. Nowadays nearly for all vanilla Linuxes we get version string 6.0.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.cpp

    r98103 r100174  
    5151#include "CPerformanceCollector.h"
    5252#include "CPerformanceMetric.h"
     53#include <iprt/string.h>
    5354
    5455/* External includes: */
     
    12371238void UIVMActivityMonitor::sltGuestAdditionsStateChange()
    12381239{
    1239     bool fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */);
     1240    bool fGuestAdditionsAvailable = guestAdditionsAvailable("6.1");
    12401241    if (m_fGuestAdditionsAvailable == fGuestAdditionsAvailable)
    12411242        return;
     
    13111312}
    13121313
    1313 bool UIVMActivityMonitor::guestAdditionsAvailable(int iMinimumMajorVersion)
    1314 {
    1315     if (m_comGuest.isNull())
     1314bool UIVMActivityMonitor::guestAdditionsAvailable(const char *pszMinimumVersion)
     1315{
     1316    if (m_comGuest.isNull() || !pszMinimumVersion)
    13161317        return false;
    13171318    bool fGuestAdditionsStatus = m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel());
    1318     if (fGuestAdditionsStatus)
    1319     {
    1320 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
    1321         QStringList versionStrings = m_comGuest.GetAdditionsVersion().split('.', Qt::SkipEmptyParts);
    1322 #else
    1323         QStringList versionStrings = m_comGuest.GetAdditionsVersion().split('.', QString::SkipEmptyParts);
    1324 #endif
    1325         if (!versionStrings.isEmpty())
    1326         {
    1327             bool fConvert = false;
    1328             int iMajorVersion = versionStrings[0].toInt(&fConvert);
    1329             if (fConvert && iMajorVersion >= iMinimumMajorVersion)
    1330                 return true;
    1331         }
     1319    if (fGuestAdditionsStatus && m_comGuest.isOk())
     1320    {
     1321        QString strGAVersion = m_comGuest.GetAdditionsVersion();
     1322        if (m_comGuest.isOk())
     1323            return (RTStrVersionCompare(strGAVersion.toUtf8().constData(), pszMinimumVersion) >= 0);
    13321324    }
    13331325    return false;
     
    15911583        return;
    15921584
    1593     m_fGuestAdditionsAvailable = guestAdditionsAvailable(6 /* minimum major version */);
     1585    m_fGuestAdditionsAvailable = guestAdditionsAvailable("6.1");
    15941586    enableDisableGuestAdditionDependedWidgets(m_fGuestAdditionsAvailable);
    15951587    if (m_pTimer)
  • trunk/src/VBox/Frontends/VirtualBox/src/activity/vmactivity/UIVMActivityMonitor.h

    r98103 r100174  
    169169    void prepareMetrics();
    170170    void prepareActions();
    171     bool guestAdditionsAvailable(int iMinimumMajorVersion);
     171    bool guestAdditionsAvailable(const char *pszMinimumVersion);
    172172    void enableDisableGuestAdditionDependedWidgets(bool fEnable);
    173173
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.cpp

    r100082 r100174  
    424424    , m_pGuestSessionWidget(0)
    425425    , m_fIsCurrent(false)
     426    , pszMinimumGuestAdditionVersion("6.1")
    426427{
    427428    if (!m_comMachine.isNull())
     
    484485                break;
    485486            case State_NoGuestAdditions:
    486                 strWarningText = UIFileManager::tr("File manager cannot work since the selected guest does not have the guest additions.");
     487                strWarningText = UIFileManager::tr("File manager cannot work since no guest additions were detected.");
     488                icon = UIIconPool::iconSet(":/status_error_16px.png");
     489                break;
     490            case State_GuestAdditionsTooOld:
     491                strWarningText = UIFileManager::tr("File manager cannot work. The guest additions need to be updated.");
    487492                icon = UIIconPool::iconSet(":/status_error_16px.png");
    488493                break;
     
    12931298}
    12941299
    1295 bool UIFileManagerGuestTable::isGuestAdditionsAvailable()
    1296 {
    1297     if (m_comGuest.isNull())
    1298         return false;
    1299     return m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel());
     1300int UIFileManagerGuestTable::isGuestAdditionsAvailable(const char* pszMinimumVersion)
     1301{
     1302    if (m_comGuest.isNull() || !pszMinimumVersion)
     1303        return 0;
     1304    bool fGuestAdditionsStatus = m_comGuest.GetAdditionsStatus(m_comGuest.GetAdditionsRunLevel());
     1305    if (fGuestAdditionsStatus && m_comGuest.isOk())
     1306    {
     1307        QString strGAVersion = m_comGuest.GetAdditionsVersion();
     1308        if (m_comGuest.isOk())
     1309        {
     1310            int iCode = RTStrVersionCompare(strGAVersion.toUtf8().constData(), pszMinimumVersion);
     1311            if (iCode >= 0)
     1312                return 1;
     1313            else
     1314                return -1;
     1315        }
     1316    }
     1317    return 0;
    13001318}
    13011319
     
    13961414    setStateAndEnableWidgets();
    13971415
    1398     if (m_comGuestSession.isOk())
    1399     {
    1400         emit sigLogOutput(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
    1401                   m_strTableName, FileManagerLogType_Info);
    1402 
    1403         switch (m_comGuestSession.GetStatus())
    1404         {
    1405             case KGuestSessionStatus_Started:
     1416    if (m_comGuestSession.isNull())
     1417        emit sigLogOutput("Guest session is invalid!", m_strTableName, FileManagerLogType_Error);
     1418    else
     1419    {
     1420        if (m_comGuestSession.isOk())
     1421        {
     1422            emit sigLogOutput(QString("%1: %2").arg("Guest session status has changed").arg(gpConverter->toString(m_comGuestSession.GetStatus())),
     1423                              m_strTableName, FileManagerLogType_Info);
     1424
     1425            switch (m_comGuestSession.GetStatus())
    14061426            {
    1407                 initFileTable();
    1408                 break;
     1427                case KGuestSessionStatus_Started:
     1428                    {
     1429                        initFileTable();
     1430                        break;
     1431                    }
     1432                case KGuestSessionStatus_Terminating:
     1433                case KGuestSessionStatus_Terminated:
     1434                case KGuestSessionStatus_TimedOutKilled:
     1435                case KGuestSessionStatus_TimedOutAbnormally:
     1436                case KGuestSessionStatus_Down:
     1437                case KGuestSessionStatus_Error:
     1438                    {
     1439                        cleanupGuestSessionListener();
     1440                        closeGuestSession();
     1441                        break;
     1442                    }
     1443                case KGuestSessionStatus_Undefined:
     1444                case KGuestSessionStatus_Starting:
     1445                case KGuestSessionStatus_Max:
     1446                default:
     1447                    break;
    14091448            }
    1410             case KGuestSessionStatus_Terminating:
    1411             case KGuestSessionStatus_Terminated:
    1412             case KGuestSessionStatus_TimedOutKilled:
    1413             case KGuestSessionStatus_TimedOutAbnormally:
    1414             case KGuestSessionStatus_Down:
    1415             case KGuestSessionStatus_Error:
    1416             {
    1417                 cleanupGuestSessionListener();
    1418                 closeGuestSession();
    1419                 break;
    1420             }
    1421             case KGuestSessionStatus_Undefined:
    1422             case KGuestSessionStatus_Starting:
    1423             case KGuestSessionStatus_Max:
    1424             default:
    1425                 break;
    1426         }
    1427     }
    1428     else
    1429         emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
     1449        }
     1450        else
     1451            emit sigLogOutput(UIErrorString::formatErrorInfo(m_comGuestSession), m_strTableName, FileManagerLogType_Error);
     1452    }
    14301453}
    14311454
     
    14591482        return;
    14601483    }
    1461     if (!isGuestAdditionsAvailable())
     1484
     1485    int iGADetectCode = isGuestAdditionsAvailable(pszMinimumGuestAdditionVersion);
     1486    if (iGADetectCode == 0)
    14621487    {
    14631488        m_enmState = State_NoGuestAdditions;
    14641489        return;
    14651490    }
     1491    else if (iGADetectCode == -1)
     1492    {
     1493        m_enmState = State_GuestAdditionsTooOld;
     1494        return;
     1495    }
     1496
    14661497    if (!m_comGuestSession.isNull() && m_comGuestSession.GetStatus() == KGuestSessionStatus_Started)
    14671498    {
     
    15381569    }
    15391570
    1540     if (!isGuestAdditionsAvailable())
    1541     {
    1542         emit sigLogOutput("Could not find Guest Additions", m_strTableName, FileManagerLogType_Error);
     1571    int iGADetectCode = isGuestAdditionsAvailable(pszMinimumGuestAdditionVersion);
     1572    if (iGADetectCode == 0)
     1573    {
     1574        emit sigLogOutput("Could not find Guest Additions",
     1575                          m_strTableName, FileManagerLogType_Error);
     1576        if (m_pGuestSessionWidget)
     1577            m_pGuestSessionWidget->markForError(true);
     1578        return false;
     1579    }
     1580    else if (iGADetectCode == -1)
     1581    {
     1582        emit sigLogOutput(QString("%1 %2").arg("The Guest Additions are older than ").arg(pszMinimumGuestAdditionVersion),
     1583                          m_strTableName, FileManagerLogType_Error);
    15431584        if (m_pGuestSessionWidget)
    15441585            m_pGuestSessionWidget->markForError(true);
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIFileManagerGuestTable.h

    r98103 r100174  
    121121        State_MachineNotRunning,
    122122        State_NoGuestAdditions,
     123        State_GuestAdditionsTooOld,
    123124        State_SessionPossible,
    124125        State_SessionRunning,
     
    151152    bool openMachineSession();
    152153    bool closeMachineSession();
    153     bool isGuestAdditionsAvailable();
     154    /* Return 0 if GA is not detected, -1 if it is there but older than @p pszMinimumGuestAdditionVersion, and 1 otherwise. */
     155    int isGuestAdditionsAvailable(const char* pszMinimumVersion);
    154156    void setStateAndEnableWidgets();
    155157
     
    173175    bool m_fIsCurrent;
    174176    State m_enmState;
     177    const char *pszMinimumGuestAdditionVersion;
    175178};
    176179
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlInterface.cpp

    r99784 r100174  
    585585void UIGuestControlInterface::putCommand(const QString &strCommand)
    586586{
    587     if (!isGuestAdditionsAvailable(m_comGuest))
     587    if (!isGuestAdditionsAvailable(m_comGuest, "6.1"))
    588588    {
    589589        emit sigOutputString("No guest addtions detected. Guest control requires guest additions");
     
    699699
    700700/* static */
    701 bool UIGuestControlInterface::isGuestAdditionsAvailable(const CGuest &guest)
    702 {
    703     if (!guest.isOk())
    704         return false;
     701bool UIGuestControlInterface::isGuestAdditionsAvailable(const CGuest &guest, const char *pszMinimumVersion)
     702{
    705703    CGuest guestNonConst = const_cast<CGuest&>(guest);
    706     return guestNonConst.GetAdditionsStatus(guestNonConst.GetAdditionsRunLevel());
     704
     705    if (guestNonConst.isNull() || !pszMinimumVersion)
     706        return false;
     707    bool fGuestAdditionsStatus = guestNonConst.GetAdditionsStatus(guestNonConst.GetAdditionsRunLevel());
     708    if (fGuestAdditionsStatus && guestNonConst.isOk())
     709    {
     710        QString strGAVersion = guestNonConst.GetAdditionsVersion();
     711        if (guestNonConst.isOk())
     712            return (RTStrVersionCompare(strGAVersion.toUtf8().constData(), pszMinimumVersion) >= 0);
     713    }
     714    return false;
    707715}
    708716
  • trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlInterface.h

    r98103 r100174  
    6767        /** Pass a non-const ref since for some reason CGuest::GetAdditionsStatus
    6868            is non-const?! */
    69        static bool    isGuestAdditionsAvailable(const CGuest &guest);
     69       static bool    isGuestAdditionsAvailable(const CGuest &guest, const char *pszMinimumVersion);
    7070       static QString getFsObjTypeString(KFsObjType type);
    7171    /** @} */
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