VirtualBox

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


Ignore:
Timestamp:
Oct 16, 2012 3:18:28 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
81422
Message:

Autostart/stop: Further work on the stop part

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartStop.cpp

    r43378 r43656  
    158158                CHECK_ERROR_BREAK(machine, COMGETTER(State)(&enmMachineState));
    159159
     160                /* Wait until the VM changes from a transient state back. */
     161                while (   enmMachineState >= MachineState_FirstTransient
     162                       && enmMachineState <= MachineState_LastTransient)
     163                {
     164                    RTThreadSleep(1000);
     165                    CHECK_ERROR_BREAK(machine, COMGETTER(State)(&enmMachineState));
     166                }
     167
    160168                /* Only power off running machines. */
    161                 /** @todo: What about transient VM states? */
    162169                if (   enmMachineState == MachineState_Running
    163170                    || enmMachineState == MachineState_Paused)
    164171                {
    165                     ComPtr<IMachine> sessionMachine;
    166172                    ComPtr<IConsole> console;
    167173                    ComPtr<IProgress> progress;
     
    172178                    /* get the associated console */
    173179                    CHECK_ERROR_BREAK(g_pSession, COMGETTER(Console)(console.asOutParam()));
    174                     CHECK_ERROR_BREAK(g_pSession, COMGETTER(Machine)(sessionMachine.asOutParam()));
    175180
    176181                    switch ((*it).enmAutostopType)
     
    194199                            BOOL fGuestEnteredACPI = false;
    195200                            CHECK_ERROR_BREAK(console, GetGuestEnteredACPIMode(&fGuestEnteredACPI));
    196                             if (fGuestEnteredACPI)
     201                            if (fGuestEnteredACPI && enmMachineState == MachineState_Running)
     202                            {
    197203                                CHECK_ERROR_BREAK(console, PowerButton());
     204
     205                                serviceLog("Waiting for VM \"%ls\" to power off...\n", (*it).strId.raw());
     206
     207                                do
     208                                {
     209                                    RTThreadSleep(1000);
     210                                    CHECK_ERROR_BREAK(machine, COMGETTER(State)(&enmMachineState));
     211                                } while (enmMachineState == MachineState_Running);
     212                            }
    198213                            else
    199214                            {
    200215                                /* Use save state instead and log this to the console. */
    201                                 serviceLog("The guest of VM \"%ls\" does not support ACPI shutdown, saving state...\n",
     216                                serviceLog("The guest of VM \"%ls\" does not support ACPI shutdown or is currently paused, saving state...\n",
    202217                                           (*it).strId.raw());
    203218                                rc = autostartSaveVMState(console);
     
    208223                            serviceLog("Unknown autostop type for VM \"%ls\"\n", (*it).strId.raw());
    209224                    }
    210                 }
    211                 g_pSession->UnlockMachine();
     225                    g_pSession->UnlockMachine();
     226                }
    212227            }
    213228        }
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