VirtualBox

Changeset 43138 in vbox


Ignore:
Timestamp:
Aug 31, 2012 1:26:04 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80511
Message:

BUGZ:3965 Allow user to change network configuration on VM start if any of involved physical network interfaces missing.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r42998 r43138  
    12001200}
    12011201
     1202bool UIMessageCenter::cannotStartWithoutNetworkIf(const QString &strMachineName,
     1203                                                  const QString &strIfNames)
     1204{
     1205    return messageOkCancel(mainMachineWindowShown(), Error,
     1206             tr("<p>Could not start the machine <b>%1</b> because the "
     1207                "following physical network interfaces were not found:</p>"
     1208                "<p><b>%2</b></p>"
     1209                "<p>You can either change the machine's network "
     1210                "settings or stop the machine.</p>")
     1211             .arg(strMachineName)
     1212             .arg(strIfNames),
     1213             0, /* pcszAutoConfirmId */
     1214             tr("Change Network Settings"),
     1215             tr("Close Virtual Machine"));
     1216}
     1217
    12021218void UIMessageCenter::cannotSwitchScreenInSeamless(quint64 uMinVRAM)
    12031219{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r42998 r43138  
    250250    int cannotEnterFullscreenMode(ULONG uWidth, ULONG uHeight,
    251251                                  ULONG uBpp, ULONG64 uMinVRAM);
     252    bool cannotStartWithoutNetworkIf(const QString &strMachineName, const QString &strIfNames);
    252253    void cannotSwitchScreenInSeamless(quint64 uMinVRAM);
    253254    int cannotSwitchScreenInFullscreen(quint64 uMinVRAM);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r42949 r43138  
    7373    bool isPreventAutoClose() const { return m_fIsPreventAutoClose; }
    7474    void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; }
     75
     76    /* Wrapper to open Machine settings / Network page: */
     77    void openNetworkAdaptersDialog() { sltOpenNetworkAdaptersDialog(); }
    7578
    7679#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r43004 r43138  
    2020/* Qt includes: */
    2121#include <QApplication>
     22#include <QNetworkInterface>
    2223#include <QWidget>
    2324#include <QTimer>
     
    154155
    155156    /* Prepare powerup: */
    156     preparePowerUp();
     157    bool fPrepared = preparePowerUp();
     158    if (!fPrepared)
     159        return;
    157160
    158161    /* Get current machine/console: */
     
    10931096}
    10941097
    1095 void UISession::preparePowerUp()
     1098bool UISession::preparePowerUp()
    10961099{
    10971100    /* Notify user about mouse&keyboard auto-capturing: */
     
    11131116        wzd.exec();
    11141117    }
     1118
     1119    /* Skip further checks if VM in saved state */
     1120    if (isSaved())
     1121        return true;
     1122
     1123    /* Make sure all the attached and enabled network
     1124     * adapters are present on the host. This check makes sense
     1125     * in two cases only - when attachement type is Bridged Network
     1126     * or Host-only Interface. NOTE: Only currently enabled
     1127     * attachement type is checked (incorrect parameters check for
     1128     * currently disabled attachement types is skipped). */
     1129    QStringList failedInterfaceNames;
     1130    ulong cCount = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(machine.GetChipsetType());
     1131    for (ulong uAdapterIndex = 0; uAdapterIndex < cCount; ++uAdapterIndex)
     1132    {
     1133        CNetworkAdapter na = machine.GetNetworkAdapter(uAdapterIndex);
     1134        if (na.GetEnabled() &&
     1135            (na.GetAttachmentType() == KNetworkAttachmentType_Bridged ||
     1136             na.GetAttachmentType() == KNetworkAttachmentType_HostOnly))
     1137        {
     1138            QStringList ifNames;
     1139            ifNames << na.GetBridgedInterface()
     1140                    << na.GetHostOnlyInterface();
     1141
     1142            foreach (const QString &strIfName, ifNames)
     1143            {
     1144                if (!strIfName.isEmpty() &&
     1145                    !QNetworkInterface::interfaceFromName(strIfName).isValid())
     1146                {
     1147                    LogFlow(("Found invalid network interface: %s\n", strIfName.toStdString().c_str()));
     1148                    failedInterfaceNames << QString("%1 (adapter %2)").arg(strIfName).arg(uAdapterIndex + 1);
     1149                    break;
     1150                }
     1151            }
     1152        }
     1153    }
     1154    /* Check failed? */
     1155    if (!failedInterfaceNames.isEmpty())
     1156    {
     1157        if (msgCenter().UIMessageCenter::cannotStartWithoutNetworkIf(machine.GetName(), failedInterfaceNames.join(", ")))
     1158            machineLogic()->openNetworkAdaptersDialog();
     1159        else
     1160        {
     1161            QTimer::singleShot(0, this, SLOT(sltCloseVirtualSession()));
     1162            return false;
     1163        }
     1164    }
     1165
     1166    return true;
    11151167}
    11161168
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r41689 r43138  
    228228    void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
    229229    void reinitMenuPool();
    230     void preparePowerUp();
     230    bool preparePowerUp();
    231231
    232232#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
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