How can I perform a controlled shutdown of a virtualbox guest using VBoxManage?

11,594

Solution 1

I hate posting answers to my own questions, but I've found the solution...

Simply install acpi-support into the guest.

apt-get install acpi-support

I figured acpid would have been enough, but it appears as though it wasn't.

I can now issue a VBoxManage command to send an ACPIPowerButton event from the host, which now cleanly performs a shutdown on the guest.

Thanks everyone for your suggestions.

Solution 2

Is your guest configured to shutdown when it gets the acpipowerbutton signal ?

Share:
11,594

Related videos on Youtube

Kcmamu
Author by

Kcmamu

Developer, Systems Admin, Geek, Gadget lover, etc. etc. I started programming in BASIC at the age of 11 on a Sinclair ZX81, advanced to a BBC Model B, where I learned 6502 assembly language programming. I never really worked with PCs until the early 90s. In the late 90s, I joined a higher educational institution as a desktop technician, a quickly got promoted to be a systems admin, working predominantly on Windows systems, but also had a keen interest in Linux systems. I later got involved in software development, working in C#, PHP, C. In my current employment, I'm the manager of the company's Information Systems department. The primary focus of our business is industrial control systems (mostly legacy systems). The work isn't exclusively legacy/control systems though, as we also support modern systems for a number of business customers.

Updated on September 17, 2022

Comments

  • Kcmamu
    Kcmamu over 1 year

    I'm currently testing Ubuntu 10.04, and have install the VirtualBox software. I have also installed Ubuntu 10.04 as a VirtualBox guest running on the host system.

    I've installed the VirtualBox Utils into the guest OS, as follows:

    sudo apt-get install virtualbox-ose-guest-utils
    

    What I want to be able to do is to initiate a controlled shutdown of the guest, from the host system using the VBoxManage command.

    I first tried this command:

    VBoxManage controlvm guest poweroff
    

    which worked, but didn't initiate a controlled shutdown, it effectively pulls the plug on the guest.

    I've since found that this command should do the trick:

    VBoxManage controlvm guest acpipowerbutton
    

    but this doesn't appear to do anything.

    Can anyone tell me what I'm doing wrong?

    p.s. I don't want to use SSH & Certificates to do this, as I'm also going to be running Windows guests, and I want the solution to work for all guests.

    Edit: Just found this post which suggests installing acpid into the guest, however having just done this and rebooted the system, it doesn't appear to have made any difference, as the host still appears to accept the command, but nothing happens to the guest.

    Second Edit: acpi powerbutton event config as follows:

    # /etc/acpi/events/powerbtn
    # This is called when the user presses the power button and calls
    # /etc/acpi/powerbtn.sh for further processing.
    
    # Optionally you can specify the placeholder %e. It will pass
    # through the whole kernel event message to the program you've
    # specified.
    
    # We need to react on "button power.*" and "button/power.*" because
    # of kernel changes.
    
    event=button[ /]power
    action=/etc/acpi/powerbtn.sh
    

    The above shell script (/etc/acpi/powerbtn.sh) exists

    • ptman
      ptman about 14 years
      Well, have you checked the contents of /etc/acpi/powerbtn.sh?
    • Kcmamu
      Kcmamu about 14 years
      Yes, looks quite complex (for my shell scripting capabilities), but appears as though it would do the correct thing. I've also tried commenting out all the lines apart from the last line, which is a call to 'shutdown -h'
  • Kcmamu
    Kcmamu about 14 years
    Just edited my question, as I've just installed acpid on the guest. I don't know how to tell if the guest is configured to shutdown when it receives the acpipowerbutton signal though?
  • user9517
    user9517 about 14 years
    For windows guests it's in control panel->Power Options-> ... Power Buttons