VirtualBox

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


Ignore:
Timestamp:
Jul 29, 2011 1:12:04 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73224
Message:

FE/Qt4: enable linked cloning of the "Current State" by implicitly creating an snapshot first

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

Legend:

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

    r38222 r38241  
    10911091}
    10921092
     1093void VBoxProblemReporter::cannotFindSnapshotByName(QWidget *pParent,
     1094                                                   const CMachine &machine,
     1095                                                   const QString &strName) const
     1096{
     1097    message (pParent ? pParent : mainWindowShown(), Error,
     1098             tr ("Can't find snapshot named <b>%1</b>.")
     1099             .arg(strName),
     1100             formatErrorInfo(machine)
     1101    );
     1102}
     1103
    10931104void VBoxProblemReporter::cannotFindMachineByName (const CVirtualBox &vbox,
    10941105                                                   const QString &name)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r38222 r38241  
    237237    void cannotDeleteSnapshot (const CConsole &aConsole, const QString &aSnapshotName);
    238238    void cannotDeleteSnapshot (const CProgress &aProgress, const QString &aSnapshotName);
     239    void cannotFindSnapshotByName(QWidget *pParent, const CMachine &machine, const QString &strMachine) const;
    239240
    240241    void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UICloneVMWizard.cpp

    r38102 r38241  
    3434    : QIWizard(pParent)
    3535    , m_machine(machine)
     36    , m_snapshot(snapshot)
    3637{
    3738    /* Create & add pages: */
    3839    setPage(PageIntro, new UICloneVMWizardPage1(machine.GetName()));
    3940    /* If we are having a snapshot we can show the "Linked" option. */
    40     if (!snapshot.isNull())
    41         setPage(PageType, new UICloneVMWizardPage2());
     41    setPage(PageType, new UICloneVMWizardPage2(snapshot.isNull()));
    4242    /* If the machine has no snapshots, we don't bother the user about options
    4343     * for it. */
     
    7777    const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null);
    7878
     79    CMachine srcMachine = m_machine;
     80    /* If the user like to create a linked clone from the current machine, we
     81     * have to take a little bit more action. First we create an snapshot, so
     82     * that new differencing images on the source VM are created. Based on that
     83     * we could use the new snapshot machine for cloning. */
     84    if (   fLinked
     85        && m_snapshot.isNull())
     86    {
     87        const QString &strId = m_machine.GetId();
     88        CSession session = vboxGlobal().openSession(strId);
     89        if (session.isNull())
     90            return false;
     91        CConsole console = session.GetConsole();
     92
     93        /* Take the snapshot */
     94        QString strSnapshotName = tr("Linked Base for %1 and %2").arg(m_machine.GetName()).arg(strName);
     95        CProgress progress = console.TakeSnapshot(strSnapshotName, "");
     96
     97        if (console.isOk())
     98        {
     99            /* Show the "Taking Snapshot" progress dialog */
     100            vboxProblem().showModalProgressDialog(progress, m_machine.GetName(), ":/progress_snapshot_create_90px.png", this, true);
     101
     102            if (!progress.isOk() || progress.GetResultCode() != 0)
     103            {
     104                vboxProblem().cannotTakeSnapshot(progress);
     105                return false;
     106            }
     107        }
     108        else
     109        {
     110            vboxProblem().cannotTakeSnapshot(console);
     111            return false;
     112        }
     113
     114        /* Unlock machine finally: */
     115        session.UnlockMachine();
     116
     117        /* Get the new snapshot and the snapshot machine. */
     118        const CSnapshot &newSnapshot = m_machine.FindSnapshot(strSnapshotName);
     119        if (newSnapshot.isNull())
     120        {
     121            vboxProblem().cannotFindSnapshotByName(this, m_machine, strSnapshotName);
     122            return false;
     123        }
     124        srcMachine = newSnapshot.GetMachine();
     125    }
     126
    79127    /* Create a new machine object. */
    80128    CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QString::null, QString::null, false);
     
    94142
    95143    /* Start cloning. */
    96     CProgress progress = m_machine.CloneTo(cloneMachine, mode, options);
    97     if (!m_machine.isOk())
    98     {
    99         vboxProblem().cannotCreateClone(m_machine, this);
     144    CProgress progress = srcMachine.CloneTo(cloneMachine, mode, options);
     145    if (!srcMachine.isOk())
     146    {
     147        vboxProblem().cannotCreateClone(srcMachine, this);
    100148        return false;
    101149    }
     
    107155    if (!progress.isOk() || progress.GetResultCode() != 0)
    108156    {
    109         vboxProblem().cannotCreateClone(m_machine, progress, this);
     157        vboxProblem().cannotCreateClone(srcMachine, progress, this);
    110158        return false;
    111159    }
     
    115163    if (!vbox.isOk())
    116164    {
    117         vboxProblem().cannotRegisterMachine(vbox, m_machine, this);
     165        vboxProblem().cannotRegisterMachine(vbox, cloneMachine, this);
    118166        return false;
    119167    }
     
    198246}
    199247
    200 UICloneVMWizardPage2::UICloneVMWizardPage2()
     248UICloneVMWizardPage2::UICloneVMWizardPage2(bool fAdditionalInfo)
     249  : m_fAdditionalInfo(fAdditionalInfo)
    201250{
    202251    /* Decorate page: */
     
    223272    /* Set 'Page2' page title: */
    224273    setTitle(tr("Cloning Configuration"));
     274
     275
     276    QString strLabel = tr("<p>Please select the type of the clone.</p><p>If you choose <b>Full Clone</b> an exact copy (including all virtual disk images) of the original VM will be created. If you select <b>Linked Clone</b>, a new VM will be created, but the virtual disk images will point to the virtual disk images of original VM.</p>");
     277    if (m_fAdditionalInfo)
     278        strLabel += tr("<p>Note that a new snapshot within the source VM is created in case you select <b>Linked Clone</b>.</p>");
     279    m_pLabel->setText(strLabel);
    225280}
    226281
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UICloneVMWizard.h

    r38102 r38241  
    5555    /* Private member vars */
    5656    CMachine m_machine;
     57    CSnapshot m_snapshot;
    5758};
    5859
     
    120121
    121122    /* Constructor: */
    122     UICloneVMWizardPage2();
     123    UICloneVMWizardPage2(bool fAdditionalInfo);
    123124    int nextId() const;
    124125
     
    136137
    137138    void buttonClicked(QAbstractButton *pButton);
     139
     140private:
     141
     142    bool m_fAdditionalInfo;
    138143};
    139144
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UICloneVMWizardPage2.ui

    r38102 r38241  
    3434    <widget class="QILabel" name="m_pLabel">
    3535     <property name="text">
    36       <string>&lt;p&gt;Please select the type of the clone.&lt;/p&gt;&lt;p&gt;If you choose &lt;b&gt;Full Clone&lt;/b&gt; an exact copy (including all virtual disk images) of the original VM will be created. If you select &lt;b&gt;Linked Clone&lt;/b&gt;, a new VM will be created, but the virtual disk images will point to the virtual disk images of original VM.&lt;/p&gt;</string>
     36      <string></string>
    3737     </property>
    3838     <property name="wordWrap">
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