You are not logged in.
I'd like to have a vbox.service that handles inserting/removing the needed modules as well as running the target vbox. I modified ngoonee's service as shown below to handle the modprobe and rmmod steps but I have two issues:
[Unit]
Description=Virtualbox Headless VM
[Service]
ExecStartPre=/usr/bin/sudo /usr/bin/modprobe -a vboxdrv vboxnetflt
ExecStart=/usr/bin/VBoxHeadless --startvm narch
ExecStop=/usr/bin/VBoxManage controlvm narch poweroff
ExecStopPost=/usr/bin/sudo /usr/bin/rmmod vboxdrv vboxnetflt
User=facade
[Install]
WantedBy=muti-user.target
Issue #1) The service fails when trying to run the ExecStopPost command since the vbox doesn't go instantly down and the modules are in use. So, without building in a sleep command... how can I have the rmmod run when the poweroff of the vbox takes some time?
Issue #2) To my knowledge, I cannot mix root user commands and user-defined commands, my solution has been to use sudo but I think that isn't very elegant. Is there a way to have the User= statement only apply to the ExecStart and ExecStop commands?
Last edited by graysky (2013-11-24 10:16:54)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Try a separate service for loading the modules (with unloading on stop and StopWhenUnneeded=true so the unloading happens as soon as you no longer need them). Add Requires and After to the VM service (now you can also have multiple VM services without modprobe/rmmod conflicts). This should clear up #2 as well.
If you're lucky, this fixes #1 too.
(I had written some more, but then I wanted to check something with VBox and it crashed my system -- it's done that a few times recently.)
Offline
Haven't used i in a while, and a quick Google search didn't turn up anything worthwhile, but doesn't VBoxHeadless fork upon starting the VM? If so, does it help to simply add the Type=Fork line to the [Service] section?
Last edited by Runiq (2013-11-24 12:24:43)
Offline