VirtualBox VM as a unit failures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I,m triying to configure an user-level unit for a VirtualBox VM, but it does not work well, when I stop, it complains:

systemctl --user status  vbox_vm_start@RHEL7.service
○ vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7
     Loaded: loaded (/home/sergio/.config/systemd/user/vbox_vm_start@.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Thu 2022-09-01 14:21:57 -03; 5s ago
    Process: 378373 ExecStart=/usr/bin/VBoxManage startvm RHEL7 --type headless (code=exited, status=0/SUCCESS)
    Process: 378581 ExecStop=/usr/bin/VBoxManage controlvm RHEL7 acpipowerbutton (code=exited, status=0/SUCCESS)
      Tasks: 40 (limit: 38236)
     Memory: 23.6M
        CPU: 8.114s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/app-vbox_vm_start.slice/vbox_vm_start@RHEL7.service
             ├─ 378386 /usr/lib/virtualbox/VBoxXPCOMIPCD
             ├─ 378392 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
             └─ 378442 /usr/lib/virtualbox/VBoxHeadless --comment RHEL7 --startvm f02a9f08-2ff2-4a92-b3cd-a8dfb17513c6 --vrde config

sep 01 14:21:51 munster.belkin.home systemd[3452]: Starting vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7...
sep 01 14:21:51 munster.belkin.home VBoxManage[378373]: Waiting for VM "RHEL7" to power on...
sep 01 14:21:51 munster.belkin.home VBoxManage[378373]: VM "RHEL7" has been successfully started.
sep 01 14:21:51 munster.belkin.home systemd[3452]: Started vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7.
sep 01 14:21:56 munster.belkin.home systemd[3452]: Stopping vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7...
sep 01 14:21:57 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378386 (VBoxXPCOMIPCD) remains running after unit stopped.
sep 01 14:21:57 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378392 (VBoxSVC) remains running after unit stopped.
sep 01 14:21:57 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378442 (VBoxHeadless) remains running after unit stopped.
sep 01 14:21:57 munster.belkin.home systemd[3452]: Stopped vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7.
sep 01 14:21:57 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Consumed 3.386s CPU time.

If I try to start, these are the errors:

× vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7
     Loaded: loaded (/home/sergio/.config/systemd/user/vbox_vm_start@.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Thu 2022-09-01 14:22:06 -03; 7s ago
    Process: 378730 ExecStart=/usr/bin/VBoxManage startvm RHEL7 --type headless (code=exited, status=1/FAILURE)
      Tasks: 40 (limit: 38236)
     Memory: 25.7M
        CPU: 3.338s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/app-vbox_vm_start.slice/vbox_vm_start@RHEL7.service
             ├─ 378386 /usr/lib/virtualbox/VBoxXPCOMIPCD
             ├─ 378392 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
             └─ 378442 /usr/lib/virtualbox/VBoxHeadless --comment RHEL7 --startvm f02a9f08-2ff2-4a92-b3cd-a8dfb17513c6 --vrde config

sep 01 14:22:06 munster.belkin.home systemd[3452]: Starting vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7...
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: The machine 'RHEL7' is already locked by a session (or being locked or unlocked)
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee n>
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: Context: "LaunchVMProcess(a->session, sessionType.raw(), ComSafeArrayAsInParam(aBstrEnv), progress.asOutPar>
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Control process exited, code=exited, status=1/FAILURE
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Failed with result 'exit-code'.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378386 (VBoxXPCOMIPCD) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378392 (VBoxSVC) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378442 (VBoxHeadless) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: Failed to start vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7.

This the unit file:
× vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7
     Loaded: loaded (/home/sergio/.config/systemd/user/vbox_vm_start@.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Thu 2022-09-01 14:22:06 -03; 7s ago
    Process: 378730 ExecStart=/usr/bin/VBoxManage startvm RHEL7 --type headless (code=exited, status=1/FAILURE)
      Tasks: 40 (limit: 38236)
     Memory: 25.7M
        CPU: 3.338s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/app-vbox_vm_start.slice/vbox_vm_start@RHEL7.service
             ├─ 378386 /usr/lib/virtualbox/VBoxXPCOMIPCD
             ├─ 378392 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
             └─ 378442 /usr/lib/virtualbox/VBoxHeadless --comment RHEL7 --startvm f02a9f08-2ff2-4a92-b3cd-a8dfb17513c6 --vrde config

sep 01 14:22:06 munster.belkin.home systemd[3452]: Starting vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7...
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: The machine 'RHEL7' is already locked by a session (or being locked or unlocked)
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee n>
sep 01 14:22:06 munster.belkin.home VBoxManage[378730]: VBoxManage: error: Context: "LaunchVMProcess(a->session, sessionType.raw(), ComSafeArrayAsInParam(aBstrEnv), progress.asOutPar>
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Control process exited, code=exited, status=1/FAILURE
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Failed with result 'exit-code'.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378386 (VBoxXPCOMIPCD) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378392 (VBoxSVC) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: vbox_vm_start@RHEL7.service: Unit process 378442 (VBoxHeadless) remains running after unit stopped.
sep 01 14:22:06 munster.belkin.home systemd[3452]: Failed to start vbox_vm_start@RHEL7.service - VirtualBox VM RHEL7.

This is the unit file:
[Unit]
Description=VirtualBox VM %i
After=network.target vboxdrv.service
Before=runlevel2.target shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=no

#ExecStart=/usr/lib/virtualbox/VBoxHeadless --comment RHEL7 --startvm f02a9f08-2ff2-4a92-b3cd-a8dfb17513c6 --vrde config
ExecStart=/usr/bin/VBoxManage startvm %i --type headless
ExecStop=/usr/bin/VBoxManage controlvm %i acpipowerbutton

[Install]
WantedBy=default.target

(End of file)

What is the proper way to configure this kind of unit?

Thanks in advance



--
--
Sergio Belkin
LPIC-2 Certified - http://www.lpi.org

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux