2

I have Ubuntu 14.04 host with some win guests drived by Virtualbox 5.1. Some of them are really big and needs about 1-2-3 minutes to get to savestate.

As far as I know there are at least two init.d scripts that controls vm state on shutdown. May be there are another more?

1. init.d/vboxdrv

It has prioriy 80 in /etc/rc0.d folder

This one requires SHUTDOWN and SHUTDOWN_USERS variables in /etc/default/virtualbox and runs VBoxManage controlvm savestate for each runnning VM.

This script exits after stopping all vms, it work like "single thread" task.

2. init.d/vboxautostart-service

has prioriy 65 in /etc/rc0.d folder

This one requires fully configured autostart service, like /etc/vobx/.start and /etc/vobx/.stop and other staff...

This script exits immideately, because it only run autostart-service deamon whit specific params:

stop() {
    [ -z "$VBOXAUTOSTART_DB" ] && exit 0
    [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0

    PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"

    # prevent inheriting this setting to VBoxSVC
    unset VBOX_RELEASE_LOG_DEST

    for user in `ls $VBOXAUTOSTART_DB/*.stop`
    do
        start_daemon `basename $user | sed -ne "s/\(.*\).stop/\1/p"` $binary $PARAMS > /dev/null 2>&1
    done

    return $RETVAL
}

So... When we use that scripts in standalone mode, I mean like

sudo service vboxautostart-service stop

or

sudo service vboxdrv stop

everything works perfectly. First one shows 10%..20%..30%.. progress bar for each vm. Second one exits immideately, but binary runned do its job and stop vms...

But! While host shutdown (shutdown -h now) I think that upstart kills that scripts (on timeout?), because no any job config provided for mentioned scripts in /etc/init/. And default upstart kill delay is 5 seconds, AFAIK.

I googled a lot off posts and recipes for creating scripts that looks more less like mentioned scrips already present in vbox package, so I don't se any sense to use those advises. None of them give recipe to get guaranteed guset graceful shutdown (or savestate) on host reboot/shutdown.

Of cource, I know I can manually take care to shutdown all vms and only after that - shutting down host... But it's not comfort for me... Besides shutdown could be initiated by apcupsd or else... IMHO, vms control should be done by one who has intended to do this )))

I would be appriciated if somebody take me clear in next questions:

  1. Should we tweak upstart config to give enough time to vbox init scripts to shutdown (savestate, etc)? Or some other sollution?
  2. Which script should be prefered to shutdown vms? autostart-service or vboxdrv? Am I right that it depends on taste only while in single user host environment?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.