systemctl stop vboxautostart-service.servise has no effect | VirualBox 5.1.6-110634~Ubuntu~xenial

Discussions related to using VirtualBox on Linux hosts.
Post Reply
iEvgeny
Posts: 2
Joined: 7. Oct 2016, 11:22

systemctl stop vboxautostart-service.servise has no effect | VirualBox 5.1.6-110634~Ubuntu~xenial

Post by iEvgeny »

Hi all!

I have configured autorun VirtualBox follows:

/etc/default/virtualbox

Code: Select all

VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/vboxautostart.cfg
/etc/vbox/vboxautostart.cfg

Code: Select all

default_policy = deny
administrator = {
    allow = true
    startup_delay = 10
}

Code: Select all

# chgrp vboxusers /etc/vbox
# chmod 1775 /etc/vbox
$ VBoxManage setproperty autostartdbpath /etc/vbox
$ VBoxManage modifyvm WinXP_SP3_RU --autostart-enabled on
$ VBoxManage modifyvm WinXP_SP3_RU --autostop-type acpishutdown
Now the guest machine is started by using vboxautostart-service.service:

Code: Select all

# systemctl start vboxautostart-service.service
But it can't be stopped as follows:

Code: Select all

# systemctl stop vboxautostart-service.service

Code: Select all

root@linux:~# systemctl status vboxautostart-service.service
● vboxautostart-service.service
   Loaded: loaded (/usr/lib/virtualbox/vboxautostart-service.sh; enabled; vendor preset: enabled)
   Active: inactive (dead) since Пт 2016-10-07 14:07:31 MSK; 6s ago
  Process: 14311 ExecStop=/usr/lib/virtualbox/vboxautostart-service.sh stop (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/vboxautostart-service.service
           ├─13909 /usr/lib/virtualbox/VBoxXPCOMIPCD
           ├─13914 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
           ├─13976 /usr/lib/virtualbox/VBoxHeadless --comment WinXP_SP3_RU --startvm 45df8aec-e1c1-43ed-be03-ff6d5429d226 --
           └─29701 /usr/bin/pulseaudio --start --log-target=syslog

окт 07 14:05:24 erp-server systemd[1]: Starting vboxautostart-service.service...
окт 07 14:05:24 erp-server vboxautostart-service.sh[13892]: vboxautostart-service.sh: Starting VirtualBox VMs configured for
окт 07 14:05:24 erp-server systemd[1]: Started vboxautostart-service.service.
окт 07 14:05:31 erp-server systemd[1]: Started vboxautostart-service.service.
окт 07 14:07:31 erp-server systemd[1]: Stopping vboxautostart-service.service...
окт 07 14:07:31 erp-server systemd[1]: Stopped vboxautostart-service.service.
However, the "old" way, when manually run, works without problems.

Code: Select all

# /usr/lib/virtualbox/vboxautostart-service.sh stop
Any idea what I can do here?

P.S.
In the process of debugging, randomly forced the demon to work.
To do this, edit the line 80 in the file /usr/lib/virtualbox/vboxautostart-service.sh

From:

Code: Select all

start-stop-daemon --background --chuid $usr --start --exec $bin -- $@
То:

Code: Select all

start-stop-daemon --background --no-close --chuid $usr --start --exec $bin -- $@ 2>&1 | logger
And it works in strange ways...
But of course this is not the solution.
iEvgeny
Posts: 2
Joined: 7. Oct 2016, 11:22

Re: systemctl stop vboxautostart-service.servise has no effect | VirualBox 5.1.6-110634~Ubuntu~xenia

Post by iEvgeny »

The problem solved by the creation of a unit:

Code: Select all

[Unit]
Description=VirtualBox autostart service
After=vboxdrv.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/virtualbox/vboxautostart-service.sh start
ExecStop=/usr/lib/virtualbox/vboxautostart-service.sh stop

[Install]
WantedBy=multi-user.target
Post Reply