VirtualBox

Changeset 84869 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 18, 2020 9:33:37 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Enabling unattended install (the most stripped version possible) in the new vm wizard.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r84861 r84869  
    2929#include "UICloudProfileManager.h"
    3030#include "UIDesktopServices.h"
     31#include "UIErrorString.h"
    3132#include "UIExtraDataManager.h"
    3233#include "UIHostNetworkManager.h"
     
    6566/* COM includes: */
    6667#include "CSystemProperties.h"
     68#include "CUnattended.h"
     69#include "CVirtualBoxErrorInfo.h"
    6770
    6871/* Other VBox stuff: */
     
    7275# include <iprt/env.h>
    7376#endif /* VBOX_WS_X11 */
     77
     78#define checkUnattendedInstallError(comUnattendedInstaller) \
     79    do { \
     80        if (!comUnattendedInstaller.isOk())      \
     81        { \
     82        COMErrorInfo comErrorInfo =  comUnattendedInstaller.errorInfo(); \
     83        QString strErrorInfo = UIErrorString::formatErrorInfo(comErrorInfo); \
     84        printf("unattended install error %s\n", qPrintable(strErrorInfo)); \
     85        return; \
     86        } \
     87    } while (0)
    7488
    7589
     
    599613        pWizard->exec();
    600614
     615        /* Cache unattended install related info and delete the wizard before handling the unattended install stuff: */
     616        bool fUnattendedEnabled = pWizard->isUnattendedInstallEnabled();
     617        QUuid uMachineUid = pWizard->createdMachineId();
     618        QString strISOPath = pWizard->unattendedISOFilePath();
     619        bool fStartHeadless = pWizard->startHeadless();
    601620
    602621        delete pWizard;
     622        /* Handle unattended install stuff: */
     623        if (fUnattendedEnabled)
     624            startUnattendedInstall(uMachineUid, strISOPath, fStartHeadless);
    603625    }
    604626    /* For cloud machine: */
     
    18491871}
    18501872
     1873void UIVirtualBoxManager::startUnattendedInstall(const QUuid &uMachineUid, const QString &strISOPath, bool fStartHeadless)
     1874{
     1875    if (!QFileInfo(strISOPath).exists())
     1876    {
     1877        /// @todo Show a relavant error message here
     1878        return;
     1879    }
     1880
     1881    CVirtualBox comVBox = uiCommon().virtualBox();
     1882    CUnattended comUnattendedInstaller = comVBox.CreateUnattendedInstaller();
     1883    AssertMsgReturnVoid(!comUnattendedInstaller.isNull(), ("Could not create unattended installer!\n"));
     1884    CMachine comMachine = comVBox.FindMachine(uMachineUid.toString());
     1885    AssertMsgReturnVoid(!comMachine.isNull(), ("Failed to find CMachine for the uuid %u!\n", uMachineUid));
     1886
     1887    comUnattendedInstaller.SetIsoPath(strISOPath);
     1888    checkUnattendedInstallError(comUnattendedInstaller);
     1889    comUnattendedInstaller.SetMachine(comMachine);
     1890    checkUnattendedInstallError(comUnattendedInstaller);
     1891    comUnattendedInstaller.Prepare();
     1892    checkUnattendedInstallError(comUnattendedInstaller);
     1893    comUnattendedInstaller.ConstructMedia();
     1894    checkUnattendedInstallError(comUnattendedInstaller);
     1895    comUnattendedInstaller.ReconfigureVM();
     1896    checkUnattendedInstallError(comUnattendedInstaller);
     1897
     1898    UICommon::LaunchMode enmLaunchMode = UICommon::LaunchMode_Default;
     1899    if (fStartHeadless)
     1900        enmLaunchMode = UICommon::LaunchMode_Headless;
     1901    uiCommon().launchMachine(comMachine, enmLaunchMode);
     1902}
     1903
    18511904void UIVirtualBoxManager::performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, UICommon::LaunchMode enmLaunchMode)
    18521905{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r84558 r84869  
    335335        /** Opens add machine dialog specifying initial name with @a strFileName. */
    336336        void openAddMachineDialog(const QString &strFileName = QString());
     337       /** Creates an uattended installer and uses that to install guest os to newly created vm. */
     338       void startUnattendedInstall(const QUuid &uMachineUid, const QString &strISOPath, bool fStartHeadless);
    337339    /** @} */
    338340
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r84861 r84869  
    117117         * 1. if we don't attach any virtual hard-drive
    118118         * 2. or attach a new (empty) one.
     119         * 3. and if the unattended install is not enabled
    119120         * Usually we are assigning extra-data values through UIExtraDataManager,
    120121         * but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it: */
    121         if (field("virtualDiskId").toString().isNull() || !field("virtualDisk").value<CMedium>().isNull())
     122        if (!isUnattendedInstallEnabled() &&
     123            (field("virtualDiskId").toString().isNull() || !field("virtualDisk").value<CMedium>().isNull()))
    122124            m_machine.SetExtraData(GUI_FirstRun, "yes");
    123125    }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r84861 r84869  
    5959    /** Returns the Id of newly created VM. */
    6060    QUuid createdMachineId() const { return m_machine.GetId(); }
     61    QString unattendedISOFilePath() const;
     62    bool isUnattendedInstallEnabled() const;
     63    bool startHeadless() const;
    6164
    6265protected:
     
    7275    friend class UIWizardNewVMPageBasic3;
    7376    friend class UIWizardNewVMPageExpert;
    74 
    75     QString unattendedISOFilePath() const;
    76     bool isUnattendedInstallEnabled() const;
    77     bool startHeadless() const;
    78 
    7977
    8078private slots:
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