Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 403337

Summary: app-emulation/virtualbox: save machine state when shutting down
Product: Gentoo Linux Reporter: Christoph Junghans (RETIRED) <junghans>
Component: Current packagesAssignee: Viorel Munteanu <ceamac>
Status: CONFIRMED ---    
Severity: enhancement CC: patrick
Priority: Lowest    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: updated init.d script
updated init.d script

Description Christoph Junghans (RETIRED) gentoo-dev 2012-02-13 01:03:17 UTC
I have used the following shutdown function for a while. (If needed I could rewrite it as init.d script.)

$ cat /etc/local.d/virtualbox.stop 
. /etc/init.d/functions.sh

for user in $(/usr/sbin/groupmems -g vboxusers -l); do
  for uuid in $(su - $user -c '/opt/bin/VBoxManage -q list runningvms' | sed -n 's/^.*{\([^}]*\)}$/\1/p'); do
    name=$(su - $user -c "/opt/bin/VBoxManage showvminfo $uuid" | awk '/^Name:/{print $2}')
    ebegin "Save state of vm '$name' of user $user"
    su - $user -c "/opt/bin/VBoxManage controlvm $uuid savestate" &>/dev/null
    eend $?
 done
done
Comment 1 Christoph Junghans (RETIRED) gentoo-dev 2013-10-21 22:36:23 UTC
Ping!
Comment 2 Christoph Junghans (RETIRED) gentoo-dev 2013-10-24 16:38:13 UTC
Created attachment 361800 [details]
updated init.d script
Comment 3 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-10-24 18:42:18 UTC
Looks interesting. Once I have some time I gonna test the script...
Comment 4 Christoph Junghans (RETIRED) gentoo-dev 2013-11-01 22:55:40 UTC
Created attachment 362412 [details]
updated init.d script

(In reply to Lars Wendler (Polynomial-C) from comment #3)
> Looks interesting. Once I have some time I gonna test the script...
I added a start function, which will start a list of machines.
Comment 5 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2013-11-02 13:24:47 UTC
Where does ${VMS_TO_START} come from? I suppose it's set via conf.d file? If yes please provide a sample file.
Comment 6 Christoph Junghans (RETIRED) gentoo-dev 2013-11-11 20:52:25 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #5)
> Where does ${VMS_TO_START} come from? I suppose it's set via conf.d file? If
> yes please provide a sample file.
Yeah one needs to create a conf.d file with 
VMS_TO_START="user:machine-uuid user2:machine-uuid2" in it.